1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Added IPTV information menu and SVDRP INFO command.

This commit is contained in:
Rolf Ahrenberg 2007-10-06 20:57:53 +00:00
parent 3e553d5324
commit d857378616
6 changed files with 162 additions and 36 deletions

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: device.c,v 1.51 2007/10/06 00:02:50 rahrenbe Exp $ * $Id: device.c,v 1.52 2007/10/06 20:57:53 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -13,7 +13,7 @@
#define IPTV_MAX_DEVICES 8 #define IPTV_MAX_DEVICES 8
cIptvDevice * IptvDevices[IPTV_MAX_DEVICES]; cIptvDevice * IptvDevices[IPTV_MAX_DEVICES] = { NULL };
unsigned int cIptvDevice::deviceCount = 0; unsigned int cIptvDevice::deviceCount = 0;
@ -63,11 +63,13 @@ cIptvDevice::~cIptvDevice()
bool cIptvDevice::Initialize(unsigned int DeviceCount) bool cIptvDevice::Initialize(unsigned int DeviceCount)
{ {
debug("cIptvDevice::Initialize()\n"); debug("cIptvDevice::Initialize(): DeviceCount=%d\n", DeviceCount);
if (DeviceCount > IPTV_MAX_DEVICES) if (DeviceCount > IPTV_MAX_DEVICES)
DeviceCount = IPTV_MAX_DEVICES; DeviceCount = IPTV_MAX_DEVICES;
for (unsigned int i = 0; i < DeviceCount; ++i) for (unsigned int i = 0; i < DeviceCount; ++i)
IptvDevices[i] = new cIptvDevice(i); IptvDevices[i] = new cIptvDevice(i);
for (unsigned int i = DeviceCount; i < IPTV_MAX_DEVICES; ++i)
IptvDevices[i] = NULL;
return true; return true;
} }
@ -76,20 +78,33 @@ unsigned int cIptvDevice::Count(void)
unsigned int count = 0; unsigned int count = 0;
debug("cIptvDevice::Count()\n"); debug("cIptvDevice::Count()\n");
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) { for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevices[i]) if (IptvDevices[i] != NULL)
count++; count++;
} }
return count; return count;
} }
cIptvDevice *cIptvDevice::Get(unsigned int DeviceIndex) cIptvDevice *cIptvDevice::GetIptvDevice(int CardIndex)
{ {
debug("cIptvDevice::Get()\n"); //debug("cIptvDevice::GetIptvDevice(%d)\n", CardIndex);
if ((DeviceIndex > 0) && (DeviceIndex <= IPTV_MAX_DEVICES)) for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
return IptvDevices[DeviceIndex - 1]; if ((IptvDevices[i] != NULL) && (IptvDevices[i]->CardIndex() == CardIndex)) {
//debug("cIptvDevice::GetIptvDevice(%d): FOUND!\n", CardIndex);
return IptvDevices[i];
}
}
return NULL; return NULL;
} }
cString cIptvDevice::GetInformation(void)
{
char Text[25];
struct tm tm_r;
time_t t = time(NULL);
strftime(Text, sizeof(Text), "%T", localtime_r(&t, &tm_r));
return cString::sprintf("IPTV device: %d\nTime: %s\n", deviceIndex, Text);
}
cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol) cString cIptvDevice::GetChannelSettings(const char *Param, int *IpPort, cIptvProtocolIf* *Protocol)
{ {
debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex); debug("cIptvDevice::GetChannelSettings(%d)\n", deviceIndex);

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: device.h,v 1.24 2007/10/05 19:00:44 ajhseppa Exp $ * $Id: device.h,v 1.25 2007/10/06 20:57:53 rahrenbe Exp $
*/ */
#ifndef __IPTV_DEVICE_H #ifndef __IPTV_DEVICE_H
@ -24,7 +24,7 @@ public:
static unsigned int deviceCount; static unsigned int deviceCount;
static bool Initialize(unsigned int DeviceCount); static bool Initialize(unsigned int DeviceCount);
static unsigned int Count(void); static unsigned int Count(void);
static cIptvDevice *Get(unsigned int DeviceIndex); static cIptvDevice *GetIptvDevice(int CardIndex);
// private parts // private parts
private: private:
@ -48,6 +48,7 @@ private:
public: public:
cIptvDevice(unsigned int DeviceIndex); cIptvDevice(unsigned int DeviceIndex);
virtual ~cIptvDevice(); virtual ~cIptvDevice();
cString GetInformation(void);
// for channel parsing & buffering // for channel parsing & buffering
private: private:

16
iptv.c
View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: iptv.c,v 1.10 2007/10/06 00:02:50 rahrenbe Exp $ * $Id: iptv.c,v 1.11 2007/10/06 20:57:53 rahrenbe Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -158,7 +158,7 @@ int cPluginIptv::ParseFilters(const char *Value, int *Filters)
while (Value && *Value && (n < SECTION_FILTER_TABLE_SIZE)) { while (Value && *Value && (n < SECTION_FILTER_TABLE_SIZE)) {
strn0cpy(buffer, Value, sizeof(buffer)); strn0cpy(buffer, Value, sizeof(buffer));
int i = atoi(buffer); int i = atoi(buffer);
debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i); //debug("cPluginIptv::ParseFilters(): Filters[%d]=%d\n", n, i);
if (i >= 0) if (i >= 0)
Filters[n++] = i; Filters[n++] = i;
if ((Value = strchr(Value, ' ')) != NULL) if ((Value = strchr(Value, ' ')) != NULL)
@ -206,8 +206,16 @@ const char **cPluginIptv::SVDRPHelpPages(void)
cString cPluginIptv::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) cString cPluginIptv::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{ {
//debug("cPluginIptv::SVDRPCommand()\n"); debug("cPluginIptv::SVDRPCommand(): Command=%s Option=%s\n", Command, Option);
// Process SVDRP commands this plugin implements if (strcasecmp(Command, "INFO") == 0) {
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
if (device)
return device->GetInformation();
else {
ReplyCode = 550; // Requested action not taken
return cString("IPTV information not available!");
}
}
return NULL; return NULL;
} }

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: VDR 1.5.7\n" "Project-Id-Version: VDR 1.5.7\n"
"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" "Report-Msgid-Bugs-To: Rolf Ahrenberg\n"
"POT-Creation-Date: 2007-10-06 02:54+0300\n" "POT-Creation-Date: 2007-10-06 23:51+0300\n"
"PO-Revision-Date: 2007-08-12 23:22+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n"
"Last-Translator: Rolf Ahrenberg\n" "Last-Translator: Rolf Ahrenberg\n"
"Language-Team: <vdr@linuxtv.org>\n" "Language-Team: <vdr@linuxtv.org>\n"
@ -47,67 +47,75 @@ msgstr "TDT (0x70)"
msgid "Experiment the IPTV" msgid "Experiment the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma" msgstr "Koe IPTV:n ihmeellinen maailma"
#: setup.c:53 #: setup.c:55
msgid "UDP" msgid "UDP"
msgstr "UDP" msgstr "UDP"
#: setup.c:54 #: setup.c:56
msgid "HTTP" msgid "HTTP"
msgstr "HTTP" msgstr "HTTP"
#: setup.c:55 #: setup.c:57
msgid "FILE" msgid "FILE"
msgstr "FILE" msgstr "FILE"
#: setup.c:170 #: setup.c:172
msgid "Protocol" msgid "Protocol"
msgstr "Protokolla" msgstr "Protokolla"
#: setup.c:174 #: setup.c:176
msgid "Delay (ms)" msgid "Delay (ms)"
msgstr "Viive (ms)" msgstr "Viive (ms)"
#: setup.c:179 #: setup.c:181
msgid "Address" msgid "Address"
msgstr "Osoite" msgstr "Osoite"
#: setup.c:180 #: setup.c:182
msgid "Port" msgid "Port"
msgstr "Portti" msgstr "Portti"
#: setup.c:195 #: setup.c:197
msgid "Rid" msgid "Rid"
msgstr "Radio-ID" msgstr "Radio-ID"
#: setup.c:267 #: setup.c:269
msgid "Cannot find unique channel settings!" msgid "Cannot find unique channel settings!"
msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!" msgstr "Yksilöllisiä kanava-asetuksia ei löydetä!"
#: setup.c:341 #: setup.c:343
msgid "IPTV Channels" msgid "IPTV Channels"
msgstr "IPTV-kanavat" msgstr "IPTV-kanavat"
#: setup.c:494 #: setup.c:492
msgid "IPTV Information"
msgstr "IPTV-tiedot"
#: setup.c:509
msgid "IPTV information not available!"
msgstr "IPTV-tietoja ei saatavilla!"
#: setup.c:578
msgid "TS buffer size [MB]" msgid "TS buffer size [MB]"
msgstr "TS-puskurin koko [MB]" msgstr "TS-puskurin koko [MB]"
#: setup.c:495 #: setup.c:579
msgid "TS buffer prefill ratio [%]" msgid "TS buffer prefill ratio [%]"
msgstr "TS-puskurin esitäyttöaste [%]" msgstr "TS-puskurin esitäyttöaste [%]"
#: setup.c:496 #: setup.c:580
msgid "Use section filtering" msgid "Use section filtering"
msgstr "Käytä sektioiden suodatusta" msgstr "Käytä sektioiden suodatusta"
#: setup.c:498 #: setup.c:582
msgid "Scan Sid automatically" msgid "Scan Sid automatically"
msgstr "Etsi palvelu-ID automaattisesti" msgstr "Etsi palvelu-ID automaattisesti"
#: setup.c:499 #: setup.c:583
msgid "Disable filters" msgid "Disable filters"
msgstr "Poista suodattimia käytöstä" msgstr "Poista suodattimia käytöstä"
#. TRANSLATORS: note the singular! #. TRANSLATORS: note the singular!
#: setup.c:502 #: setup.c:586
msgid "Disable filter" msgid "Disable filter"
msgstr "Poista suodatin käytöstä" msgstr "Poista suodatin käytöstä"

101
setup.c
View File

@ -3,16 +3,18 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: setup.c,v 1.20 2007/10/06 00:02:50 rahrenbe Exp $ * $Id: setup.c,v 1.21 2007/10/06 20:57:53 rahrenbe Exp $
*/ */
#include <string.h> #include <string.h>
#include <vdr/device.h> #include <vdr/device.h>
#include <vdr/interface.h> #include <vdr/interface.h>
#include <vdr/status.h>
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "device.h"
#include "setup.h" #include "setup.h"
#ifndef trVDR #ifndef trVDR
@ -467,6 +469,88 @@ eOSState cIptvMenuChannels::ProcessKey(eKeys Key)
return state; return state;
} }
// --- cIptvMenuInfo ---------------------------------------------------------
class cIptvMenuInfo : public cOsdMenu
{
private:
enum {
INFO_TIMEOUT = 2000
};
char *text;
cTimeMs timeout;
void UpdateInfo();
public:
cIptvMenuInfo();
virtual ~cIptvMenuInfo();
virtual void Display(void);
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuInfo::cIptvMenuInfo()
:cOsdMenu(tr("IPTV Information")), text(NULL), timeout(INFO_TIMEOUT)
{
UpdateInfo();
}
cIptvMenuInfo::~cIptvMenuInfo()
{
free(text);
}
void cIptvMenuInfo::UpdateInfo(void)
{
cIptvDevice *device = cIptvDevice::GetIptvDevice(cDevice::ActualDevice()->CardIndex());
char Text[64];
if (device)
snprintf(Text, sizeof(Text), "%s", *device->GetInformation());
else
snprintf(Text, sizeof(Text), "%s", tr("IPTV information not available!"));
free(text);
text = Text ? strdup(Text) : NULL;
Display();
timeout.Set(INFO_TIMEOUT);
}
void cIptvMenuInfo::Display(void)
{
cOsdMenu::Display();
DisplayMenu()->SetText(text, true);
if (text)
cStatus::MsgOsdTextItem(text);
}
eOSState cIptvMenuInfo::ProcessKey(eKeys Key)
{
switch (Key) {
case kUp|k_Repeat:
case kUp:
case kDown|k_Repeat:
case kDown:
case kLeft|k_Repeat:
case kLeft:
case kRight|k_Repeat:
case kRight:
DisplayMenu()->Scroll(NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft, NORMALKEY(Key) == kLeft || NORMALKEY(Key) == kRight);
cStatus::MsgOsdTextItem(NULL, NORMALKEY(Key) == kUp || NORMALKEY(Key) == kLeft);
return osContinue;
default: break;
}
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kOk: return osBack;
default: if (timeout.TimedOut())
UpdateInfo();
return osContinue;
}
}
return state;
}
// --- cIptvPluginSetup ------------------------------------------------------ // --- cIptvPluginSetup ------------------------------------------------------
cIptvPluginSetup::cIptvPluginSetup() cIptvPluginSetup::cIptvPluginSetup()
@ -484,7 +568,7 @@ cIptvPluginSetup::cIptvPluginSetup()
disabledFilterNames[i] = tr(section_filter_table[i].description); disabledFilterNames[i] = tr(section_filter_table[i].description);
} }
Setup(); Setup();
SetHelp(trVDR("Channels"), NULL, NULL, NULL); SetHelp(trVDR("Channels"), NULL, NULL, trVDR("Button$Info"));
} }
void cIptvPluginSetup::Setup(void) void cIptvPluginSetup::Setup(void)
@ -514,6 +598,14 @@ eOSState cIptvPluginSetup::EditChannel(void)
return AddSubMenu(new cIptvMenuChannels()); return AddSubMenu(new cIptvMenuChannels());
} }
eOSState cIptvPluginSetup::ShowInfo(void)
{
debug("cIptvPluginSetup::ShowInfo()\n");
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuInfo());
}
eOSState cIptvPluginSetup::ProcessKey(eKeys Key) eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
{ {
int oldsectionFiltering = sectionFiltering; int oldsectionFiltering = sectionFiltering;
@ -521,8 +613,9 @@ eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
eOSState state = cMenuSetupPage::ProcessKey(Key); eOSState state = cMenuSetupPage::ProcessKey(Key);
if (state == osUnknown) { if (state == osUnknown) {
switch (Key) { switch (Key) {
case kRed: return EditChannel(); case kRed: return EditChannel();
default: break; case kBlue: return ShowInfo();
default: state = osContinue;
} }
} }
if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) { if ((Key != kNone) && ((numDisabledFilters != oldNumDisabledFilters) || (sectionFiltering != oldsectionFiltering))) {

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: setup.h,v 1.10 2007/10/06 00:02:50 rahrenbe Exp $ * $Id: setup.h,v 1.11 2007/10/06 20:57:53 rahrenbe Exp $
*/ */
#ifndef __IPTV_SETUP_H #ifndef __IPTV_SETUP_H
@ -24,6 +24,7 @@ private:
const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE]; const char *disabledFilterNames[SECTION_FILTER_TABLE_SIZE];
eOSState EditChannel(void); eOSState EditChannel(void);
eOSState ShowInfo(void);
virtual void Setup(void); virtual void Setup(void);
void StoreFilters(const char *Name, int *Values); void StoreFilters(const char *Name, int *Values);