mirror of
https://github.com/samsonjs/media.git
synced 2026-04-08 11:45:51 +00:00
Rename some white/blacklist occurences in HLS library
ISSUE: #7565 PiperOrigin-RevId: 319536055
This commit is contained in:
parent
3d968dddb9
commit
0ee3a35ade
5 changed files with 60 additions and 60 deletions
|
|
@ -371,28 +371,28 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
}
|
||||
|
||||
/**
|
||||
* Attempts to blacklist the track associated with the given chunk. Blacklisting will fail if the
|
||||
* track is the only non-blacklisted track in the selection.
|
||||
* Attempts to exclude the track associated with the given chunk. Exclusion will fail if the track
|
||||
* is the only non-excluded track in the selection.
|
||||
*
|
||||
* @param chunk The chunk whose load caused the blacklisting attempt.
|
||||
* @param blacklistDurationMs The number of milliseconds for which the track selection should be
|
||||
* blacklisted.
|
||||
* @return Whether the blacklisting succeeded.
|
||||
* @param chunk The chunk whose load caused the exclusion attempt.
|
||||
* @param exclusionDurationMs The number of milliseconds for which the track selection should be
|
||||
* excluded.
|
||||
* @return Whether the exclusion succeeded.
|
||||
*/
|
||||
public boolean maybeBlacklistTrack(Chunk chunk, long blacklistDurationMs) {
|
||||
public boolean maybeExcludeTrack(Chunk chunk, long exclusionDurationMs) {
|
||||
return trackSelection.blacklist(
|
||||
trackSelection.indexOf(trackGroup.indexOf(chunk.trackFormat)), blacklistDurationMs);
|
||||
trackSelection.indexOf(trackGroup.indexOf(chunk.trackFormat)), exclusionDurationMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a playlist load encounters an error.
|
||||
*
|
||||
* @param playlistUrl The {@link Uri} of the playlist whose load encountered an error.
|
||||
* @param blacklistDurationMs The duration for which the playlist should be blacklisted. Or {@link
|
||||
* C#TIME_UNSET} if the playlist should not be blacklisted.
|
||||
* @return True if blacklisting did not encounter errors. False otherwise.
|
||||
* @param exclusionDurationMs The duration for which the playlist should be excluded. Or {@link
|
||||
* C#TIME_UNSET} if the playlist should not be excluded.
|
||||
* @return True if excluding did not encounter errors. False otherwise.
|
||||
*/
|
||||
public boolean onPlaylistError(Uri playlistUrl, long blacklistDurationMs) {
|
||||
public boolean onPlaylistError(Uri playlistUrl, long exclusionDurationMs) {
|
||||
int trackGroupIndex = C.INDEX_UNSET;
|
||||
for (int i = 0; i < playlistUrls.length; i++) {
|
||||
if (playlistUrls[i].equals(playlistUrl)) {
|
||||
|
|
@ -408,8 +408,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
return true;
|
||||
}
|
||||
seenExpectedPlaylistError |= playlistUrl.equals(expectedPlaylistUrl);
|
||||
return blacklistDurationMs == C.TIME_UNSET
|
||||
|| trackSelection.blacklist(trackSelectionIndex, blacklistDurationMs);
|
||||
return exclusionDurationMs == C.TIME_UNSET
|
||||
|| trackSelection.blacklist(trackSelectionIndex, exclusionDurationMs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -452,13 +452,13 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onPlaylistError(Uri url, long blacklistDurationMs) {
|
||||
boolean noBlacklistingFailure = true;
|
||||
public boolean onPlaylistError(Uri url, long exclusionDurationMs) {
|
||||
boolean exclusionSucceeded = true;
|
||||
for (HlsSampleStreamWrapper streamWrapper : sampleStreamWrappers) {
|
||||
noBlacklistingFailure &= streamWrapper.onPlaylistError(url, blacklistDurationMs);
|
||||
exclusionSucceeded &= streamWrapper.onPlaylistError(url, exclusionDurationMs);
|
||||
}
|
||||
callback.onContinueLoadingRequested(this);
|
||||
return noBlacklistingFailure;
|
||||
return exclusionSucceeded;
|
||||
}
|
||||
|
||||
// Internal methods.
|
||||
|
|
|
|||
|
|
@ -515,8 +515,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
chunkSource.setIsTimestampMaster(isTimestampMaster);
|
||||
}
|
||||
|
||||
public boolean onPlaylistError(Uri playlistUrl, long blacklistDurationMs) {
|
||||
return chunkSource.onPlaylistError(playlistUrl, blacklistDurationMs);
|
||||
public boolean onPlaylistError(Uri playlistUrl, long exclusionDurationMs) {
|
||||
return chunkSource.onPlaylistError(playlistUrl, exclusionDurationMs);
|
||||
}
|
||||
|
||||
// SampleStream implementation.
|
||||
|
|
@ -793,7 +793,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
int errorCount) {
|
||||
long bytesLoaded = loadable.bytesLoaded();
|
||||
boolean isMediaChunk = isMediaChunk(loadable);
|
||||
boolean blacklistSucceeded = false;
|
||||
boolean exclusionSucceeded = false;
|
||||
LoadEventInfo loadEventInfo =
|
||||
new LoadEventInfo(
|
||||
loadable.loadTaskId,
|
||||
|
|
@ -815,12 +815,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
LoadErrorInfo loadErrorInfo =
|
||||
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
||||
LoadErrorAction loadErrorAction;
|
||||
long blacklistDurationMs = loadErrorHandlingPolicy.getBlacklistDurationMsFor(loadErrorInfo);
|
||||
if (blacklistDurationMs != C.TIME_UNSET) {
|
||||
blacklistSucceeded = chunkSource.maybeBlacklistTrack(loadable, blacklistDurationMs);
|
||||
long exclusionDurationMs = loadErrorHandlingPolicy.getBlacklistDurationMsFor(loadErrorInfo);
|
||||
if (exclusionDurationMs != C.TIME_UNSET) {
|
||||
exclusionSucceeded = chunkSource.maybeExcludeTrack(loadable, exclusionDurationMs);
|
||||
}
|
||||
|
||||
if (blacklistSucceeded) {
|
||||
if (exclusionSucceeded) {
|
||||
if (isMediaChunk && bytesLoaded == 0) {
|
||||
HlsMediaChunk removed = mediaChunks.remove(mediaChunks.size() - 1);
|
||||
Assertions.checkState(removed == loadable);
|
||||
|
|
@ -829,7 +829,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
}
|
||||
}
|
||||
loadErrorAction = Loader.DONT_RETRY;
|
||||
} else /* did not blacklist */ {
|
||||
} else /* did not exclude */ {
|
||||
long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(loadErrorInfo);
|
||||
loadErrorAction =
|
||||
retryDelayMs != C.TIME_UNSET
|
||||
|
|
@ -854,7 +854,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
|
||||
}
|
||||
|
||||
if (blacklistSucceeded) {
|
||||
if (exclusionSucceeded) {
|
||||
if (!prepared) {
|
||||
continueLoading(lastSeekPositionUs);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ public final class DefaultHlsPlaylistTracker
|
|||
long currentTimeMs = SystemClock.elapsedRealtime();
|
||||
for (int i = 0; i < variantsSize; i++) {
|
||||
MediaPlaylistBundle bundle = playlistBundles.get(variants.get(i).url);
|
||||
if (currentTimeMs > bundle.blacklistUntilMs) {
|
||||
if (currentTimeMs > bundle.excludeUntilMs) {
|
||||
primaryMediaPlaylistUrl = bundle.playlistUrl;
|
||||
bundle.loadPlaylist();
|
||||
return true;
|
||||
|
|
@ -377,13 +377,13 @@ public final class DefaultHlsPlaylistTracker
|
|||
}
|
||||
}
|
||||
|
||||
private boolean notifyPlaylistError(Uri playlistUrl, long blacklistDurationMs) {
|
||||
private boolean notifyPlaylistError(Uri playlistUrl, long exclusionDurationMs) {
|
||||
int listenersSize = listeners.size();
|
||||
boolean anyBlacklistingFailed = false;
|
||||
boolean anyExclusionFailed = false;
|
||||
for (int i = 0; i < listenersSize; i++) {
|
||||
anyBlacklistingFailed |= !listeners.get(i).onPlaylistError(playlistUrl, blacklistDurationMs);
|
||||
anyExclusionFailed |= !listeners.get(i).onPlaylistError(playlistUrl, exclusionDurationMs);
|
||||
}
|
||||
return anyBlacklistingFailed;
|
||||
return anyExclusionFailed;
|
||||
}
|
||||
|
||||
private HlsMediaPlaylist getLatestPlaylistSnapshot(
|
||||
|
|
@ -467,7 +467,7 @@ public final class DefaultHlsPlaylistTracker
|
|||
private long lastSnapshotLoadMs;
|
||||
private long lastSnapshotChangeMs;
|
||||
private long earliestNextLoadTimeMs;
|
||||
private long blacklistUntilMs;
|
||||
private long excludeUntilMs;
|
||||
private boolean loadPending;
|
||||
private IOException playlistError;
|
||||
|
||||
|
|
@ -504,7 +504,7 @@ public final class DefaultHlsPlaylistTracker
|
|||
}
|
||||
|
||||
public void loadPlaylist() {
|
||||
blacklistUntilMs = 0;
|
||||
excludeUntilMs = 0;
|
||||
if (loadPending || mediaPlaylistLoader.isLoading() || mediaPlaylistLoader.hasFatalError()) {
|
||||
// Load already pending, in progress, or a fatal error has been encountered. Do nothing.
|
||||
return;
|
||||
|
|
@ -590,16 +590,16 @@ public final class DefaultHlsPlaylistTracker
|
|||
LoadErrorInfo loadErrorInfo =
|
||||
new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount);
|
||||
LoadErrorAction loadErrorAction;
|
||||
long blacklistDurationMs = loadErrorHandlingPolicy.getBlacklistDurationMsFor(loadErrorInfo);
|
||||
boolean shouldBlacklist = blacklistDurationMs != C.TIME_UNSET;
|
||||
long exclusionDurationMs = loadErrorHandlingPolicy.getBlacklistDurationMsFor(loadErrorInfo);
|
||||
boolean shouldExclude = exclusionDurationMs != C.TIME_UNSET;
|
||||
|
||||
boolean blacklistingFailed =
|
||||
notifyPlaylistError(playlistUrl, blacklistDurationMs) || !shouldBlacklist;
|
||||
if (shouldBlacklist) {
|
||||
blacklistingFailed |= blacklistPlaylist(blacklistDurationMs);
|
||||
boolean exclusionFailed =
|
||||
notifyPlaylistError(playlistUrl, exclusionDurationMs) || !shouldExclude;
|
||||
if (shouldExclude) {
|
||||
exclusionFailed |= excludePlaylist(exclusionDurationMs);
|
||||
}
|
||||
|
||||
if (blacklistingFailed) {
|
||||
if (exclusionFailed) {
|
||||
long retryDelay = loadErrorHandlingPolicy.getRetryDelayMsFor(loadErrorInfo);
|
||||
loadErrorAction =
|
||||
retryDelay != C.TIME_UNSET
|
||||
|
|
@ -654,7 +654,7 @@ public final class DefaultHlsPlaylistTracker
|
|||
< playlistSnapshot.mediaSequence) {
|
||||
// TODO: Allow customization of playlist resets handling.
|
||||
// The media sequence jumped backwards. The server has probably reset. We do not try
|
||||
// blacklisting in this case.
|
||||
// excluding in this case.
|
||||
playlistError = new PlaylistResetException(playlistUrl);
|
||||
notifyPlaylistError(playlistUrl, C.TIME_UNSET);
|
||||
} else if (currentTimeMs - lastSnapshotChangeMs
|
||||
|
|
@ -668,11 +668,11 @@ public final class DefaultHlsPlaylistTracker
|
|||
new MediaLoadData(C.DATA_TYPE_MANIFEST),
|
||||
playlistError,
|
||||
/* errorCount= */ 1);
|
||||
long blacklistDurationMs =
|
||||
long exclusionDurationMs =
|
||||
loadErrorHandlingPolicy.getBlacklistDurationMsFor(loadErrorInfo);
|
||||
notifyPlaylistError(playlistUrl, blacklistDurationMs);
|
||||
if (blacklistDurationMs != C.TIME_UNSET) {
|
||||
blacklistPlaylist(blacklistDurationMs);
|
||||
notifyPlaylistError(playlistUrl, exclusionDurationMs);
|
||||
if (exclusionDurationMs != C.TIME_UNSET) {
|
||||
excludePlaylist(exclusionDurationMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -693,14 +693,14 @@ public final class DefaultHlsPlaylistTracker
|
|||
}
|
||||
|
||||
/**
|
||||
* Blacklists the playlist.
|
||||
* Excludes the playlist.
|
||||
*
|
||||
* @param blacklistDurationMs The number of milliseconds for which the playlist should be
|
||||
* blacklisted.
|
||||
* @return Whether the playlist is the primary, despite being blacklisted.
|
||||
* @param exclusionDurationMs The number of milliseconds for which the playlist should be
|
||||
* excluded.
|
||||
* @return Whether the playlist is the primary, despite being excluded.
|
||||
*/
|
||||
private boolean blacklistPlaylist(long blacklistDurationMs) {
|
||||
blacklistUntilMs = SystemClock.elapsedRealtime() + blacklistDurationMs;
|
||||
private boolean excludePlaylist(long exclusionDurationMs) {
|
||||
excludeUntilMs = SystemClock.elapsedRealtime() + exclusionDurationMs;
|
||||
return playlistUrl.equals(primaryMediaPlaylistUrl) && !maybeSelectNewPrimaryUrl();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import java.io.IOException;
|
|||
* media playlists while the master playlist is an optional kind of playlist defined by the HLS
|
||||
* specification (RFC 8216).
|
||||
*
|
||||
* <p>Playlist loads might encounter errors. The tracker may choose to blacklist them to ensure a
|
||||
* <p>Playlist loads might encounter errors. The tracker may choose to exclude them to ensure a
|
||||
* primary playlist is always available.
|
||||
*/
|
||||
public interface HlsPlaylistTracker {
|
||||
|
|
@ -76,11 +76,11 @@ public interface HlsPlaylistTracker {
|
|||
* Called if an error is encountered while loading a playlist.
|
||||
*
|
||||
* @param url The loaded url that caused the error.
|
||||
* @param blacklistDurationMs The duration for which the playlist should be blacklisted. Or
|
||||
* {@link C#TIME_UNSET} if the playlist should not be blacklisted.
|
||||
* @return True if blacklisting did not encounter errors. False otherwise.
|
||||
* @param exclusionDurationMs The duration for which the playlist should be excluded. Or {@link
|
||||
* C#TIME_UNSET} if the playlist should not be excluded.
|
||||
* @return True if excluding did not encounter errors. False otherwise.
|
||||
*/
|
||||
boolean onPlaylistError(Uri url, long blacklistDurationMs);
|
||||
boolean onPlaylistError(Uri url, long exclusionDurationMs);
|
||||
}
|
||||
|
||||
/** Thrown when a playlist is considered to be stuck due to a server side error. */
|
||||
|
|
@ -208,10 +208,10 @@ public interface HlsPlaylistTracker {
|
|||
void maybeThrowPlaylistRefreshError(Uri url) throws IOException;
|
||||
|
||||
/**
|
||||
* Requests a playlist refresh and whitelists it.
|
||||
* Requests a playlist refresh and removes it from the exclusion list.
|
||||
*
|
||||
* <p>The playlist tracker may choose the delay the playlist refresh. The request is discarded if
|
||||
* a refresh was already pending.
|
||||
* <p>The playlist tracker may choose to delay the playlist refresh. The request is discarded if a
|
||||
* refresh was already pending.
|
||||
*
|
||||
* @param url The {@link Uri} of the playlist to be refreshed.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue