Rename indexes to indices in TrackSelectionOverrides
And in a couple of related places. This is for consistency with the rest of the codebase where we exclusively use indices. #minor-release PiperOrigin-RevId: 408273372
This commit is contained in:
parent
39d6ad855f
commit
8900d655d9
@ -111,7 +111,7 @@ public final class TrackSelectionOverrides implements Bundleable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the selection of {@link #trackIndexes} for a {@link TrackGroup}.
|
||||
* Forces the selection of {@link #trackIndices} for a {@link TrackGroup}.
|
||||
*
|
||||
* <p>If multiple {link #tracks} are overridden, as many as possible will be selected depending on
|
||||
* the player capabilities.
|
||||
@ -124,10 +124,10 @@ public final class TrackSelectionOverrides implements Bundleable {
|
||||
*/
|
||||
public static final class TrackSelectionOverride implements Bundleable {
|
||||
|
||||
/** The {@link TrackGroup} whose {@link #trackIndexes} are forced to be selected. */
|
||||
/** The {@link TrackGroup} whose {@link #trackIndices} are forced to be selected. */
|
||||
public final TrackGroup trackGroup;
|
||||
/** The index of tracks in a {@link TrackGroup} to be selected. */
|
||||
public final ImmutableList<Integer> trackIndexes;
|
||||
/** The indices of tracks in a {@link TrackGroup} to be selected. */
|
||||
public final ImmutableList<Integer> trackIndices;
|
||||
|
||||
/** Constructs an instance to force all tracks in {@code trackGroup} to be selected. */
|
||||
public TrackSelectionOverride(TrackGroup trackGroup) {
|
||||
@ -136,23 +136,23 @@ public final class TrackSelectionOverrides implements Bundleable {
|
||||
for (int i = 0; i < trackGroup.length; i++) {
|
||||
builder.add(i);
|
||||
}
|
||||
this.trackIndexes = builder.build();
|
||||
this.trackIndices = builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance to force {@code trackIndexes} in {@code trackGroup} to be selected.
|
||||
* Constructs an instance to force {@code trackIndices} in {@code trackGroup} to be selected.
|
||||
*
|
||||
* @param trackGroup The {@link TrackGroup} for which to override the track selection.
|
||||
* @param trackIndexes The indexes of the tracks in the {@link TrackGroup} to select.
|
||||
* @param trackIndices The indices of the tracks in the {@link TrackGroup} to select.
|
||||
*/
|
||||
public TrackSelectionOverride(TrackGroup trackGroup, List<Integer> trackIndexes) {
|
||||
if (!trackIndexes.isEmpty()) {
|
||||
if (min(trackIndexes) < 0 || max(trackIndexes) >= trackGroup.length) {
|
||||
public TrackSelectionOverride(TrackGroup trackGroup, List<Integer> trackIndices) {
|
||||
if (!trackIndices.isEmpty()) {
|
||||
if (min(trackIndices) < 0 || max(trackIndices) >= trackGroup.length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
this.trackGroup = trackGroup;
|
||||
this.trackIndexes = ImmutableList.copyOf(trackIndexes);
|
||||
this.trackIndices = ImmutableList.copyOf(trackIndices);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -164,12 +164,12 @@ public final class TrackSelectionOverrides implements Bundleable {
|
||||
return false;
|
||||
}
|
||||
TrackSelectionOverride that = (TrackSelectionOverride) obj;
|
||||
return trackGroup.equals(that.trackGroup) && trackIndexes.equals(that.trackIndexes);
|
||||
return trackGroup.equals(that.trackGroup) && trackIndices.equals(that.trackIndices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return trackGroup.hashCode() + 31 * trackIndexes.hashCode();
|
||||
return trackGroup.hashCode() + 31 * trackIndices.hashCode();
|
||||
}
|
||||
|
||||
private @C.TrackType int getTrackType() {
|
||||
@ -194,7 +194,7 @@ public final class TrackSelectionOverrides implements Bundleable {
|
||||
public Bundle toBundle() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBundle(keyForField(FIELD_TRACK_GROUP), trackGroup.toBundle());
|
||||
bundle.putIntArray(keyForField(FIELD_TRACKS), Ints.toArray(trackIndexes));
|
||||
bundle.putIntArray(keyForField(FIELD_TRACKS), Ints.toArray(trackIndices));
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public final class TrackSelectionOverridesTest {
|
||||
new TrackSelectionOverride(newTrackGroupWithIds(1, 2));
|
||||
|
||||
assertThat(trackSelectionOverride.trackGroup).isEqualTo(newTrackGroupWithIds(1, 2));
|
||||
assertThat(trackSelectionOverride.trackIndexes).containsExactly(0, 1).inOrder();
|
||||
assertThat(trackSelectionOverride.trackIndices).containsExactly(0, 1).inOrder();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -54,7 +54,7 @@ public final class TrackSelectionOverridesTest {
|
||||
new TrackSelectionOverride(newTrackGroupWithIds(1, 2), ImmutableList.of(1));
|
||||
|
||||
assertThat(trackSelectionOverride.trackGroup).isEqualTo(newTrackGroupWithIds(1, 2));
|
||||
assertThat(trackSelectionOverride.trackIndexes).containsExactly(1);
|
||||
assertThat(trackSelectionOverride.trackIndices).containsExactly(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -63,7 +63,7 @@ public final class TrackSelectionOverridesTest {
|
||||
new TrackSelectionOverride(newTrackGroupWithIds(1, 2), ImmutableList.of());
|
||||
|
||||
assertThat(trackSelectionOverride.trackGroup).isEqualTo(newTrackGroupWithIds(1, 2));
|
||||
assertThat(trackSelectionOverride.trackIndexes).isEmpty();
|
||||
assertThat(trackSelectionOverride.trackIndices).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -114,9 +114,9 @@ public final class TrackSelectionOverridesTest {
|
||||
public void addOverride_onSameGroup_replacesOverride() {
|
||||
TrackGroup trackGroup = newTrackGroupWithIds(1, 2, 3);
|
||||
TrackSelectionOverride override1 =
|
||||
new TrackSelectionOverride(trackGroup, /* trackIndexes= */ ImmutableList.of(0));
|
||||
new TrackSelectionOverride(trackGroup, /* trackIndices= */ ImmutableList.of(0));
|
||||
TrackSelectionOverride override2 =
|
||||
new TrackSelectionOverride(trackGroup, /* trackIndexes= */ ImmutableList.of(1));
|
||||
new TrackSelectionOverride(trackGroup, /* trackIndices= */ ImmutableList.of(1));
|
||||
|
||||
TrackSelectionOverrides trackSelectionOverrides =
|
||||
new TrackSelectionOverrides.Builder().addOverride(override1).addOverride(override2).build();
|
||||
|
@ -73,7 +73,7 @@ public final class TrackSelectionParametersTest {
|
||||
new TrackGroup(
|
||||
new Format.Builder().setId(4).build(),
|
||||
new Format.Builder().setId(5).build()),
|
||||
/* trackIndexes= */ ImmutableList.of(1)))
|
||||
/* trackIndices= */ ImmutableList.of(1)))
|
||||
.build();
|
||||
TrackSelectionParameters parameters =
|
||||
TrackSelectionParameters.DEFAULT_WITHOUT_CONTEXT
|
||||
|
@ -312,7 +312,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
rendererDisabledFlags =
|
||||
makeSparseBooleanArrayFromTrueKeys(
|
||||
bundle.getIntArray(
|
||||
Parameters.keyForField(Parameters.FIELD_RENDERER_DISABLED_INDEXES)));
|
||||
Parameters.keyForField(Parameters.FIELD_RENDERER_DISABLED_INDICES)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -830,9 +830,9 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
|
||||
private void setSelectionOverridesFromBundle(Bundle bundle) {
|
||||
@Nullable
|
||||
int[] rendererIndexes =
|
||||
int[] rendererIndices =
|
||||
bundle.getIntArray(
|
||||
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES));
|
||||
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES_RENDERER_INDICES));
|
||||
List<TrackGroupArray> trackGroupArrays =
|
||||
BundleableUtil.fromBundleNullableList(
|
||||
TrackGroupArray.CREATOR,
|
||||
@ -846,11 +846,11 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
Parameters.keyForField(Parameters.FIELD_SELECTION_OVERRIDES)),
|
||||
/* defaultValue= */ new SparseArray<>());
|
||||
|
||||
if (rendererIndexes == null || rendererIndexes.length != trackGroupArrays.size()) {
|
||||
if (rendererIndices == null || rendererIndices.length != trackGroupArrays.size()) {
|
||||
return; // Incorrect format, ignore all overrides.
|
||||
}
|
||||
for (int i = 0; i < rendererIndexes.length; i++) {
|
||||
int rendererIndex = rendererIndexes[i];
|
||||
for (int i = 0; i < rendererIndices.length; i++) {
|
||||
int rendererIndex = rendererIndices[i];
|
||||
TrackGroupArray groups = trackGroupArrays.get(i);
|
||||
@Nullable SelectionOverride selectionOverride = selectionOverrides.get(i);
|
||||
setSelectionOverride(rendererIndex, groups, selectionOverride);
|
||||
@ -1112,10 +1112,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
FIELD_EXCEED_RENDERER_CAPABILITIES_IF_NECESSARY,
|
||||
FIELD_TUNNELING_ENABLED,
|
||||
FIELD_ALLOW_MULTIPLE_ADAPTIVE_SELECTIONS,
|
||||
FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES,
|
||||
FIELD_SELECTION_OVERRIDES_RENDERER_INDICES,
|
||||
FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS,
|
||||
FIELD_SELECTION_OVERRIDES,
|
||||
FIELD_RENDERER_DISABLED_INDEXES,
|
||||
FIELD_RENDERER_DISABLED_INDICES,
|
||||
})
|
||||
private @interface FieldNumber {}
|
||||
|
||||
@ -1131,10 +1131,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
private static final int FIELD_EXCEED_RENDERER_CAPABILITIES_IF_NECESSARY = 1008;
|
||||
private static final int FIELD_TUNNELING_ENABLED = 1009;
|
||||
private static final int FIELD_ALLOW_MULTIPLE_ADAPTIVE_SELECTIONS = 1010;
|
||||
private static final int FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES = 1011;
|
||||
private static final int FIELD_SELECTION_OVERRIDES_RENDERER_INDICES = 1011;
|
||||
private static final int FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS = 1012;
|
||||
private static final int FIELD_SELECTION_OVERRIDES = 1013;
|
||||
private static final int FIELD_RENDERER_DISABLED_INDEXES = 1014;
|
||||
private static final int FIELD_RENDERER_DISABLED_INDICES = 1014;
|
||||
|
||||
@Override
|
||||
public Bundle toBundle() {
|
||||
@ -1177,7 +1177,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
putSelectionOverridesToBundle(bundle, selectionOverrides);
|
||||
// Only true values are put into rendererDisabledFlags.
|
||||
bundle.putIntArray(
|
||||
keyForField(FIELD_RENDERER_DISABLED_INDEXES),
|
||||
keyForField(FIELD_RENDERER_DISABLED_INDICES),
|
||||
getKeysFromSparseBooleanArray(rendererDisabledFlags));
|
||||
|
||||
return bundle;
|
||||
@ -1199,7 +1199,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
private static void putSelectionOverridesToBundle(
|
||||
Bundle bundle,
|
||||
SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides) {
|
||||
ArrayList<Integer> rendererIndexes = new ArrayList<>();
|
||||
ArrayList<Integer> rendererIndices = new ArrayList<>();
|
||||
ArrayList<TrackGroupArray> trackGroupArrays = new ArrayList<>();
|
||||
SparseArray<SelectionOverride> selections = new SparseArray<>();
|
||||
|
||||
@ -1212,10 +1212,10 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
selections.put(trackGroupArrays.size(), selection);
|
||||
}
|
||||
trackGroupArrays.add(override.getKey());
|
||||
rendererIndexes.add(rendererIndex);
|
||||
rendererIndices.add(rendererIndex);
|
||||
}
|
||||
bundle.putIntArray(
|
||||
keyForField(FIELD_SELECTION_OVERRIDES_RENDERER_INDEXES), Ints.toArray(rendererIndexes));
|
||||
keyForField(FIELD_SELECTION_OVERRIDES_RENDERER_INDICES), Ints.toArray(rendererIndices));
|
||||
bundle.putParcelableArrayList(
|
||||
keyForField(FIELD_SELECTION_OVERRIDES_TRACK_GROUP_ARRAYS),
|
||||
BundleableUtil.toBundleArrayList(trackGroupArrays));
|
||||
@ -1579,7 +1579,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
TrackSelectionOverride overrideTracks =
|
||||
params.trackSelectionOverrides.getOverride(trackGroup);
|
||||
if (overrideTracks != null) {
|
||||
if (overrideTracks.trackIndexes.isEmpty()) {
|
||||
if (overrideTracks.trackIndices.isEmpty()) {
|
||||
// TrackGroup is disabled. Deselect the currentDefinition if applicable. Otherwise ignore.
|
||||
if (currentDefinition != null && currentDefinition.group.equals(trackGroup)) {
|
||||
currentDefinition = null;
|
||||
@ -1588,7 +1588,7 @@ public class DefaultTrackSelector extends MappingTrackSelector {
|
||||
// Override current definition with new selection.
|
||||
currentDefinition =
|
||||
new ExoTrackSelection.Definition(
|
||||
trackGroup, Ints.toArray(overrideTracks.trackIndexes));
|
||||
trackGroup, Ints.toArray(overrideTracks.trackIndices));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||
|
||||
/**
|
||||
* Returns initial bitrate group assignments for a {@code country}. The initial bitrate is a list
|
||||
* of indexes for [Wifi, 2G, 3G, 4G, 5G_NSA, 5G_SA].
|
||||
* of indices for [Wifi, 2G, 3G, 4G, 5G_NSA, 5G_SA].
|
||||
*/
|
||||
private static int[] getInitialBitrateCountryGroupAssignment(String country) {
|
||||
switch (country) {
|
||||
|
@ -222,13 +222,13 @@ public final class DefaultTrackSelectorTest {
|
||||
new TrackSelectionOverrides.Builder()
|
||||
.addOverride(
|
||||
new TrackSelectionOverride(
|
||||
videoGroupHighBitrate, /* trackIndexes= */ ImmutableList.of()))
|
||||
videoGroupHighBitrate, /* trackIndices= */ ImmutableList.of()))
|
||||
.addOverride(
|
||||
new TrackSelectionOverride(
|
||||
videoGroupMidBitrate, /* trackIndexes= */ ImmutableList.of(0)))
|
||||
videoGroupMidBitrate, /* trackIndices= */ ImmutableList.of(0)))
|
||||
.addOverride(
|
||||
new TrackSelectionOverride(
|
||||
videoGroupLowBitrate, /* trackIndexes= */ ImmutableList.of()))
|
||||
videoGroupLowBitrate, /* trackIndices= */ ImmutableList.of()))
|
||||
.build()));
|
||||
|
||||
TrackSelectorResult result =
|
||||
@ -1935,7 +1935,7 @@ public final class DefaultTrackSelectorTest {
|
||||
.setOverrideForType(
|
||||
new TrackSelectionOverride(
|
||||
new TrackGroup(AUDIO_FORMAT, AUDIO_FORMAT, AUDIO_FORMAT, AUDIO_FORMAT),
|
||||
/* trackIndexes= */ ImmutableList.of(0, 2, 3)))
|
||||
/* trackIndices= */ ImmutableList.of(0, 2, 3)))
|
||||
.build())
|
||||
.setDisabledTrackTypes(ImmutableSet.of(C.TRACK_TYPE_AUDIO))
|
||||
.build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user