Commit fdbae637 by olly Committed by Ian Baker

Simplify application of track overrides

PiperOrigin-RevId: 432485797
parent 23db1145
...@@ -21,6 +21,7 @@ import androidx.media3.common.Format; ...@@ -21,6 +21,7 @@ import androidx.media3.common.Format;
import androidx.media3.common.Timeline; import androidx.media3.common.Timeline;
import androidx.media3.common.TrackGroup; import androidx.media3.common.TrackGroup;
import androidx.media3.common.TrackSelection; import androidx.media3.common.TrackSelection;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.UnstableApi;
import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId; import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
import androidx.media3.exoplayer.source.chunk.Chunk; import androidx.media3.exoplayer.source.chunk.Chunk;
...@@ -48,6 +49,8 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -48,6 +49,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
...@@ -64,6 +67,10 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -64,6 +67,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;
......
...@@ -67,7 +67,10 @@ public class FakeTrackSelector extends DefaultTrackSelector { ...@@ -67,7 +67,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