From f9a3885ef2d21cef30180f2a90a0a305981a27c6 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 10 Mar 2002 12:45:58 +0100 Subject: [PATCH] New Setup parameter TrustedTransponder --- HISTORY | 4 ++++ MANUAL | 18 ++++++++++++++++-- config.c | 9 ++++++--- config.h | 5 ++++- dvbapi.c | 14 +++++++++++--- dvbapi.h | 4 +--- eit.c | 19 ++++++++----------- eit.h | 6 +++--- i18n.c | 12 +++++++++++- menu.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 10 files changed, 107 insertions(+), 29 deletions(-) diff --git a/HISTORY b/HISTORY index ec4e2707..6b1b6cfc 100644 --- a/HISTORY +++ b/HISTORY @@ -1092,3 +1092,7 @@ Video Disk Recorder Revision History activity, but this should be no problem for normal use). - Changed the MANUAL description of the "Conditional Access" setup parameters to reflect the actual "CICAM DVBn m" notation in the "Setup" menu. +- The new Setup parameter TrustedTransponder can be used to define which + transponder shall be used to set the system time (see MANUAL for details). + If you have been using the SetSystemTime option previously, you now MUST + select a channel that you trust to have a reliable time base. diff --git a/MANUAL b/MANUAL index e322dbae..e5337b6d 100644 --- a/MANUAL +++ b/MANUAL @@ -415,9 +415,23 @@ Video Disk Recorder User's Manual SetSystemTime = 0 Defines whether the system time will be set according to the time received from the DVB data stream. 0 = system time will not be set - 1 = system time wil be set + 1 = system time will be set Note that this works only if VDR is running under a user - id that has permisson to set the system time. + id that has permisson to set the system time. You also + need to set the option TrustedTransponder to a channel + that you trust to transmit a reliable time base (not all + channels seem to have access to a correct time base...). + + TrustedTransponder = 0 The frequency of the transponder that shall be used to + set the system time. The Setup menu will offer the full + list of channels, even if several of them are on the + same transponder. Also, when selecting a channel, saving + the Setup and opening the Setup menu again, there may be + a different channel listed here, since the first one + in 'channels.conf' that is on the given transponder will + be taken. Note that in order to set the system time from + the transponder data the option SetSystemTime must also + be enabled. MarginStart = 2 Defines how many minutes before the official start time MarginStop = 10 of a broadcast VDR shall start recording, and how long diff --git a/config.c b/config.c index ad22d95c..4bed561e 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.89 2002/03/08 14:57:08 kls Exp $ + * $Id: config.c 1.90 2002/03/10 12:22:25 kls Exp $ */ #include "config.h" @@ -811,7 +811,7 @@ cChannel *cChannels::GetByNumber(int Number) { cChannel *channel = (cChannel *)First(); while (channel) { - if (channel->number == Number) + if (!channel->groupSep && channel->number == Number) return channel; channel = (cChannel *)channel->Next(); } @@ -822,7 +822,7 @@ cChannel *cChannels::GetByServiceID(unsigned short ServiceId) { cChannel *channel = (cChannel *)First(); while (channel) { - if (channel->pnr == ServiceId) + if (!channel->groupSep && channel->pnr == ServiceId) return channel; channel = (cChannel *)channel->Next(); } @@ -931,6 +931,7 @@ cSetup::cSetup(void) LnbFrequHi = 10600; DiSEqC = 0; SetSystemTime = 0; + TrustedTransponder = 0; MarginStart = 2; MarginStop = 10; EPGScanTimeout = 5; @@ -1017,6 +1018,7 @@ bool cSetup::Parse(char *s) else if (!strcasecmp(Name, "LnbFrequHi")) LnbFrequHi = atoi(Value); else if (!strcasecmp(Name, "DiSEqC")) DiSEqC = atoi(Value); else if (!strcasecmp(Name, "SetSystemTime")) SetSystemTime = atoi(Value); + else if (!strcasecmp(Name, "TrustedTransponder")) TrustedTransponder = atoi(Value); else if (!strcasecmp(Name, "MarginStart")) MarginStart = atoi(Value); else if (!strcasecmp(Name, "MarginStop")) MarginStop = atoi(Value); else if (!strcasecmp(Name, "EPGScanTimeout")) EPGScanTimeout = atoi(Value); @@ -1098,6 +1100,7 @@ bool cSetup::Save(const char *FileName) fprintf(f, "LnbFrequHi = %d\n", LnbFrequHi); fprintf(f, "DiSEqC = %d\n", DiSEqC); fprintf(f, "SetSystemTime = %d\n", SetSystemTime); + fprintf(f, "TrustedTransponder = %d\n", TrustedTransponder); fprintf(f, "MarginStart = %d\n", MarginStart); fprintf(f, "MarginStop = %d\n", MarginStop); fprintf(f, "EPGScanTimeout = %d\n", EPGScanTimeout); diff --git a/config.h b/config.h index 1913764f..e3cd3add 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.103 2002/03/08 17:59:02 kls Exp $ + * $Id: config.h 1.104 2002/03/10 12:45:11 kls Exp $ */ #ifndef __CONFIG_H @@ -92,6 +92,8 @@ public: void Set(eKeys Key, unsigned int Code); }; +#define ISTRANSPONDER(f1, f2) (abs((f1) - (f2)) < 4) + class cChannel : public cListObject { private: static char *buffer; @@ -340,6 +342,7 @@ public: int LnbFrequHi; int DiSEqC; int SetSystemTime; + int TrustedTransponder; int MarginStart, MarginStop; int EPGScanTimeout; int EPGBugfixLevel; diff --git a/dvbapi.c b/dvbapi.c index dc7eba0b..b8214fa6 100644 --- a/dvbapi.c +++ b/dvbapi.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbapi.c 1.161 2002/03/09 14:18:25 kls Exp $ + * $Id: dvbapi.c 1.162 2002/03/10 11:01:38 kls Exp $ */ #include "dvbapi.h" @@ -1723,8 +1723,6 @@ cDvbApi::cDvbApi(int n) if (fd_frontend >= 0 && fd_demuxv >= 0 && fd_demuxa1 >= 0 && fd_demuxa2 >= 0 && fd_demuxd1 >= 0 && fd_demuxd2 >= 0 && fd_demuxt >= 0) { siProcessor = new cSIProcessor(OstName(DEV_OST_DEMUX, n)); - if (!dvbApi[0]) // only the first one shall set the system time - siProcessor->SetUseTSTime(Setup.SetSystemTime); FrontendInfo feinfo; CHECK(ioctl(fd_frontend, FE_GET_INFO, &feinfo)); frontendType = feinfo.type; @@ -2324,6 +2322,11 @@ eSetChannelResult cDvbApi::SetChannel(int ChannelNumber, int Frequency, char Pol CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER)); } + // Stop setting system time: + + if (siProcessor) + siProcessor->SetCurrentTransponder(0); + // If this card can't receive this channel, we must not actually switch // the channel here, because that would irritate the driver when we // start replaying in Transfer Mode immediately after switching the channel: @@ -2475,6 +2478,11 @@ eSetChannelResult cDvbApi::SetChannel(int ChannelNumber, int Frequency, char Pol CHECK(ioctl(fd_video, VIDEO_SET_BLANK, false)); } + // Start setting system time: + + if (Result == scrOk && siProcessor) + siProcessor->SetCurrentTransponder(Frequency); + return Result; } diff --git a/dvbapi.h b/dvbapi.h index 4545eff3..e9cf8c83 100644 --- a/dvbapi.h +++ b/dvbapi.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbapi.h 1.67 2002/03/09 14:18:10 kls Exp $ + * $Id: dvbapi.h 1.68 2002/03/10 10:50:00 kls Exp $ */ #ifndef __DVBAPI_H @@ -149,8 +149,6 @@ public: private: cSIProcessor *siProcessor; public: - void SetUseTSTime(bool On) { if (siProcessor) siProcessor->SetUseTSTime(On); } - // Image Grab facilities bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1); diff --git a/eit.c b/eit.c index 9985fbbd..e0b33f69 100644 --- a/eit.c +++ b/eit.c @@ -16,7 +16,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.c 1.39 2002/03/01 16:32:11 kls Exp $ + * $Id: eit.c 1.40 2002/03/10 12:45:38 kls Exp $ ***************************************************************************/ #include "eit.h" @@ -981,7 +981,6 @@ cSIProcessor::cSIProcessor(const char *FileName) { fileName = strdup(FileName); masterSIProcessor = numSIProcessors == 0; // the first one becomes the 'master' - useTStime = false; filters = NULL; if (!numSIProcessors++) // the first one creates it schedules = new cSchedules; @@ -1138,7 +1137,7 @@ void cSIProcessor::Action() case 0x14: if (buf[0] == 0x70) { - if (useTStime) + if (Setup.SetSystemTime && Setup.TrustedTransponder && ISTRANSPONDER(currentTransponder, Setup.TrustedTransponder)) { cTDT ctdt((tdt_t *)buf); ctdt.SetSystemTime(); @@ -1222,14 +1221,6 @@ bool cSIProcessor::AddFilter(u_char pid, u_char tid) return false; } -/** set whether local systems time should be -set by the received TDT or TOT packets */ -bool cSIProcessor::SetUseTSTime(bool use) -{ - useTStime = use; - return useTStime; -} - /** */ bool cSIProcessor::ShutDownFilters(void) { @@ -1246,6 +1237,12 @@ bool cSIProcessor::ShutDownFilters(void) return true; // there's no real 'boolean' to return here... } +/** */ +void cSIProcessor::SetCurrentTransponder(int CurrentTransponder) +{ + currentTransponder = CurrentTransponder; +} + /** */ bool cSIProcessor::SetCurrentServiceID(unsigned short servid) { diff --git a/eit.h b/eit.h index 55c0f4e0..5221c403 100644 --- a/eit.h +++ b/eit.h @@ -16,7 +16,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: eit.h 1.15 2002/02/23 15:30:25 kls Exp $ + * $Id: eit.h 1.16 2002/03/10 10:56:57 kls Exp $ ***************************************************************************/ #ifndef __EIT_H @@ -139,7 +139,7 @@ private: static cMutex schedulesMutex; static const char *epgDataFileName; bool masterSIProcessor; - bool useTStime; + int currentTransponder; SIP_FILTER *filters; char *fileName; bool active; @@ -157,7 +157,7 @@ public: // longer used, the cMutexLock must be destroyed. static bool Read(FILE *f = NULL); void SetStatus(bool On); - bool SetUseTSTime(bool use); + void SetCurrentTransponder(int CurrentTransponder); bool SetCurrentServiceID(unsigned short servid); }; diff --git a/i18n.c b/i18n.c index 650c611c..7656bfa0 100644 --- a/i18n.c +++ b/i18n.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: i18n.c 1.61 2002/03/09 16:21:59 kls Exp $ + * $Id: i18n.c 1.62 2002/03/10 10:43:46 kls Exp $ * * Slovenian translations provided by Miha Setina * Italian translations provided by Alberto Carraro @@ -964,6 +964,16 @@ const tPhrase Phrases[] = { "Juster system-klokken", "Vastaanota kellonaika", }, + { "TrustedTransponder", + "Vertr. Transponder", + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + "", // TODO + }, { "MarginStart", "Zeitpuffer bei Anfang", "Premor pred zacetkom", diff --git a/menu.c b/menu.c index fd605aa1..38df6197 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.163 2002/03/09 16:57:34 kls Exp $ + * $Id: menu.c 1.164 2002/03/10 12:45:58 kls Exp $ */ #include "menu.h" @@ -168,6 +168,47 @@ void cMenuEditChanItem::Set(void) SetValue(buf); } +// --- cMenuEditTranItem ----------------------------------------------------- + +class cMenuEditTranItem : public cMenuEditChanItem { +private: + int number; + int transponder; +public: + cMenuEditTranItem(const char *Name, int *Value); + virtual eOSState ProcessKey(eKeys Key); + }; + +cMenuEditTranItem::cMenuEditTranItem(const char *Name, int *Value) +:cMenuEditChanItem(Name, Value) +{ + number = 0; + transponder = *Value; + cChannel *channel = Channels.First(); + while (channel) { + if (!channel->groupSep && ISTRANSPONDER(channel->frequency, *Value)) { + number = channel->number; + break; + } + channel = (cChannel *)channel->Next(); + } + *Value = number; + Set(); + *Value = transponder; +} + +eOSState cMenuEditTranItem::ProcessKey(eKeys Key) +{ + *value = number; + eOSState state = cMenuEditChanItem::ProcessKey(Key); + number = *value; + cChannel *channel = Channels.GetByNumber(*value); + if (channel) + transponder = channel->frequency; + *value = transponder; + return state; +} + // --- cMenuEditDayItem ------------------------------------------------------ class cMenuEditDayItem : public cMenuEditIntItem { @@ -1911,6 +1952,7 @@ void cMenuSetup::Set(void) Add(new cMenuEditIntItem( tr("LnbFrequHi"), &data.LnbFrequHi)); Add(new cMenuEditBoolItem(tr("Setup$DiSEqC"), &data.DiSEqC)); Add(new cMenuEditBoolItem(tr("SetSystemTime"), &data.SetSystemTime)); + Add(new cMenuEditTranItem(tr("TrustedTransponder"), &data.TrustedTransponder)); Add(new cMenuEditIntItem( tr("MarginStart"), &data.MarginStart)); Add(new cMenuEditIntItem( tr("MarginStop"), &data.MarginStop)); Add(new cMenuEditIntItem( tr("EPGScanTimeout"), &data.EPGScanTimeout)); @@ -1950,7 +1992,6 @@ eOSState cMenuSetup::ProcessKey(eKeys Key) if (state == osUnknown) { switch (Key) { case kOk: state = (Setup.PrimaryDVB != data.PrimaryDVB) ? osSwitchDvb : osEnd; - cDvbApi::PrimaryDvbApi->SetUseTSTime(data.SetSystemTime); cDvbApi::PrimaryDvbApi->SetVideoFormat(data.VideoFormat ? VIDEO_FORMAT_16_9 : VIDEO_FORMAT_4_3); Setup = data; Setup.Save();