Commit d7df4260 by olly Committed by Ian Baker

Simplify application of track overrides

PiperOrigin-RevId: 432485797
parent aafe5f48
...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.source.chunk.Chunk; ...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.source.chunk.Chunk;
import com.google.android.exoplayer2.source.chunk.MediaChunk; import com.google.android.exoplayer2.source.chunk.MediaChunk;
import com.google.android.exoplayer2.source.chunk.MediaChunkIterator; import com.google.android.exoplayer2.source.chunk.MediaChunkIterator;
import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.util.Log;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.compatqual.NullableType; import org.checkerframework.checker.nullness.compatqual.NullableType;
...@@ -45,6 +46,8 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -45,6 +46,8 @@ public interface ExoTrackSelection extends TrackSelection {
/** The type that will be returned from {@link TrackSelection#getType()}. */ /** The type that will be returned from {@link TrackSelection#getType()}. */
public final @Type int type; public final @Type int type;
private static final String TAG = "ETSDefinition";
/** /**
* @param group The {@link TrackGroup}. Must not be null. * @param group The {@link TrackGroup}. Must not be null.
* @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be * @param tracks The indices of the selected tracks within the {@link TrackGroup}. Must not be
...@@ -61,6 +64,10 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -61,6 +64,10 @@ public interface ExoTrackSelection extends TrackSelection {
* @param type The type that will be returned from {@link TrackSelection#getType()}. * @param type The type that will be returned from {@link TrackSelection#getType()}.
*/ */
public Definition(TrackGroup group, int[] tracks, @Type int type) { public Definition(TrackGroup group, int[] tracks, @Type int type) {
if (tracks.length == 0) {
// TODO: Turn this into an assertion.
Log.e(TAG, "Empty tracks are not allowed", new IllegalArgumentException());
}
this.group = group; this.group = group;
this.tracks = tracks; this.tracks = tracks;
this.type = type; this.type = type;
......
...@@ -65,7 +65,10 @@ public class FakeTrackSelector extends DefaultTrackSelector { ...@@ -65,7 +65,10 @@ public class FakeTrackSelector extends DefaultTrackSelector {
for (int i = 0; i < rendererCount; i++) { for (int i = 0; i < rendererCount; i++) {
TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(i); TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(i);
boolean hasTracks = trackGroupArray.length > 0; boolean hasTracks = trackGroupArray.length > 0;
definitions[i] = hasTracks ? new ExoTrackSelection.Definition(trackGroupArray.get(0)) : null; definitions[i] =
hasTracks
? new ExoTrackSelection.Definition(trackGroupArray.get(0), /* tracks...= */ 0)
: null;
} }
return definitions; return definitions;
} }
......
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