Add DASH text representation parsing tests
PiperOrigin-RevId: 305140826
This commit is contained in:
parent
2b44ff3c71
commit
d87fc72378
@ -26,6 +26,7 @@ import com.google.android.exoplayer2.Format;
|
|||||||
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
|
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
|
||||||
import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTimelineElement;
|
import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTimelineElement;
|
||||||
import com.google.android.exoplayer2.testutil.TestUtil;
|
import com.google.android.exoplayer2.testutil.TestUtil;
|
||||||
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
@ -47,6 +48,7 @@ public class DashManifestParserTest {
|
|||||||
private static final String SAMPLE_MPD_EVENT_STREAM = "mpd/sample_mpd_event_stream";
|
private static final String SAMPLE_MPD_EVENT_STREAM = "mpd/sample_mpd_event_stream";
|
||||||
private static final String SAMPLE_MPD_LABELS = "mpd/sample_mpd_labels";
|
private static final String SAMPLE_MPD_LABELS = "mpd/sample_mpd_labels";
|
||||||
private static final String SAMPLE_MPD_ASSET_IDENTIFIER = "mpd/sample_mpd_asset_identifier";
|
private static final String SAMPLE_MPD_ASSET_IDENTIFIER = "mpd/sample_mpd_asset_identifier";
|
||||||
|
private static final String SAMPLE_MPD_TEXT = "mpd/sample_mpd_text";
|
||||||
|
|
||||||
private static final String NEXT_TAG_NAME = "Next";
|
private static final String NEXT_TAG_NAME = "Next";
|
||||||
private static final String NEXT_TAG = "<" + NEXT_TAG_NAME + "/>";
|
private static final String NEXT_TAG = "<" + NEXT_TAG_NAME + "/>";
|
||||||
@ -67,15 +69,15 @@ public class DashManifestParserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseMediaPresentationDescription_segmentTemplate() throws IOException {
|
public void parseMediaPresentationDescription_segmentTemplate() throws IOException {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
DashManifest mpd =
|
DashManifest manifest =
|
||||||
parser.parse(
|
parser.parse(
|
||||||
Uri.parse("https://example.com/test.mpd"),
|
Uri.parse("https://example.com/test.mpd"),
|
||||||
TestUtil.getInputStream(
|
TestUtil.getInputStream(
|
||||||
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_SEGMENT_TEMPLATE));
|
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_SEGMENT_TEMPLATE));
|
||||||
|
|
||||||
assertThat(mpd.getPeriodCount()).isEqualTo(1);
|
assertThat(manifest.getPeriodCount()).isEqualTo(1);
|
||||||
|
|
||||||
Period period = mpd.getPeriod(0);
|
Period period = manifest.getPeriod(0);
|
||||||
assertThat(period).isNotNull();
|
assertThat(period).isNotNull();
|
||||||
assertThat(period.adaptationSets).hasSize(2);
|
assertThat(period.adaptationSets).hasSize(2);
|
||||||
|
|
||||||
@ -99,13 +101,13 @@ public class DashManifestParserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseMediaPresentationDescription_eventStream() throws IOException {
|
public void parseMediaPresentationDescription_eventStream() throws IOException {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
DashManifest mpd =
|
DashManifest manifest =
|
||||||
parser.parse(
|
parser.parse(
|
||||||
Uri.parse("https://example.com/test.mpd"),
|
Uri.parse("https://example.com/test.mpd"),
|
||||||
TestUtil.getInputStream(
|
TestUtil.getInputStream(
|
||||||
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_EVENT_STREAM));
|
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_EVENT_STREAM));
|
||||||
|
|
||||||
Period period = mpd.getPeriod(0);
|
Period period = manifest.getPeriod(0);
|
||||||
assertThat(period.eventStreams).hasSize(3);
|
assertThat(period.eventStreams).hasSize(3);
|
||||||
|
|
||||||
// assert text-only event stream
|
// assert text-only event stream
|
||||||
@ -169,14 +171,14 @@ public class DashManifestParserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseMediaPresentationDescription_programInformation() throws IOException {
|
public void parseMediaPresentationDescription_programInformation() throws IOException {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
DashManifest mpd =
|
DashManifest manifest =
|
||||||
parser.parse(
|
parser.parse(
|
||||||
Uri.parse("Https://example.com/test.mpd"),
|
Uri.parse("Https://example.com/test.mpd"),
|
||||||
TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD));
|
TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD));
|
||||||
ProgramInformation expectedProgramInformation =
|
ProgramInformation expectedProgramInformation =
|
||||||
new ProgramInformation(
|
new ProgramInformation(
|
||||||
"MediaTitle", "MediaSource", "MediaCopyright", "www.example.com", "enUs");
|
"MediaTitle", "MediaSource", "MediaCopyright", "www.example.com", "enUs");
|
||||||
assertThat(mpd.programInformation).isEqualTo(expectedProgramInformation);
|
assertThat(manifest.programInformation).isEqualTo(expectedProgramInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -194,6 +196,35 @@ public class DashManifestParserTest {
|
|||||||
assertThat(adaptationSets.get(1).representations.get(0).format.label).isEqualTo("video label");
|
assertThat(adaptationSets.get(1).representations.get(0).format.label).isEqualTo("video label");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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(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(adaptationSets.get(1).type).isEqualTo(C.TRACK_TYPE_TEXT);
|
||||||
|
|
||||||
|
format = adaptationSets.get(2).representations.get(0).format;
|
||||||
|
assertThat(format.containerMimeType).isEqualTo(MimeTypes.APPLICATION_TTML);
|
||||||
|
assertThat(format.sampleMimeType).isEqualTo(MimeTypes.APPLICATION_TTML);
|
||||||
|
assertThat(format.codecs).isNull();
|
||||||
|
assertThat(adaptationSets.get(2).type).isEqualTo(C.TRACK_TYPE_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseSegmentTimeline_repeatCount() throws Exception {
|
public void parseSegmentTimeline_repeatCount() throws Exception {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
@ -382,15 +413,15 @@ public class DashManifestParserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parsePeriodAssetIdentifier() throws IOException {
|
public void parsePeriodAssetIdentifier() throws IOException {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
DashManifest mpd =
|
DashManifest manifest =
|
||||||
parser.parse(
|
parser.parse(
|
||||||
Uri.parse("https://example.com/test.mpd"),
|
Uri.parse("https://example.com/test.mpd"),
|
||||||
TestUtil.getInputStream(
|
TestUtil.getInputStream(
|
||||||
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_ASSET_IDENTIFIER));
|
ApplicationProvider.getApplicationContext(), SAMPLE_MPD_ASSET_IDENTIFIER));
|
||||||
|
|
||||||
assertThat(mpd.getPeriodCount()).isEqualTo(1);
|
assertThat(manifest.getPeriodCount()).isEqualTo(1);
|
||||||
|
|
||||||
Period period = mpd.getPeriod(0);
|
Period period = manifest.getPeriod(0);
|
||||||
assertThat(period).isNotNull();
|
assertThat(period).isNotNull();
|
||||||
@Nullable Descriptor assetIdentifier = period.assetIdentifier;
|
@Nullable Descriptor assetIdentifier = period.assetIdentifier;
|
||||||
assertThat(assetIdentifier).isNotNull();
|
assertThat(assetIdentifier).isNotNull();
|
||||||
|
25
testdata/src/test/assets/mpd/sample_mpd_text
vendored
Normal file
25
testdata/src/test/assets/mpd/sample_mpd_text
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MPD type="static" duration="1s" mediaPresentationDuration="PT1S">
|
||||||
|
<Period>
|
||||||
|
<SegmentTemplate startNumber="0" timescale="1000" media="sq/$Number$">
|
||||||
|
<SegmentTimeline>
|
||||||
|
<S d="1000"/>
|
||||||
|
</SegmentTimeline>
|
||||||
|
</SegmentTemplate>
|
||||||
|
<AdaptationSet id="0" mimeType="application/x-rawcc" subsegmentAlignment="true">
|
||||||
|
<Representation id="0" codecs="cea608" bandwidth="16">
|
||||||
|
<BaseURL>https://test.com/0</BaseURL>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
<AdaptationSet id="0" mimeType="application/mp4" subsegmentAlignment="true">
|
||||||
|
<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>
|
||||||
|
</Representation>
|
||||||
|
</AdaptationSet>
|
||||||
|
</Period>
|
||||||
|
</MPD>
|
Loading…
x
Reference in New Issue
Block a user