Search in sources :

Example 6 with PlayerTrackEmsgHandler

use of com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler in project ExoPlayer by google.

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(com.google.android.exoplayer2.source.dash.manifest.DashManifestParser) FakeDataSource(com.google.android.exoplayer2.testutil.FakeDataSource) LoaderErrorThrower(com.google.android.exoplayer2.upstream.LoaderErrorThrower) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) ChunkHolder(com.google.android.exoplayer2.source.chunk.ChunkHolder) DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest) FixedTrackSelection(com.google.android.exoplayer2.trackselection.FixedTrackSelection) Test(org.junit.Test)

Example 7 with PlayerTrackEmsgHandler

use of com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler in project ExoPlayer by google.

the class DefaultDashChunkSource method onChunkLoadCompleted.

@Override
public void onChunkLoadCompleted(Chunk chunk) {
    if (chunk instanceof InitializationChunk) {
        InitializationChunk initializationChunk = (InitializationChunk) chunk;
        int trackIndex = trackSelection.indexOf(initializationChunk.trackFormat);
        RepresentationHolder representationHolder = representationHolders[trackIndex];
        // where it does we should ignore it.
        if (representationHolder.segmentIndex == null) {
            @Nullable ChunkIndex chunkIndex = representationHolder.chunkExtractor.getChunkIndex();
            if (chunkIndex != null) {
                representationHolders[trackIndex] = representationHolder.copyWithNewSegmentIndex(new DashWrappingSegmentIndex(chunkIndex, representationHolder.representation.presentationTimeOffsetUs));
            }
        }
    }
    if (playerTrackEmsgHandler != null) {
        playerTrackEmsgHandler.onChunkLoadCompleted(chunk);
    }
}
Also used : InitializationChunk(com.google.android.exoplayer2.source.chunk.InitializationChunk) Nullable(androidx.annotation.Nullable) ChunkIndex(com.google.android.exoplayer2.extractor.ChunkIndex)

Aggregations

TrackGroup (com.google.android.exoplayer2.source.TrackGroup)4 Nullable (androidx.annotation.Nullable)3 DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)3 DashManifestParser (com.google.android.exoplayer2.source.dash.manifest.DashManifestParser)3 FakeDataSource (com.google.android.exoplayer2.testutil.FakeDataSource)3 LoaderErrorThrower (com.google.android.exoplayer2.upstream.LoaderErrorThrower)3 Format (com.google.android.exoplayer2.Format)2 ChunkHolder (com.google.android.exoplayer2.source.chunk.ChunkHolder)2 ContainerMediaChunk (com.google.android.exoplayer2.source.chunk.ContainerMediaChunk)2 MediaChunk (com.google.android.exoplayer2.source.chunk.MediaChunk)2 SingleSampleMediaChunk (com.google.android.exoplayer2.source.chunk.SingleSampleMediaChunk)2 FixedTrackSelection (com.google.android.exoplayer2.trackselection.FixedTrackSelection)2 Test (org.junit.Test)2 ChunkIndex (com.google.android.exoplayer2.extractor.ChunkIndex)1 BehindLiveWindowException (com.google.android.exoplayer2.source.BehindLiveWindowException)1 BaseMediaChunkIterator (com.google.android.exoplayer2.source.chunk.BaseMediaChunkIterator)1 ChunkSampleStream (com.google.android.exoplayer2.source.chunk.ChunkSampleStream)1 InitializationChunk (com.google.android.exoplayer2.source.chunk.InitializationChunk)1 MediaChunkIterator (com.google.android.exoplayer2.source.chunk.MediaChunkIterator)1 PlayerTrackEmsgHandler (com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler)1