summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <Klaus (dot) Schmidinger (at) tvdr (dot) de>2010-02-28 16:07:00 +0100
committerKlaus Schmidinger <Klaus (dot) Schmidinger (at) tvdr (dot) de>2010-02-28 16:07:00 +0100
commit5ce592e54a4aa741444afae8eb80dff47bc355fd (patch)
treebc0cbae41372e945dda8979328b49adba34a9a92 /channels.c
parent09a17d56e2a3f975a0467e8da4ca26c946b6ccf7 (diff)
downloadvdr-patch-lnbsharing-5ce592e54a4aa741444afae8eb80dff47bc355fd.tar.gz
vdr-patch-lnbsharing-5ce592e54a4aa741444afae8eb80dff47bc355fd.tar.bz2
Version 1.7.13vdr-1.7.13
- Updated the Italian OSD texts (thanks to Diego Pierotto). - Changed the position of Sirius 4 to S4.8E in sources.conf (thanks to Alexander Gross). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Moved the declaration of cMenuCommands to menu.h, so that plugins can use it. - Added a note to the MANUAL, saying that adding new transponders only works if the "EPG scan" is active (suggested by Halim Sahim). - Improved handling frames at the beginning and end of a recording in cDvbPlayer for devices with large buffers (thanks to Reinhard Nissl). - Implemented cDeviceHook to allow plugins more control over which device can provide which transponder (thanks to Reinhard Nissl). - Implemented cDevice::GetCurrentlyTunedTransponder() (thanks to Reinhard Nissl). - Moved strictly necessary Makefile options into Make.global, which is included by all plugins (thanks to Paul Menzel). The Makefiles of existing plugins should be modified like this: ------------------------------------------------------------ --- PLUGINS/src/hello/Makefile 2009/10/18 14:00:07 2.1 +++ PLUGINS/src/hello/Makefile 2010/02/06 14:50:03 2.2 @@ -18,7 +18,7 @@ ### The C++ compiler and options: CXX ?= g++ -CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses +CXXFLAGS ?= -g -O2 -Wall -Woverloaded-virtual -Wno-parentheses ### The directory environment: @@ -26,6 +26,10 @@ LIBDIR = ../../lib TMPDIR = /tmp +### Make sure that necessary options are included: + +include $(VDRDIR)/Make.global + ### Allow user defined options to overwrite defaults: -include $(VDRDIR)/Make.config ------------------------------------------------------------ - Added device definitions to the diseqc.conf file format, so that certain satellite positions can be limited to a given list of devices. This obsoletes the SOURCECAPS patch. - Keeping subtitles visible when pausing replay (thanks to Rolf Ahrenberg). - Fixed adding new transponders in case there is only a single channel in the channel list (reported by Halim Sahin). - The file name in the "Timers" menu now shows only the base name of the recording without the folder path (if any). Otherwise with long folder paths the actual recording name was not visible at all. - Updated the Romanian OSD texts (thanks to Lucian Muresan). - Exported some libsi functions (thanks to Lucian Muresan). - Improved scalability of the default skins. - Fixed the German translation of "Folder name must not contain '%c'!" (thanks to Frank Schmirler). - Updated the Estonian OSD texts (thanks to Arthur Konovalov). - Plugins can now define new sources. In order to implement this, the following changes were made: + The transponder parameter string is no longer interpreted by cChannel, but rather stored as is and used only by the respective device. That way plugins can use a channel's parameter string to store arbitrary data (see vdr.5). + The new class cSourceParam can be used by plugins to define new sources, and to implement OSD items that will be used in the channel editor for editing the source specific parameters of a channel (see dvbdevice.c for an example of how this is done for the default DVB devices). + Purely numerical values are no longer accepted in the 'source' parameter of a channel. This obsoletes the PLUGINPARAM patch. - Updated the Lithuanian OSD texts (thanks to Valdemaras Pipiras). - cSafeFile::Close() now flushes the file (suggested by Stephan Austermühle). - The option "Setup/DVB/Use Dolby Digital" now only controls whether Dolby Digital tracks appear in the "Audio" menu. Dolby Digital is always recorded. This obsoletes the DOLBYINREC patch.
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c316
1 files changed, 26 insertions, 290 deletions
diff --git a/channels.c b/channels.c
index c14df19..a694d54 100644
--- a/channels.c
+++ b/channels.c
@@ -4,11 +4,10 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: channels.c 2.12 2010/01/02 17:38:40 kls Exp $
+ * $Id: channels.c 2.13 2010/02/21 13:36:04 kls Exp $
*/
#include "channels.h"
-#include <linux/dvb/frontend.h>
#include <ctype.h>
#include "device.h"
#include "epg.h"
@@ -18,133 +17,6 @@
// format characters in order to allow any number of blanks after a numeric
// value!
-// --- Channel Parameter Maps ------------------------------------------------
-
-const tChannelParameterMap InversionValues[] = {
- { 0, INVERSION_OFF, trNOOP("off") },
- { 1, INVERSION_ON, trNOOP("on") },
- { 999, INVERSION_AUTO, trNOOP("auto") },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap BandwidthValues[] = {
- { 6, 6000000, "6 MHz" },
- { 7, 7000000, "7 MHz" },
- { 8, 8000000, "8 MHz" },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap CoderateValues[] = {
- { 0, FEC_NONE, trNOOP("none") },
- { 12, FEC_1_2, "1/2" },
- { 23, FEC_2_3, "2/3" },
- { 34, FEC_3_4, "3/4" },
- { 35, FEC_3_5, "3/5" },
- { 45, FEC_4_5, "4/5" },
- { 56, FEC_5_6, "5/6" },
- { 67, FEC_6_7, "6/7" },
- { 78, FEC_7_8, "7/8" },
- { 89, FEC_8_9, "8/9" },
- { 910, FEC_9_10, "9/10" },
- { 999, FEC_AUTO, trNOOP("auto") },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap ModulationValues[] = {
- { 16, QAM_16, "QAM16" },
- { 32, QAM_32, "QAM32" },
- { 64, QAM_64, "QAM64" },
- { 128, QAM_128, "QAM128" },
- { 256, QAM_256, "QAM256" },
- { 2, QPSK, "QPSK" },
- { 5, PSK_8, "8PSK" },
- { 6, APSK_16, "16APSK" },
- { 10, VSB_8, "VSB8" },
- { 11, VSB_16, "VSB16" },
- { 998, QAM_AUTO, "QAMAUTO" },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap SystemValues[] = {
- { 0, SYS_DVBS, "DVB-S" },
- { 1, SYS_DVBS2, "DVB-S2" },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap TransmissionValues[] = {
- { 2, TRANSMISSION_MODE_2K, "2K" },
- { 8, TRANSMISSION_MODE_8K, "8K" },
- { 999, TRANSMISSION_MODE_AUTO, trNOOP("auto") },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap GuardValues[] = {
- { 4, GUARD_INTERVAL_1_4, "1/4" },
- { 8, GUARD_INTERVAL_1_8, "1/8" },
- { 16, GUARD_INTERVAL_1_16, "1/16" },
- { 32, GUARD_INTERVAL_1_32, "1/32" },
- { 999, GUARD_INTERVAL_AUTO, trNOOP("auto") },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap HierarchyValues[] = {
- { 0, HIERARCHY_NONE, trNOOP("none") },
- { 1, HIERARCHY_1, "1" },
- { 2, HIERARCHY_2, "2" },
- { 4, HIERARCHY_4, "4" },
- { 999, HIERARCHY_AUTO, trNOOP("auto") },
- { -1, 0, NULL }
- };
-
-const tChannelParameterMap RollOffValues[] = {
- { 0, ROLLOFF_AUTO, trNOOP("auto") },
- { 20, ROLLOFF_20, "0.20" },
- { 25, ROLLOFF_25, "0.25" },
- { 35, ROLLOFF_35, "0.35" },
- { -1, 0, NULL }
- };
-
-int UserIndex(int Value, const tChannelParameterMap *Map)
-{
- const tChannelParameterMap *map = Map;
- while (map && map->userValue != -1) {
- if (map->userValue == Value)
- return map - Map;
- map++;
- }
- return -1;
-}
-
-int DriverIndex(int Value, const tChannelParameterMap *Map)
-{
- const tChannelParameterMap *map = Map;
- while (map && map->userValue != -1) {
- if (map->driverValue == Value)
- return map - Map;
- map++;
- }
- return -1;
-}
-
-int MapToUser(int Value, const tChannelParameterMap *Map, const char **String)
-{
- int n = DriverIndex(Value, Map);
- if (n >= 0) {
- if (String)
- *String = tr(Map[n].userString);
- return Map[n].userValue;
- }
- return -1;
-}
-
-int MapToDriver(int Value, const tChannelParameterMap *Map)
-{
- int n = UserIndex(Value, Map);
- if (n >= 0)
- return Map[n].driverValue;
- return -1;
-}
-
// --- tChannelID ------------------------------------------------------------
const tChannelID tChannelID::InvalidID;
@@ -189,16 +61,6 @@ cChannel::cChannel(void)
provider = strdup("");
portalName = strdup("");
memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__);
- inversion = INVERSION_AUTO;
- bandwidth = 8000000;
- coderateH = FEC_AUTO;
- coderateL = FEC_AUTO;
- modulation = QPSK;
- system = SYS_DVBS;
- transmission = TRANSMISSION_MODE_AUTO;
- guard = GUARD_INTERVAL_AUTO;
- hierarchy = HIERARCHY_AUTO;
- rollOff = ROLLOFF_AUTO;
modification = CHANNELMOD_NONE;
schedule = NULL;
linkChannels = NULL;
@@ -248,17 +110,18 @@ cChannel& cChannel::operator= (const cChannel &Channel)
provider = strcpyrealloc(provider, Channel.provider);
portalName = strcpyrealloc(portalName, Channel.portalName);
memcpy(&__BeginData__, &Channel.__BeginData__, (char *)&Channel.__EndData__ - (char *)&Channel.__BeginData__);
+ parameters = Channel.parameters;
return *this;
}
int cChannel::Transponder(int Frequency, char Polarization)
{
// some satellites have transponders at the same frequency, just with different polarization:
- switch (tolower(Polarization)) {
- case 'h': Frequency += 100000; break;
- case 'v': Frequency += 200000; break;
- case 'l': Frequency += 300000; break;
- case 'r': Frequency += 400000; break;
+ switch (toupper(Polarization)) {
+ case 'H': Frequency += 100000; break;
+ case 'V': Frequency += 200000; break;
+ case 'L': Frequency += 300000; break;
+ case 'R': Frequency += 400000; break;
default: esyslog("ERROR: invalid value for Polarization '%c'", Polarization);
}
return Frequency;
@@ -269,8 +132,11 @@ int cChannel::Transponder(void) const
int tf = frequency;
while (tf > 20000)
tf /= 1000;
- if (IsSat())
- tf = Transponder(tf, polarization);
+ if (IsSat()) {
+ const char *p = strpbrk(parameters, "HVLRhvlr"); // lowercase for backwards compatibility
+ if (p)
+ tf = Transponder(tf, *p);
+ }
return tf;
}
@@ -296,22 +162,16 @@ void cChannel::CopyTransponderData(const cChannel *Channel)
frequency = Channel->frequency;
source = Channel->source;
srate = Channel->srate;
- polarization = Channel->polarization;
- inversion = Channel->inversion;
- bandwidth = Channel->bandwidth;
- coderateH = Channel->coderateH;
- coderateL = Channel->coderateL;
- modulation = Channel->modulation;
- system = Channel->system;
- transmission = Channel->transmission;
- guard = Channel->guard;
- hierarchy = Channel->hierarchy;
- rollOff = Channel->rollOff;
+ parameters = Channel->parameters;
}
}
-bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH, int Modulation, int System, int RollOff)
+bool cChannel::SetTransponderData(int Source, int Frequency, int Srate, const char *Parameters, bool Quiet)
{
+ if (strchr(Parameters, ':')) {
+ esyslog("ERROR: parameter string '%s' contains ':'", Parameters);
+ return false;
+ }
// Workarounds for broadcaster stupidity:
// Some providers broadcast the transponder frequency of their channels with two different
// values (like 12551 and 12552), so we need to allow for a little tolerance here
@@ -324,60 +184,14 @@ bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarizatio
if (abs(srate - Srate) <= 1)
Srate = srate;
- if (source != Source || frequency != Frequency || polarization != Polarization || srate != Srate || coderateH != CoderateH || modulation != Modulation || system != System || rollOff != RollOff) {
- cString OldTransponderData = TransponderDataToString();
- source = Source;
- frequency = Frequency;
- polarization = Polarization;
- srate = Srate;
- coderateH = CoderateH;
- modulation = Modulation;
- system = System;
- rollOff = RollOff;
- schedule = NULL;
- if (Number()) {
- dsyslog("changing transponder data of channel %d from %s to %s", Number(), *OldTransponderData, *TransponderDataToString());
- modification |= CHANNELMOD_TRANSP;
- Channels.SetModified();
- }
- }
- return true;
-}
-
-bool cChannel::SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH)
-{
- if (source != Source || frequency != Frequency || modulation != Modulation || srate != Srate || coderateH != CoderateH) {
+ if (source != Source || frequency != Frequency || srate != Srate || strcmp(parameters, Parameters)) {
cString OldTransponderData = TransponderDataToString();
source = Source;
frequency = Frequency;
- modulation = Modulation;
srate = Srate;
- coderateH = CoderateH;
+ parameters = Parameters;
schedule = NULL;
- if (Number()) {
- dsyslog("changing transponder data of channel %d from %s to %s", Number(), *OldTransponderData, *TransponderDataToString());
- modification |= CHANNELMOD_TRANSP;
- Channels.SetModified();
- }
- }
- return true;
-}
-
-bool cChannel::SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CoderateH, int CoderateL, int Guard, int Transmission)
-{
- if (source != Source || frequency != Frequency || bandwidth != Bandwidth || modulation != Modulation || hierarchy != Hierarchy || coderateH != CoderateH || coderateL != CoderateL || guard != Guard || transmission != Transmission) {
- cString OldTransponderData = TransponderDataToString();
- source = Source;
- frequency = Frequency;
- bandwidth = Bandwidth;
- modulation = Modulation;
- hierarchy = Hierarchy;
- coderateH = CoderateH;
- coderateL = CoderateL;
- guard = Guard;
- transmission = Transmission;
- schedule = NULL;
- if (Number()) {
+ if (Number() && !Quiet) {
dsyslog("changing transponder data of channel %d from %s to %s", Number(), *OldTransponderData, *TransponderDataToString());
modification |= CHANNELMOD_TRANSP;
Channels.SetModified();
@@ -634,90 +448,11 @@ void cChannel::SetRefChannel(cChannel *RefChannel)
refChannel = RefChannel;
}
-static int PrintParameter(char *p, char Name, int Value)
-{
- return Value >= 0 && Value != 999 ? sprintf(p, "%c%d", Name, Value) : 0;
-}
-
cString cChannel::TransponderDataToString(void) const
{
if (cSource::IsTerr(source))
- return cString::sprintf("%d:%s:%s", frequency, *ParametersToString(), *cSource::ToString(source));
- return cString::sprintf("%d:%s:%s:%d", frequency, *ParametersToString(), *cSource::ToString(source), srate);
-}
-
-cString cChannel::ParametersToString(void) const
-{
- char type = **cSource::ToString(source);
- if (isdigit(type))
- type = 'S';
-#define ST(s) if (strchr(s, type))
- char buffer[64];
- char *q = buffer;
- *q = 0;
- ST(" S ") q += sprintf(q, "%c", polarization);
- ST(" T") q += PrintParameter(q, 'B', MapToUser(bandwidth, BandwidthValues));
- ST("CST") q += PrintParameter(q, 'C', MapToUser(coderateH, CoderateValues));
- ST(" T") q += PrintParameter(q, 'D', MapToUser(coderateL, CoderateValues));
- ST(" T") q += PrintParameter(q, 'G', MapToUser(guard, GuardValues));
- ST("CST") q += PrintParameter(q, 'I', MapToUser(inversion, InversionValues));
- ST("CST") q += PrintParameter(q, 'M', MapToUser(modulation, ModulationValues));
- ST(" S ") q += PrintParameter(q, 'O', MapToUser(rollOff, RollOffValues));
- ST(" S ") q += PrintParameter(q, 'S', MapToUser(system, SystemValues));
- ST(" T") q += PrintParameter(q, 'T', MapToUser(transmission, TransmissionValues));
- ST(" T") q += PrintParameter(q, 'Y', MapToUser(hierarchy, HierarchyValues));
- return buffer;
-}
-
-static const char *ParseParameter(const char *s, int &Value, const tChannelParameterMap *Map)
-{
- if (*++s) {
- char *p = NULL;
- errno = 0;
- int n = strtol(s, &p, 10);
- if (!errno && p != s) {
- Value = MapToDriver(n, Map);
- if (Value >= 0)
- return p;
- }
- }
- esyslog("ERROR: invalid value for parameter '%c'", *(s - 1));
- return NULL;
-}
-
-static const char *SkipDigits(const char *s)
-{
- while (*++s && isdigit(*s))
- ;
- return s;
-}
-
-bool cChannel::StringToParameters(const char *s)
-{
- while (s && *s) {
- switch (toupper(*s)) {
- case 'A': s = SkipDigits(s); break; // for compatibility with the "multiproto" approach - may be removed in future versions
- case 'B': s = ParseParameter(s, bandwidth, BandwidthValues); break;
- case 'C': s = ParseParameter(s, coderateH, CoderateValues); break;
- case 'D': s = ParseParameter(s, coderateL, CoderateValues); break;
- case 'G': s = ParseParameter(s, guard, GuardValues); break;
- case 'H': polarization = *s++; break;
- case 'I': s = ParseParameter(s, inversion, InversionValues); break;
- case 'L': polarization = *s++; break;
- case 'M': s = ParseParameter(s, modulation, ModulationValues); break;
- case 'O': s = ParseParameter(s, rollOff, RollOffValues); break;
- case 'P': s = SkipDigits(s); break; // for compatibility with the "multiproto" approach - may be removed in future versions
- case 'R': polarization = *s++; break;
- case 'S': s = ParseParameter(s, system, SystemValues); break;
- case 'T': s = ParseParameter(s, transmission, TransmissionValues); break;
- case 'V': polarization = *s++; break;
- case 'Y': s = ParseParameter(s, hierarchy, HierarchyValues); break;
- case 'Z': s = SkipDigits(s); break; // for compatibility with the original DVB-S2 patch - may be removed in future versions
- default: esyslog("ERROR: unknown parameter key '%c'", *s);
- return false;
- }
- }
- return true;
+ return cString::sprintf("%d:%s:%s", frequency, *parameters, *cSource::ToString(source));
+ return cString::sprintf("%d:%s:%s:%d", frequency, *parameters, *cSource::ToString(source), srate);
}
cString cChannel::ToText(const cChannel *Channel)
@@ -762,7 +497,7 @@ cString cChannel::ToText(const cChannel *Channel)
q = caidbuf;
q += IntArrayToString(q, Channel->caids, 16);
*q = 0;
- buffer = cString::sprintf("%s:%d:%s:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d\n", FullName, Channel->frequency, *Channel->ParametersToString(), *cSource::ToString(Channel->source), Channel->srate, vpidbuf, apidbuf, Channel->tpid, caidbuf, Channel->sid, Channel->nid, Channel->tid, Channel->rid);
+ buffer = cString::sprintf("%s:%d:%s:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d\n", FullName, Channel->frequency, *Channel->parameters, *cSource::ToString(Channel->source), Channel->srate, vpidbuf, apidbuf, Channel->tpid, caidbuf, Channel->sid, Channel->nid, Channel->tid, Channel->rid);
}
return buffer;
}
@@ -814,7 +549,8 @@ bool cChannel::Parse(const char *s)
dpids[0] = 0;
ok = false;
if (parambuf && sourcebuf && vpidbuf && apidbuf) {
- ok = StringToParameters(parambuf) && (source = cSource::FromString(sourcebuf)) >= 0;
+ parameters = parambuf;
+ ok = (source = cSource::FromString(sourcebuf)) >= 0;
char *p;
if ((p = strchr(vpidbuf, '=')) != NULL) {