use of androidx.media3.exoplayer.dash.manifest.DashManifestParser 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);
}
Aggregations