Skip to content

Commit

Permalink
fix(DASH): Support "forced-subtitle" role (shaka-project#3807)
Browse files Browse the repository at this point in the history
Previously, Shaka Player only supported "forced_subtitle",
which was the working name before the role was finalized.

Closes shaka-project#3767
  • Loading branch information
Álvaro Velad Galván committed Jan 7, 2022
1 parent 680ab22 commit f767260
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/dash/dash_parser.js
Expand Up @@ -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;
Expand Down
34 changes: 33 additions & 1 deletion test/dash/dash_parser_manifest_unit.js
Expand Up @@ -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 = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
Expand Down Expand Up @@ -1906,6 +1906,38 @@ describe('DashParser Manifest', () => {
expect(textStream.forced).toBe(true);
});

it('converts Roles element to "forced"', async () => {
const manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet id="1" contentType="text">',
' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
' value="captions" />',
' <Accessibility schemeIdUri="urn:mpeg:dash:role:2011" ',
' value="forced-subtitle" />',
' <Accessibility schemeIdUri="foobar" value="bar" />',
' <Representation id="text-en" mimeType="text/webvtt">',
' <BaseURL>t-en.vtt</BaseURL>',
' </Representation>',
' </AdaptationSet>',
' <AdaptationSet id="1" mimeType="video/mp4">',
' <Representation id="video-sd" width="640" height="480">',
' <BaseURL>v-sd.mp4</BaseURL>',
' <SegmentBase indexRange="100-200" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>',
].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 =
Expand Down

0 comments on commit f767260

Please sign in to comment.