1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Improved syncing on sections when parsing the NIT and SDT

This commit is contained in:
Klaus Schmidinger 2015-03-17 15:10:57 +01:00
parent fd7ccc7627
commit 62596f991e
5 changed files with 29 additions and 17 deletions

View File

@ -8618,3 +8618,4 @@ Video Disk Recorder Revision History
network. network.
- Added some comment to cPixmap about the relation between OSD, ViewPort and DrawPort - Added some comment to cPixmap about the relation between OSD, ViewPort and DrawPort
(suggested by Thomas Reufer). (suggested by Thomas Reufer).
- Improved syncing on sections when parsing the NIT and SDT.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "filter.h"
@ -18,23 +18,32 @@ cSectionSyncer::cSectionSyncer(void)
} }
void cSectionSyncer::Reset(void) void cSectionSyncer::Reset(void)
{
lastVersion = thisVersion = 0xFF;
nextNumber = 0;
}
void cSectionSyncer::Repeat(void)
{ {
lastVersion = 0xFF; lastVersion = 0xFF;
synced = false; nextNumber--;
} }
bool cSectionSyncer::Sync(uchar Version, int Number, int LastNumber) bool cSectionSyncer::Sync(uchar Version, int Number, int LastNumber)
{ {
if (Version == lastVersion) if (Version != lastVersion) {
return false; if (Version != thisVersion) {
if (!synced) { thisVersion = Version;
if (Number != 0) nextNumber = 0;
return false; // sync on first section }
synced = true; if (Number == nextNumber) {
if (Number == LastNumber)
lastVersion = Version;
nextNumber++;
return true;
}
} }
if (Number == LastNumber) return false;
lastVersion = Version;
return synced;
} }
// --- cFilterData ----------------------------------------------------------- // --- cFilterData -----------------------------------------------------------

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __FILTER_H
@ -16,10 +16,12 @@
class cSectionSyncer { class cSectionSyncer {
private: private:
int lastVersion; int lastVersion;
bool synced; int thisVersion;
int nextNumber;
public: public:
cSectionSyncer(void); cSectionSyncer(void);
void Reset(void); void Reset(void);
void Repeat(void);
bool Sync(uchar Version, int Number, int LastNumber); bool Sync(uchar Version, int Number, int LastNumber);
}; };

4
nit.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #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); 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)) { 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; return;
} }
SI::NIT::TransportStream ts; SI::NIT::TransportStream ts;

4
sdt.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #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())) if (!sectionSyncer.Sync(sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber()))
return; return;
if (!Channels.Lock(true, 10)) { 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; return;
} }
dbgsdt("SDT: %2d %2d %2d %s %d\n", sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber(), *cSource::ToString(source), Transponder()); dbgsdt("SDT: %2d %2d %2d %s %d\n", sdt.getVersionNumber(), sdt.getSectionNumber(), sdt.getLastSectionNumber(), *cSource::ToString(source), Transponder());