Search in sources :

Example 21 with DashManifest

use of androidx.media3.exoplayer.dash.manifest.DashManifest in project media by androidx.

the class DashMediaPeriodTest method cea608AccessibilityDescriptor_createsCea608TrackGroup.

@Test
public void cea608AccessibilityDescriptor_createsCea608TrackGroup() throws IOException {
    DashManifest manifest = parseManifest("media/mpd/sample_mpd_cea_608_accessibility");
    DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
    List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
    // We expect two adaptation sets. The first containing the video representations, and the second
    // containing the embedded CEA-608 tracks.
    Format.Builder cea608FormatBuilder = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608);
    TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
    "123", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format), new TrackGroup(/* id= */
    "123:cc", cea608FormatBuilder.setId("123:cea608:1").setLanguage("eng").setAccessibilityChannel(1).build(), cea608FormatBuilder.setId("123:cea608:3").setLanguage("deu").setAccessibilityChannel(3).build()));
    MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
Also used : Format(androidx.media3.common.Format) TrackGroup(androidx.media3.common.TrackGroup) DashManifest(androidx.media3.exoplayer.dash.manifest.DashManifest) TrackGroupArray(androidx.media3.common.TrackGroupArray) AdaptationSet(androidx.media3.exoplayer.dash.manifest.AdaptationSet) Test(org.junit.Test)

Example 22 with DashManifest

use of androidx.media3.exoplayer.dash.manifest.DashManifest in project media by androidx.

the class DashManifestParserTest method parseMediaPresentationDescription_images.

@Test
public void parseMediaPresentationDescription_images() throws IOException {
    DashManifestParser parser = new DashManifestParser();
    DashManifest manifest = parser.parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_IMAGES));
    AdaptationSet adaptationSet = manifest.getPeriod(0).adaptationSets.get(0);
    Format format = adaptationSet.representations.get(0).format;
    assertThat(format.sampleMimeType).isEqualTo("image/jpeg");
    assertThat(format.width).isEqualTo(320);
    assertThat(format.height).isEqualTo(180);
}
Also used : Format(androidx.media3.common.Format) Test(org.junit.Test)

Example 23 with DashManifest

use of androidx.media3.exoplayer.dash.manifest.DashManifest in project media by androidx.

the class DashManifestParserTest method parseMediaPresentationDescription_eventStream.

@Test
public void parseMediaPresentationDescription_eventStream() throws IOException {
    DashManifestParser parser = new DashManifestParser();
    DashManifest manifest = parser.parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_EVENT_STREAM));
    Period period = manifest.getPeriod(0);
    assertThat(period.eventStreams).hasSize(3);
    // assert text-only event stream
    EventStream eventStream1 = period.eventStreams.get(0);
    assertThat(eventStream1.events.length).isEqualTo(1);
    EventMessage expectedEvent1 = new EventMessage("urn:uuid:XYZY", "call", 10000, 0, "+ 1 800 10101010".getBytes(Charsets.UTF_8));
    assertThat(eventStream1.events[0]).isEqualTo(expectedEvent1);
    assertThat(eventStream1.presentationTimesUs[0]).isEqualTo(0);
    // assert CData-structured event stream
    EventStream eventStream2 = period.eventStreams.get(1);
    assertThat(eventStream2.events.length).isEqualTo(1);
    EventMessage expectedEvent2 = new EventMessage("urn:dvb:iptv:cpm:2014", "", 1500000, 1, Util.getUtf8Bytes("<![CDATA[<BroadcastEvent>\n" + "      <Program crid=\"crid://broadcaster.example.com/ABCDEF\"/>\n" + "      <InstanceDescription>\n" + "      <Title xml:lang=\"en\">The title</Title>\n" + "      <Synopsis xml:lang=\"en\" length=\"medium\">" + "The description</Synopsis>\n" + "      <ParentalGuidance>\n" + "      <mpeg7:ParentalRating href=\"urn:dvb:iptv:rating:2014:15\"/>\n" + "      <mpeg7:Region>GB</mpeg7:Region>\n" + "      </ParentalGuidance>\n" + "      </InstanceDescription>\n" + "      </BroadcastEvent>]]>"));
    assertThat(eventStream2.events[0]).isEqualTo(expectedEvent2);
    assertThat(eventStream2.presentationTimesUs[0]).isEqualTo(300000000);
    // assert xml-structured event stream
    EventStream eventStream3 = period.eventStreams.get(2);
    assertThat(eventStream3.events.length).isEqualTo(1);
    EventMessage expectedEvent3 = new EventMessage("urn:scte:scte35:2014:xml+bin", "", 1000000, 2, Util.getUtf8Bytes("<scte35:Signal>\n" + "         <scte35:Binary>\n" + "         /DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==\n" + "         </scte35:Binary>\n" + "       </scte35:Signal>"));
    assertThat(eventStream3.events[0]).isEqualTo(expectedEvent3);
    assertThat(eventStream3.presentationTimesUs[0]).isEqualTo(1000000000);
}
Also used : EventMessage(androidx.media3.extractor.metadata.emsg.EventMessage) Test(org.junit.Test)

Example 24 with DashManifest

use of androidx.media3.exoplayer.dash.manifest.DashManifest in project media by androidx.

the class DashWidevineOfflineTest method downloadLicense.

private void downloadLicense() throws IOException {
    DataSource dataSource = httpDataSourceFactory.createDataSource();
    DashManifest dashManifest = DashUtil.loadManifest(dataSource, Uri.parse(DashTestData.WIDEVINE_H264_MANIFEST));
    Format format = DashUtil.loadFormatWithDrmInitData(dataSource, dashManifest.getPeriod(0));
    offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(format);
    assertThat(offlineLicenseKeySetId).isNotNull();
    assertThat(offlineLicenseKeySetId.length).isGreaterThan(0);
    testRunner.setOfflineLicenseKeySetId(offlineLicenseKeySetId);
}
Also used : Format(androidx.media3.common.Format) DashManifest(androidx.media3.exoplayer.dash.manifest.DashManifest) DefaultHttpDataSource(androidx.media3.datasource.DefaultHttpDataSource) DataSource(androidx.media3.datasource.DataSource)

Aggregations

Test (org.junit.Test)14 DashManifest (androidx.media3.exoplayer.dash.manifest.DashManifest)12 TrackGroup (androidx.media3.common.TrackGroup)8 AdaptationSet (androidx.media3.exoplayer.dash.manifest.AdaptationSet)7 Format (androidx.media3.common.Format)6 TrackGroupArray (androidx.media3.common.TrackGroupArray)5 StreamKey (androidx.media3.common.StreamKey)3 DashManifestParser (androidx.media3.exoplayer.dash.manifest.DashManifestParser)3 Representation (androidx.media3.exoplayer.dash.manifest.Representation)3 LoaderErrorThrower (androidx.media3.exoplayer.upstream.LoaderErrorThrower)3 FakeDataSource (androidx.media3.test.utils.FakeDataSource)3 ArrayList (java.util.ArrayList)3 Period (androidx.media3.exoplayer.dash.manifest.Period)2 MultiSegmentRepresentation (androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation)2 SingleSegmentRepresentation (androidx.media3.exoplayer.dash.manifest.Representation.SingleSegmentRepresentation)2 LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)2 ChunkHolder (androidx.media3.exoplayer.source.chunk.ChunkHolder)2 FixedTrackSelection (androidx.media3.exoplayer.trackselection.FixedTrackSelection)2 Random (java.util.Random)2 Nullable (androidx.annotation.Nullable)1