From 85e34776ff520d001cb6e0236a3308f143f093f0 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 24 Jan 2009 13:47:46 +0100 Subject: [PATCH] The PAT/PMT is now only processed if its version changes --- CONTRIBUTORS | 2 ++ HISTORY | 2 ++ device.c | 3 ++- remux.c | 14 +++++++++++++- remux.h | 7 ++++++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4fd72978..98d5ca42 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1195,6 +1195,8 @@ Reinhard Nissl for reporting a possible problem with removing deleted recordings for pointing out that a check of mutexCurrentAudioTrack needs to be done in to cDevice::PlayTs() + for reporting that the PAT/PMT is processed too often, even if its version + hasn't changed Richard Robson for reporting freezing replay if a timer starts while in Transfer Mode from the diff --git a/HISTORY b/HISTORY index 43d19600..51ae4d52 100644 --- a/HISTORY +++ b/HISTORY @@ -5963,3 +5963,5 @@ Video Disk Recorder Revision History the edited PES recording is set to 1 for I-frames and 2 for all others (P- and B-frames). The exact frame type doesn't matter for VDR, it only needs to know if it's an I-frame or not. +- The PAT/PMT is now only processed if its version changes (reported by Reinhard + Nissl). diff --git a/device.c b/device.c index d1e350f2..23c0870a 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 2.9 2009/01/24 11:16:31 kls Exp $ + * $Id: device.c 2.10 2009/01/24 13:40:54 kls Exp $ */ #include "device.h" @@ -1340,6 +1340,7 @@ int cDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly) } } else if (Data == NULL) { + patPmtParser.Reset(); tsToPesVideo.Reset(); tsToPesAudio.Reset(); tsToPesSubtitle.Reset(); diff --git a/remux.c b/remux.c index 23c5b379..b0086214 100644 --- a/remux.c +++ b/remux.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remux.c 2.12 2009/01/24 12:29:19 kls Exp $ + * $Id: remux.c 2.13 2009/01/24 13:44:45 kls Exp $ */ #include "remux.h" @@ -351,8 +351,14 @@ uchar *cPatPmtGenerator::GetPmt(int &Index) // --- cPatPmtParser --------------------------------------------------------- cPatPmtParser::cPatPmtParser(void) +{ + Reset(); +} + +void cPatPmtParser::Reset(void) { pmtSize = 0; + patVersion = pmtVersion = -1; pmtPid = -1; vpid = vtype = 0; } @@ -370,6 +376,8 @@ void cPatPmtParser::ParsePat(const uchar *Data, int Length) SI::PAT Pat(Data, false); if (Pat.CheckCRCAndParse()) { dbgpatpmt("PAT: TSid = %d, c/n = %d, v = %d, s = %d, ls = %d\n", Pat.getTransportStreamId(), Pat.getCurrentNextIndicator(), Pat.getVersionNumber(), Pat.getSectionNumber(), Pat.getLastSectionNumber()); + if (patVersion == Pat.getVersionNumber()) + return; SI::PAT::Association assoc; for (SI::Loop::Iterator it; Pat.associationLoop.getNext(assoc, it); ) { dbgpatpmt(" isNITPid = %d\n", assoc.isNITPid()); @@ -378,6 +386,7 @@ void cPatPmtParser::ParsePat(const uchar *Data, int Length) dbgpatpmt(" service id = %d, pid = %d\n", assoc.getServiceId(), assoc.getPid()); } } + patVersion = Pat.getVersionNumber(); } else esyslog("ERROR: can't parse PAT"); @@ -428,6 +437,8 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) if (Pmt.CheckCRCAndParse()) { dbgpatpmt("PMT: sid = %d, c/n = %d, v = %d, s = %d, ls = %d\n", Pmt.getServiceId(), Pmt.getCurrentNextIndicator(), Pmt.getVersionNumber(), Pmt.getSectionNumber(), Pmt.getLastSectionNumber()); dbgpatpmt(" pcr = %d\n", Pmt.getPCRPid()); + if (pmtVersion == Pmt.getVersionNumber()) + return; cDevice::PrimaryDevice()->ClrAvailableTracks(false, true); int NumApids = 0; int NumDpids = 0; @@ -533,6 +544,7 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) cDevice::PrimaryDevice()->EnsureAudioTrack(true); cDevice::PrimaryDevice()->EnsureSubtitleTrack(); } + pmtVersion = Pmt.getVersionNumber(); } else esyslog("ERROR: can't parse PMT"); diff --git a/remux.h b/remux.h index b65da73b..8cb1223a 100644 --- a/remux.h +++ b/remux.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: remux.h 2.6 2009/01/23 16:44:46 kls Exp $ + * $Id: remux.h 2.7 2009/01/24 13:38:10 kls Exp $ */ #ifndef __REMUX_H @@ -192,6 +192,8 @@ class cPatPmtParser { private: uchar pmt[MAX_SECTION_SIZE]; int pmtSize; + int patVersion; + int pmtVersion; int pmtPid; int vpid; int vtype; @@ -199,6 +201,9 @@ protected: int SectionLength(const uchar *Data, int Length) { return (Length >= 3) ? ((int(Data[1]) & 0x0F) << 8)| Data[2] : 0; } public: cPatPmtParser(void); + void Reset(void); + ///< Resets the parser. This function must be called whenever a new + ///< stream is parsed. void ParsePat(const uchar *Data, int Length); ///< Parses the PAT data from the single TS packet in Data. ///< Length is always TS_SIZE.