From c5071cc87b5d5bf4cf6c685a45a8e69f9f36f5ae Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 10 Mar 2014 14:50:58 +0100 Subject: [PATCH] The SDT is now only parsed *after* the NIT has been read --- HISTORY | 3 +++ device.c | 4 ++-- nit.c | 8 ++++++-- nit.h | 6 ++++-- sdt.c | 25 ++++++++++++++++++------- sdt.h | 5 ++++- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/HISTORY b/HISTORY index 6388b82f..517bfe6e 100644 --- a/HISTORY +++ b/HISTORY @@ -8226,3 +8226,6 @@ Video Disk Recorder Revision History - Fixed drawing the live indicator in the LCARS skin in case there are no devices. - When checking for obsolete channels, those with an RID that is not 0 are now ignored (suggested by Oliver Endriss). +- The SDT is now only parsed *after* the NIT has been read, and it explicitly uses + the source value derived from the NIT. This should prevent new channels from being + created with the wrong source. diff --git a/device.c b/device.c index 901fa2b3..ff1980d6 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 3.12 2014/02/18 13:12:39 kls Exp $ + * $Id: device.c 3.13 2014/03/10 14:12:27 kls Exp $ */ #include "device.h" @@ -575,7 +575,7 @@ void cDevice::StartSectionHandler(void) AttachFilter(eitFilter = new cEitFilter); AttachFilter(patFilter = new cPatFilter); AttachFilter(sdtFilter = new cSdtFilter(patFilter)); - AttachFilter(nitFilter = new cNitFilter); + AttachFilter(nitFilter = new cNitFilter(sdtFilter)); } } diff --git a/nit.c b/nit.c index 4bdee4ca..9bd69587 100644 --- a/nit.c +++ b/nit.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: nit.c 3.1 2014/03/10 13:31:23 kls Exp $ + * $Id: nit.c 3.2 2014/03/10 14:35:31 kls Exp $ */ #include "nit.h" @@ -19,8 +19,9 @@ #define DVB_SYSTEM_1 0 // see also dvbdevice.c #define DVB_SYSTEM_2 1 -cNitFilter::cNitFilter(void) +cNitFilter::cNitFilter(cSdtFilter *SdtFilter) { + sdtFilter = SdtFilter; numNits = 0; networkId = 0; Set(0x10, 0x40); // NIT @@ -183,6 +184,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length } } } + sdtFilter->Trigger(Source); } break; case SI::S2SatelliteDeliverySystemDescriptorTag: { @@ -253,6 +255,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length } } } + sdtFilter->Trigger(Source); } break; case SI::TerrestrialDeliverySystemDescriptorTag: { @@ -316,6 +319,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length } } } + sdtFilter->Trigger(Source); } break; case SI::ExtensionDescriptorTag: { diff --git a/nit.h b/nit.h index c4ac82b5..4673f960 100644 --- a/nit.h +++ b/nit.h @@ -4,13 +4,14 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: nit.h 1.3 2007/06/10 08:50:21 kls Exp $ + * $Id: nit.h 3.1 2014/03/10 14:12:05 kls Exp $ */ #ifndef __NIT_H #define __NIT_H #include "filter.h" +#include "sdt.h" #define MAXNITS 16 #define MAXNETWORKNAME Utf8BufSize(256) @@ -26,13 +27,14 @@ private: }; cSectionSyncer sectionSyncer; + cSdtFilter *sdtFilter; cNit nits[MAXNITS]; u_short networkId; int numNits; protected: virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); public: - cNitFilter(void); + cNitFilter(cSdtFilter *SdtFilter); virtual void SetStatus(bool On); }; diff --git a/sdt.c b/sdt.c index 44c6c9d9..7537cfc1 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 3.2 2014/02/18 10:37:50 kls Exp $ + * $Id: sdt.c 3.3 2014/03/10 14:42:20 kls Exp $ */ #include "sdt.h" @@ -17,19 +17,30 @@ cSdtFilter::cSdtFilter(cPatFilter *PatFilter) { + source = cSource::stNone; patFilter = PatFilter; Set(0x11, 0x42); // SDT } void cSdtFilter::SetStatus(bool On) { + cMutexLock MutexLock(&mutex); cFilter::SetStatus(On); sectionSyncer.Reset(); + if (!On) + source = cSource::stNone; +} + +void cSdtFilter::Trigger(int Source) +{ + cMutexLock MutexLock(&mutex); + source = Source; } void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length) { - if (!(Source() && Transponder())) + cMutexLock MutexLock(&mutex); + if (!(source && Transponder())) return; SI::SDT sdt(Data, false); if (!sdt.CheckCRCAndParse()) @@ -40,9 +51,9 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length return; SI::SDT::Service SiSdtService; for (SI::Loop::Iterator it; sdt.serviceLoop.getNext(SiSdtService, it); ) { - cChannel *channel = Channels.GetByChannelID(tChannelID(Source(), sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId())); + cChannel *channel = Channels.GetByChannelID(tChannelID(source, sdt.getOriginalNetworkId(), sdt.getTransportStreamId(), SiSdtService.getServiceId())); if (!channel) - channel = Channels.GetByChannelID(tChannelID(Source(), 0, Transponder(), SiSdtService.getServiceId())); + channel = Channels.GetByChannelID(tChannelID(source, 0, Transponder(), SiSdtService.getServiceId())); if (channel) channel->SetSeen(); @@ -66,7 +77,7 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length sd->serviceName.getText(NameBuf, ShortNameBuf, sizeof(NameBuf), sizeof(ShortNameBuf)); char *pn = compactspace(NameBuf); char *ps = compactspace(ShortNameBuf); - if (!*ps && cSource::IsCable(Source())) { + if (!*ps && cSource::IsCable(source)) { // Some cable providers don't mark short channel names according to the // standard, but rather go their own way and use "name>short name": char *p = strchr(pn, '>'); // fix for UPC Wien @@ -117,7 +128,7 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length SI::NVODReferenceDescriptor *nrd = (SI::NVODReferenceDescriptor *)d; SI::NVODReferenceDescriptor::Service Service; for (SI::Loop::Iterator it; nrd->serviceLoop.getNext(Service, it); ) { - cChannel *link = Channels.GetByChannelID(tChannelID(Source(), Service.getOriginalNetworkId(), Service.getTransportStream(), Service.getServiceId())); + cChannel *link = Channels.GetByChannelID(tChannelID(source, Service.getOriginalNetworkId(), Service.getTransportStream(), Service.getServiceId())); if (!link && Setup.UpdateChannels >= 4) { link = Channels.NewChannel(Channel(), "NVOD", "", "", Service.getOriginalNetworkId(), Service.getTransportStream(), Service.getServiceId()); patFilter->Trigger(Service.getServiceId()); @@ -142,6 +153,6 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length } } if (sdt.getSectionNumber() == sdt.getLastSectionNumber()) - Channels.MarkObsoleteChannels(Source(), sdt.getOriginalNetworkId(), sdt.getTransportStreamId()); + Channels.MarkObsoleteChannels(source, sdt.getOriginalNetworkId(), sdt.getTransportStreamId()); Channels.Unlock(); } diff --git a/sdt.h b/sdt.h index a427119c..01653f45 100644 --- a/sdt.h +++ b/sdt.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sdt.h 1.2 2004/01/05 14:30:14 kls Exp $ + * $Id: sdt.h 3.1 2014/03/10 14:40:54 kls Exp $ */ #ifndef __SDT_H @@ -15,13 +15,16 @@ class cSdtFilter : public cFilter { private: + cMutex mutex; cSectionSyncer sectionSyncer; + int source; cPatFilter *patFilter; protected: virtual void Process(u_short Pid, u_char Tid, const u_char *Data, int Length); public: cSdtFilter(cPatFilter *PatFilter); virtual void SetStatus(bool On); + void Trigger(int Source); }; #endif //__SDT_H