Add isBlacklisted method to ExoTrackSelection interface.

Make BaseTrackSelection blacklist and isBlacklisted methods non-final.

PiperOrigin-RevId: 366256521
This commit is contained in:
olly 2021-04-01 16:32:24 +01:00 committed by Oliver Woodman
parent b4aee72a4a
commit 1242237294
3 changed files with 18 additions and 10 deletions

View file

@ -164,7 +164,7 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
}
@Override
public final boolean blacklist(int index, long exclusionDurationMs) {
public boolean blacklist(int index, long exclusionDurationMs) {
long nowMs = SystemClock.elapsedRealtime();
boolean canExclude = isBlacklisted(index, nowMs);
for (int i = 0; i < length && !canExclude; i++) {
@ -180,15 +180,8 @@ public abstract class BaseTrackSelection implements ExoTrackSelection {
return true;
}
// Internal methods.
/**
* Returns whether the track at the specified index in the selection is excluded.
*
* @param index The index of the track in the selection.
* @param nowMs The current time in the timebase of {@link SystemClock#elapsedRealtime()}.
*/
protected final boolean isBlacklisted(int index, long nowMs) {
@Override
public boolean isBlacklisted(int index, long nowMs) {
return excludeUntilTimes[index] > nowMs;
}

View file

@ -271,4 +271,13 @@ public interface ExoTrackSelection extends TrackSelection {
* @return Whether exclusion was successful.
*/
boolean blacklist(int index, long exclusionDurationMs);
/**
* Returns whether the track at the specified index in the selection is excluded.
*
* @param index The index of the track in the selection.
* @param nowMs The current time in the timebase of {@link
* android.os.SystemClock#elapsedRealtime()}.
*/
boolean isBlacklisted(int index, long nowMs);
}

View file

@ -150,4 +150,10 @@ public final class FakeTrackSelection implements ExoTrackSelection {
assertThat(isEnabled).isTrue();
return false;
}
@Override
public boolean isBlacklisted(int index, long exclusionDurationMs) {
assertThat(isEnabled).isTrue();
return false;
}
}