Automated rollback of changelist 166843123.

*** Reason for rollback ***

Doesn't work because trackOutputProvider can be null when extracting init data.

*** Original change description ***

Don't copy primary-track format to non-primary tracks

Copying non-primary-track formats to non-primary tracks
looks non-trivial (I tried; went down a dead-end), so
leaving that for now.

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166883654
This commit is contained in:
olly 2017-08-29 12:15:50 -07:00 committed by Oliver Woodman
parent 55e928f75a
commit d9cd13ce74
3 changed files with 20 additions and 41 deletions

View File

@ -15,7 +15,6 @@
*/ */
package com.google.android.exoplayer2.source.chunk; package com.google.android.exoplayer2.source.chunk;
import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import com.google.android.exoplayer2.extractor.DummyTrackOutput; import com.google.android.exoplayer2.extractor.DummyTrackOutput;
import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.extractor.TrackOutput;
@ -33,23 +32,12 @@ import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.TrackOut
private final SampleQueue[] sampleQueues; private final SampleQueue[] sampleQueues;
/** /**
* @param primaryTrackType The type of the primary track. * @param trackTypes The track types of the individual track outputs.
* @param primarySampleQueue The primary track sample queues. * @param sampleQueues The individual sample queues.
* @param embeddedTrackTypes The types of any embedded tracks, or null.
* @param embeddedSampleQueues The track sample queues for any embedded tracks, or null.
*/ */
@SuppressWarnings("ConstantConditions") public BaseMediaChunkOutput(int[] trackTypes, SampleQueue[] sampleQueues) {
public BaseMediaChunkOutput(int primaryTrackType, SampleQueue primarySampleQueue, this.trackTypes = trackTypes;
@Nullable int[] embeddedTrackTypes, @Nullable SampleQueue[] embeddedSampleQueues) { this.sampleQueues = sampleQueues;
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];
}
} }
@Override @Override
@ -63,11 +51,6 @@ import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper.TrackOut
return new DummyTrackOutput(); return new DummyTrackOutput();
} }
@Override
public boolean isPrimaryTrack(int type) {
return type == trackTypes[0];
}
/** /**
* Returns the current absolute write indices of the individual sample queues. * Returns the current absolute write indices of the individual sample queues.
*/ */

View File

@ -45,22 +45,13 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
* <p> * <p>
* The same {@link TrackOutput} is returned if multiple calls are made with the same {@code id}. * The same {@link TrackOutput} is returned if multiple calls are made with the same {@code id}.
* *
* @param id The track identifier. * @param id A track identifier.
* @param type The track type. Typically one of the {@link com.google.android.exoplayer2.C} * @param type The type of the track. Typically one of the
* {@code TRACK_TYPE_*} constants. * {@link com.google.android.exoplayer2.C} {@code TRACK_TYPE_*} constants.
* @return The {@link TrackOutput} for the given track identifier. * @return The {@link TrackOutput} for the given track identifier.
*/ */
TrackOutput track(int id, int type); 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; public final Extractor extractor;
@ -155,7 +146,6 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
private final Format manifestFormat; private final Format manifestFormat;
public Format sampleFormat; public Format sampleFormat;
private boolean isPrimaryTrack;
private TrackOutput trackOutput; private TrackOutput trackOutput;
public BindingTrackOutput(int id, int type, Format manifestFormat) { public BindingTrackOutput(int id, int type, Format manifestFormat) {
@ -169,17 +159,17 @@ public final class ChunkExtractorWrapper implements ExtractorOutput {
trackOutput = new DummyTrackOutput(); trackOutput = new DummyTrackOutput();
return; return;
} }
isPrimaryTrack = trackOutputProvider.isPrimaryTrack(type);
trackOutput = trackOutputProvider.track(id, type); trackOutput = trackOutputProvider.track(id, type);
if (sampleFormat != null) { if (trackOutput != null) {
trackOutput.format(sampleFormat); trackOutput.format(sampleFormat);
} }
} }
@Override @Override
public void format(Format format) { public void format(Format format) {
// TODO: Non-primary tracks should be copied with data from their own manifest formats. // TODO: This should only happen for the primary track. Additional metadata/text tracks need
sampleFormat = isPrimaryTrack ? format.copyWithManifestFormatInfo(manifestFormat) : format; // to be copied with different manifest derived formats.
sampleFormat = format.copyWithManifestFormatInfo(manifestFormat);
trackOutput.format(sampleFormat); trackOutput.format(sampleFormat);
} }

View File

@ -87,15 +87,21 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
int embeddedTrackCount = embeddedTrackTypes == null ? 0 : embeddedTrackTypes.length; int embeddedTrackCount = embeddedTrackTypes == null ? 0 : embeddedTrackTypes.length;
embeddedSampleQueues = new SampleQueue[embeddedTrackCount]; embeddedSampleQueues = new SampleQueue[embeddedTrackCount];
embeddedTracksSelected = new boolean[embeddedTrackCount]; embeddedTracksSelected = new boolean[embeddedTrackCount];
int[] trackTypes = new int[1 + embeddedTrackCount];
SampleQueue[] sampleQueues = new SampleQueue[1 + embeddedTrackCount];
primarySampleQueue = new SampleQueue(allocator); primarySampleQueue = new SampleQueue(allocator);
trackTypes[0] = primaryTrackType;
sampleQueues[0] = primarySampleQueue;
for (int i = 0; i < embeddedTrackCount; i++) { for (int i = 0; i < embeddedTrackCount; i++) {
SampleQueue sampleQueue = new SampleQueue(allocator); SampleQueue sampleQueue = new SampleQueue(allocator);
embeddedSampleQueues[i] = sampleQueue; embeddedSampleQueues[i] = sampleQueue;
sampleQueues[i + 1] = sampleQueue;
trackTypes[i + 1] = embeddedTrackTypes[i];
} }
mediaChunkOutput = new BaseMediaChunkOutput(primaryTrackType, primarySampleQueue, mediaChunkOutput = new BaseMediaChunkOutput(trackTypes, sampleQueues);
embeddedTrackTypes, embeddedSampleQueues);
pendingResetPositionUs = positionUs; pendingResetPositionUs = positionUs;
lastSeekPositionUs = positionUs; lastSeekPositionUs = positionUs;
} }