From 5cbc33d89772b5e4d67abc473fafa7de7eb4e7be Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 20 Dec 2008 10:46:53 +0100 Subject: Fixed handling the 'pointer field' in generating and parsing PAT/PMT --- CONTRIBUTORS | 1 + HISTORY | 4 +++- remux.c | 14 +++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ea212734..5de7402a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2201,6 +2201,7 @@ Frank Schmirler for making entering text via the numeric keys check the characters against the allowed characters for fixing handling address masks in SVDRP host settings + for fixing handling the 'pointer field' in generating and parsing PAT/PMT Jörn Reder for reporting that a recording may unnecessarily block a device with a CAM, while diff --git a/HISTORY b/HISTORY index 13485c4f..96c41b25 100644 --- a/HISTORY +++ b/HISTORY @@ -5849,6 +5849,8 @@ Video Disk Recorder Revision History the patch from ftp://ftp.cadsoft.de/vdr/Developer/av7110_v4ldvb_api5_audiobuf_test_1.diff to the driver (thanks to Oliver Endriss). -2008-12-17: Version 1.7.3 +2008-12-20: Version 1.7.3 - Updated the Russian OSD texts (thanks to Oleg Roitburd). +- Fixed handling the 'pointer field' in generating and parsing PAT/PMT (thanks to + Frank Schmirler). diff --git a/remux.c b/remux.c index 19385495..e7de8a1b 100644 --- a/remux.c +++ b/remux.c @@ -11,7 +11,7 @@ * The cRepacker family's code was originally written by Reinhard Nissl , * and adapted to the VDR coding style by Klaus.Schmidinger@cadsoft.de. * - * $Id: remux.c 2.2 2008/12/13 14:30:15 kls Exp $ + * $Id: remux.c 2.3 2008/12/20 10:38:47 kls Exp $ */ #include "remux.h" @@ -2298,6 +2298,7 @@ void cPatPmtGenerator::GeneratePat(void) p[i++] = 0x40; // flags (3), pid hi (5) p[i++] = 0x00; // pid lo p[i++] = 0x10; // flags (4), continuity counter (4) + p[i++] = 0x00; // pointer field (payload unit start indicator is set) int PayloadStart = i; p[i++] = 0x00; // table id p[i++] = 0xB0; // section syntax indicator (1), dummy (3), section length hi (4) @@ -2367,13 +2368,18 @@ void cPatPmtGenerator::GeneratePmt(tChannelID ChannelID) MakeCRC(buf + i, buf, i); // split the PMT section into several TS packets: uchar *q = buf; + bool pusi = true; while (i > 0) { uchar *p = pmt[numPmtPackets++]; int j = 0; p[j++] = 0x47; // TS indicator - p[j++] = 0x40 | (P_PNR >> 8); // flags (3), pid hi (5) + p[j++] = (pusi ? 0x40 : 0x00) | (P_PNR >> 8); // flags (3), pid hi (5) p[j++] = P_PNR & 0xFF; // pid lo p[j++] = 0x10; // flags (4), continuity counter (4) + if (pusi) { + p[j++] = 0x00; // pointer field (payload unit start indicator is set) + pusi = false; + } int l = TS_SIZE - j; memcpy(p + j, q, l); q += l; @@ -2412,6 +2418,7 @@ cPatPmtParser::cPatPmtParser(void) void cPatPmtParser::ParsePat(const uchar *Data, int Length) { // The PAT is always assumed to fit into a single TS packet + Data += Data[0] + 1; // process pointer_field 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()); @@ -2432,7 +2439,8 @@ void cPatPmtParser::ParsePmt(const uchar *Data, int Length) { // The PMT may extend over several TS packets, so we need to assemble them if (pmtSize == 0) { - // this is the first packet + Data += Data[0] + 1; // this is the first packet + Length -= Data[0] + 1; if (SectionLength(Data, Length) > Length) { if (Length <= int(sizeof(pmt))) { memcpy(pmt, Data, Length); -- cgit v1.2.3