Updated for vdr-1.7.23.

Updated SVDRP interface.
This commit is contained in:
Rolf Ahrenberg 2012-01-15 23:07:53 +02:00
parent 1e3b10faa7
commit cf8920ddd6
5 changed files with 118 additions and 84 deletions

View File

@ -422,6 +422,8 @@ VDR Plugin 'femon' Revision History
- Added cppcheck target into Makefile.
- Refactored bitstream code.
20XX-XX-XX: Version 1.7.12
2012-01-15: Version 1.7.12
- Updated for vdr-1.7.23.
- Updated SVDRP interface.
— Added Hungarian translation (Thanks to Fuley Istvan).

88
femon.c
View File

@ -14,8 +14,8 @@
#include "femonservice.h"
#include "femontools.h"
#if defined(APIVERSNUM) && APIVERSNUM < 10722
#error "VDR-1.7.22 API version or greater is required!"
#if defined(APIVERSNUM) && APIVERSNUM < 10723
#error "VDR-1.7.23 API version or greater is required!"
#endif
static const char VERSION[] = "1.7.12";
@ -135,13 +135,13 @@ bool cPluginFemon::Service(const char *Id, void *Data)
FemonService_v1_0 *data = (FemonService_v1_0*)Data;
if (!cDevice::ActualDevice())
return false;
int ndx = cDevice::ActualDevice()->CardIndex();
data->fe_name = getFrontendName(ndx);
data->fe_status = getFrontendStatus(ndx);
data->fe_snr = getSNR(ndx);
data->fe_signal = getSignal(ndx);
data->fe_ber = getBER(ndx);
data->fe_unc = getUNC(ndx);
cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice());
data->fe_name = getFrontendName(dev);
data->fe_status = getFrontendStatus(dev);
data->fe_snr = getSNR(dev);
data->fe_signal = getSignal(dev);
data->fe_ber = getBER(dev);
data->fe_unc = getUNC(dev);
data->video_bitrate = cFemonOsd::Instance() ? cFemonOsd::Instance()->GetVideoBitrate() : 0.0;
data->audio_bitrate = cFemonOsd::Instance() ? cFemonOsd::Instance()->GetAudioBitrate() : 0.0;
data->dolby_bitrate = cFemonOsd::Instance() ? cFemonOsd::Instance()->GetDolbyBitrate() : 0.0;
@ -163,30 +163,30 @@ const char **cPluginFemon::SVDRPHelpPages(void)
" Switch to next possible device.",
"PREV\n"
" Switch to previous possible device.",
"INFO\n"
" Print the current frontend information.",
"NAME\n"
" Print the current frontend name.",
"STAT\n"
" Print the current frontend status.",
"STRG\n"
" Print the current signal strength.",
"QUAL\n"
" Print the current signal quality.",
"SGNL\n"
" Print the current signal strength from driver.",
"SNRA\n"
" Print the current signal-to-noise ratio from driver.",
"BERA\n"
" Print the current bit error rate.",
"UNCB\n"
" Print the current uncorrected blocks rate.",
"INFO <card index>\n"
" Print the frontend information.",
"NAME <card index>\n"
" Print the frontend name.",
"STAT <card index>\n"
" Print the frontend status.",
"STRG <card index>\n"
" Print the signal strength.",
"QUAL <card index>\n"
" Print the signal quality.",
"SGNL <card index>\n"
" Print the signal strength from driver.",
"SNRA <card index>\n"
" Print the signal-to-noise ratio from driver.",
"BERA <card index>\n"
" Print the bit error rate.",
"UNCB <card index>\n"
" Print the uncorrected blocks rate.",
"VIBR\n"
" Print the actual device and current video bitrate [Mbit/s].",
" Print the current video bitrate [Mbit/s].",
"AUBR\n"
" Print the actual device and current audio bitrate [kbit/s].",
" Print the current audio bitrate [kbit/s].",
"DDBR\n"
" Print the actual device and current dolby bitrate [kbit/s].",
" Print the current dolby bitrate [kbit/s].",
NULL
};
return HelpPages;
@ -194,6 +194,12 @@ const char **cPluginFemon::SVDRPHelpPages(void)
cString cPluginFemon::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{
cDvbDevice *dev = dynamic_cast<cDvbDevice*>(cDevice::ActualDevice());
if (*Option && isnumber(Option)) {
cDvbDevice *dev2 = dynamic_cast<cDvbDevice*>(cDevice::GetDevice(strtol(Option, NULL, 10)));
if (dev2)
dev = dev2;
}
if (strcasecmp(Command, "OPEN") == 0) {
if (cReplayControl::NowReplaying()) {
ReplyCode = 550; // Requested action not taken
@ -221,33 +227,33 @@ cString cPluginFemon::SVDRPCommand(const char *Command, const char *Option, int
return cString("Cannot switch device");
}
else if (strcasecmp(Command, "INFO") == 0) {
return getFrontendInfo(cDevice::ActualDevice()->CardIndex());
return getFrontendInfo(dev);
}
else if (strcasecmp(Command, "NAME") == 0) {
return getFrontendName(cDevice::ActualDevice()->CardIndex());
return getFrontendName(dev);
}
else if (strcasecmp(Command, "STAT") == 0) {
return getFrontendStatus(cDevice::ActualDevice()->CardIndex());
return getFrontendStatus(dev);
}
else if (strcasecmp(Command, "STRG") == 0) {
return cString::sprintf("%d on device #%d", cDevice::ActualDevice()->SignalStrength(), cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%d on device #%d", dev->SignalStrength(), dev->CardIndex());
}
else if (strcasecmp(Command, "QUAL") == 0) {
return cString::sprintf("%d on device #%d", cDevice::ActualDevice()->SignalQuality(), cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%d on device #%d", dev->SignalQuality(), dev->CardIndex());
}
else if (strcasecmp(Command, "SGNL") == 0) {
int value = getSignal(cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%04X (%02d%%) on device #%d", value, value / 655, cDevice::ActualDevice()->CardIndex());
int value = getSignal(dev);
return cString::sprintf("%04X (%02d%%) on device #%d", value, value / 655, dev->CardIndex());
}
else if (strcasecmp(Command, "SNRA") == 0) {
int value = getSNR(cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%04X (%02d%%) on device #%d", value, value / 655, cDevice::ActualDevice()->CardIndex());
int value = getSNR(dev);
return cString::sprintf("%04X (%02d%%) on device #%d", value, value / 655, dev->CardIndex());
}
else if (strcasecmp(Command, "BERA") == 0) {
return cString::sprintf("%08X on device #%d", getBER(cDevice::ActualDevice()->CardIndex()), cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%08X on device #%d", getBER(dev), dev->CardIndex());
}
else if (strcasecmp(Command, "UNCB") == 0) {
return cString::sprintf("%08X on device #%d", getUNC(cDevice::ActualDevice()->CardIndex()), cDevice::ActualDevice()->CardIndex());
return cString::sprintf("%08X on device #%d", getUNC(dev), dev->CardIndex());
}
else if (strcasecmp(Command, "VIBR") == 0) {
if (cFemonOsd::Instance())

View File

@ -419,7 +419,7 @@ void cFemonOsd::DrawInfoWindow(void)
offset += OSDROWHEIGHT;
switch (channel->Source() & cSource::st_Mask) {
case cSource::stSat:
OSDDRAWINFOLINE(*cString::sprintf("DVB-S%s #%d - %s", (m_FrontendInfo.caps & 0x10000000) ? "2" : "", (m_SvdrpFrontend >= 0) ? m_SvdrpFrontend : cDevice::ActualDevice()->CardIndex(), m_FrontendInfo.name));
OSDDRAWINFOLINE(*cString::sprintf("%s #%d - %s", *getSatelliteSystem(dtp.System()), (m_SvdrpFrontend >= 0) ? m_SvdrpFrontend : cDevice::ActualDevice()->CardIndex(), m_FrontendInfo.name));
offset += OSDROWHEIGHT;
OSDDRAWINFOLEFT( trVDR("Frequency"), *getFrequencyMHz(channel->Frequency()));
OSDDRAWINFORIGHT(trVDR("Source"), *cSource::ToString(channel->Source()));
@ -430,7 +430,8 @@ void cFemonOsd::DrawInfoWindow(void)
OSDDRAWINFOLEFT( trVDR("Inversion"), *getInversion(dtp.Inversion()));
OSDDRAWINFORIGHT(trVDR("CoderateH"), *getCoderate(dtp.CoderateH()));
offset += OSDROWHEIGHT;
OSDDRAWINFOLEFT( trVDR("System"), *getSystem(dtp.System()));
OSDDRAWINFOLEFT( trVDR("System"), *getSatelliteSystem(dtp.System()));
if (dtp.System())
OSDDRAWINFORIGHT(trVDR("RollOff"), *getRollOff(dtp.RollOff()));
break;
@ -448,7 +449,7 @@ void cFemonOsd::DrawInfoWindow(void)
break;
case cSource::stTerr:
OSDDRAWINFOLINE(*cString::sprintf("DVB-T #%d - %s", (m_SvdrpFrontend >= 0) ? m_SvdrpFrontend : cDevice::ActualDevice()->CardIndex(), m_FrontendInfo.name));
OSDDRAWINFOLINE(*cString::sprintf("%s #%d - %s", *getTerrestrialSystem(dtp.System()), (m_SvdrpFrontend >= 0) ? m_SvdrpFrontend : cDevice::ActualDevice()->CardIndex(), m_FrontendInfo.name));
offset += OSDROWHEIGHT;
OSDDRAWINFOLEFT( trVDR("Frequency"), *getFrequencyMHz(channel->Frequency()));
OSDDRAWINFORIGHT(trVDR("Transmission"), *getTransmission(dtp.Transmission()));
@ -461,6 +462,10 @@ void cFemonOsd::DrawInfoWindow(void)
offset += OSDROWHEIGHT;
OSDDRAWINFOLEFT( trVDR("Hierarchy"), *getHierarchy(dtp.Hierarchy()));
OSDDRAWINFORIGHT(trVDR("Guard"), *getGuard(dtp.Guard()));
offset += OSDROWHEIGHT;
OSDDRAWINFOLEFT( trVDR("System"), *getTerrestrialSystem(dtp.System()));
if (dtp.System())
OSDDRAWINFORIGHT(trVDR("PlpId"), *cString::sprintf("%d", dtp.PlpId()));
break;
default:
@ -622,8 +627,8 @@ void cFemonOsd::Show(void)
{
debug("%s()\n", __PRETTY_FUNCTION__);
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
cString dev = cString::sprintf(FRONTEND_DEVICE, cDevice::ActualDevice()->CardIndex(), 0);
m_Frontend = open(dev, O_RDONLY | O_NONBLOCK);
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)
@ -680,8 +685,8 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
if (!device->IsPrimaryDevice() || !channelNumber || cDevice::PrimaryDevice()->CurrentChannel() != channelNumber)
return;
close(m_Frontend);
cString dev = cString::sprintf(FRONTEND_DEVICE, cDevice::ActualDevice()->CardIndex(), 0);
m_Frontend = open(dev, O_RDONLY | O_NONBLOCK);
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)

View File

@ -76,7 +76,7 @@ static const char *getUserString(int Value, const tDvbParameterMap *Map)
return "---";
}
cString getFrontendInfo(int cardIndex)
cString getFrontendInfo(cDvbDevice *device)
{
cString info;
struct dvb_frontend_info value;
@ -86,13 +86,15 @@ cString getFrontendInfo(int cardIndex)
uint32_t ber = 0;
uint32_t unc = 0;
cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel());
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return info;
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return NULL;
return info;
info = cString::sprintf("CARD:%d\nSTRG:%d\nQUAL:%d", cardIndex, cDevice::ActualDevice()->SignalStrength(), cDevice::ActualDevice()->SignalQuality());
info = cString::sprintf("CARD:%d\nSTRG:%d\nQUAL:%d", device->CardIndex(), device->SignalStrength(), device->SignalQuality());
if (ioctl(fe, FE_GET_INFO, &value) >= 0)
info = cString::sprintf("%s\nTYPE:%d\nNAME:%s", *info, value.type, value.name);
@ -117,42 +119,48 @@ cString getFrontendInfo(int cardIndex)
return info;
}
cString getFrontendName(int cardIndex)
cString getFrontendName(cDvbDevice *device)
{
struct dvb_frontend_info value;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return NULL;
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return NULL;
memset(&value, 0, sizeof(value));
ioctl(fe, FE_GET_INFO, &value);
close(fe);
return (cString::sprintf("%s on device #%d", value.name, cardIndex));
return (cString::sprintf("%s on device #%d", value.name, device->CardIndex()));
}
cString getFrontendStatus(int cardIndex)
cString getFrontendStatus(cDvbDevice *device)
{
fe_status_t value;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return NULL;
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return NULL;
memset(&value, 0, sizeof(value));
ioctl(fe, FE_READ_STATUS, &value);
close(fe);
return (cString::sprintf("Status %s:%s:%s:%s:%s on device #%d", (value & FE_HAS_LOCK) ? "LOCKED" : "-", (value & FE_HAS_SIGNAL) ? "SIGNAL" : "-", (value & FE_HAS_CARRIER) ? "CARRIER" : "-", (value & FE_HAS_VITERBI) ? "VITERBI" : "-", (value & FE_HAS_SYNC) ? "SYNC" : "-", cardIndex));
return (cString::sprintf("Status %s:%s:%s:%s:%s on device #%d", (value & FE_HAS_LOCK) ? "LOCKED" : "-", (value & FE_HAS_SIGNAL) ? "SIGNAL" : "-", (value & FE_HAS_CARRIER) ? "CARRIER" : "-", (value & FE_HAS_VITERBI) ? "VITERBI" : "-", (value & FE_HAS_SYNC) ? "SYNC" : "-", device->CardIndex()));
}
uint16_t getSignal(int cardIndex)
uint16_t getSignal(cDvbDevice *device)
{
uint16_t value = 0;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return (value);
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return (value);
ioctl(fe, FE_READ_SIGNAL_STRENGTH, &value);
@ -161,12 +169,14 @@ uint16_t getSignal(int cardIndex)
return (value);
}
uint16_t getSNR(int cardIndex)
uint16_t getSNR(cDvbDevice *device)
{
uint16_t value = 0;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return (value);
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return (value);
ioctl(fe, FE_READ_SNR, &value);
@ -175,12 +185,14 @@ uint16_t getSNR(int cardIndex)
return (value);
}
uint32_t getBER(int cardIndex)
uint32_t getBER(cDvbDevice *device)
{
uint32_t value = 0;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return (value);
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return (value);
ioctl(fe, FE_READ_BER, &value);
@ -189,12 +201,14 @@ uint32_t getBER(int cardIndex)
return (value);
}
uint32_t getUNC(int cardIndex)
uint32_t getUNC(cDvbDevice *device)
{
uint32_t value = 0;
cString dev = cString::sprintf(FRONTEND_DEVICE, cardIndex, 0);
int fe = open(dev, O_RDONLY | O_NONBLOCK);
if (!device)
return (value);
int fe = open(*cString::sprintf(FRONTEND_DEVICE, device->Adapter(), device->Frontend()), O_RDONLY | O_NONBLOCK);
if (fe < 0)
return (value);
ioctl(fe, FE_READ_UNCORRECTED_BLOCKS, &value);
@ -347,9 +361,14 @@ cString getModulation(int value)
return cString::sprintf("%s", getUserString(value, ModulationValues));
}
cString getSystem(int value)
cString getTerrestrialSystem(int value)
{
return cString::sprintf("%s", getUserString(value, SystemValues));
return cString::sprintf("%s", getUserString(value, SystemValuesTerr));
}
cString getSatelliteSystem(int value)
{
return cString::sprintf("%s", getUserString(value, SystemValuesSat));
}
cString getRollOff(int value)

View File

@ -10,6 +10,7 @@
#include <stdint.h>
#include <vdr/channels.h>
#include <vdr/dvbdevice.h>
#include <vdr/remux.h>
#include <vdr/tools.h>
@ -25,15 +26,15 @@
#define FRONTEND_DEVICE "/dev/dvb/adapter%d/frontend%d"
cString getFrontendInfo(int cardIndex = 0);
cString getFrontendName(int cardIndex = 0);
cString getFrontendStatus(int cardIndex = 0);
cString getFrontendInfo(cDvbDevice *device);
cString getFrontendName(cDvbDevice *device);
cString getFrontendStatus(cDvbDevice *device);
uint16_t getSNR(int cardIndex = 0);
uint16_t getSignal(int cardIndex = 0);
uint16_t getSNR(cDvbDevice *device);
uint16_t getSignal(cDvbDevice *device);
uint32_t getBER(int cardIndex = 0);
uint32_t getUNC(int cardIndex = 0);
uint32_t getBER(cDvbDevice *device);
uint32_t getUNC(cDvbDevice *device);
cString getApids(const cChannel *channel);
cString getDpids(const cChannel *channel);
@ -51,7 +52,8 @@ cString getInversion(int value);
cString getHierarchy(int value);
cString getGuard(int value);
cString getModulation(int value);
cString getSystem(int value);
cString getTerrestrialSystem(int value);
cString getSatelliteSystem(int value);
cString getRollOff(int value);
cString getResolution(int width, int height, int scan);
cString getAspectRatio(int value);