Skip to content

Commit

Permalink
feat: Add support for AC-3 and EC-3 audio in DVB streams (#5484)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Aug 17, 2023
1 parent c8a27ca commit 9bd559b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion lib/util/ts_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,36 @@ shaka.util.TsParser = class {
offset += 12 + programInfoLength;
while (offset < tableEnd) {
const pid = ((data[offset + 1] & 0x1f) << 8) | data[offset + 2];
const esInfoLength = ((data[offset + 3] & 0x0f) << 8) | data[offset + 4];
switch (data[offset]) {
case 0x06:
// stream_type 6 can mean a lot of different things in case of DVB.
// We need to look at the descriptors. Right now, we're only
// interested in AC-3 and EC-3 audio, so we do the descriptor parsing
// only when we don't have an audio PID yet.
if (result.audio == -1 && esInfoLength > 0) {
let parsePos = offset + 5;
let remaining = esInfoLength;
while (remaining > 2) {
const descriptorId = data[parsePos];
switch (descriptorId) {
// DVB Descriptor for AC-3
case 0x6a:
result.audio = pid;
result.audioCodec = 'ac3';
break;
// DVB Descriptor for EC-3
case 0x7a:
result.audio = pid;
result.audioCodec = 'ec3';
break;
}
const descriptorLen = data[parsePos + 1] + 2;
parsePos += descriptorLen;
remaining -= descriptorLen;
}
}
break;
// SAMPLE-AES AAC
case 0xcf:
break;
Expand Down Expand Up @@ -289,7 +318,7 @@ shaka.util.TsParser = class {
}
// move to the next table entry
// skip past the elementary stream descriptors, if present
offset += (((data[offset + 3] & 0x0f) << 8) | data[offset + 4]) + 5;
offset += esInfoLength + 5;
}
return result;
}
Expand Down

0 comments on commit 9bd559b

Please sign in to comment.