use of androidx.media3.exoplayer.dash.manifest.AdaptationSet in project media by androidx.
the class DashMediaPeriodTest method adaptationSetSwitchingProperty_mergesTrackGroups.
@Test
public void adaptationSetSwitchingProperty_mergesTrackGroups() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_switching_property");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect the three adaptation sets with the switch descriptor to be merged, retaining the
// representations in their original order.
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"0", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format, adaptationSets.get(2).representations.get(0).format, adaptationSets.get(2).representations.get(1).format, adaptationSets.get(3).representations.get(0).format), new TrackGroup(/* id= */
"3", adaptationSets.get(1).representations.get(0).format));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of androidx.media3.exoplayer.dash.manifest.AdaptationSet in project media by androidx.
the class DashMediaPeriodTest method adaptationSetSwitchingProperty_andTrickPlayProperty_mergesTrackGroups.
@Test
public void adaptationSetSwitchingProperty_andTrickPlayProperty_mergesTrackGroups() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_switching_and_trick_play_property");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect all adaptation sets to be merged into one group, retaining representations in their
// original order.
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"0", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format, adaptationSets.get(1).representations.get(0).format, adaptationSets.get(2).representations.get(0).format, adaptationSets.get(2).representations.get(1).format, adaptationSets.get(3).representations.get(0).format));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of androidx.media3.exoplayer.dash.manifest.AdaptationSet in project media by androidx.
the class DashManifestParserTest method parseMediaPresentationDescription_text.
@Test
public void parseMediaPresentationDescription_text() throws IOException {
DashManifestParser parser = new DashManifestParser();
DashManifest manifest = parser.parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_TEXT));
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
Format format = adaptationSets.get(0).representations.get(0).format;
assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_RAWCC);
assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_CEA608);
assertThat(format.codecs).isEqualTo("cea608");
assertThat(format.roleFlags).isEqualTo(C.ROLE_FLAG_SUBTITLE | C.ROLE_FLAG_MAIN);
assertThat(format.selectionFlags).isEqualTo(0);
assertThat(adaptationSets.get(0).type).isEqualTo(C.TRACK_TYPE_TEXT);
format = adaptationSets.get(1).representations.get(0).format;
assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_MP4);
assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_TTML);
assertThat(format.codecs).isEqualTo("stpp.ttml.im1t");
assertThat(format.roleFlags).isEqualTo(C.ROLE_FLAG_SUBTITLE);
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();
assertThat(format.roleFlags).isEqualTo(0);
assertThat(adaptationSets.get(2).type).isEqualTo(C.TRACK_TYPE_TEXT);
}
use of androidx.media3.exoplayer.dash.manifest.AdaptationSet in project media by androidx.
the class DashManifestParserTest method parseEssentialAndSupplementalProperties.
@Test
public void parseEssentialAndSupplementalProperties() throws IOException {
DashManifestParser parser = new DashManifestParser();
DashManifest manifest = parser.parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_ESSENTIAL_SUPPLEMENTAL_PROPERTIES));
// Verify test setup.
assertThat(manifest.getPeriodCount()).isEqualTo(1);
assertThat(manifest.getPeriod(0).adaptationSets).hasSize(1);
AdaptationSet adaptationSet = manifest.getPeriod(0).adaptationSets.get(0);
assertThat(adaptationSet.representations).hasSize(2);
Representation representation0 = adaptationSet.representations.get(0);
Representation representation1 = adaptationSet.representations.get(1);
assertThat(representation0).isInstanceOf(SingleSegmentRepresentation.class);
assertThat(representation1).isInstanceOf(MultiSegmentRepresentation.class);
// Verify parsed properties.
assertThat(adaptationSet.essentialProperties).hasSize(1);
assertThat(adaptationSet.essentialProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:essential-scheme:2050");
assertThat(adaptationSet.essentialProperties.get(0).value).isEqualTo("adaptationEssential");
assertThat(adaptationSet.supplementalProperties).hasSize(1);
assertThat(adaptationSet.supplementalProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:supplemental-scheme:2050");
assertThat(adaptationSet.supplementalProperties.get(0).value).isEqualTo("adaptationSupplemental");
assertThat(representation0.essentialProperties).hasSize(2);
assertThat(representation0.essentialProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:essential-scheme:2050");
assertThat(representation0.essentialProperties.get(0).value).isEqualTo("adaptationEssential");
assertThat(representation0.essentialProperties.get(1).schemeIdUri).isEqualTo("urn:mpeg:dash:essential-scheme:2050");
assertThat(representation0.essentialProperties.get(1).value).isEqualTo("representationEssential");
assertThat(representation0.supplementalProperties).hasSize(2);
assertThat(representation0.supplementalProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:supplemental-scheme:2050");
assertThat(representation0.supplementalProperties.get(0).value).isEqualTo("adaptationSupplemental");
assertThat(representation0.supplementalProperties.get(1).schemeIdUri).isEqualTo("urn:mpeg:dash:supplemental-scheme:2050");
assertThat(representation0.supplementalProperties.get(1).value).isEqualTo("representationSupplemental");
assertThat(representation1.essentialProperties).hasSize(2);
assertThat(representation0.essentialProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:essential-scheme:2050");
assertThat(representation0.essentialProperties.get(0).value).isEqualTo("adaptationEssential");
assertThat(representation1.essentialProperties.get(1).schemeIdUri).isEqualTo("urn:mpeg:dash:essential-scheme:2050");
assertThat(representation1.essentialProperties.get(1).value).isEqualTo("representationEssential");
assertThat(representation1.supplementalProperties).hasSize(2);
assertThat(representation0.supplementalProperties.get(0).schemeIdUri).isEqualTo("urn:mpeg:dash:supplemental-scheme:2050");
assertThat(representation0.supplementalProperties.get(0).value).isEqualTo("adaptationSupplemental");
assertThat(representation1.supplementalProperties.get(1).schemeIdUri).isEqualTo("urn:mpeg:dash:supplemental-scheme:2050");
assertThat(representation1.supplementalProperties.get(1).value).isEqualTo("representationSupplemental");
}
use of androidx.media3.exoplayer.dash.manifest.AdaptationSet in project media by androidx.
the class DashMediaSource method getAvailableEndTimeInManifestUs.
private static long getAvailableEndTimeInManifestUs(Period period, long periodDurationUs, long nowUnixTimeUs) {
long periodStartTimeInManifestUs = Util.msToUs(period.startMs);
long availableEndTimeInManifestUs = Long.MAX_VALUE;
boolean haveAudioVideoAdaptationSets = hasVideoOrAudioAdaptationSets(period);
for (int i = 0; i < period.adaptationSets.size(); i++) {
AdaptationSet adaptationSet = period.adaptationSets.get(i);
List<Representation> representations = adaptationSet.representations;
// or video adaptation set. See: https://github.com/google/ExoPlayer/issues/4029
if ((haveAudioVideoAdaptationSets && adaptationSet.type == C.TRACK_TYPE_TEXT) || representations.isEmpty()) {
continue;
}
@Nullable DashSegmentIndex index = representations.get(0).getIndex();
if (index == null) {
return periodStartTimeInManifestUs + periodDurationUs;
}
long availableSegmentCount = index.getAvailableSegmentCount(periodDurationUs, nowUnixTimeUs);
if (availableSegmentCount == 0) {
return periodStartTimeInManifestUs;
}
long firstAvailableSegmentNum = index.getFirstAvailableSegmentNum(periodDurationUs, nowUnixTimeUs);
long lastAvailableSegmentNum = firstAvailableSegmentNum + availableSegmentCount - 1;
long adaptationSetAvailableEndTimeInManifestUs = periodStartTimeInManifestUs + index.getTimeUs(lastAvailableSegmentNum) + index.getDurationUs(lastAvailableSegmentNum, periodDurationUs);
availableEndTimeInManifestUs = min(availableEndTimeInManifestUs, adaptationSetAvailableEndTimeInManifestUs);
}
return availableEndTimeInManifestUs;
}
Aggregations