mirror of
https://github.com/rofafor/vdr-plugin-femon.git
synced 2023-10-10 11:36:53 +00:00
Added preliminary video (VPID) and audio (APID1) bitrate calculations.
This commit is contained in:
parent
26918d18ce
commit
2d06d2c6c1
4
HISTORY
4
HISTORY
@ -8,3 +8,7 @@ VDR Plugin 'femon' Revision History
|
||||
2004-02-23: Version 0.0.1b
|
||||
|
||||
- Fixed cThread to work under vdr-1.2.6.
|
||||
|
||||
2004-02-26: Version 0.0.2
|
||||
|
||||
- Added preliminary video (VPID) and audio (APID1) bitrate calculations.
|
||||
|
2
Makefile
2
Makefile
@ -46,7 +46,7 @@ DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
|
||||
|
||||
### The object files (add further files here):
|
||||
|
||||
OBJS = femon.o femonosd.o femoncfg.o femoni18n.o
|
||||
OBJS = femon.o femonosd.o femonreceiver.o femoncfg.o femoni18n.o
|
||||
|
||||
### Implicit rules:
|
||||
|
||||
|
5
README
5
README
@ -25,7 +25,9 @@ The plugin is based on a neat console frontend status monitor application called
|
||||
further information). The other parts of plugin code are borrowed from the
|
||||
excellent OSD Picture-In-Picture plugin by Sascha Volkenandt <sascha@akv-soft.de>
|
||||
and Andreas Regel <andreas.regel@powarman.de>. Props to Sascha for being brave
|
||||
enough to test this piece of junk and ofcourse for german translations.
|
||||
enough to test this piece of junk and ofcourse for german translations. The bitrate
|
||||
calculation algorithm is copied from dvbstream application by Dave Chapman
|
||||
<dave@dchapman.com>.
|
||||
|
||||
Shortcomings / Todo list:
|
||||
|
||||
@ -38,4 +40,3 @@ Shortcomings / Todo list:
|
||||
- Sometimes (read always) ttxtsubs plugin messes up the OSD - user should disable
|
||||
ttxtsubs, but closing and reopening the femon plugin might help as well. BTW. the
|
||||
same things happens with OSDTeletext plugin too :)
|
||||
- Where's the bitrate!?
|
||||
|
2
femon.c
2
femon.c
@ -76,7 +76,7 @@ cMenuFemonSetup::cMenuFemonSetup(void)
|
||||
{
|
||||
Add(new cMenuEditBoolItem(tr("Hide Mainmenu Entry"), &femonConfig.hidemenu, tr("no"), tr("yes")));
|
||||
Add(new cMenuEditBoolItem(tr("Position"), &femonConfig.position, tr("bottom"), tr("top")));
|
||||
Add(new cMenuEditIntItem( tr("Update Interval [0.1s]"), &femonConfig.interval, 1, 20));
|
||||
Add(new cMenuEditIntItem( tr("Update Interval [0.1s]"), &femonConfig.interval, 5, 50));
|
||||
Add(new cMenuEditIntItem( tr("Red Limit [%]"), &femonConfig.redlimit, 1, 50));
|
||||
Add(new cMenuEditIntItem( tr("Green Limit [%]"), &femonConfig.greenlimit, 51, 100));
|
||||
}
|
||||
|
2
femon.h
2
femon.h
@ -4,7 +4,7 @@
|
||||
#include <vdr/plugin.h>
|
||||
#include "femoncfg.h"
|
||||
|
||||
static const char *VERSION = "0.0.1b";
|
||||
static const char *VERSION = "0.0.2";
|
||||
static const char *DESCRIPTION = "DVB Signal Quality Monitor (OSD)";
|
||||
static const char *MAINMENUENTRY = "Signal Quality";
|
||||
|
||||
|
@ -14,7 +14,7 @@ cFemonConfig::cFemonConfig(void)
|
||||
{
|
||||
hidemenu = 0;
|
||||
position = 1;
|
||||
interval = 5;
|
||||
interval = 10;
|
||||
redlimit = 33;
|
||||
greenlimit = 66;
|
||||
}
|
||||
|
52
femonosd.c
52
femonosd.c
@ -6,10 +6,10 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "femonosd.h"
|
||||
#include "femoncfg.h"
|
||||
#include "femonosd.h"
|
||||
|
||||
#define FEMON_DEVICE "/dev/dvb/adapter%d/frontend%d"
|
||||
#define FE_DEVICE "/dev/dvb/adapter%d/frontend%d"
|
||||
#define CHANNELINPUT_TIMEOUT 1000
|
||||
#define CHANNELINFO_TIMEOUT 5000
|
||||
#define OSDHEIGHT 5
|
||||
@ -24,6 +24,7 @@ cFemonOsd::cFemonOsd(void)
|
||||
//printf("cFemonOsd::cFemonOsd()\n");
|
||||
m_Osd = NULL;
|
||||
m_Window = -1;
|
||||
m_Receiver = NULL;
|
||||
m_Frontend = -1;
|
||||
m_Active = false;
|
||||
m_Number = 0;
|
||||
@ -42,6 +43,8 @@ cFemonOsd::~cFemonOsd(void)
|
||||
m_Active = false;
|
||||
Cancel(3);
|
||||
}
|
||||
if (m_Receiver)
|
||||
delete m_Receiver;
|
||||
if (m_Osd)
|
||||
delete m_Osd;
|
||||
}
|
||||
@ -54,6 +57,8 @@ void cFemonOsd::Action(void)
|
||||
uint32_t ber, unc;
|
||||
fe_status_t fe_status;
|
||||
char buf[128];
|
||||
double VRate = 0.0;
|
||||
double ARate = 0.0;
|
||||
|
||||
m_Active = true;
|
||||
while (m_Active) {
|
||||
@ -68,9 +73,24 @@ void cFemonOsd::Action(void)
|
||||
#if (VDRVERSNUM >= 10300) || defined(ELCHIAIOVERSION)
|
||||
eDvbFont OldFont = m_Osd->SetFont(fontSml);
|
||||
#endif
|
||||
sprintf(buf, "%d - %s", cDevice::CurrentChannel(), Channels.GetByNumber(cDevice::CurrentChannel())->Name());
|
||||
sprintf(buf, "%d %s", cDevice::CurrentChannel(), Channels.GetByNumber(cDevice::CurrentChannel())->Name());
|
||||
m_Osd->Fill(0, 0, m_Width, cOsd::LineHeight() - 1, clrWhite, m_Window);
|
||||
m_Osd->Text(cOsd::CellWidth(), 0, buf, clrBlack, clrWhite, m_Window);
|
||||
if (m_Receiver) {
|
||||
// do some averaging to smooth the value
|
||||
VRate = (VRate + (m_Receiver->VideoPacketCount() * 184.0 * 8.0) / (femonConfig.interval * 102.4 * 1024.0)) / 2.0;
|
||||
ARate = (ARate + (m_Receiver->AudioPacketCount() * 184.0 * 8.0) / (femonConfig.interval * 102.4 * 1024.0)) / 2.0;
|
||||
sprintf(buf, "V: %.1f Mbit/s\n", VRate);
|
||||
#if (VDRVERSNUM >= 10300) || defined(ELCHIAIOVERSION)
|
||||
m_Osd->Text((m_Width - 20 * cOsd::CellWidth()), 0, buf, clrBlack, clrWhite, m_Window);
|
||||
sprintf(buf, "A: %.1f Mbit/s\n", ARate);
|
||||
m_Osd->Text((m_Width - 10 * cOsd::CellWidth()), 0, buf, clrBlack, clrWhite, m_Window);
|
||||
#else
|
||||
m_Osd->Text((m_Width - 22 * cOsd::CellWidth()), 0, buf, clrBlack, clrWhite, m_Window);
|
||||
sprintf(buf, "A: %.1f Mbit/s\n", ARate);
|
||||
m_Osd->Text((m_Width - 11 * cOsd::CellWidth()), 0, buf, clrBlack, clrWhite, m_Window);
|
||||
#endif
|
||||
}
|
||||
sprintf(buf, "STR: %04x", signal);
|
||||
m_Osd->Text(cOsd::CellWidth(), 3 * cOsd::LineHeight(), buf, clrWhite, clrBackground, m_Window);
|
||||
sprintf(buf, "SNR: %04x", snr);
|
||||
@ -129,10 +149,10 @@ void cFemonOsd::Action(void)
|
||||
void cFemonOsd::Show(void)
|
||||
{
|
||||
//printf("cFemonOsd::Show()\n");
|
||||
char *fedev = NULL;
|
||||
asprintf(&fedev, FEMON_DEVICE, cDevice::ActualDevice()->CardIndex(), 0); // only the first frontend supported
|
||||
m_Frontend = open(fedev, O_RDONLY | O_NONBLOCK);
|
||||
free(fedev);
|
||||
char *dev = NULL;
|
||||
asprintf(&dev, FE_DEVICE, cDevice::ActualDevice()->CardIndex(), 0);
|
||||
m_Frontend = open(dev, O_RDONLY | O_NONBLOCK);
|
||||
free(dev);
|
||||
if (m_Frontend < 0) {
|
||||
isyslog("cFemonOsd::Show() cannot open frontend device.");
|
||||
m_Frontend = -1;
|
||||
@ -142,6 +162,7 @@ void cFemonOsd::Show(void)
|
||||
isyslog("cFemonOsd::Show() cannot read frontend info.");
|
||||
m_Frontend = -1;
|
||||
close(m_Frontend);
|
||||
return;
|
||||
}
|
||||
m_InfoTime = time_ms();
|
||||
m_Osd = cOsd::OpenRaw(m_Xpos, m_Ypos);
|
||||
@ -157,6 +178,10 @@ void cFemonOsd::Show(void)
|
||||
m_Osd->AddColor(clrTransparent, m_Window);
|
||||
m_Osd->Clear(m_Window);
|
||||
m_Osd->Flush();
|
||||
if (m_Receiver)
|
||||
delete m_Receiver;
|
||||
m_Receiver = new cFemonReceiver(Channels.GetByNumber(cDevice::CurrentChannel())->Ca(), Channels.GetByNumber(cDevice::CurrentChannel())->Vpid(), Channels.GetByNumber(cDevice::CurrentChannel())->Apid1());
|
||||
cDevice::ActualDevice()->AttachReceiver(m_Receiver);
|
||||
Start();
|
||||
}
|
||||
}
|
||||
@ -164,12 +189,11 @@ void cFemonOsd::Show(void)
|
||||
void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
|
||||
{
|
||||
//printf("cFemonOsd::ChannelSwitch()\n");
|
||||
char *fedev = NULL;
|
||||
|
||||
char *dev = NULL;
|
||||
close(m_Frontend);
|
||||
asprintf(&fedev, FEMON_DEVICE, cDevice::ActualDevice()->CardIndex(), 0); // only the first frontend$
|
||||
m_Frontend = open(fedev, O_RDONLY | O_NONBLOCK);
|
||||
free(fedev);
|
||||
asprintf(&dev, FE_DEVICE, cDevice::ActualDevice()->CardIndex(), 0); // only the first frontend$
|
||||
m_Frontend = open(dev, O_RDONLY | O_NONBLOCK);
|
||||
free(dev);
|
||||
if (m_Frontend < 0) {
|
||||
isyslog("cFemonOsd::ChannelSwitch() cannot open frontend device.");
|
||||
m_Frontend = -1;
|
||||
@ -180,6 +204,10 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
|
||||
m_Frontend = -1;
|
||||
close(m_Frontend);
|
||||
}
|
||||
if (m_Receiver)
|
||||
delete m_Receiver;
|
||||
m_Receiver = new cFemonReceiver(Channels.GetByNumber(cDevice::CurrentChannel())->Ca(), Channels.GetByNumber(cDevice::CurrentChannel())->Vpid(), Channels.GetByNumber(cDevice::CurrentChannel())->Apid1());
|
||||
cDevice::ActualDevice()->AttachReceiver(m_Receiver);
|
||||
m_InfoTime = time_ms();
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,14 @@
|
||||
#include <vdr/status.h>
|
||||
#include <vdr/channels.h>
|
||||
#include <vdr/font.h>
|
||||
#include "femonreceiver.h"
|
||||
|
||||
class cFemonOsd : public cOsdObject, public cThread, public cStatus {
|
||||
private:
|
||||
bool m_Active;
|
||||
cOsdBase *m_Osd;
|
||||
tWindowHandle m_Window;
|
||||
cFemonReceiver *m_Receiver;
|
||||
int m_Frontend;
|
||||
struct dvb_frontend_info m_FrontendInfo;
|
||||
int m_Number;
|
||||
|
59
femonreceiver.c
Normal file
59
femonreceiver.c
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* A Frontend Monitor plugin for the Video Disk Recorder
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "femonreceiver.h"
|
||||
|
||||
#define TS_SIZE 188
|
||||
|
||||
cFemonReceiver::cFemonReceiver(int Ca, int Vpid, int Apid)
|
||||
:cReceiver(Ca, -1, 2, Vpid, Apid)
|
||||
{
|
||||
//printf("cFemonReceiver::cFemonReceiver()\n");
|
||||
m_VPid = Vpid;
|
||||
m_APid = Apid;
|
||||
m_VideoCount = 0;
|
||||
m_AudioCount = 0;
|
||||
}
|
||||
|
||||
cFemonReceiver::~cFemonReceiver(void)
|
||||
{
|
||||
//printf("cFemonReceiver::~cFemonReceiver()\n");
|
||||
}
|
||||
|
||||
void cFemonReceiver::Activate(bool On)
|
||||
{
|
||||
//printf("cFemonReceiver::Activate()\n");
|
||||
}
|
||||
|
||||
void cFemonReceiver::Receive(uchar *Data, int Length)
|
||||
{
|
||||
//printf("cFemonReceiver::Receive()\n");
|
||||
if (Length == TS_SIZE) {
|
||||
int pid = ((Data[1]&0x1f) << 8) | (Data[2]);
|
||||
if (pid == m_VPid)
|
||||
m_VideoCount++;
|
||||
if (pid == m_APid)
|
||||
m_AudioCount++;
|
||||
}
|
||||
}
|
||||
|
||||
int cFemonReceiver::VideoPacketCount(void)
|
||||
{
|
||||
//printf("cFemonReceiver::VideoPacketCount()\n");
|
||||
int count = m_VideoCount;
|
||||
m_VideoCount = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
int cFemonReceiver::AudioPacketCount(void)
|
||||
{
|
||||
//printf("cFemonReceiver::AudioPacketCount()\n");
|
||||
int count = m_AudioCount;
|
||||
m_AudioCount = 0;
|
||||
return count;
|
||||
}
|
26
femonreceiver.h
Normal file
26
femonreceiver.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __FEMONRECEIVER_H
|
||||
#define __FEMONRECEIVER_H
|
||||
|
||||
#include <vdr/receiver.h>
|
||||
|
||||
class cFemonReceiver : public cReceiver {
|
||||
private:
|
||||
int m_VPid;
|
||||
int m_APid;
|
||||
int m_VideoCount;
|
||||
int m_AudioCount;
|
||||
|
||||
protected:
|
||||
virtual void Activate(bool On);
|
||||
virtual void Receive(uchar *Data, int Length);
|
||||
|
||||
public:
|
||||
cFemonReceiver(int Ca, int Vpid, int Apid);
|
||||
virtual ~cFemonReceiver();
|
||||
|
||||
int VideoPacketCount(void);
|
||||
int AudioPacketCount(void);
|
||||
};
|
||||
|
||||
#endif //__FEMONRECEIVER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user