Commit a4c12ca9 by ibaker Committed by tonihei

Parse DASH forced-subtitle role value

Issue: google/ExoPlayer#9727

#minor-release

PiperOrigin-RevId: 412266397
parent 2054b290
......@@ -1477,6 +1477,8 @@ public class DashManifestParser extends DefaultHandler
case "main":
return C.SELECTION_FLAG_DEFAULT;
case "forced_subtitle":
// Support both hyphen and underscore (https://github.com/google/ExoPlayer/issues/9727).
case "forced-subtitle":
return C.SELECTION_FLAG_FORCED;
default:
return 0;
......@@ -1547,6 +1549,8 @@ public class DashManifestParser extends DefaultHandler
case "caption":
return C.ROLE_FLAG_CAPTION;
case "forced_subtitle":
// Support both hyphen and underscore (https://github.com/google/ExoPlayer/issues/9727).
case "forced-subtitle":
case "subtitle":
return C.ROLE_FLAG_SUBTITLE;
case "sign":
......
......@@ -254,7 +254,13 @@ public class DashManifestParserTest {
assertThat(format.selectionFlags).isEqualTo(C.SELECTION_FLAG_FORCED);
assertThat(adaptationSets.get(1).type).isEqualTo(C.TRACK_TYPE_TEXT);
// Ensure that forced-subtitle and forced_subtitle are both parsed as a 'forced' text track.
// https://github.com/google/ExoPlayer/issues/9727
format = adaptationSets.get(2).representations.get(0).format;
assertThat(format.roleFlags).isEqualTo(C.ROLE_FLAG_SUBTITLE);
assertThat(format.selectionFlags).isEqualTo(C.SELECTION_FLAG_FORCED);
format = adaptationSets.get(3).representations.get(0).format;
assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_TTML);
assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_TTML);
assertThat(format.codecs).isNull();
......@@ -586,10 +592,11 @@ public class DashManifestParserTest {
assertThat(manifest.getPeriodCount()).isEqualTo(1);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
assertThat(adaptationSets).hasSize(3);
assertThat(adaptationSets).hasSize(4);
assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(0))).isEqualTo(C.TIME_UNSET);
assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(1))).isEqualTo(C.TIME_UNSET);
assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(2))).isEqualTo(C.TIME_UNSET);
assertThat(getAvailabilityTimeOffsetUs(adaptationSets.get(3))).isEqualTo(C.TIME_UNSET);
}
@Test
......
......@@ -13,11 +13,17 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="0" mimeType="application/mp4" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:DASH:role:2011" value="forced_subtitle"/>
<Role schemeIdUri="urn:mpeg:DASH:role:2011" value="forced-subtitle"/>
<Representation id="0" codecs="stpp.ttml.im1t" bandwidth="16">
<BaseURL>https://test.com/0</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="0" mimeType="application/mp4" subsegmentAlignment="true">
<Role schemeIdUri="urn:mpeg:DASH:role:2011" value="forced_subtitle"/>
<Representation id="0" codecs="stpp.ttml.im1t" bandwidth="16">
<BaseURL>https://test.com/0</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="0" mimeType="application/ttml+xml" subsegmentAlignment="true">
<Representation id="0" bandwidth="16">
<BaseURL>https://test.com/0</BaseURL>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment