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.
- 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.

View File

@ -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;
return synced;
nextNumber++;
return true;
}
}
return false;
}
// --- cFilterData -----------------------------------------------------------

View File

@ -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);
};

4
nit.c
View File

@ -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;

4
sdt.c
View File

@ -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());