From c7256c1c1123f2222c6b272af6472bc568b7d2ec Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 5 Jan 2014 10:41:46 +0100 Subject: [PATCH] Channels that are no longer contained in the current SDT of a transponder are now marked with the keyword OBSOLETE in their name and provider fields --- HISTORY | 7 ++++++- channels.c | 22 +++++++++++++++++++++- channels.h | 6 +++++- sdt.c | 6 +++++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index 3519fde60..787549462 100644 --- a/HISTORY +++ b/HISTORY @@ -8032,7 +8032,7 @@ Video Disk Recorder Revision History the last replayed recording (if any) by pressing Ok repeatedly in the Recordings menu. -2014-01-01: Version 2.1.3 +2014-01-05: Version 2.1.3 - Changed the return value of cPositioner::HorizonLongitude() to 0 in case the latitude of the antenna location is beyond +/-81 degrees. @@ -8110,3 +8110,8 @@ Video Disk Recorder Revision History -PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --variable=$(1) vdr || pkg-config --variable=$(1) ../../../vdr.pc)) +PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:../../.." pkg-config --variable=$(1) vdr)) - Eliminated MAXDVBDEVICES (suggested by Oliver Endriss). +- Channels that are no longer contained in the current SDT of a transponder are now + marked with the keyword OBSOLETE in their name and provider fields. That way you can + identify obsolete channels when you switch to them, and you can get the complete + overview of all obsolete channels by sorting the Channels list by provider (by + pressing the 0 key twice). Automatic deletion of obsolete channels may follow later. diff --git a/channels.c b/channels.c index 61bed5416..11367c7b6 100644 --- a/channels.c +++ b/channels.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.c 3.3 2013/12/28 11:33:08 kls Exp $ + * $Id: channels.c 3.4 2014/01/04 15:01:52 kls Exp $ */ #include "channels.h" @@ -64,6 +64,7 @@ cChannel::cChannel(void) memset(&__BeginData__, 0, (char *)&__EndData__ - (char *)&__BeginData__); parameters = ""; modification = CHANNELMOD_NONE; + seen = 0; schedule = NULL; linkChannels = NULL; refChannel = NULL; @@ -411,6 +412,11 @@ void cChannel::SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *Compos } } +void cChannel::SetSeen(void) +{ + seen = time(NULL); +} + void cChannel::SetCaIds(const int *CaIds) { if (caids[0] && caids[0] <= CA_USER_MAX) @@ -1019,6 +1025,7 @@ cChannel *cChannels::NewChannel(const cChannel *Transponder, const char *Name, c NewChannel->CopyTransponderData(Transponder); NewChannel->SetId(Nid, Tid, Sid, Rid); NewChannel->SetName(Name, ShortName, Provider); + NewChannel->SetSeen(); Add(NewChannel); ReNumber(); return NewChannel; @@ -1026,6 +1033,19 @@ cChannel *cChannels::NewChannel(const cChannel *Transponder, const char *Name, c return NULL; } +#define CHANNELMARKOBSOLETE "OBSOLETE" +#define CHANNELTIMEOBSOLETE 3600 // seconds to wait before declaring a channel obsolete (in case it has actually been seen before) + +void cChannels::MarkObsoleteChannels(int Source, int Nid, int Tid) +{ + for (cChannel *channel = First(); channel; channel = Next(channel)) { + if (time(NULL) - channel->Seen() > CHANNELTIMEOBSOLETE && channel->Source() == Source && channel->Nid() == Nid && channel->Tid() == Tid) { + if (!endswith(channel->Name(), CHANNELMARKOBSOLETE)) + channel->SetName(cString::sprintf("%s %s", channel->Name(), CHANNELMARKOBSOLETE), channel->ShortName(), cString::sprintf("%s %s", CHANNELMARKOBSOLETE, channel->Provider())); + } + } +} + cString ChannelString(const cChannel *Channel, int Number) { char buffer[256]; diff --git a/channels.h b/channels.h index f719f1e59..7ca1e3e5f 100644 --- a/channels.h +++ b/channels.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.h 3.1 2013/11/04 09:52:02 kls Exp $ + * $Id: channels.h 3.2 2014/01/04 15:01:21 kls Exp $ */ #ifndef __CHANNELS_H @@ -128,6 +128,7 @@ class cChannel : public cListObject { mutable cString shortNameSource; cString parameters; int modification; + time_t seen; // When this channel was last seen in the SDT of its transponder mutable const cSchedule *schedule; cLinkChannels *linkChannels; cChannel *refChannel; @@ -187,6 +188,7 @@ class cChannel : public cListObject { tChannelID GetChannelID(void) const { return tChannelID(source, nid, (nid || tid) ? tid : Transponder(), sid, rid); } bool HasTimer(void) const; int Modification(int Mask = CHANNELMOD_ALL); + time_t Seen(void) { return seen; } void CopyTransponderData(const cChannel *Channel); bool SetTransponderData(int Source, int Frequency, int Srate, const char *Parameters, bool Quiet = false); void SetId(int Nid, int Tid, int Sid, int Rid = 0); @@ -198,6 +200,7 @@ class cChannel : public cListObject { void SetLinkChannels(cLinkChannels *LinkChannels); void SetRefChannel(cChannel *RefChannel); void SetSubtitlingDescriptors(uchar *SubtitlingTypes, uint16_t *CompositionPageIds, uint16_t *AncillaryPageIds); + void SetSeen(void); }; class cChannels : public cRwLock, public cConfig { @@ -237,6 +240,7 @@ class cChannels : public cRwLock, public cConfig { ///< modification has been made, and 2 if the user has made a modification. ///< Calling this function resets the 'modified' flag to 0. cChannel *NewChannel(const cChannel *Transponder, const char *Name, const char *ShortName, const char *Provider, int Nid, int Tid, int Sid, int Rid = 0); + void MarkObsoleteChannels(int Source, int Nid, int Tid); }; extern cChannels Channels; diff --git a/sdt.c b/sdt.c index 5f2502b02..c6d0ce542 100644 --- a/sdt.c +++ b/sdt.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sdt.c 2.5 2010/05/16 14:23:21 kls Exp $ + * $Id: sdt.c 3.1 2014/01/04 15:02:31 kls Exp $ */ #include "sdt.h" @@ -43,6 +43,8 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length cChannel *channel = Channels.GetByChannelID(tChannelID(Source(), sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId())); if (!channel) channel = Channels.GetByChannelID(tChannelID(Source(), 0, Transponder(), SiSdtService.getServiceId())); + if (channel) + channel->SetSeen(); cLinkChannels *LinkChannels = NULL; SI::Descriptor *d; @@ -139,5 +141,7 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length delete LinkChannels; } } + if (sdt.getSectionNumber() == sdt.getLastSectionNumber()) + Channels.MarkObsoleteChannels(Source(), sdt.getOriginalNetworkId(), sdt.getTransportStreamId()); Channels.Unlock(); }