Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for AC-3 and EC-3 audio in DVB streams #5484

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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