Commit c37af0b5 by aquilescanta Committed by Ian Baker

Make ChunkExtractor return a ChunkIndex instead of a SeekMap

PiperOrigin-RevId: 315283645
parent 770df863
......@@ -21,6 +21,7 @@ import android.util.SparseArray;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.extractor.DummyTrackOutput;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput;
......@@ -74,8 +75,8 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac
@Override
@Nullable
public SeekMap getSeekMap() {
return seekMap;
public ChunkIndex getChunkIndex() {
return seekMap instanceof ChunkIndex ? (ChunkIndex) seekMap : null;
}
@Override
......
......@@ -18,9 +18,9 @@ package com.google.android.exoplayer2.source.chunk;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.extractor.TrackOutput;
import java.io.IOException;
......@@ -50,11 +50,11 @@ public interface ChunkExtractor {
}
/**
* Returns the {@link SeekMap} most recently output by the extractor, or null if the extractor has
* not output a {@link SeekMap}.
* Returns the {@link ChunkIndex} most recently obtained from the chunks, or null if a {@link
* ChunkIndex} has not been obtained.
*/
@Nullable
SeekMap getSeekMap();
ChunkIndex getChunkIndex();
/**
* Returns the sample {@link Format}s for the tracks identified by the extractor, or null if the
......
......@@ -136,9 +136,10 @@ public final class DashUtil {
@Nullable
public static ChunkIndex loadChunkIndex(
DataSource dataSource, int trackType, Representation representation) throws IOException {
@Nullable
ChunkExtractor chunkExtractor =
loadInitializationData(dataSource, trackType, representation, true);
return chunkExtractor == null ? null : (ChunkIndex) chunkExtractor.getSeekMap();
return chunkExtractor == null ? null : chunkExtractor.getChunkIndex();
}
/**
......
......@@ -24,7 +24,6 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.SeekParameters;
import com.google.android.exoplayer2.extractor.ChunkIndex;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor;
......@@ -400,13 +399,12 @@ public class DefaultDashChunkSource implements DashChunkSource {
// from the stream. If the manifest defines an index then the stream shouldn't, but in cases
// where it does we should ignore it.
if (representationHolder.segmentIndex == null) {
SeekMap seekMap = representationHolder.chunkExtractor.getSeekMap();
if (seekMap != null) {
@Nullable ChunkIndex chunkIndex = representationHolder.chunkExtractor.getChunkIndex();
if (chunkIndex != null) {
representationHolders[trackIndex] =
representationHolder.copyWithNewSegmentIndex(
new DashWrappingSegmentIndex(
(ChunkIndex) seekMap,
representationHolder.representation.presentationTimeOffsetUs));
chunkIndex, representationHolder.representation.presentationTimeOffsetUs));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment