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

updated vdr patch and added a preliminary channel editor.

This commit is contained in:
Rolf Ahrenberg 2007-09-18 18:48:10 +00:00
parent d2548271e9
commit dc6ff5edc6
5 changed files with 547 additions and 80 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.22 2007/09/16 16:03:24 rahrenbe Exp $ * $Id: device.c,v 1.23 2007/09/18 18:48:10 rahrenbe Exp $
*/ */
#include "common.h" #include "common.h"
@ -106,13 +106,13 @@ bool cIptvDevice::ProvidesIptv(const char *Param) const
bool cIptvDevice::ProvidesSource(int Source) const bool cIptvDevice::ProvidesSource(int Source) const
{ {
debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex); debug("cIptvDevice::ProvidesSource(%d)\n", deviceIndex);
return ((Source & cSource::st_Mask) == cSource::stPlug); return (cSource::IsPlug(Source));
} }
bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const bool cIptvDevice::ProvidesTransponder(const cChannel *Channel) const
{ {
debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex); debug("cIptvDevice::ProvidesTransponder(%d)\n", deviceIndex);
return (ProvidesSource(Channel->Source()) && ProvidesIptv(Channel->Param())); return (ProvidesSource(Channel->Source()) && ProvidesIptv(Channel->PluginParam()));
} }
bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const bool cIptvDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
@ -135,9 +135,9 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
cIptvProtocolIf *protocol; cIptvProtocolIf *protocol;
debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex); debug("cIptvDevice::SetChannelDevice(%d)\n", deviceIndex);
addr = GetChannelSettings(Channel->Param(), &port, &protocol); addr = GetChannelSettings(Channel->PluginParam(), &port, &protocol);
if (isempty(addr)) { if (isempty(addr)) {
error("ERROR: Unrecognized IPTV channel settings: %s", Channel->Param()); error("ERROR: Unrecognized IPTV channel settings: %s", Channel->PluginParam());
return false; return false;
} }
// pad prefill to multiple of TS_SIZE // pad prefill to multiple of TS_SIZE

View File

@ -1,11 +1,11 @@
diff -Nru vdr-1.5.9-vanilla/channels.c vdr-1.5.9-iptv/channels.c diff -Nru vdr-1.5.9-vanilla/channels.c vdr-1.5.9-iptv/channels.c
--- vdr-1.5.9-vanilla/channels.c 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/channels.c 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/channels.c 2007-09-11 20:22:48.000000000 +0300 +++ vdr-1.5.9-iptv/channels.c 2007-09-18 19:36:45.000000000 +0300
@@ -166,6 +166,7 @@ @@ -166,6 +166,7 @@
shortName = strdup(""); shortName = strdup("");
provider = strdup(""); provider = strdup("");
portalName = strdup(""); portalName = strdup("");
+ param = strdup(""); + pluginParam = strdup("");
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__); memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
inversion = INVERSION_AUTO; inversion = INVERSION_AUTO;
bandwidth = BANDWIDTH_AUTO; bandwidth = BANDWIDTH_AUTO;
@ -13,7 +13,7 @@ diff -Nru vdr-1.5.9-vanilla/channels.c vdr-1.5.9-iptv/channels.c
shortName = NULL; shortName = NULL;
provider = NULL; provider = NULL;
portalName = NULL; portalName = NULL;
+ param = NULL; + pluginParam = NULL;
schedule = NULL; schedule = NULL;
linkChannels = NULL; linkChannels = NULL;
refChannel = NULL; refChannel = NULL;
@ -21,7 +21,7 @@ diff -Nru vdr-1.5.9-vanilla/channels.c vdr-1.5.9-iptv/channels.c
free(shortName); free(shortName);
free(provider); free(provider);
free(portalName); free(portalName);
+ free(param); + free(pluginParam);
} }
cChannel& cChannel::operator= (const cChannel &Channel) cChannel& cChannel::operator= (const cChannel &Channel)
@ -29,61 +29,98 @@ diff -Nru vdr-1.5.9-vanilla/channels.c vdr-1.5.9-iptv/channels.c
shortName = strcpyrealloc(shortName, Channel.shortName); shortName = strcpyrealloc(shortName, Channel.shortName);
provider = strcpyrealloc(provider, Channel.provider); provider = strcpyrealloc(provider, Channel.provider);
portalName = strcpyrealloc(portalName, Channel.portalName); portalName = strcpyrealloc(portalName, Channel.portalName);
+ param = strcpyrealloc(param, Channel.param); + pluginParam = strcpyrealloc(pluginParam, Channel.pluginParam);
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__); memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
return *this; return *this;
} }
@@ -582,15 +586,16 @@ @@ -280,9 +284,26 @@
char buffer[64]; transmission = Channel->transmission;
guard = Channel->guard;
hierarchy = Channel->hierarchy;
+ if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, Channel->pluginParam);
}
}
+bool cChannel::SetPlugTransponderData(int Source, int Frequency, const char *PluginParam)
+{
+ if (source != Source || frequency != Frequency || (strcmp(pluginParam, PluginParam) != 0)) {
+ if (Number()) {
+ dsyslog("changing transponder data of channel %d from %s:%d:%s to %s:%d:%s", Number(), *cSource::ToString(source), frequency, pluginParam, *cSource::ToString(Source), Frequency, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ source = Source;
+ frequency = Frequency;
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ schedule = NULL;
+ }
+ return true;
+}
+
bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH)
{
// Workarounds for broadcaster stupidity:
@@ -407,6 +428,18 @@
}
}
+void cChannel::SetPluginParam(const char *PluginParam)
+{
+ if (!isempty(PluginParam) && strcmp(pluginParam, PluginParam) != 0) {
+ if (Number()) {
+ dsyslog("changing plugin parameters of channel %d from '%s' to '%s'", Number(), pluginParam, PluginParam);
+ modification |= CHANNELMOD_TRANSP;
+ Channels.SetModified();
+ }
+ pluginParam = strcpyrealloc(pluginParam, PluginParam);
+ }
+}
+
#define STRDIFF 0x01
#define VALDIFF 0x02
@@ -579,7 +612,7 @@
if (isdigit(type))
type = 'S';
#define ST(s) if (strchr(s, type))
- char buffer[64];
+ char buffer[256];
char *q = buffer; char *q = buffer;
*q = 0; *q = 0;
- ST(" S ") q += sprintf(q, "%c", polarization); ST(" S ") q += sprintf(q, "%c", polarization);
- ST("CST") q += PrintParameter(q, 'I', MapToUser(inversion, InversionValues)); @@ -591,6 +624,7 @@
- ST("CST") q += PrintParameter(q, 'C', MapToUser(coderateH, CoderateValues)); ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
- ST(" T") q += PrintParameter(q, 'D', MapToUser(coderateL, CoderateValues)); ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
- ST("C T") q += PrintParameter(q, 'M', MapToUser(modulation, ModulationValues)); ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
- ST(" T") q += PrintParameter(q, 'B', MapToUser(bandwidth, BandwidthValues)); + ST("P ") snprintf(buffer, sizeof(buffer), "%s", pluginParam);
- ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
- ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
- ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
+ ST(" S ") q += sprintf(q, "%c", polarization);
+ ST(" CST") q += PrintParameter(q, 'I', MapToUser(inversion, InversionValues));
+ ST(" CST") q += PrintParameter(q, 'C', MapToUser(coderateH, CoderateValues));
+ ST(" T") q += PrintParameter(q, 'D', MapToUser(coderateL, CoderateValues));
+ ST(" C T") q += PrintParameter(q, 'M', MapToUser(modulation, ModulationValues));
+ ST(" T") q += PrintParameter(q, 'B', MapToUser(bandwidth, BandwidthValues));
+ ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
+ ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
+ ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
+ ST("P ") q += sprintf(q, "%s", param);
return buffer; return buffer;
} }
@@ -612,7 +617,7 @@ @@ -612,7 +646,7 @@
bool cChannel::StringToParameters(const char *s) bool cChannel::StringToParameters(const char *s)
{ {
- while (s && *s) { - while (s && *s) {
+ while (s && *s && IsPlug()) { + while (s && *s && !IsPlug()) {
switch (toupper(*s)) { switch (toupper(*s)) {
case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break; case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
case 'C': s = ParseParameter(s, coderateH, CoderateValues); break; case 'C': s = ParseParameter(s, coderateH, CoderateValues); break;
@@ -813,6 +818,7 @@ @@ -813,6 +847,7 @@
shortName = strcpyrealloc(shortName, p); shortName = strcpyrealloc(shortName, p);
} }
name = strcpyrealloc(name, namebuf); name = strcpyrealloc(name, namebuf);
+ param = strcpyrealloc(param, parambuf); + if (IsPlug()) pluginParam = strcpyrealloc(pluginParam, parambuf);
free(parambuf); free(parambuf);
free(sourcebuf); free(sourcebuf);
diff -Nru vdr-1.5.9-vanilla/channels.h vdr-1.5.9-iptv/channels.h diff -Nru vdr-1.5.9-vanilla/channels.h vdr-1.5.9-iptv/channels.h
--- vdr-1.5.9-vanilla/channels.h 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/channels.h 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/channels.h 2007-09-11 20:22:48.000000000 +0300 +++ vdr-1.5.9-iptv/channels.h 2007-09-18 19:36:24.000000000 +0300
@@ -114,6 +114,7 @@ @@ -114,6 +114,7 @@
char *shortName; char *shortName;
char *provider; char *provider;
char *portalName; char *portalName;
+ char *param; + char *pluginParam;
int __BeginData__; int __BeginData__;
int frequency; // MHz int frequency; // MHz
int source; int source;
@ -91,7 +128,7 @@ diff -Nru vdr-1.5.9-vanilla/channels.h vdr-1.5.9-iptv/channels.h
int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf' int Frequency(void) const { return frequency; } ///< Returns the actual frequency, as given in 'channels.conf'
int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat int Transponder(void) const; ///< Returns the transponder frequency in MHz, plus the polarization in case of sat
static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization static int Transponder(int Frequency, char Polarization); ///< builds the transponder from the given Frequency and Polarization
+ const char *Param(void) const { return param; } + const char *PluginParam(void) const { return pluginParam; }
int Source(void) const { return source; } int Source(void) const { return source; }
int Srate(void) const { return srate; } int Srate(void) const { return srate; }
int Vpid(void) const { return vpid; } int Vpid(void) const { return vpid; }
@ -103,14 +140,29 @@ diff -Nru vdr-1.5.9-vanilla/channels.h vdr-1.5.9-iptv/channels.h
bool IsCable(void) const { return cSource::IsCable(source); } bool IsCable(void) const { return cSource::IsCable(source); }
bool IsSat(void) const { return cSource::IsSat(source); } bool IsSat(void) const { return cSource::IsSat(source); }
bool IsTerr(void) const { return cSource::IsTerr(source); } bool IsTerr(void) const { return cSource::IsTerr(source); }
@@ -206,12 +209,14 @@
bool HasTimer(void) const;
int Modification(int Mask = CHANNELMOD_ALL);
void CopyTransponderData(const cChannel *Channel);
+ bool SetPlugTransponderData(int Source, int Frequency, const char *PluginParam);
bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH);
bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH);
bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);
void SetId(int Nid, int Tid, int Sid, int Rid = 0);
void SetName(const char *Name, const char *ShortName, const char *Provider);
void SetPortalName(const char *PortalName);
+ void SetPluginParam(const char *PluginParam);
void SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int Tpid);
void SetCaIds(const int *CaIds); // list must be zero-terminated
void SetCaDescriptors(int Level);
diff -Nru vdr-1.5.9-vanilla/menu.c vdr-1.5.9-iptv/menu.c diff -Nru vdr-1.5.9-vanilla/menu.c vdr-1.5.9-iptv/menu.c
--- vdr-1.5.9-vanilla/menu.c 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/menu.c 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/menu.c 2007-09-11 20:23:26.000000000 +0300 +++ vdr-1.5.9-iptv/menu.c 2007-09-18 19:36:24.000000000 +0300
@@ -219,6 +219,7 @@ @@ -219,6 +219,7 @@
cChannel *channel; cChannel *channel;
cChannel data; cChannel data;
char name[256]; char name[256];
+ char param[256]; + char pluginParam[256];
void Setup(void); void Setup(void);
public: public:
cMenuEditChannel(cChannel *Channel, bool New = false); cMenuEditChannel(cChannel *Channel, bool New = false);
@ -118,41 +170,29 @@ diff -Nru vdr-1.5.9-vanilla/menu.c vdr-1.5.9-iptv/menu.c
// Parameters for all types of sources: // Parameters for all types of sources:
strn0cpy(name, data.name, sizeof(name)); strn0cpy(name, data.name, sizeof(name));
+ strn0cpy(param, data.param, sizeof(param)); + strn0cpy(pluginParam, data.pluginParam, sizeof(pluginParam));
Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name), tr(FileNameChars))); Add(new cMenuEditStrItem( tr("Name"), name, sizeof(name), tr(FileNameChars)));
Add(new cMenuEditSrcItem( tr("Source"), &data.source)); Add(new cMenuEditSrcItem( tr("Source"), &data.source));
Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency)); Add(new cMenuEditIntItem( tr("Frequency"), &data.frequency));
@@ -269,16 +271,17 @@ @@ -279,6 +281,7 @@
Add(new cMenuEditIntItem( tr("Rid"), &data.rid, 0)); ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
XXX*/ ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
// Parameters for specific types of sources: ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
- ST(" S ") Add(new cMenuEditChrItem( tr("Polarization"), &data.polarization, "hvlr")); + ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), pluginParam, sizeof(pluginParam), tr(FileNameChars)));
- ST("CS ") Add(new cMenuEditIntItem( tr("Srate"), &data.srate));
- ST("CST") Add(new cMenuEditMapItem( tr("Inversion"), &data.inversion, InversionValues, tr("off")));
- ST("CST") Add(new cMenuEditMapItem( tr("CoderateH"), &data.coderateH, CoderateValues, tr("none")));
- ST(" T") Add(new cMenuEditMapItem( tr("CoderateL"), &data.coderateL, CoderateValues, tr("none")));
- ST("C T") Add(new cMenuEditMapItem( tr("Modulation"), &data.modulation, ModulationValues, "QPSK"));
- ST(" T") Add(new cMenuEditMapItem( tr("Bandwidth"), &data.bandwidth, BandwidthValues));
- ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
- ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
- ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
+ ST(" S ") Add(new cMenuEditChrItem( tr("Polarization"), &data.polarization, "hvlr"));
+ ST(" CS ") Add(new cMenuEditIntItem( tr("Srate"), &data.srate));
+ ST(" CST") Add(new cMenuEditMapItem( tr("Inversion"), &data.inversion, InversionValues, tr("off")));
+ ST(" CST") Add(new cMenuEditMapItem( tr("CoderateH"), &data.coderateH, CoderateValues, tr("none")));
+ ST(" T") Add(new cMenuEditMapItem( tr("CoderateL"), &data.coderateL, CoderateValues, tr("none")));
+ ST(" C T") Add(new cMenuEditMapItem( tr("Modulation"), &data.modulation, ModulationValues, "QPSK"));
+ ST(" T") Add(new cMenuEditMapItem( tr("Bandwidth"), &data.bandwidth, BandwidthValues));
+ ST(" T") Add(new cMenuEditMapItem( tr("Transmission"), &data.transmission, TransmissionValues));
+ ST(" T") Add(new cMenuEditMapItem( tr("Guard"), &data.guard, GuardValues));
+ ST(" T") Add(new cMenuEditMapItem( tr("Hierarchy"), &data.hierarchy, HierarchyValues, tr("none")));
+ ST("P ") Add(new cMenuEditStrItem( tr("Parameters"), param, sizeof(param), tr(FileNameChars)));
SetCurrent(Get(current)); SetCurrent(Get(current));
Display(); Display();
@@ -293,6 +296,7 @@
if (Key == kOk) {
if (Channels.HasUniqueChannelID(&data, channel)) {
data.name = strcpyrealloc(data.name, name);
+ data.pluginParam = strcpyrealloc(data.pluginParam, pluginParam);
if (channel) {
*channel = data;
isyslog("edited channel %d %s", channel->Number(), *data.ToText());
diff -Nru vdr-1.5.9-vanilla/po/fi_FI.po vdr-1.5.9-iptv/po/fi_FI.po diff -Nru vdr-1.5.9-vanilla/po/fi_FI.po vdr-1.5.9-iptv/po/fi_FI.po
--- vdr-1.5.9-vanilla/po/fi_FI.po 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/po/fi_FI.po 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/po/fi_FI.po 2007-09-11 20:24:22.000000000 +0300 +++ vdr-1.5.9-iptv/po/fi_FI.po 2007-09-18 19:36:24.000000000 +0300
@@ -1271,3 +1271,7 @@ @@ -1271,3 +1271,7 @@
#, c-format #, c-format
msgid "VDR will shut down in %s minutes" msgid "VDR will shut down in %s minutes"
@ -163,7 +203,7 @@ diff -Nru vdr-1.5.9-vanilla/po/fi_FI.po vdr-1.5.9-iptv/po/fi_FI.po
+msgstr "Parametrit" +msgstr "Parametrit"
diff -Nru vdr-1.5.9-vanilla/sources.c vdr-1.5.9-iptv/sources.c diff -Nru vdr-1.5.9-vanilla/sources.c vdr-1.5.9-iptv/sources.c
--- vdr-1.5.9-vanilla/sources.c 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/sources.c 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/sources.c 2007-09-11 20:22:48.000000000 +0300 +++ vdr-1.5.9-iptv/sources.c 2007-09-18 19:36:24.000000000 +0300
@@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
char buffer[16]; char buffer[16];
char *q = buffer; char *q = buffer;
@ -182,7 +222,7 @@ diff -Nru vdr-1.5.9-vanilla/sources.c vdr-1.5.9-iptv/sources.c
case 'T': type = stTerr; break; case 'T': type = stTerr; break;
diff -Nru vdr-1.5.9-vanilla/sources.conf vdr-1.5.9-iptv/sources.conf diff -Nru vdr-1.5.9-vanilla/sources.conf vdr-1.5.9-iptv/sources.conf
--- vdr-1.5.9-vanilla/sources.conf 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/sources.conf 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/sources.conf 2007-09-11 20:22:48.000000000 +0300 +++ vdr-1.5.9-iptv/sources.conf 2007-09-18 19:36:24.000000000 +0300
@@ -188,3 +188,7 @@ @@ -188,3 +188,7 @@
# Terrestrial # Terrestrial
@ -193,7 +233,7 @@ diff -Nru vdr-1.5.9-vanilla/sources.conf vdr-1.5.9-iptv/sources.conf
+P Plugin +P Plugin
diff -Nru vdr-1.5.9-vanilla/sources.h vdr-1.5.9-iptv/sources.h diff -Nru vdr-1.5.9-vanilla/sources.h vdr-1.5.9-iptv/sources.h
--- vdr-1.5.9-vanilla/sources.h 2007-08-26 18:45:20.000000000 +0300 --- vdr-1.5.9-vanilla/sources.h 2007-08-26 18:45:20.000000000 +0300
+++ vdr-1.5.9-iptv/sources.h 2007-09-11 20:22:48.000000000 +0300 +++ vdr-1.5.9-iptv/sources.h 2007-09-18 19:36:24.000000000 +0300
@@ -16,10 +16,11 @@ @@ -16,10 +16,11 @@
public: public:
enum eSourceType { enum eSourceType {

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-09-16 16:48+0300\n" "POT-Creation-Date: 2007-09-18 21:37+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"
@ -19,22 +19,50 @@ msgstr ""
msgid "Experiment the IPTV" msgid "Experiment the IPTV"
msgstr "Koe IPTV:n ihmeellinen maailma" msgstr "Koe IPTV:n ihmeellinen maailma"
#: setup.c:32 #: setup.c:53
msgid "UDP"
msgstr "UDP"
#: setup.c:54
msgid "HTTP"
msgstr "HTTP"
#: setup.c:55
msgid "FILE"
msgstr "FILE"
#: setup.c:170
msgid "Protocol"
msgstr "Protokolla"
#: setup.c:178
msgid "Address"
msgstr "Osoite"
#: setup.c:179
msgid "Port"
msgstr "Portti"
#: setup.c:280
msgid "IPTV Channels"
msgstr "IPTV-kanavat"
#: setup.c:416
msgid "TS buffer size [MB]" msgid "TS buffer size [MB]"
msgstr "TS-puskurin koko [MB]" msgstr "TS-puskurin koko [MB]"
#: setup.c:33 #: setup.c:417
msgid "TS buffer prefill ratio [%]" msgid "TS buffer prefill ratio [%]"
msgstr "TS-puskurin esitäyttöaste [%]" msgstr "TS-puskurin esitäyttöaste [%]"
#: setup.c:34 #: setup.c:418
msgid "UDP buffer size [packets]" msgid "UDP buffer size [packets]"
msgstr "UDP-puskurin koko [pakettia]" msgstr "UDP-puskurin koko [pakettia]"
#: setup.c:35 #: setup.c:419
msgid "HTTP buffer size [packets]" msgid "HTTP buffer size [packets]"
msgstr "HTTP-puskurin koko [pakettia]" msgstr "HTTP-puskurin koko [pakettia]"
#: setup.c:36 #: setup.c:420
msgid "FILE buffer size [packets]" msgid "FILE buffer size [packets]"
msgstr "FILE-puskurin koko [pakettia]" msgstr "FILE-puskurin koko [pakettia]"

402
setup.c
View File

@ -3,9 +3,14 @@
* *
* 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.5 2007/09/16 13:49:35 rahrenbe Exp $ * $Id: setup.c,v 1.6 2007/09/18 18:48:11 rahrenbe Exp $
*/ */
#include <string.h>
#include <vdr/device.h>
#include <vdr/interface.h>
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#include "setup.h" #include "setup.h"
@ -14,7 +19,386 @@
#define trVDR(s) tr(s) #define trVDR(s) tr(s)
#endif #endif
cIptvPluginSetup::cIptvPluginSetup(void) // --- cIptvMenuEditChannel --------------------------------------------------
class cIptvMenuEditChannel : public cOsdMenu
{
private:
enum {
eProtocolUDP,
eProtocolHTTP,
eProtocolFILE,
eProtocolCount
};
struct tIptvChannel {
int frequency, source, protocol, port, vpid, ppid, tpid, sid, nid, tid, rid;
int apid[MAXAPIDS + 1], dpid[MAXDPIDS + 1], spid[MAXSPIDS + 1], caids[MAXCAIDS + 1];
char name[256], location[256];
} data;
cChannel *channel;
const char *protocols[eProtocolCount];
void Setup(void);
cString GetIptvSettings(const char *Param, int *Port, int *Protocol);
void GetChannelData(cChannel *Channel);
void SetChannelData(cChannel *Channel);
public:
cIptvMenuEditChannel(cChannel *Channel, bool New = false);
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuEditChannel::cIptvMenuEditChannel(cChannel *Channel, bool New)
:cOsdMenu(trVDR("Edit channel"), 16)
{
protocols[eProtocolUDP] = tr("UDP");
protocols[eProtocolHTTP] = tr("HTTP");
protocols[eProtocolFILE] = tr("FILE");
channel = Channel;
GetChannelData(channel);
if (New) {
channel = NULL;
data.nid = 0;
data.tid = 0;
data.rid = 0;
}
Setup();
}
cString cIptvMenuEditChannel::GetIptvSettings(const char *Param, int *Port, int *Protocol)
{
char *loc = NULL;
if (sscanf(Param, "IPTV|UDP|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolUDP;
return addr;
}
else if (sscanf(Param, "IPTV|HTTP|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolHTTP;
return addr;
}
else if (sscanf(Param, "IPTV|FILE|%a[^|]|%u", &loc, Port) == 2) {
cString addr(loc, true);
*Protocol = eProtocolFILE;
return addr;
}
return NULL;
}
void cIptvMenuEditChannel::GetChannelData(cChannel *Channel)
{
if (Channel) {
int port, protocol;
data.frequency = Channel->Frequency();
data.source = Channel->Source();
data.vpid = Channel->Vpid();
data.ppid = Channel->Ppid();
data.tpid = Channel->Tpid();
for (unsigned int i = 0; i < sizeof(data.apid); ++i)
data.apid[i] = Channel->Apid(i);
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
data.dpid[i] = Channel->Dpid(i);
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
data.spid[i] = Channel->Spid(i);
for (unsigned int i = 0; i < sizeof(data.caids); ++i)
data.caids[i] = Channel->Ca(i);
data.sid = Channel->Sid();
data.nid = Channel->Nid();
data.tid = Channel->Tid();
data.rid = Channel->Rid();
strn0cpy(data.name, Channel->Name(), sizeof(data.name));
strn0cpy(data.location, *GetIptvSettings(Channel->PluginParam(), &port, &protocol), sizeof(data.location));
data.protocol = protocol;
data.port = port;
}
else {
data.frequency = 1;
data.source = cSource::FromData(cSource::stPlug);
data.vpid = 0;
data.ppid = 0;
data.tpid = 0;
for (unsigned int i = 0; i < sizeof(data.apid); ++i)
data.apid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.dpid); ++i)
data.dpid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.spid); ++i)
data.spid[i] = 0;
for (unsigned int i = 0; i < sizeof(data.caids); ++i)
data.caids[i] = 0;
data.sid = 1;
data.nid = 0;
data.tid = 0;
data.rid = 0;
strn0cpy(data.name, "IPTV", sizeof(data.name));
strn0cpy(data.location, "127.0.0.1", sizeof(data.location));
data.protocol = eProtocolUDP;
data.port = 0;
}
}
void cIptvMenuEditChannel::SetChannelData(cChannel *Channel)
{
if (Channel) {
cString param;
char alangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char dlangs[MAXDPIDS][MAXLANGCODE2] = { "" };
switch (data.protocol) {
case eProtocolFILE:
param = cString::sprintf("IPTV|FILE|%s|0", data.location);
break;
case eProtocolHTTP:
param = cString::sprintf("IPTV|HTTP|%s|%d", data.location, data.port);
break;
default:
case eProtocolUDP:
param = cString::sprintf("IPTV|UDP|%s|%d", data.location, data.port);
break;
}
Channel->SetPids(data.vpid, data.ppid, data.apid, alangs, data.dpid, dlangs, data.tpid);
Channel->SetCaIds(data.caids);
Channel->SetId(data.nid, data.tid, data.sid, data.rid);
Channel->SetName(data.name, "", "IPTV");
Channel->SetPlugTransponderData(cSource::stPlug, data.frequency, param);
}
}
void cIptvMenuEditChannel::Setup(void)
{
int current = Current();
Clear();
// IPTV specific settings
Add(new cMenuEditStraItem(tr("Protocol"), &data.protocol, 3, protocols));
switch (data.protocol) {
case eProtocolFILE:
Add(new cMenuEditStrItem(trVDR("File"), data.location, sizeof(data.location), trVDR(FileNameChars)));
break;
case eProtocolHTTP:
case eProtocolUDP:
default:
Add(new cMenuEditStrItem(tr("Address"),data.location, sizeof(data.location), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(tr("Port"), &data.port, 0, 0xFFFF));
break;
}
// Normal settings
Add(new cMenuEditStrItem(trVDR("Name"), data.name, sizeof(data.name), trVDR(FileNameChars)));
Add(new cMenuEditIntItem(trVDR("Frequency"), &data.frequency));
Add(new cMenuEditIntItem(trVDR("Vpid"), &data.vpid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Ppid"), &data.ppid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid1"), &data.apid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Apid2"), &data.apid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid1"), &data.dpid[0], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Dpid2"), &data.dpid[1], 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("Tpid"), &data.tpid, 0, 0x1FFF));
Add(new cMenuEditIntItem(trVDR("CA"), &data.caids[0], 0, 0xFFFF));
Add(new cMenuEditIntItem(trVDR("Sid"), &data.sid, 1, 0xFFFF));
SetCurrent(Get(current));
Display();
}
eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key)
{
int oldProtocol = data.protocol;
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
if (Key == kOk) {
cChannel newchannel;
SetChannelData(&newchannel);
if (Channels.HasUniqueChannelID(&newchannel, channel)) {
if (channel) {
SetChannelData(channel);
isyslog("edited channel %d %s", channel->Number(), *channel->ToText());
state = osBack;
}
else {
channel = new cChannel;
SetChannelData(channel);
Channels.Add(channel);
Channels.ReNumber();
isyslog("added channel %d %s", channel->Number(), *channel->ToText());
state = osUser1;
}
Channels.SetModified(true);
}
else {
Skins.Message(mtError, trVDR("Channel settings are not unique!"));
state = osContinue;
}
}
}
if ((Key != kNone) && (data.protocol != oldProtocol))
Setup();
return state;
}
// --- cIptvMenuChannelItem --------------------------------------------------
class cIptvMenuChannelItem : public cOsdItem
{
private:
cChannel *channel;
public:
cIptvMenuChannelItem(cChannel *Channel);
virtual void Set(void);
cChannel *Channel(void) { return channel; }
};
cIptvMenuChannelItem::cIptvMenuChannelItem(cChannel *Channel)
{
channel = Channel;
Set();
}
void cIptvMenuChannelItem::Set(void)
{
char *buffer = NULL;
asprintf(&buffer, "%d\t%s", channel->Number(), channel->Name());
SetText(buffer, false);
}
// --- cIptvMenuChannels -----------------------------------------------------
class cIptvMenuChannels : public cOsdMenu
{
private:
void Setup(void);
cChannel *GetChannel(int Index);
void Propagate(void);
protected:
eOSState Edit(void);
eOSState New(void);
eOSState Delete(void);
public:
cIptvMenuChannels();
~cIptvMenuChannels();
virtual eOSState ProcessKey(eKeys Key);
};
cIptvMenuChannels::cIptvMenuChannels(void)
:cOsdMenu(tr("IPTV Channels"), numdigits(Channels.MaxNumber()) + 1)
{
Setup();
Channels.IncBeingEdited();
}
cIptvMenuChannels::~cIptvMenuChannels()
{
Channels.DecBeingEdited();
}
void cIptvMenuChannels::Setup(void)
{
Clear();
for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() && channel->IsPlug() && !strncmp(channel->PluginParam(), "IPTV", 4)) {
cIptvMenuChannelItem *item = new cIptvMenuChannelItem(channel);
Add(item);
}
}
SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
Display();
}
cChannel *cIptvMenuChannels::GetChannel(int Index)
{
cIptvMenuChannelItem *p = (cIptvMenuChannelItem *)Get(Index);
return p ? (cChannel *)p->Channel() : NULL;
}
void cIptvMenuChannels::Propagate(void)
{
Channels.ReNumber();
for (cIptvMenuChannelItem *ci = (cIptvMenuChannelItem *)First(); ci; ci = (cIptvMenuChannelItem *)ci->Next())
ci->Set();
Display();
Channels.SetModified(true);
}
eOSState cIptvMenuChannels::Edit(void)
{
if (HasSubMenu() || Count() == 0)
return osContinue;
cChannel *ch = GetChannel(Current());
if (ch)
return AddSubMenu(new cIptvMenuEditChannel(ch));
return osContinue;
}
eOSState cIptvMenuChannels::New(void)
{
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuEditChannel(GetChannel(Current()), true));
}
eOSState cIptvMenuChannels::Delete(void)
{
if (!HasSubMenu() && Count() > 0) {
int CurrentChannelNr = cDevice::CurrentChannel();
cChannel *CurrentChannel = Channels.GetByNumber(CurrentChannelNr);
int Index = Current();
cChannel *channel = GetChannel(Current());
int DeletedChannel = channel->Number();
// Check if there is a timer using this channel:
if (channel->HasTimer()) {
Skins.Message(mtError, trVDR("Channel is being used by a timer!"));
return osContinue;
}
if (Interface->Confirm(trVDR("Delete channel?"))) {
if (CurrentChannel && channel == CurrentChannel) {
int n = Channels.GetNextNormal(CurrentChannel->Index());
if (n < 0)
n = Channels.GetPrevNormal(CurrentChannel->Index());
CurrentChannel = Channels.Get(n);
CurrentChannelNr = 0; // triggers channel switch below
}
Channels.Del(channel);
cOsdMenu::Del(Index);
Propagate();
isyslog("channel %d deleted", DeletedChannel);
if (CurrentChannel && CurrentChannel->Number() != CurrentChannelNr) {
if (!cDevice::PrimaryDevice()->Replaying() || cDevice::PrimaryDevice()->Transferring())
Channels.SwitchTo(CurrentChannel->Number());
else
cDevice::SetCurrentChannel(CurrentChannel);
}
}
}
return osContinue;
}
eOSState cIptvMenuChannels::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
switch (state) {
case osUser1: {
cChannel *channel = Channels.Last();
if (channel) {
Add(new cIptvMenuChannelItem(channel), true);
return CloseSubMenu();
}
}
break;
default:
if (state == osUnknown) {
switch (Key) {
case kOk:
case kRed: return Edit();
case kGreen: return New();
case kYellow: return Delete();
default: break;
}
}
}
return state;
}
// --- cIptvPluginSetup ------------------------------------------------------
cIptvPluginSetup::cIptvPluginSetup()
{ {
tsBufferSize = IptvConfig.GetTsBufferSize(); tsBufferSize = IptvConfig.GetTsBufferSize();
tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio(); tsBufferPrefill = IptvConfig.GetTsBufferPrefillRatio();
@ -38,9 +422,22 @@ void cIptvPluginSetup::Setup(void)
Display(); Display();
} }
eOSState cIptvPluginSetup::EditChannel(void)
{
if (HasSubMenu())
return osContinue;
return AddSubMenu(new cIptvMenuChannels());
}
eOSState cIptvPluginSetup::ProcessKey(eKeys Key) eOSState cIptvPluginSetup::ProcessKey(eKeys Key)
{ {
eOSState state = cMenuSetupPage::ProcessKey(Key); eOSState state = cMenuSetupPage::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case kRed: return EditChannel();
default: break;
}
}
return state; return state;
} }
@ -59,3 +456,4 @@ void cIptvPluginSetup::Store(void)
IptvConfig.SetHttpBufferSize(httpBufferSize); IptvConfig.SetHttpBufferSize(httpBufferSize);
IptvConfig.SetFileBufferSize(fileBufferSize); IptvConfig.SetFileBufferSize(fileBufferSize);
} }

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.3 2007/09/16 13:38:20 rahrenbe Exp $ * $Id: setup.h,v 1.4 2007/09/18 18:48:11 rahrenbe Exp $
*/ */
#ifndef __IPTV_SETUP_H #ifndef __IPTV_SETUP_H
@ -19,6 +19,7 @@ private:
int udpBufferSize; int udpBufferSize;
int httpBufferSize; int httpBufferSize;
int fileBufferSize; int fileBufferSize;
eOSState EditChannel(void);
virtual void Setup(void); virtual void Setup(void);
protected: protected: