From 62596f991ebf30a61cdbe1de15acd2c63f598149 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 17 Mar 2015 15:10:57 +0100 Subject: [PATCH] Improved syncing on sections when parsing the NIT and SDT --- HISTORY | 1 + filter.c | 31 ++++++++++++++++++++----------- filter.h | 6 ++++-- nit.c | 4 ++-- sdt.c | 4 ++-- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/HISTORY b/HISTORY index 43f926ee..1471aa51 100644 --- a/HISTORY +++ b/HISTORY @@ -8618,3 +8618,4 @@ Video Disk Recorder Revision History network. - Added some comment to cPixmap about the relation between OSD, ViewPort and DrawPort (suggested by Thomas Reufer). +- Improved syncing on sections when parsing the NIT and SDT. diff --git a/filter.c b/filter.c index 08bde5a4..331983a8 100644 --- a/filter.c +++ b/filter.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: filter.c 1.4 2004/01/11 13:31:34 kls Exp $ + * $Id: filter.c 4.1 2015/03/17 15:04:39 kls Exp $ */ #include "filter.h" @@ -18,23 +18,32 @@ cSectionSyncer::cSectionSyncer(void) } void cSectionSyncer::Reset(void) +{ + lastVersion = thisVersion = 0xFF; + nextNumber = 0; +} + +void cSectionSyncer::Repeat(void) { lastVersion = 0xFF; - synced = false; + nextNumber--; } bool cSectionSyncer::Sync(uchar Version, int Number, int LastNumber) { - if (Version == lastVersion) - return false; - if (!synced) { - if (Number != 0) - return false; // sync on first section - synced = true; + if (Version != lastVersion) { + if (Version != thisVersion) { + thisVersion = Version; + nextNumber = 0; + } + if (Number == nextNumber) { + if (Number == LastNumber) + lastVersion = Version; + nextNumber++; + return true; + } } - if (Number == LastNumber) - lastVersion = Version; - return synced; + return false; } // --- cFilterData ----------------------------------------------------------- diff --git a/filter.h b/filter.h index 9bd163fe..282a1e90 100644 --- a/filter.h +++ b/filter.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: filter.h 1.3 2004/01/11 13:31:59 kls Exp $ + * $Id: filter.h 4.1 2015/03/17 15:00:08 kls Exp $ */ #ifndef __FILTER_H @@ -16,10 +16,12 @@ class cSectionSyncer { private: int lastVersion; - bool synced; + int thisVersion; + int nextNumber; public: cSectionSyncer(void); void Reset(void); + void Repeat(void); bool Sync(uchar Version, int Number, int LastNumber); }; diff --git a/nit.c b/nit.c index aaf7c88c..15579453 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 4.1 2015/03/16 15:24:18 kls Exp $ + * $Id: nit.c 4.2 2015/03/17 15:10:09 kls Exp $ */ #include "nit.h" @@ -62,7 +62,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length dbgnit("NIT: %02X %2d %2d %2d %s %d %d '%s'\n", Tid, nit.getVersionNumber(), nit.getSectionNumber(), nit.getLastSectionNumber(), *cSource::ToString(Source()), nit.getNetworkId(), Transponder(), NetworkName); } if (!Channels.Lock(true, 10)) { - sectionSyncer.Reset(); // let's not miss any section of the NIT + sectionSyncer.Repeat(); // let's not miss any section of the NIT return; } SI::NIT::TransportStream ts; diff --git a/sdt.c b/sdt.c index 0b33e52a..782bec65 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 4.3 2015/03/16 15:24:12 kls Exp $ + * $Id: sdt.c 4.4 2015/03/17 15:09:54 kls Exp $ */ #include "sdt.h" @@ -53,7 +53,7 @@ void cSdtFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length if (!sectionSyncer.Sync(sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber())) return; if (!Channels.Lock(true, 10)) { - sectionSyncer.Reset(); // let's not miss any section of the SDT + sectionSyncer.Repeat(); // let's not miss any section of the SDT return; } dbgsdt("SDT: %2d %2d %2d %s %d\n", sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber(), *cSource::ToString(source), Transponder());