c61a7591 by David LaPalomento

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.
1 parent eaf4677b
......@@ -437,6 +437,9 @@
// rest of header + CRC = 9 + 4
pmtSectionLength -= 13;
// capture the PID of PCR packets so we can ignore them if we see any
self.stream.programMapTable.pcrPid = (data[offset + 8] & 0x1f) << 8 | data[offset + 9];
// align offset to the first entry in the PMT
offset += 12 + pmtProgramDescriptorsLength;
......@@ -479,6 +482,10 @@
// Service Description Table
} else if (0x1FFF === pid) {
// NULL packet
} else if (self.stream.programMapTable.pcrPid) {
// program clock reference (PCR) PID for the primary program
// PTS values are sufficient to synchronize playback for us so
// we can safely ignore these
} else {
videojs.log("Unknown PID parsing TS packet: " + pid);
}
......
......@@ -64,12 +64,15 @@
makePmt = function(options) {
var
result = [],
pcr = options.pcr || 0,
entryCount = 0,
k,
sectionLength;
for (k in options.pids) {
entryCount++;
if (k !== 'pcr') {
entryCount++;
}
}
// table_id
result.push(0x02);
......@@ -88,8 +91,8 @@
// last_section_number
result.push(0x00);
// reserved PCR_PID
result.push(0xe1);
result.push(0x00);
result.push(0xe0 | (pcr & (0x1f << 8)));
result.push(pcr & 0xff);
// reserved program_info_length
result.push(0xf0);
result.push(0x11); // hard-coded 17 byte descriptor
......@@ -229,6 +232,19 @@
ok(true, 'did not throw when a NIT is encountered');
});
test('ignores packets with PCR pids', function() {
parser.parseSegmentBinaryData(new Uint8Array(makePacket({
programs: {
0x01: [0x01]
}
}).concat(makePacket({
pid: 0x01,
pcr: 0x02
}))));
equal(parser.stream.programMapTable.pcrPid, 0x02, 'parsed the PCR pid');
});
test('recognizes metadata streams', function() {
parser.parseSegmentBinaryData(new Uint8Array(makePacket({
programs: {
......