Parse DASH forced-subtitle role value

Issue: google/ExoPlayer#9727

#minor-release

PiperOrigin-RevId: 412266397
This commit is contained in:
ibaker 2021-11-25 13:48:15 +00:00 committed by kim-vde
parent 3cc64ae2df
commit 276f103c89
4 changed files with 22 additions and 2 deletions

View file

@ -11,6 +11,9 @@
* Add a method to `AdPlaybackState` to allow resetting an ad group so that
it can be played again
([#9615](https://github.com/google/ExoPlayer/issues/9615)).
* DASH:
* Support the `forced-subtitle` track role
([#9727](https://github.com/google/ExoPlayer/issues/9727)).
* HLS:
* Support key-frame accurate seeking in HLS
([#2882](https://github.com/google/ExoPlayer/issues/2882)).

View file

@ -1475,6 +1475,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;
@ -1545,6 +1547,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":

View file

@ -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

View file

@ -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>