From f767260dcc96787b2ceda7548ddd95210e8130e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Fri, 7 Jan 2022 06:50:34 +0100 Subject: [PATCH] fix(DASH): Support "forced-subtitle" role (#3807) Previously, Shaka Player only supported "forced_subtitle", which was the working name before the role was finalized. Closes #3767 --- lib/dash/dash_parser.js | 6 +++-- test/dash/dash_parser_manifest_unit.js | 34 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index e21754a211..08cc1f2318 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -1230,8 +1230,10 @@ shaka.dash.DashParser = class { let forced = false; if (isText) { - // See: https://github.com/google/shaka-player/issues/2122 - forced = roles.includes('forced_subtitle'); + // See: https://github.com/google/shaka-player/issues/2122 and + // https://github.com/Dash-Industry-Forum/DASH-IF-IOP/issues/165 + forced = roles.includes('forced_subtitle') || + roles.includes('forced-subtitle'); } let tilesLayout; diff --git a/test/dash/dash_parser_manifest_unit.js b/test/dash/dash_parser_manifest_unit.js index e46cd634a0..0e263f5a02 100644 --- a/test/dash/dash_parser_manifest_unit.js +++ b/test/dash/dash_parser_manifest_unit.js @@ -1874,7 +1874,7 @@ describe('DashParser Manifest', () => { expect(textStream.kind).toBe('caption'); }); - it('converts Roles element to "forced"', async () => { + it('converts Roles element to "forced" (old role)', async () => { const manifestText = [ '', ' ', @@ -1906,6 +1906,38 @@ describe('DashParser Manifest', () => { expect(textStream.forced).toBe(true); }); + it('converts Roles element to "forced"', async () => { + const manifestText = [ + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' t-en.vtt', + ' ', + ' ', + ' ', + ' ', + ' v-sd.mp4', + ' ', + ' ', + ' ', + ' ', + '', + ].join('\n'); + + fakeNetEngine.setResponseText('dummy://foo', manifestText); + /** @type {shaka.extern.Manifest} */ + const manifest = await parser.start('dummy://foo', playerInterface); + const textStream = manifest.textStreams[0]; + expect(textStream.roles).toEqual(['captions', 'forced-subtitle']); + expect(textStream.forced).toBe(true); + }); + it('supports HDR signaling via profiles', async () => { // (DASH-IF IOP v4.3 10.3.3.) const hdrProfile =