Skip to content

Commit

Permalink
fix(DASH): Fix Dolby Atmos detection when there is not SupplementalPr…
Browse files Browse the repository at this point in the history
…operty (#7847)

The correct way is to use JOC, but some packagers do not use it.
  • Loading branch information
avelad authored Jan 8, 2025
1 parent c5dc5f4 commit cf581cd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2291,8 +2291,12 @@ shaka.dash.DashParser = class {
return element.attributes['schemeIdUri'] == expectedUri &&
element.attributes['value'] == expectedValue;
});
const codecs = context.representation.codecs;
// Detect the presence of Dolby Atmos audio content based on the codec and
// bandwidth. Bandwidth above 384 kbps is a good indicator of Atmos content.
const isAtmos = codecs.includes('ec-3') && context.bandwidth >= 384000;
let spatialAudio = false;
if (hasJoc) {
if (hasJoc || isAtmos) {
spatialAudio = true;
}

Expand Down Expand Up @@ -2324,7 +2328,6 @@ shaka.dash.DashParser = class {

let hdr;
const profiles = context.profiles;
const codecs = context.representation.codecs;

const hevcHDR = 'http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10';
if (profiles.includes(hevcHDR) && (codecs.includes('hvc1.2.4.L153.B0') ||
Expand Down
22 changes: 22 additions & 0 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,28 @@ describe('DashParser Manifest', () => {
expect(stream.spatialAudio).toBe(true);
});

it('Detects spatial audio by codec and bandwidth', async () => {
const source = [
'<MPD>',
' <Period duration="PT30M">',
' <AdaptationSet mimeType="audio/mp4" lang="\u2603">',
' <Representation bandwidth="384000" codecs="ec-3">',
' <BaseURL>http://example.com</BaseURL>',
' <SegmentTemplate media="2.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', source);

/** @type {shaka.extern.Manifest} */
const manifest = await parser.start('dummy://foo', playerInterface);
const stream = manifest.variants[0].audio;
expect(stream.spatialAudio).toBe(true);
});

it('correctly parses CEA-608 closed caption tags without channel numbers',
async () => {
const source = [
Expand Down

0 comments on commit cf581cd

Please sign in to comment.