1
0
mirror of https://github.com/rofafor/vdr-plugin-femon.git synced 2023-10-10 13:36:53 +02:00

Added initial support for PVRINPUT devices (Thanks to Winfried Köhler).

Added initial support for IPTV devices.
This commit is contained in:
Rolf Ahrenberg 2012-02-05 14:04:04 +02:00
parent d809e98052
commit 09cf40f215
4 changed files with 191 additions and 117 deletions

View File

@ -427,3 +427,8 @@ VDR Plugin 'femon' Revision History
- Updated for vdr-1.7.23. - Updated for vdr-1.7.23.
- Updated SVDRP interface. - Updated SVDRP interface.
- Added Hungarian translation (Thanks to Fuley Istvan). - Added Hungarian translation (Thanks to Fuley Istvan).
2012-02-05: Version 1.7.13
- Added initial support for PVRINPUT devices (Thanks to Winfried Köhler).
- Added initial support for IPTV devices.

View File

@ -18,7 +18,7 @@
#error "VDR-1.7.23 API version or greater is required!" #error "VDR-1.7.23 API version or greater is required!"
#endif #endif
static const char VERSION[] = "1.7.12"; static const char VERSION[] = "1.7.13";
static const char DESCRIPTION[] = trNOOP("DVB Signal Information Monitor (OSD)"); static const char DESCRIPTION[] = trNOOP("DVB Signal Information Monitor (OSD)");
static const char MAINMENUENTRY[] = trNOOP("Signal Information"); static const char MAINMENUENTRY[] = trNOOP("Signal Information");

View File

@ -184,6 +184,7 @@ cFemonOsd::cFemonOsd()
m_UNC(0), m_UNC(0),
m_UNCValid(false), m_UNCValid(false),
m_FrontendStatusValid(false), m_FrontendStatusValid(false),
m_DeviceSource(DEVICESOURCE_DVBAPI),
m_DisplayMode(femonConfig.displaymode), m_DisplayMode(femonConfig.displaymode),
m_OsdWidth(cOsd::OsdWidth() * (100 - femonConfig.downscale) / 100), m_OsdWidth(cOsd::OsdWidth() * (100 - femonConfig.downscale) / 100),
m_OsdHeight(cOsd::OsdHeight() * (100 - femonConfig.downscale) / 100), m_OsdHeight(cOsd::OsdHeight() * (100 - femonConfig.downscale) / 100),
@ -549,76 +550,111 @@ void cFemonOsd::Action(void)
m_SvdrpFrontend = -1; m_SvdrpFrontend = -1;
m_SvdrpVideoBitrate = -1.0; m_SvdrpVideoBitrate = -1.0;
m_SvdrpAudioBitrate = -1.0; m_SvdrpAudioBitrate = -1.0;
if (m_Frontend != -1) { switch (m_DeviceSource) {
m_Quality = cDevice::ActualDevice()->SignalQuality(); case DEVICESOURCE_PVRINPUT:
m_QualityValid = (m_Quality >= 0); m_Quality = cDevice::ActualDevice()->SignalStrength();
m_Strength = cDevice::ActualDevice()->SignalStrength(); m_QualityValid = (m_Quality >= 0);
m_StrengthValid = (m_Strength >= 0); m_Strength = cDevice::ActualDevice()->SignalStrength();
m_FrontendStatusValid = (ioctl(m_Frontend, FE_READ_STATUS, &m_FrontendStatus) >= 0); m_StrengthValid = (m_Strength >= 0);
m_SignalValid = (ioctl(m_Frontend, FE_READ_SIGNAL_STRENGTH, &m_Signal) >= 0); m_FrontendStatus = (fe_status_t)(m_StrengthValid ? (FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC) : 0);
m_SNRValid = (ioctl(m_Frontend, FE_READ_SNR, &m_SNR) >= 0); m_FrontendStatusValid = m_StrengthValid;
m_BERValid = (ioctl(m_Frontend, FE_READ_BER, &m_BER) >= 0); m_Signal = m_Strength * 0xFFFF / 100;
m_UNCValid = (ioctl(m_Frontend, FE_READ_UNCORRECTED_BLOCKS, &m_UNC) >= 0); m_SignalValid = m_StrengthValid;
DrawInfoWindow(); m_SNR = 0;
DrawStatusWindow(); m_SNRValid = false;
} m_BER = 0;
else if (m_SvdrpConnection.handle >= 0) { m_BERValid = false;
cmd.handle = m_SvdrpConnection.handle; m_UNC = 0;
m_SvdrpPlugin->Service("SvdrpCommand-v1.0", &cmd); m_UNCValid = false;
if (cmd.responseCode == 900) { break;
m_StrengthValid = false; case DEVICESOURCE_IPTV:
m_QualityValid = false; m_Quality = cDevice::ActualDevice()->SignalQuality();
m_FrontendStatusValid = false; m_QualityValid = (m_Quality >= 0);
m_SignalValid = false; m_Strength = cDevice::ActualDevice()->SignalStrength();
m_SNRValid = false; m_StrengthValid = (m_Strength >= 0);
m_BERValid = false; m_FrontendStatus = (fe_status_t)(m_StrengthValid ? (FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC) : 0);
m_UNCValid = false; m_FrontendStatusValid = m_StrengthValid;
for (cLine *line = cmd.reply.First(); line; line = cmd.reply.Next(line)) { m_Signal = m_Strength * 0xFFFF / 100;
const char *s = line->Text(); m_SignalValid = m_StrengthValid;
if (!strncasecmp(s, "CARD:", 5)) m_SNR = m_Quality * 0xFFFF / 100;
m_SvdrpFrontend = (int)strtol(s + 5, NULL, 10); m_SNRValid = m_QualityValid;
else if (!strncasecmp(s, "STRG:", 5)) { m_BER = 0;
m_Strength = (int)strtol(s + 5, NULL, 10); m_BERValid = false;
m_StrengthValid = (m_Strength >= 0); m_UNC = 0;
} m_UNCValid = false;
else if (!strncasecmp(s, "QUAL:", 5)) { break;
m_Quality = (int)strtol(s + 5, NULL, 10); default:
m_QualityValid = (m_Quality >= 0); case DEVICESOURCE_DVBAPI:
} if (m_Frontend != -1) {
else if (!strncasecmp(s, "TYPE:", 5)) m_Quality = cDevice::ActualDevice()->SignalQuality();
m_FrontendInfo.type = (fe_type_t)strtol(s + 5, NULL, 10); m_QualityValid = (m_Quality >= 0);
else if (!strncasecmp(s, "NAME:", 5)) { m_Strength = cDevice::ActualDevice()->SignalStrength();
strn0cpy(m_FrontendInfo.name, s + 5, sizeof(m_FrontendInfo.name)); m_StrengthValid = (m_Strength >= 0);
} m_FrontendStatusValid = (ioctl(m_Frontend, FE_READ_STATUS, &m_FrontendStatus) >= 0);
else if (!strncasecmp(s, "STAT:", 5)) { m_SignalValid = (ioctl(m_Frontend, FE_READ_SIGNAL_STRENGTH, &m_Signal) >= 0);
m_FrontendStatus = (fe_status_t)strtol(s + 5, NULL, 16); m_SNRValid = (ioctl(m_Frontend, FE_READ_SNR, &m_SNR) >= 0);
m_FrontendStatusValid = true; m_BERValid = (ioctl(m_Frontend, FE_READ_BER, &m_BER) >= 0);
} m_UNCValid = (ioctl(m_Frontend, FE_READ_UNCORRECTED_BLOCKS, &m_UNC) >= 0);
else if (!strncasecmp(s, "SGNL:", 5)) {
m_Signal = (uint16_t)strtol(s + 5, NULL, 16);
m_SignalValid = true;
}
else if (!strncasecmp(s, "SNRA:", 5)) {
m_SNR = (uint16_t)strtol(s + 5, NULL, 16);
m_SNRValid = true;
}
else if (!strncasecmp(s, "BERA:", 5)) {
m_BER = (uint32_t)strtol(s + 5, NULL, 16);
m_BERValid = true;
}
else if (!strncasecmp(s, "UNCB:", 5)) {
m_UNC = (uint32_t)strtol(s + 5, NULL, 16);
m_UNCValid = true;
}
else if (!strncasecmp(s, "VIBR:", 5))
m_SvdrpVideoBitrate = (double)strtol(s + 5, NULL, 10);
else if (!strncasecmp(s, "AUBR:", 5))
m_SvdrpAudioBitrate = (double)strtol(s + 5, NULL, 10);
} }
} else if (m_SvdrpConnection.handle >= 0) {
DrawInfoWindow(); cmd.handle = m_SvdrpConnection.handle;
DrawStatusWindow(); m_SvdrpPlugin->Service("SvdrpCommand-v1.0", &cmd);
} if (cmd.responseCode == 900) {
m_StrengthValid = false;
m_QualityValid = false;
m_FrontendStatusValid = false;
m_SignalValid = false;
m_SNRValid = false;
m_BERValid = false;
m_UNCValid = false;
for (cLine *line = cmd.reply.First(); line; line = cmd.reply.Next(line)) {
const char *s = line->Text();
if (!strncasecmp(s, "CARD:", 5))
m_SvdrpFrontend = (int)strtol(s + 5, NULL, 10);
else if (!strncasecmp(s, "STRG:", 5)) {
m_Strength = (int)strtol(s + 5, NULL, 10);
m_StrengthValid = (m_Strength >= 0);
}
else if (!strncasecmp(s, "QUAL:", 5)) {
m_Quality = (int)strtol(s + 5, NULL, 10);
m_QualityValid = (m_Quality >= 0);
}
else if (!strncasecmp(s, "TYPE:", 5))
m_FrontendInfo.type = (fe_type_t)strtol(s + 5, NULL, 10);
else if (!strncasecmp(s, "NAME:", 5)) {
strn0cpy(m_FrontendInfo.name, s + 5, sizeof(m_FrontendInfo.name));
}
else if (!strncasecmp(s, "STAT:", 5)) {
m_FrontendStatus = (fe_status_t)strtol(s + 5, NULL, 16);
m_FrontendStatusValid = true;
}
else if (!strncasecmp(s, "SGNL:", 5)) {
m_Signal = (uint16_t)strtol(s + 5, NULL, 16);
m_SignalValid = true;
}
else if (!strncasecmp(s, "SNRA:", 5)) {
m_SNR = (uint16_t)strtol(s + 5, NULL, 16);
m_SNRValid = true;
}
else if (!strncasecmp(s, "BERA:", 5)) {
m_BER = (uint32_t)strtol(s + 5, NULL, 16);
m_BERValid = true;
}
else if (!strncasecmp(s, "UNCB:", 5)) {
m_UNC = (uint32_t)strtol(s + 5, NULL, 16);
m_UNCValid = true;
}
else if (!strncasecmp(s, "VIBR:", 5))
m_SvdrpVideoBitrate = (double)strtol(s + 5, NULL, 10);
else if (!strncasecmp(s, "AUBR:", 5))
m_SvdrpAudioBitrate = (double)strtol(s + 5, NULL, 10);
}
}
}
break;
}
DrawInfoWindow();
DrawStatusWindow();
m_Sleep.Wait(max((int)(100 * femonConfig.updateinterval - t.Elapsed()), 3)); m_Sleep.Wait(max((int)(100 * femonConfig.updateinterval - t.Elapsed()), 3));
} }
} }
@ -627,26 +663,40 @@ void cFemonOsd::Show(void)
{ {
debug("%s()\n", __PRETTY_FUNCTION__); debug("%s()\n", __PRETTY_FUNCTION__);
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice()); cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
m_Frontend = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (m_Frontend >= 0) { m_DeviceSource = DEVICESOURCE_DVBAPI;
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) { if (channel) {
if (!femonConfig.usesvdrp) if (channel->IsSourceType('I'))
error("cFemonOsd::Show() cannot read frontend info."); m_DeviceSource = DEVICESOURCE_IPTV;
close(m_Frontend); else if (channel->IsSourceType('V'))
m_Frontend = -1; m_DeviceSource = DEVICESOURCE_PVRINPUT;
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo)); }
if (m_DeviceSource == DEVICESOURCE_DVBAPI) {
cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice());
m_Frontend = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (m_Frontend >= 0) {
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) {
if (!femonConfig.usesvdrp)
error("cFemonOsd::Show() cannot read frontend info.");
close(m_Frontend);
m_Frontend = -1;
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo));
return;
}
}
else if (femonConfig.usesvdrp) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
else {
error("cFemonOsd::Show() cannot open frontend device.");
return; return;
} }
} }
else if (femonConfig.usesvdrp) { else
if (!SvdrpConnect() || !SvdrpTune()) m_Frontend = -1;
return;
}
else {
error("cFemonOsd::Show() cannot open frontend device.");
return;
}
m_Osd = cOsdProvider::NewOsd(m_OsdLeft, m_OsdTop); m_Osd = cOsdProvider::NewOsd(m_OsdLeft, m_OsdTop);
if (m_Osd) { if (m_Osd) {
@ -667,12 +717,9 @@ void cFemonOsd::Show(void)
m_Receiver->Deactivate(); m_Receiver->Deactivate();
DELETENULL(m_Receiver); DELETENULL(m_Receiver);
} }
if (femonConfig.analyzestream) { if (femonConfig.analyzestream && channel) {
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); m_Receiver = new cFemonReceiver(channel->Vtype(), channel->Vpid(), channel->Apid(IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0), channel->Dpid(IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0));
if (channel) { cDevice::ActualDevice()->AttachReceiver(m_Receiver);
m_Receiver = new cFemonReceiver(channel->Vtype(), channel->Vpid(), channel->Apid(IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0), channel->Dpid(IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0));
cDevice::ActualDevice()->AttachReceiver(m_Receiver);
}
} }
Start(); Start();
} }
@ -682,40 +729,54 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
{ {
debug("%s(%d,%d)\n", __PRETTY_FUNCTION__, device->DeviceNumber(), channelNumber); debug("%s(%d,%d)\n", __PRETTY_FUNCTION__, device->DeviceNumber(), channelNumber);
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
if (!device->IsPrimaryDevice() || !channelNumber || cDevice::PrimaryDevice()->CurrentChannel() != channelNumber) cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
if (!device->IsPrimaryDevice() || !channelNumber || !channel || channel->Number() != channelNumber)
return; return;
close(m_Frontend);
cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice()); m_DeviceSource = DEVICESOURCE_DVBAPI;
m_Frontend = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1; if (channel) {
if (channel->IsSourceType('I'))
m_DeviceSource = DEVICESOURCE_IPTV;
else if (channel->IsSourceType('V'))
m_DeviceSource = DEVICESOURCE_PVRINPUT;
}
if (m_Frontend >= 0) { if (m_Frontend >= 0) {
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) { close(m_Frontend);
if (!femonConfig.usesvdrp) m_Frontend = -1;
error("cFemonOsd::ChannelSwitch() cannot read frontend info."); }
close(m_Frontend);
m_Frontend = -1; if (m_DeviceSource == DEVICESOURCE_DVBAPI) {
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo)); cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice());
m_Frontend = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (m_Frontend >= 0) {
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) {
if (!femonConfig.usesvdrp)
error("cFemonOsd::ChannelSwitch() cannot read frontend info.");
close(m_Frontend);
m_Frontend = -1;
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo));
return;
}
}
else if (femonConfig.usesvdrp) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
else {
error("cFemonOsd::ChannelSwitch() cannot open frontend device.");
return; return;
} }
} }
else if (femonConfig.usesvdrp) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
else {
error("cFemonOsd::ChannelSwitch() cannot open frontend device.");
return;
}
if (m_Receiver) { if (m_Receiver) {
m_Receiver->Deactivate(); m_Receiver->Deactivate();
DELETENULL(m_Receiver); DELETENULL(m_Receiver);
} }
if (femonConfig.analyzestream) { if (femonConfig.analyzestream && channel) {
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); m_Receiver = new cFemonReceiver(channel->Vtype(), channel->Vpid(), channel->Apid(IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0), channel->Dpid(IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0));
if (channel) { cDevice::ActualDevice()->AttachReceiver(m_Receiver);
m_Receiver = new cFemonReceiver(channel->Vtype(), channel->Vpid(), channel->Apid(IS_AUDIO_TRACK(track) ? int(track - ttAudioFirst) : 0), channel->Dpid(IS_DOLBY_TRACK(track) ? int(track - ttDolbyFirst) : 0));
cDevice::ActualDevice()->AttachReceiver(m_Receiver);
}
} }
} }

View File

@ -24,6 +24,13 @@
class cFemonOsd : public cOsdObject, public cThread, public cStatus { class cFemonOsd : public cOsdObject, public cThread, public cStatus {
private: private:
enum eDeviceSourceType {
DEVICESOURCE_DVBAPI = 0,
DEVICESOURCE_IPTV,
DEVICESOURCE_PVRINPUT,
DEVICESOURCE_COUNT
};
static cFemonOsd *pInstance; static cFemonOsd *pInstance;
cOsd *m_Osd; cOsd *m_Osd;
@ -51,6 +58,7 @@ private:
fe_status_t m_FrontendStatus; fe_status_t m_FrontendStatus;
bool m_FrontendStatusValid; bool m_FrontendStatusValid;
dvb_frontend_info m_FrontendInfo; dvb_frontend_info m_FrontendInfo;
eDeviceSourceType m_DeviceSource;
int m_DisplayMode; int m_DisplayMode;
int m_OsdWidth; int m_OsdWidth;
int m_OsdHeight; int m_OsdHeight;