From f23ee0a9af765571cae0257fa4e6b31ee0d64b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 17 Mar 2021 18:27:42 +0100 Subject: [PATCH] feat(Dash): Extract HDR metadata from DASH manifests (#3226) --- lib/dash/dash_parser.js | 20 ++++++++++++++++- test/dash/dash_parser_manifest_unit.js | 31 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index 2b19c7aaf6..f1534a82a2 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -361,6 +361,8 @@ shaka.dash.DashParser = class { this.config_.dash.autoCorrectDrift); } + const profiles = mpd.getAttribute('profiles') || ''; + /** @type {shaka.dash.DashParser.Context} */ const context = { // Don't base on updatePeriod_ since emsg boxes can cause manifest @@ -374,6 +376,7 @@ shaka.dash.DashParser = class { bandwidth: 0, indexRangeWarningGiven: false, availabilityTimeOffset: availabilityTimeOffset, + profiles: profiles.split(','), }; const periodsAndDuration = this.parsePeriods_(context, baseUris, mpd); @@ -1111,6 +1114,16 @@ 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') || + codecs.includes('hev1.2.4.L153.B0'))) { + hdr = 'PQ'; + } + /** @type {shaka.extern.Stream} */ const stream = { id: this.globalId_++, @@ -1145,6 +1158,7 @@ shaka.dash.DashParser = class { audioSamplingRate: context.representation.audioSamplingRate, spatialAudio: spatialAudio, closedCaptions, + hdr, tilesLayout, }; return stream; @@ -1768,7 +1782,8 @@ shaka.dash.DashParser.InheritanceFrame; * representation: ?shaka.dash.DashParser.InheritanceFrame, * bandwidth: number, * indexRangeWarningGiven: boolean, - * availabilityTimeOffset: number + * availabilityTimeOffset: number, + * profiles: !Array. * }} * * @description @@ -1794,6 +1809,9 @@ shaka.dash.DashParser.InheritanceFrame; * True if the warning about SegmentURL@indexRange has been printed. * @property {number} availabilityTimeOffset * The sum of the availabilityTimeOffset values that apply to the element. + * @property {!Array.} profiles + * Profiles of DASH are defined to enable interoperability and the signaling + * of the use of features. */ shaka.dash.DashParser.Context; diff --git a/test/dash/dash_parser_manifest_unit.js b/test/dash/dash_parser_manifest_unit.js index 039cbb72ea..371072c690 100644 --- a/test/dash/dash_parser_manifest_unit.js +++ b/test/dash/dash_parser_manifest_unit.js @@ -1854,6 +1854,37 @@ describe('DashParser Manifest', () => { expect(textStream.forced).toBe(true); }); + it('supports HDR signaling', async () => { + const hdrProfile = + 'http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10'; + const manifestText = [ + ``, + ' ', + ' ', + ' ', + ' v-sd.mp4', + ' ', + ' ', + ' ', + ' ', + ' ', + ' a-en.mp4', + ' ', + ' ', + ' ', + ' ', + '', + ].join('\n'); + + fakeNetEngine.setResponseText('dummy://foo', manifestText); + + /** @type {shaka.extern.Manifest} */ + const manifest = await parser.start('dummy://foo', playerInterface); + expect(manifest.variants.length).toBe(1); + const stream = manifest.variants[0].video; + expect(stream.hdr).toBe('PQ'); + }); + it('Does not error when image adaptation sets are present', async () => { const manifestText = [ '',