Commit 2c042844 by tonihei Committed by Rohit Singh

Rename ExoTrackSelection.blacklist to excludeTrack

It is not possible to provide a safe deprecation path because
BaseTrackSelection can't easily know which of the methods is
implemented by subclasses.

PiperOrigin-RevId: 523471578
parent 81d9c6c1
...@@ -595,13 +595,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -595,13 +595,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
@Override @Override
public boolean blacklist(int index, long exclusionDurationMs) { public boolean excludeTrack(int index, long exclusionDurationMs) {
return trackSelection.blacklist(index, exclusionDurationMs); return trackSelection.excludeTrack(index, exclusionDurationMs);
} }
@Override @Override
public boolean isBlacklisted(int index, long nowMs) { public boolean isTrackExcluded(int index, long nowMs) {
return trackSelection.isBlacklisted(index, nowMs); return trackSelection.isTrackExcluded(index, nowMs);
} }
@Override @Override
......
...@@ -455,7 +455,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -455,7 +455,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
previousReason = Iterables.getLast(queue).trackSelectionReason; previousReason = Iterables.getLast(queue).trackSelectionReason;
} }
int newSelectedIndex = determineIdealSelectedIndex(nowMs, chunkDurationUs); int newSelectedIndex = determineIdealSelectedIndex(nowMs, chunkDurationUs);
if (!isBlacklisted(previousSelectedIndex, nowMs)) { if (!isTrackExcluded(previousSelectedIndex, nowMs)) {
// Revert back to the previous selection if conditions are not suitable for switching. // Revert back to the previous selection if conditions are not suitable for switching.
Format currentFormat = getFormat(previousSelectedIndex); Format currentFormat = getFormat(previousSelectedIndex);
Format selectedFormat = getFormat(newSelectedIndex); Format selectedFormat = getFormat(newSelectedIndex);
...@@ -590,7 +590,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -590,7 +590,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
long effectiveBitrate = getAllocatedBandwidth(chunkDurationUs); long effectiveBitrate = getAllocatedBandwidth(chunkDurationUs);
int lowestBitrateAllowedIndex = 0; int lowestBitrateAllowedIndex = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (nowMs == Long.MIN_VALUE || !isBlacklisted(i, nowMs)) { if (nowMs == Long.MIN_VALUE || !isTrackExcluded(i, nowMs)) {
Format format = getFormat(i); Format format = getFormat(i);
if (canSelectFormat(format, format.bitrate, effectiveBitrate)) { if (canSelectFormat(format, format.bitrate, effectiveBitrate)) {
return i; return i;
......
...@@ -164,11 +164,11 @@ public abstract class BaseTrackSelection implements ExoTrackSelection { ...@@ -164,11 +164,11 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
} }
@Override @Override
public boolean blacklist(int index, long exclusionDurationMs) { public boolean excludeTrack(int index, long exclusionDurationMs) {
long nowMs = SystemClock.elapsedRealtime(); long nowMs = SystemClock.elapsedRealtime();
boolean canExclude = isBlacklisted(index, nowMs); boolean canExclude = isTrackExcluded(index, nowMs);
for (int i = 0; i < length && !canExclude; i++) { for (int i = 0; i < length && !canExclude; i++) {
canExclude = i != index && !isBlacklisted(i, nowMs); canExclude = i != index && !isTrackExcluded(i, nowMs);
} }
if (!canExclude) { if (!canExclude) {
return false; return false;
...@@ -181,7 +181,7 @@ public abstract class BaseTrackSelection implements ExoTrackSelection { ...@@ -181,7 +181,7 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
} }
@Override @Override
public boolean isBlacklisted(int index, long nowMs) { public boolean isTrackExcluded(int index, long nowMs) {
return excludeUntilTimes[index] > nowMs; return excludeUntilTimes[index] > nowMs;
} }
......
...@@ -278,7 +278,7 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -278,7 +278,7 @@ public interface ExoTrackSelection extends TrackSelection {
* milliseconds. * milliseconds.
* @return Whether exclusion was successful. * @return Whether exclusion was successful.
*/ */
boolean blacklist(int index, long exclusionDurationMs); boolean excludeTrack(int index, long exclusionDurationMs);
/** /**
* Returns whether the track at the specified index in the selection is excluded. * Returns whether the track at the specified index in the selection is excluded.
...@@ -287,5 +287,5 @@ public interface ExoTrackSelection extends TrackSelection { ...@@ -287,5 +287,5 @@ public interface ExoTrackSelection extends TrackSelection {
* @param nowMs The current time in the timebase of {@link * @param nowMs The current time in the timebase of {@link
* android.os.SystemClock#elapsedRealtime()}. * android.os.SystemClock#elapsedRealtime()}.
*/ */
boolean isBlacklisted(int index, long nowMs); boolean isTrackExcluded(int index, long nowMs);
} }
...@@ -91,7 +91,7 @@ public final class RandomTrackSelection extends BaseTrackSelection { ...@@ -91,7 +91,7 @@ public final class RandomTrackSelection extends BaseTrackSelection {
long nowMs = SystemClock.elapsedRealtime(); long nowMs = SystemClock.elapsedRealtime();
int allowedFormatCount = 0; int allowedFormatCount = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (!isBlacklisted(i, nowMs)) { if (!isTrackExcluded(i, nowMs)) {
allowedFormatCount++; allowedFormatCount++;
} }
} }
...@@ -101,7 +101,7 @@ public final class RandomTrackSelection extends BaseTrackSelection { ...@@ -101,7 +101,7 @@ public final class RandomTrackSelection extends BaseTrackSelection {
// Adjust the format index to account for excluded formats. // Adjust the format index to account for excluded formats.
allowedFormatCount = 0; allowedFormatCount = 0;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (!isBlacklisted(i, nowMs) && selectedIndex == allowedFormatCount++) { if (!isTrackExcluded(i, nowMs) && selectedIndex == allowedFormatCount++) {
selectedIndex = i; selectedIndex = i;
return; return;
} }
......
...@@ -121,7 +121,7 @@ public final class TrackSelectionUtil { ...@@ -121,7 +121,7 @@ public final class TrackSelectionUtil {
int numberOfTracks = trackSelection.length(); int numberOfTracks = trackSelection.length();
int numberOfExcludedTracks = 0; int numberOfExcludedTracks = 0;
for (int i = 0; i < numberOfTracks; i++) { for (int i = 0; i < numberOfTracks; i++) {
if (trackSelection.isBlacklisted(i, nowMs)) { if (trackSelection.isTrackExcluded(i, nowMs)) {
numberOfExcludedTracks++; numberOfExcludedTracks++;
} }
} }
......
...@@ -530,7 +530,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -530,7 +530,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
boolean cancelLoad = false; boolean cancelLoad = false;
if (fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_TRACK) { if (fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_TRACK) {
cancelLoad = cancelLoad =
trackSelection.blacklist( trackSelection.excludeTrack(
trackSelection.indexOf(chunk.trackFormat), fallbackSelection.exclusionDurationMs); trackSelection.indexOf(chunk.trackFormat), fallbackSelection.exclusionDurationMs);
} else if (fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_LOCATION) { } else if (fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_LOCATION) {
baseUrlExclusionList.exclude( baseUrlExclusionList.exclude(
...@@ -558,7 +558,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -558,7 +558,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int numberOfTracks = trackSelection.length(); int numberOfTracks = trackSelection.length();
int numberOfExcludedTracks = 0; int numberOfExcludedTracks = 0;
for (int i = 0; i < numberOfTracks; i++) { for (int i = 0; i < numberOfTracks; i++) {
if (trackSelection.isBlacklisted(i, nowMs)) { if (trackSelection.isTrackExcluded(i, nowMs)) {
numberOfExcludedTracks++; numberOfExcludedTracks++;
} }
} }
......
...@@ -573,7 +573,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -573,7 +573,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* @return Whether the exclusion succeeded. * @return Whether the exclusion succeeded.
*/ */
public boolean maybeExcludeTrack(Chunk chunk, long exclusionDurationMs) { public boolean maybeExcludeTrack(Chunk chunk, long exclusionDurationMs) {
return trackSelection.blacklist( return trackSelection.excludeTrack(
trackSelection.indexOf(trackGroup.indexOf(chunk.trackFormat)), exclusionDurationMs); trackSelection.indexOf(trackGroup.indexOf(chunk.trackFormat)), exclusionDurationMs);
} }
...@@ -602,7 +602,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -602,7 +602,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
seenExpectedPlaylistError |= playlistUrl.equals(expectedPlaylistUrl); seenExpectedPlaylistError |= playlistUrl.equals(expectedPlaylistUrl);
return exclusionDurationMs == C.TIME_UNSET return exclusionDurationMs == C.TIME_UNSET
|| (trackSelection.blacklist(trackSelectionIndex, exclusionDurationMs) || (trackSelection.excludeTrack(trackSelectionIndex, exclusionDurationMs)
&& playlistTracker.excludeMediaPlaylist(playlistUrl, exclusionDurationMs)); && playlistTracker.excludeMediaPlaylist(playlistUrl, exclusionDurationMs));
} }
...@@ -894,12 +894,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -894,12 +894,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
List<? extends MediaChunk> queue, List<? extends MediaChunk> queue,
MediaChunkIterator[] mediaChunkIterators) { MediaChunkIterator[] mediaChunkIterators) {
long nowMs = SystemClock.elapsedRealtime(); long nowMs = SystemClock.elapsedRealtime();
if (!isBlacklisted(selectedIndex, nowMs)) { if (!isTrackExcluded(selectedIndex, nowMs)) {
return; return;
} }
// Try from lowest bitrate to highest. // Try from lowest bitrate to highest.
for (int i = length - 1; i >= 0; i--) { for (int i = length - 1; i >= 0; i--) {
if (!isBlacklisted(i, nowMs)) { if (!isTrackExcluded(i, nowMs)) {
selectedIndex = i; selectedIndex = i;
return; return;
} }
......
...@@ -297,7 +297,7 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -297,7 +297,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
return cancelable return cancelable
&& fallbackSelection != null && fallbackSelection != null
&& fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_TRACK && fallbackSelection.type == LoadErrorHandlingPolicy.FALLBACK_TYPE_TRACK
&& trackSelection.blacklist( && trackSelection.excludeTrack(
trackSelection.indexOf(chunk.trackFormat), fallbackSelection.exclusionDurationMs); trackSelection.indexOf(chunk.trackFormat), fallbackSelection.exclusionDurationMs);
} }
......
...@@ -146,13 +146,13 @@ public final class FakeTrackSelection implements ExoTrackSelection { ...@@ -146,13 +146,13 @@ public final class FakeTrackSelection implements ExoTrackSelection {
} }
@Override @Override
public boolean blacklist(int index, long exclusionDurationMs) { public boolean excludeTrack(int index, long exclusionDurationMs) {
assertThat(isEnabled).isTrue(); assertThat(isEnabled).isTrue();
return false; return false;
} }
@Override @Override
public boolean isBlacklisted(int index, long nowMs) { public boolean isTrackExcluded(int index, long nowMs) {
assertThat(isEnabled).isTrue(); assertThat(isEnabled).isTrue();
return false; return false;
} }
......
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