From ca708213a67338d94d950d8ce867c1085e65a574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 8 Jan 2025 19:55:48 +0100 Subject: [PATCH] fix(DASH): Fix Dolby Atmos detection when there is not SupplementalProperty (#7847) The correct way is to use JOC, but some packagers do not use it. --- lib/dash/dash_parser.js | 7 +++++-- test/dash/dash_parser_manifest_unit.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index fecfaa6461..af1d602756 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -2295,8 +2295,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; } @@ -2328,7 +2332,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') || diff --git a/test/dash/dash_parser_manifest_unit.js b/test/dash/dash_parser_manifest_unit.js index 74bfb04732..5fd23b5f1f 100644 --- a/test/dash/dash_parser_manifest_unit.js +++ b/test/dash/dash_parser_manifest_unit.js @@ -544,6 +544,28 @@ describe('DashParser Manifest', () => { expect(stream.spatialAudio).toBe(true); }); + it('Detects spatial audio by codec and bandwidth', async () => { + const source = [ + '', + ' ', + ' ', + ' ', + ' http://example.com', + ' ', + ' ', + ' ', + ' ', + '', + ].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 = [