Search in sources :

Example 11 with AdaptationSet

use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.

the class DashMediaPeriodTest method trickPlayProperty_mergesTrackGroups.

@Test
public void trickPlayProperty_mergesTrackGroups() throws IOException {
    DashManifest manifest = parseManifest("media/mpd/sample_mpd_trick_play_property");
    DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
    List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
    // We expect the trick play adaptation sets to be merged with the ones to which they refer,
    // 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), new TrackGroup(/* id= */
    "2", 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);
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) AdaptationSet(com.google.android.exoplayer2.source.dash.manifest.AdaptationSet) Test(org.junit.Test)

Example 12 with AdaptationSet

use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.

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);
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) AdaptationSet(com.google.android.exoplayer2.source.dash.manifest.AdaptationSet) Test(org.junit.Test)

Example 13 with AdaptationSet

use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.

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");
}
Also used : SingleSegmentRepresentation(com.google.android.exoplayer2.source.dash.manifest.Representation.SingleSegmentRepresentation) MultiSegmentRepresentation(com.google.android.exoplayer2.source.dash.manifest.Representation.MultiSegmentRepresentation) Test(org.junit.Test)

Example 14 with AdaptationSet

use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.

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);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 15 with AdaptationSet

use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.

the class DashMediaPeriod method buildSampleStream.

private ChunkSampleStream<DashChunkSource> buildSampleStream(int adaptationSetIndex, TrackSelection selection, long positionUs) {
    AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
    int embeddedTrackCount = 0;
    int[] embeddedTrackTypes = new int[2];
    boolean enableEventMessageTrack = hasEventMessageTrack(adaptationSet);
    if (enableEventMessageTrack) {
        embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
    }
    boolean enableCea608Track = hasCea608Track(adaptationSet);
    if (enableCea608Track) {
        embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
    }
    if (embeddedTrackCount < embeddedTrackTypes.length) {
        embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
    }
    DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex, adaptationSetIndex, selection, elapsedRealtimeOffset, enableEventMessageTrack, enableCea608Track);
    ChunkSampleStream<DashChunkSource> stream = new ChunkSampleStream<>(adaptationSet.type, embeddedTrackTypes, chunkSource, this, allocator, positionUs, minLoadableRetryCount, eventDispatcher);
    return stream;
}
Also used : ChunkSampleStream(com.google.android.exoplayer2.source.chunk.ChunkSampleStream) AdaptationSet(com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)

Aggregations

AdaptationSet (com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)16 Format (com.google.android.exoplayer2.Format)9 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)8 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)7 Representation (com.google.android.exoplayer2.source.dash.manifest.Representation)7 DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)6 Nullable (androidx.annotation.Nullable)5 StreamKey (com.google.android.exoplayer2.offline.StreamKey)4 MultiSegmentRepresentation (com.google.android.exoplayer2.source.dash.manifest.Representation.MultiSegmentRepresentation)3 SingleSegmentRepresentation (com.google.android.exoplayer2.source.dash.manifest.Representation.SingleSegmentRepresentation)3 Descriptor (com.google.android.exoplayer2.source.dash.manifest.Descriptor)2 Period (com.google.android.exoplayer2.source.dash.manifest.Period)2 SingleSegmentBase (com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase)2 SparseArray (android.util.SparseArray)1 SparseIntArray (android.util.SparseIntArray)1 DownloadException (com.google.android.exoplayer2.offline.DownloadException)1 ChunkSampleStream (com.google.android.exoplayer2.source.chunk.ChunkSampleStream)1 DashSegmentIndex (com.google.android.exoplayer2.source.dash.DashSegmentIndex)1