Search in sources :

Example 1 with DashManifestParser

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

the class DefaultDashChunkSourceTest method getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag.

@Test
public void getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag() throws Exception {
    long nowMs = 2_000_000_000_000L;
    SystemClock.setCurrentTimeMillis(nowMs);
    DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_VOD));
    DefaultDashChunkSource chunkSource = new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(), /* periodIndex= */
    0, /* adaptationSetIndices= */
    new int[] { 0 }, new FixedTrackSelection(new TrackGroup(new Format.Builder().build()), /* track= */
    0), C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
    0, /* maxSegmentsPerLoad= */
    1, /* enableEventMessageTrack= */
    false, /* closedCaptionFormats */
    ImmutableList.of(), /* playerTrackEmsgHandler= */
    null, PlayerId.UNSET);
    ChunkHolder output = new ChunkHolder();
    chunkSource.getNextChunk(/* playbackPositionUs= */
    0, /* loadPositionUs= */
    0, /* queue= */
    ImmutableList.of(), output);
    assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
}
Also used : DashManifestParser(androidx.media3.exoplayer.dash.manifest.DashManifestParser) FakeDataSource(androidx.media3.test.utils.FakeDataSource) LoaderErrorThrower(androidx.media3.exoplayer.upstream.LoaderErrorThrower) TrackGroup(androidx.media3.common.TrackGroup) ChunkHolder(androidx.media3.exoplayer.source.chunk.ChunkHolder) DashManifest(androidx.media3.exoplayer.dash.manifest.DashManifest) FixedTrackSelection(androidx.media3.exoplayer.trackselection.FixedTrackSelection) Test(org.junit.Test)

Example 2 with DashManifestParser

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

the class DefaultDashChunkSourceTest method createDashChunkSource.

private DashChunkSource createDashChunkSource(int numberOfTracks) throws IOException {
    Assertions.checkArgument(numberOfTracks < 6);
    DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_VOD_LOCATION_FALLBACK));
    int[] adaptationSetIndices = new int[] { 0 };
    int[] selectedTracks = new int[numberOfTracks];
    Format[] formats = new Format[numberOfTracks];
    for (int i = 0; i < numberOfTracks; i++) {
        selectedTracks[i] = i;
        formats[i] = manifest.getPeriod(0).adaptationSets.get(adaptationSetIndices[0]).representations.get(i).format;
    }
    AdaptiveTrackSelection adaptiveTrackSelection = new AdaptiveTrackSelection(new TrackGroup(formats), selectedTracks, new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build());
    return new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(new Random(/* seed= */
    1234)), /* periodIndex= */
    0, /* adaptationSetIndices= */
    adaptationSetIndices, adaptiveTrackSelection, C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
    0, /* maxSegmentsPerLoad= */
    1, /* enableEventMessageTrack= */
    false, /* closedCaptionFormats */
    ImmutableList.of(), /* playerTrackEmsgHandler= */
    null, PlayerId.UNSET);
}
Also used : DashManifest(androidx.media3.exoplayer.dash.manifest.DashManifest) DashManifestParser(androidx.media3.exoplayer.dash.manifest.DashManifestParser) Format(androidx.media3.common.Format) Random(java.util.Random) FakeDataSource(androidx.media3.test.utils.FakeDataSource) AdaptiveTrackSelection(androidx.media3.exoplayer.trackselection.AdaptiveTrackSelection) TrackGroup(androidx.media3.common.TrackGroup) LoaderErrorThrower(androidx.media3.exoplayer.upstream.LoaderErrorThrower)

Example 3 with DashManifestParser

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

the class DashManifestParserTest method parseSegmentTimeline_timeOffsetsAndUndefinedRepeatCount.

@Test
public void parseSegmentTimeline_timeOffsetsAndUndefinedRepeatCount() throws Exception {
    DashManifestParser parser = new DashManifestParser();
    XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
    xpp.setInput(new StringReader("<SegmentTimeline><S t=\"0\" " + "d=\"96000\" r=\"-1\"/><S t=\"192000\" d=\"48000\" r=\"-1\"/>" + "</SegmentTimeline>" + NEXT_TAG));
    xpp.next();
    List<SegmentTimelineElement> elements = parser.parseSegmentTimeline(xpp, /* timescale= */
    48000, /* periodDurationMs= */
    10000);
    assertThat(elements).containsExactly(new SegmentTimelineElement(/* startTime= */
    0, /* duration= */
    96000), new SegmentTimelineElement(/* startTime= */
    96000, /* duration= */
    96000), new SegmentTimelineElement(/* startTime= */
    192000, /* duration= */
    48000), new SegmentTimelineElement(/* startTime= */
    240000, /* duration= */
    48000), new SegmentTimelineElement(/* startTime= */
    288000, /* duration= */
    48000), new SegmentTimelineElement(/* startTime= */
    336000, /* duration= */
    48000), new SegmentTimelineElement(/* startTime= */
    384000, /* duration= */
    48000), new SegmentTimelineElement(/* startTime= */
    432000, /* duration= */
    48000)).inOrder();
    assertNextTag(xpp);
}
Also used : SegmentTimelineElement(androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTimelineElement) XmlPullParser(org.xmlpull.v1.XmlPullParser) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 4 with DashManifestParser

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

the class DashManifestParserTest method parseMediaPresentationDescription_segmentTemplate.

@Test
public void parseMediaPresentationDescription_segmentTemplate() throws IOException {
    DashManifestParser parser = new DashManifestParser();
    DashManifest manifest = parser.parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_SEGMENT_TEMPLATE));
    assertThat(manifest.getPeriodCount()).isEqualTo(1);
    Period period = manifest.getPeriod(0);
    assertThat(period).isNotNull();
    assertThat(period.adaptationSets).hasSize(2);
    for (AdaptationSet adaptationSet : period.adaptationSets) {
        assertThat(adaptationSet).isNotNull();
        for (Representation representation : adaptationSet.representations) {
            if (representation instanceof Representation.MultiSegmentRepresentation) {
                Representation.MultiSegmentRepresentation multiSegmentRepresentation = (Representation.MultiSegmentRepresentation) representation;
                long firstSegmentIndex = multiSegmentRepresentation.getFirstSegmentNum();
                RangedUri uri = multiSegmentRepresentation.getSegmentUrl(firstSegmentIndex);
                assertThat(uri.resolveUriString(representation.baseUrls.get(0).url)).contains("redirector.googlevideo.com");
            }
        }
    }
}
Also used : MultiSegmentRepresentation(androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation) SingleSegmentRepresentation(androidx.media3.exoplayer.dash.manifest.Representation.SingleSegmentRepresentation) MultiSegmentRepresentation(androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation) MultiSegmentRepresentation(androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation) Test(org.junit.Test)

Example 5 with DashManifestParser

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

the class DefaultDashChunkSourceTest method getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag.

@Test
public void getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag() throws Exception {
    long nowMs = 2_000_000_000_000L;
    SystemClock.setCurrentTimeMillis(nowMs);
    DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_LIVE_WITH_OFFSET_INSIDE_WINDOW));
    DefaultDashChunkSource chunkSource = new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(), /* periodIndex= */
    0, /* adaptationSetIndices= */
    new int[] { 0 }, new FixedTrackSelection(new TrackGroup(new Format.Builder().build()), /* track= */
    0), C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
    0, /* maxSegmentsPerLoad= */
    1, /* enableEventMessageTrack= */
    false, /* closedCaptionFormats */
    ImmutableList.of(), /* playerTrackEmsgHandler= */
    null, PlayerId.UNSET);
    long nowInPeriodUs = Util.msToUs(nowMs - manifest.availabilityStartTimeMs);
    ChunkHolder output = new ChunkHolder();
    chunkSource.getNextChunk(/* playbackPositionUs= */
    nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* loadPositionUs= */
    nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* queue= */
    ImmutableList.of(), output);
    assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
    chunkSource.getNextChunk(/* playbackPositionUs= */
    nowInPeriodUs, /* loadPositionUs= */
    nowInPeriodUs, /* queue= */
    ImmutableList.of(), output);
    assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isNotEqualTo(0);
}
Also used : DashManifestParser(androidx.media3.exoplayer.dash.manifest.DashManifestParser) FakeDataSource(androidx.media3.test.utils.FakeDataSource) LoaderErrorThrower(androidx.media3.exoplayer.upstream.LoaderErrorThrower) TrackGroup(androidx.media3.common.TrackGroup) ChunkHolder(androidx.media3.exoplayer.source.chunk.ChunkHolder) DashManifest(androidx.media3.exoplayer.dash.manifest.DashManifest) FixedTrackSelection(androidx.media3.exoplayer.trackselection.FixedTrackSelection) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Format (androidx.media3.common.Format)3 TrackGroup (androidx.media3.common.TrackGroup)3 DashManifest (androidx.media3.exoplayer.dash.manifest.DashManifest)3 DashManifestParser (androidx.media3.exoplayer.dash.manifest.DashManifestParser)3 SegmentTimelineElement (androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTimelineElement)3 LoaderErrorThrower (androidx.media3.exoplayer.upstream.LoaderErrorThrower)3 FakeDataSource (androidx.media3.test.utils.FakeDataSource)3 StringReader (java.io.StringReader)3 XmlPullParser (org.xmlpull.v1.XmlPullParser)3 MultiSegmentRepresentation (androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation)2 SingleSegmentRepresentation (androidx.media3.exoplayer.dash.manifest.Representation.SingleSegmentRepresentation)2 ChunkHolder (androidx.media3.exoplayer.source.chunk.ChunkHolder)2 FixedTrackSelection (androidx.media3.exoplayer.trackselection.FixedTrackSelection)2 AdaptiveTrackSelection (androidx.media3.exoplayer.trackselection.AdaptiveTrackSelection)1 EventMessage (androidx.media3.extractor.metadata.emsg.EventMessage)1 Random (java.util.Random)1