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