Don't warn when PCR pids are encountered
We don't need a PCR stream for a program to keep synchronized but it's not a problem if one is included. Parse out the PCR PID when it's specified and make sure the warning message isn't output when they are encountered.
Showing
2 changed files
with
26 additions
and
3 deletions
... | @@ -437,6 +437,9 @@ | ... | @@ -437,6 +437,9 @@ |
437 | // rest of header + CRC = 9 + 4 | 437 | // rest of header + CRC = 9 + 4 |
438 | pmtSectionLength -= 13; | 438 | pmtSectionLength -= 13; |
439 | 439 | ||
440 | // capture the PID of PCR packets so we can ignore them if we see any | ||
441 | self.stream.programMapTable.pcrPid = (data[offset + 8] & 0x1f) << 8 | data[offset + 9]; | ||
442 | |||
440 | // align offset to the first entry in the PMT | 443 | // align offset to the first entry in the PMT |
441 | offset += 12 + pmtProgramDescriptorsLength; | 444 | offset += 12 + pmtProgramDescriptorsLength; |
442 | 445 | ||
... | @@ -479,6 +482,10 @@ | ... | @@ -479,6 +482,10 @@ |
479 | // Service Description Table | 482 | // Service Description Table |
480 | } else if (0x1FFF === pid) { | 483 | } else if (0x1FFF === pid) { |
481 | // NULL packet | 484 | // NULL packet |
485 | } else if (self.stream.programMapTable.pcrPid) { | ||
486 | // program clock reference (PCR) PID for the primary program | ||
487 | // PTS values are sufficient to synchronize playback for us so | ||
488 | // we can safely ignore these | ||
482 | } else { | 489 | } else { |
483 | videojs.log("Unknown PID parsing TS packet: " + pid); | 490 | videojs.log("Unknown PID parsing TS packet: " + pid); |
484 | } | 491 | } | ... | ... |
... | @@ -64,12 +64,15 @@ | ... | @@ -64,12 +64,15 @@ |
64 | makePmt = function(options) { | 64 | makePmt = function(options) { |
65 | var | 65 | var |
66 | result = [], | 66 | result = [], |
67 | pcr = options.pcr || 0, | ||
67 | entryCount = 0, | 68 | entryCount = 0, |
68 | k, | 69 | k, |
69 | sectionLength; | 70 | sectionLength; |
70 | 71 | ||
71 | for (k in options.pids) { | 72 | for (k in options.pids) { |
72 | entryCount++; | 73 | if (k !== 'pcr') { |
74 | entryCount++; | ||
75 | } | ||
73 | } | 76 | } |
74 | // table_id | 77 | // table_id |
75 | result.push(0x02); | 78 | result.push(0x02); |
... | @@ -88,8 +91,8 @@ | ... | @@ -88,8 +91,8 @@ |
88 | // last_section_number | 91 | // last_section_number |
89 | result.push(0x00); | 92 | result.push(0x00); |
90 | // reserved PCR_PID | 93 | // reserved PCR_PID |
91 | result.push(0xe1); | 94 | result.push(0xe0 | (pcr & (0x1f << 8))); |
92 | result.push(0x00); | 95 | result.push(pcr & 0xff); |
93 | // reserved program_info_length | 96 | // reserved program_info_length |
94 | result.push(0xf0); | 97 | result.push(0xf0); |
95 | result.push(0x11); // hard-coded 17 byte descriptor | 98 | result.push(0x11); // hard-coded 17 byte descriptor |
... | @@ -229,6 +232,19 @@ | ... | @@ -229,6 +232,19 @@ |
229 | ok(true, 'did not throw when a NIT is encountered'); | 232 | ok(true, 'did not throw when a NIT is encountered'); |
230 | }); | 233 | }); |
231 | 234 | ||
235 | test('ignores packets with PCR pids', function() { | ||
236 | parser.parseSegmentBinaryData(new Uint8Array(makePacket({ | ||
237 | programs: { | ||
238 | 0x01: [0x01] | ||
239 | } | ||
240 | }).concat(makePacket({ | ||
241 | pid: 0x01, | ||
242 | pcr: 0x02 | ||
243 | })))); | ||
244 | |||
245 | equal(parser.stream.programMapTable.pcrPid, 0x02, 'parsed the PCR pid'); | ||
246 | }); | ||
247 | |||
232 | test('recognizes metadata streams', function() { | 248 | test('recognizes metadata streams', function() { |
233 | parser.parseSegmentBinaryData(new Uint8Array(makePacket({ | 249 | parser.parseSegmentBinaryData(new Uint8Array(makePacket({ |
234 | programs: { | 250 | programs: { | ... | ... |
-
Please register or sign in to post a comment