diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java index 0b6c196d7c..9531aaf32e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.source.chunk; -import android.support.annotation.Nullable; import android.util.Log; import com.google.android.exoplayer2.extractor.DummyTrackOutput; import com.google.android.exoplayer2.extractor.TrackOutput; @@ -33,23 +32,12 @@ import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.TrackOut private final SampleQueue[] sampleQueues; /** - * @param primaryTrackType The type of the primary track. - * @param primarySampleQueue The primary track sample queues. - * @param embeddedTrackTypes The types of any embedded tracks, or null. - * @param embeddedSampleQueues The track sample queues for any embedded tracks, or null. + * @param trackTypes The track types of the individual track outputs. + * @param sampleQueues The individual sample queues. */ - @SuppressWarnings("ConstantConditions") - public BaseMediaChunkOutput(int primaryTrackType, SampleQueue primarySampleQueue, - @Nullable int[] embeddedTrackTypes, @Nullable SampleQueue[] embeddedSampleQueues) { - int embeddedTrackCount = embeddedTrackTypes == null ? 0 : embeddedTrackTypes.length; - trackTypes = new int[1 + embeddedTrackCount]; - sampleQueues = new SampleQueue[1 + embeddedTrackCount]; - trackTypes[0] = primaryTrackType; - sampleQueues[0] = primarySampleQueue; - for (int i = 0; i < embeddedTrackCount; i++) { - trackTypes[i + 1] = embeddedTrackTypes[i]; - sampleQueues[i + 1] = embeddedSampleQueues[i]; - } + public BaseMediaChunkOutput(int[] trackTypes, SampleQueue[] sampleQueues) { + this.trackTypes = trackTypes; + this.sampleQueues = sampleQueues; } @Override @@ -63,11 +51,6 @@ import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.TrackOut return new DummyTrackOutput(); } - @Override - public boolean isPrimaryTrack(int type) { - return type == trackTypes[0]; - } - /** * Returns the current absolute write indices of the individual sample queues. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java index eda9ed3cf7..07d1cce8cb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkExtractorWrapper.java @@ -45,22 +45,13 @@ public final class ChunkExtractorWrapper implements ExtractorOutput { *
* The same {@link TrackOutput} is returned if multiple calls are made with the same {@code id}.
*
- * @param id The track identifier.
- * @param type The track type. Typically one of the {@link com.google.android.exoplayer2.C}
- * {@code TRACK_TYPE_*} constants.
+ * @param id A track identifier.
+ * @param type The type of the track. Typically one of the
+ * {@link com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
* @return The {@link TrackOutput} for the given track identifier.
*/
TrackOutput track(int id, int type);
- /**
- * Returns whether the specified type corresponds to the primary track.
- *
- * @param type The track type. Typically one of the {@link com.google.android.exoplayer2.C}
- * {@code TRACK_TYPE_*} constants.
- * @return Whether {@code type} corresponds to the primary track.
- */
- boolean isPrimaryTrack(int type);
-
}
public final Extractor extractor;
@@ -155,7 +146,6 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
private final Format manifestFormat;
public Format sampleFormat;
- private boolean isPrimaryTrack;
private TrackOutput trackOutput;
public BindingTrackOutput(int id, int type, Format manifestFormat) {
@@ -169,17 +159,17 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
trackOutput = new DummyTrackOutput();
return;
}
- isPrimaryTrack = trackOutputProvider.isPrimaryTrack(type);
trackOutput = trackOutputProvider.track(id, type);
- if (sampleFormat != null) {
+ if (trackOutput != null) {
trackOutput.format(sampleFormat);
}
}
@Override
public void format(Format format) {
- // TODO: Non-primary tracks should be copied with data from their own manifest formats.
- sampleFormat = isPrimaryTrack ? format.copyWithManifestFormatInfo(manifestFormat) : format;
+ // TODO: This should only happen for the primary track. Additional metadata/text tracks need
+ // to be copied with different manifest derived formats.
+ sampleFormat = format.copyWithManifestFormatInfo(manifestFormat);
trackOutput.format(sampleFormat);
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
index e8586f7230..f2609a0ffd 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
@@ -87,15 +87,21 @@ public class ChunkSampleStream