mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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
This commit is contained in:
parent
baf1aa1cdb
commit
7ee53219ff
11 changed files with 26 additions and 24 deletions
|
|
@ -28,6 +28,8 @@
|
||||||
instead. Note that even for the deprecated variants, the offset is not
|
instead. Note that even for the deprecated variants, the offset is not
|
||||||
anymore added to `startTimeUs` and `endTimeUs` of the `MediaLoadData`
|
anymore added to `startTimeUs` and `endTimeUs` of the `MediaLoadData`
|
||||||
objects that are dispatched by the dispatcher.
|
objects that are dispatched by the dispatcher.
|
||||||
|
* Rename `ExoTrackSelection.blacklist` to `excludeTrack` and
|
||||||
|
`isBlacklisted` to `isTrackExcluded`.
|
||||||
* Session:
|
* Session:
|
||||||
* Fix bug where multiple identical queue items published by a legacy
|
* Fix bug where multiple identical queue items published by a legacy
|
||||||
`MediaSessionCompat` result in an exception in `MediaController`
|
`MediaSessionCompat` result in an exception in `MediaController`
|
||||||
|
|
|
||||||
|
|
@ -596,13 +596,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
|
||||||
|
|
|
||||||
|
|
@ -457,7 +457,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);
|
||||||
|
|
@ -592,7 +592,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;
|
||||||
|
|
|
||||||
|
|
@ -166,11 +166,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;
|
||||||
|
|
@ -183,7 +183,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,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.
|
||||||
|
|
@ -289,5 +289,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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -532,7 +532,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(
|
||||||
|
|
@ -560,7 +560,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;
|
||||||
* @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;
|
||||||
}
|
}
|
||||||
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;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,13 +148,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue