ef1c74f6 by Jernej Fijačko Committed by David LaPalomento

Allow playback of content with network PID entries inside PAT

1 parent ad2140d0
...@@ -221,6 +221,9 @@ ...@@ -221,6 +221,9 @@
221 patTableId, // :int 221 patTableId, // :int
222 patCurrentNextIndicator, // Boolean 222 patCurrentNextIndicator, // Boolean
223 patSectionLength, // :uint 223 patSectionLength, // :uint
224 patNumEntries, // :uint
225 patNumPrograms, // :uint
226 patProgramOffset, // :uint
224 227
225 pesPacketSize, // :int, 228 pesPacketSize, // :int,
226 dataAlignmentIndicator, // :Boolean, 229 dataAlignmentIndicator, // :Boolean,
...@@ -302,9 +305,22 @@ ...@@ -302,9 +305,22 @@
302 // raise an exception if we encounter one 305 // raise an exception if we encounter one
303 // section_length = rest of header + (n * entry length) + CRC 306 // section_length = rest of header + (n * entry length) + CRC
304 // = 5 + (n * 4) + 4 307 // = 5 + (n * 4) + 4
305 if ((patSectionLength - 5 - 4) / 4 !== 1) { 308 patNumEntries = (patSectionLength - 5 - 4) / 4;
309 patNumPrograms = 0;
310 patProgramOffset = offset;
311 for (var entryIndex = 0; entryIndex < patNumEntries; entryIndex++) {
312 // network PID program number equals 0 and can be ignored
313 if (((data[offset + 4*entryIndex]) << 8 | data[offset + 4*entryIndex + 1]) > 0) {
314 patNumPrograms++;
315 patProgramOffset = offset + 4*entryIndex;
316 }
317 }
318 if (patNumPrograms !== 1) {
306 throw new Error("TS has more that 1 program"); 319 throw new Error("TS has more that 1 program");
307 } 320 }
321 else {
322 offset = patProgramOffset;
323 }
308 324
309 // the Program Map Table (PMT) associates the underlying 325 // the Program Map Table (PMT) associates the underlying
310 // video and audio streams with a unique PID 326 // video and audio streams with a unique PID
......