Search in sources :

Example 1 with DashWrappingSegmentIndex

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

the class DashDownloader method getSegmentIndex.

@Nullable
private DashSegmentIndex getSegmentIndex(DataSource dataSource, int trackType, Representation representation, boolean removing) throws IOException, InterruptedException {
    DashSegmentIndex index = representation.getIndex();
    if (index != null) {
        return index;
    }
    RunnableFutureTask<@NullableType ChunkIndex, IOException> runnable = new RunnableFutureTask<@NullableType ChunkIndex, IOException>() {

        @Override
        @NullableType
        protected ChunkIndex doWork() throws IOException {
            return DashUtil.loadChunkIndex(dataSource, trackType, representation);
        }
    };
    @Nullable ChunkIndex seekMap = execute(runnable, removing);
    return seekMap == null ? null : new DashWrappingSegmentIndex(seekMap, representation.presentationTimeOffsetUs);
}
Also used : DashWrappingSegmentIndex(com.google.android.exoplayer2.source.dash.DashWrappingSegmentIndex) RunnableFutureTask(com.google.android.exoplayer2.util.RunnableFutureTask) IOException(java.io.IOException) NullableType(org.checkerframework.checker.nullness.compatqual.NullableType) DashSegmentIndex(com.google.android.exoplayer2.source.dash.DashSegmentIndex) ChunkIndex(com.google.android.exoplayer2.extractor.ChunkIndex) Nullable(androidx.annotation.Nullable) Nullable(androidx.annotation.Nullable)

Example 2 with DashWrappingSegmentIndex

use of com.google.android.exoplayer2.source.dash.DashWrappingSegmentIndex 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

Nullable (androidx.annotation.Nullable)2 ChunkIndex (com.google.android.exoplayer2.extractor.ChunkIndex)2 InitializationChunk (com.google.android.exoplayer2.source.chunk.InitializationChunk)1 DashSegmentIndex (com.google.android.exoplayer2.source.dash.DashSegmentIndex)1 DashWrappingSegmentIndex (com.google.android.exoplayer2.source.dash.DashWrappingSegmentIndex)1 RunnableFutureTask (com.google.android.exoplayer2.util.RunnableFutureTask)1 IOException (java.io.IOException)1 NullableType (org.checkerframework.checker.nullness.compatqual.NullableType)1