summaryrefslogtreecommitdiff
path: root/remux.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2008-12-20 10:46:53 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2008-12-20 10:46:53 +0100
commit5cbc33d89772b5e4d67abc473fafa7de7eb4e7be (patch)
treee18d0a8e0db3c78e2f91c61a9ed8b5fc334bd0f4 /remux.c
parent051f0def475fd03ee8b2920db41dfdfcaaed3217 (diff)
downloadvdr-5cbc33d89772b5e4d67abc473fafa7de7eb4e7be.tar.gz
vdr-5cbc33d89772b5e4d67abc473fafa7de7eb4e7be.tar.bz2
Fixed handling the 'pointer field' in generating and parsing PAT/PMT
Diffstat (limited to 'remux.c')
-rw-r--r--remux.c14
1 files changed, 11 insertions, 3 deletions
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 <rnissl@gmx.de>,
* 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);