Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b30e2b96
authored
Jul 06, 2020
by
kimvde
Committed by
Ian Baker
Jul 06, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Rename some white/blacklist occurrences in core library
ISSUE: #7565 PiperOrigin-RevId: 319734842
parent
6872910d
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
72 additions
and
75 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSource.java
library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java
library/core/src/main/java/com/google/android/exoplayer2/trackselection/BaseTrackSelection.java
library/core/src/main/java/com/google/android/exoplayer2/trackselection/RandomTrackSelection.java
library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackSelection.java
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java
View file @
b30e2b96
...
...
@@ -489,12 +489,12 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
LoadErrorInfo
loadErrorInfo
=
new
LoadErrorInfo
(
loadEventInfo
,
mediaLoadData
,
error
,
errorCount
);
long
blacklist
DurationMs
=
long
exclusion
DurationMs
=
cancelable
?
loadErrorHandlingPolicy
.
getBlacklistDurationMsFor
(
loadErrorInfo
)
:
C
.
TIME_UNSET
;
@Nullable
LoadErrorAction
loadErrorAction
=
null
;
if
(
chunkSource
.
onChunkLoadError
(
loadable
,
cancelable
,
error
,
blacklist
DurationMs
))
{
if
(
chunkSource
.
onChunkLoadError
(
loadable
,
cancelable
,
error
,
exclusion
DurationMs
))
{
if
(
cancelable
)
{
loadErrorAction
=
Loader
.
DONT_RETRY
;
if
(
isMediaChunk
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSource.java
View file @
b30e2b96
...
...
@@ -96,12 +96,12 @@ public interface ChunkSource {
* @param chunk The chunk whose load encountered the error.
* @param cancelable Whether the load can be canceled.
* @param e The error.
* @param
blacklistDurationMs The duration for which the associated track may be blacklist
ed, or
* {@link C#TIME_UNSET} if the track may not be
blacklist
ed.
* @param
exclusionDurationMs The duration for which the associated track may be exclud
ed, or
* {@link C#TIME_UNSET} if the track may not be
exclud
ed.
* @return Whether the load should be canceled so that a replacement chunk can be loaded instead.
* Must be {@code false} if {@code cancelable} is {@code false}. If {@code true}, {@link
* #getNextChunk(long, long, List, ChunkHolder)} will be called to obtain the replacement
* chunk.
*/
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
blacklist
DurationMs
);
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
exclusion
DurationMs
);
}
library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java
View file @
b30e2b96
...
...
@@ -569,22 +569,22 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
* Computes the ideal selected index ignoring buffer health.
*
* @param nowMs The current time in the timebase of {@link Clock#elapsedRealtime()}, or {@link
* Long#MIN_VALUE} to ignore
blacklisting
.
* Long#MIN_VALUE} to ignore
track exclusion
.
*/
private
int
determineIdealSelectedIndex
(
long
nowMs
)
{
long
effectiveBitrate
=
bandwidthProvider
.
getAllocatedBandwidth
();
int
lowestBitrate
NonBlacklist
edIndex
=
0
;
int
lowestBitrate
Allow
edIndex
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(
nowMs
==
Long
.
MIN_VALUE
||
!
isBlacklisted
(
i
,
nowMs
))
{
Format
format
=
getFormat
(
i
);
if
(
canSelectFormat
(
format
,
format
.
bitrate
,
playbackSpeed
,
effectiveBitrate
))
{
return
i
;
}
else
{
lowestBitrate
NonBlacklist
edIndex
=
i
;
lowestBitrate
Allow
edIndex
=
i
;
}
}
}
return
lowestBitrate
NonBlacklist
edIndex
;
return
lowestBitrate
Allow
edIndex
;
}
private
long
minDurationForQualityIncreaseUs
(
long
availableDurationUs
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/trackselection/BaseTrackSelection.java
View file @
b30e2b96
...
...
@@ -49,10 +49,8 @@ public abstract class BaseTrackSelection implements TrackSelection {
* The {@link Format}s of the selected tracks, in order of decreasing bandwidth.
*/
private
final
Format
[]
formats
;
/**
* Selected track blacklist timestamps, in order of decreasing bandwidth.
*/
private
final
long
[]
blacklistUntilTimes
;
/** Selected track exclusion timestamps, in order of decreasing bandwidth. */
private
final
long
[]
excludeUntilTimes
;
// Lazily initialized hashcode.
private
int
hashCode
;
...
...
@@ -77,7 +75,7 @@ public abstract class BaseTrackSelection implements TrackSelection {
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
this
.
tracks
[
i
]
=
group
.
indexOf
(
formats
[
i
]);
}
blacklist
UntilTimes
=
new
long
[
length
];
exclude
UntilTimes
=
new
long
[
length
];
}
@Override
...
...
@@ -152,30 +150,30 @@ public abstract class BaseTrackSelection implements TrackSelection {
}
@Override
public
final
boolean
blacklist
(
int
index
,
long
blacklist
DurationMs
)
{
public
final
boolean
blacklist
(
int
index
,
long
exclusion
DurationMs
)
{
long
nowMs
=
SystemClock
.
elapsedRealtime
();
boolean
can
Blacklist
=
isBlacklisted
(
index
,
nowMs
);
for
(
int
i
=
0
;
i
<
length
&&
!
can
Blacklist
;
i
++)
{
can
Blacklist
=
i
!=
index
&&
!
isBlacklisted
(
i
,
nowMs
);
boolean
can
Exclude
=
isBlacklisted
(
index
,
nowMs
);
for
(
int
i
=
0
;
i
<
length
&&
!
can
Exclude
;
i
++)
{
can
Exclude
=
i
!=
index
&&
!
isBlacklisted
(
i
,
nowMs
);
}
if
(!
can
Blacklist
)
{
if
(!
can
Exclude
)
{
return
false
;
}
blacklist
UntilTimes
[
index
]
=
exclude
UntilTimes
[
index
]
=
Math
.
max
(
blacklist
UntilTimes
[
index
],
Util
.
addWithOverflowDefault
(
nowMs
,
blacklist
DurationMs
,
Long
.
MAX_VALUE
));
exclude
UntilTimes
[
index
],
Util
.
addWithOverflowDefault
(
nowMs
,
exclusion
DurationMs
,
Long
.
MAX_VALUE
));
return
true
;
}
/**
* Returns whether the track at the specified index in the selection is
blacklist
ed.
* Returns whether the track at the specified index in the selection is
exclud
ed.
*
* @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
)
{
return
blacklist
UntilTimes
[
index
]
>
nowMs
;
return
exclude
UntilTimes
[
index
]
>
nowMs
;
}
// Object overrides.
...
...
library/core/src/main/java/com/google/android/exoplayer2/trackselection/RandomTrackSelection.java
View file @
b30e2b96
...
...
@@ -102,21 +102,21 @@ public final class RandomTrackSelection extends BaseTrackSelection {
long
availableDurationUs
,
List
<?
extends
MediaChunk
>
queue
,
MediaChunkIterator
[]
mediaChunkIterators
)
{
// Count the number of
non-blacklist
ed formats.
// Count the number of
allow
ed formats.
long
nowMs
=
SystemClock
.
elapsedRealtime
();
int
nonBlacklist
edFormatCount
=
0
;
int
allow
edFormatCount
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(!
isBlacklisted
(
i
,
nowMs
))
{
nonBlacklist
edFormatCount
++;
allow
edFormatCount
++;
}
}
selectedIndex
=
random
.
nextInt
(
nonBlacklist
edFormatCount
);
if
(
nonBlacklist
edFormatCount
!=
length
)
{
// Adjust the format index to account for
blacklist
ed formats.
nonBlacklist
edFormatCount
=
0
;
selectedIndex
=
random
.
nextInt
(
allow
edFormatCount
);
if
(
allow
edFormatCount
!=
length
)
{
// Adjust the format index to account for
exclud
ed formats.
allow
edFormatCount
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(!
isBlacklisted
(
i
,
nowMs
)
&&
selectedIndex
==
nonBlacklist
edFormatCount
++)
{
if
(!
isBlacklisted
(
i
,
nowMs
)
&&
selectedIndex
==
allow
edFormatCount
++)
{
selectedIndex
=
i
;
return
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelection.java
View file @
b30e2b96
...
...
@@ -294,20 +294,20 @@ public interface TrackSelection {
}
/**
* Attempts to
blacklist the track at the specified index in the selection, making it ineligible
*
for
selection by calls to {@link #updateSelectedTrack(long, long, long, List,
* Attempts to
exclude the track at the specified index in the selection, making it ineligible for
* selection by calls to {@link #updateSelectedTrack(long, long, long, List,
* MediaChunkIterator[])} for the specified period of time.
*
* <p>
Blacklisting will fail if all other tracks are currently blacklisted. If blacklisting the
*
currently
selected track, note that it will remain selected until the next call to {@link
* <p>
Exclusion will fail if all other tracks are currently excluded. If excluding the currently
* selected track, note that it will remain selected until the next call to {@link
* #updateSelectedTrack(long, long, long, List, MediaChunkIterator[])}.
*
* <p>This method will only be called when the selection is enabled.
*
* @param index The index of the track in the selection.
* @param
blacklistDurationMs The duration of time for which the track should be blacklist
ed, in
* @param
exclusionDurationMs The duration of time for which the track should be exclud
ed, in
* milliseconds.
* @return Whether
blacklisting
was successful.
* @return Whether
exclusion
was successful.
*/
boolean
blacklist
(
int
index
,
long
blacklist
DurationMs
);
boolean
blacklist
(
int
index
,
long
exclusion
DurationMs
);
}
library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicy.java
View file @
b30e2b96
...
...
@@ -32,7 +32,7 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
* streams.
*/
public
static
final
int
DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE
=
6
;
/** The default duration for which a track is
blacklist
ed in milliseconds. */
/** The default duration for which a track is
exclud
ed in milliseconds. */
public
static
final
long
DEFAULT_TRACK_BLACKLIST_MS
=
60_000
;
private
static
final
int
DEFAULT_BEHAVIOR_MIN_LOADABLE_RETRY_COUNT
=
-
1
;
...
...
@@ -61,8 +61,9 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
}
/**
* Blacklists resources whose load error was an {@link InvalidResponseCodeException} with response
* code HTTP 404 or 410. The duration of the blacklisting is {@link #DEFAULT_TRACK_BLACKLIST_MS}.
* Returns the exclusion duration, given by {@link #DEFAULT_TRACK_BLACKLIST_MS}, if the load error
* was an {@link InvalidResponseCodeException} with response code HTTP 404, 410 or 416, or {@link
* C#TIME_UNSET} otherwise.
*/
@Override
public
long
getBlacklistDurationMsFor
(
LoadErrorInfo
loadErrorInfo
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/LoadErrorHandlingPolicy.java
View file @
b30e2b96
...
...
@@ -23,18 +23,16 @@ import com.google.android.exoplayer2.upstream.Loader.Loadable;
import
java.io.IOException
;
/**
* Defines how errors encountered by
{@link Loader Loaders}
are handled.
* Defines how errors encountered by
loaders
are handled.
*
* <p>Loader clients may blacklist a resource when a load error occurs. Blacklisting works around
* load errors by loading an alternative resource. Clients do not try blacklisting when a resource
* does not have an alternative. When a resource does have valid alternatives, {@link
* #getBlacklistDurationMsFor(int, long, IOException, int)} defines whether the resource should be
* blacklisted. Blacklisting will succeed if any of the alternatives is not in the black list.
* <p>A loader that can choose between one of a number of resources can exclude a resource when a
* load error occurs. In this case, {@link #getBlacklistDurationMsFor(int, long, IOException, int)}
* defines whether the resource should be excluded. Exclusion will succeed unless all of the
* alternatives are already excluded.
*
* <p>When blacklisting does not take place, {@link #getRetryDelayMsFor(int, long, IOException,
* int)} defines whether the load is retried. Errors whose load is not retried are propagated. Load
* errors whose load is retried are propagated according to {@link
* #getMinimumLoadableRetryCount(int)}.
* <p>When exclusion does not take place, {@link #getRetryDelayMsFor(int, long, IOException, int)}
* defines whether the load is retried. An error that's not retried will always be propagated. An
* error that is retried will be propagated according to {@link #getMinimumLoadableRetryCount(int)}.
*
* <p>Methods are invoked on the playback thread.
*/
...
...
@@ -74,11 +72,11 @@ public interface LoadErrorHandlingPolicy {
/**
* Returns the number of milliseconds for which a resource associated to a provided load error
* should be
blacklisted, or {@link C#TIME_UNSET} if the resource should not be blacklist
ed.
* should be
excluded, or {@link C#TIME_UNSET} if the resource should not be exclud
ed.
*
* @param loadErrorInfo A {@link LoadErrorInfo} holding information about the load error.
* @return The
blacklist
duration in milliseconds, or {@link C#TIME_UNSET} if the resource should
* not be
blacklist
ed.
* @return The
exclusion
duration in milliseconds, or {@link C#TIME_UNSET} if the resource should
* not be
exclud
ed.
*/
@SuppressWarnings
(
"deprecation"
)
default
long
getBlacklistDurationMsFor
(
LoadErrorInfo
loadErrorInfo
)
{
...
...
@@ -100,9 +98,9 @@ public interface LoadErrorHandlingPolicy {
* Returns the number of milliseconds to wait before attempting the load again, or {@link
* C#TIME_UNSET} if the error is fatal and should not be retried.
*
* <p>
{@link Loader} clients may ignore the retry delay returned by this method in order to wait
*
for a specific event before retrying. However, the load is retried if and only if this method
*
does not return
{@link C#TIME_UNSET}.
* <p>
Loaders may ignore the retry delay returned by this method in order to wait for a specific
*
event before retrying. However, the load is retried if and only if this method does not return
* {@link C#TIME_UNSET}.
*
* @param loadErrorInfo A {@link LoadErrorInfo} holding information about the load error.
* @return The number of milliseconds to wait before attempting the load again, or {@link
...
...
library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
View file @
b30e2b96
...
...
@@ -47,35 +47,35 @@ public final class DefaultLoadErrorHandlingPolicyTest {
new
MediaLoadData
(
/* dataType= */
C
.
DATA_TYPE_UNKNOWN
);
@Test
public
void
get
BlacklistDurationMsFor_blacklist
404
()
{
public
void
get
ExclusionDurationMsFor_responseCode
404
()
{
InvalidResponseCodeException
exception
=
new
InvalidResponseCodeException
(
404
,
"Not Found"
,
Collections
.
emptyMap
(),
new
DataSpec
(
Uri
.
EMPTY
));
assertThat
(
getDefaultPolicy
BlacklistOutput
For
(
exception
))
assertThat
(
getDefaultPolicy
ExclusionDurationMs
For
(
exception
))
.
isEqualTo
(
DefaultLoadErrorHandlingPolicy
.
DEFAULT_TRACK_BLACKLIST_MS
);
}
@Test
public
void
get
BlacklistDurationMsFor_blacklist
410
()
{
public
void
get
ExclusionDurationMsFor_responseCode
410
()
{
InvalidResponseCodeException
exception
=
new
InvalidResponseCodeException
(
410
,
"Gone"
,
Collections
.
emptyMap
(),
new
DataSpec
(
Uri
.
EMPTY
));
assertThat
(
getDefaultPolicy
BlacklistOutput
For
(
exception
))
assertThat
(
getDefaultPolicy
ExclusionDurationMs
For
(
exception
))
.
isEqualTo
(
DefaultLoadErrorHandlingPolicy
.
DEFAULT_TRACK_BLACKLIST_MS
);
}
@Test
public
void
get
BlacklistDurationMsFor_dontBlacklist
UnexpectedHttpCodes
()
{
public
void
get
ExclusionDurationMsFor_dontExclude
UnexpectedHttpCodes
()
{
InvalidResponseCodeException
exception
=
new
InvalidResponseCodeException
(
500
,
"Internal Server Error"
,
Collections
.
emptyMap
(),
new
DataSpec
(
Uri
.
EMPTY
));
assertThat
(
getDefaultPolicy
BlacklistOutput
For
(
exception
)).
isEqualTo
(
C
.
TIME_UNSET
);
assertThat
(
getDefaultPolicy
ExclusionDurationMs
For
(
exception
)).
isEqualTo
(
C
.
TIME_UNSET
);
}
@Test
public
void
get
BlacklistDurationMsFor_dontBlacklist
UnexpectedExceptions
()
{
public
void
get
ExclusionDurationMsFor_dontExclude
UnexpectedExceptions
()
{
IOException
exception
=
new
IOException
();
assertThat
(
getDefaultPolicy
BlacklistOutput
For
(
exception
)).
isEqualTo
(
C
.
TIME_UNSET
);
assertThat
(
getDefaultPolicy
ExclusionDurationMs
For
(
exception
)).
isEqualTo
(
C
.
TIME_UNSET
);
}
@Test
...
...
@@ -91,7 +91,7 @@ public final class DefaultLoadErrorHandlingPolicyTest {
assertThat
(
getDefaultPolicyRetryDelayOutputFor
(
new
IOException
(),
9
)).
isEqualTo
(
5000
);
}
private
static
long
getDefaultPolicy
BlacklistOutput
For
(
IOException
exception
)
{
private
static
long
getDefaultPolicy
ExclusionDurationMs
For
(
IOException
exception
)
{
LoadErrorInfo
loadErrorInfo
=
new
LoadErrorInfo
(
PLACEHOLDER_LOAD_EVENT_INFO
,
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java
View file @
b30e2b96
...
...
@@ -415,7 +415,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
@Override
public
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
blacklist
DurationMs
)
{
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
exclusion
DurationMs
)
{
if
(!
cancelable
)
{
return
false
;
}
...
...
@@ -438,8 +438,8 @@ public class DefaultDashChunkSource implements DashChunkSource {
}
}
}
return
blacklist
DurationMs
!=
C
.
TIME_UNSET
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
blacklist
DurationMs
);
return
exclusion
DurationMs
!=
C
.
TIME_UNSET
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
exclusion
DurationMs
);
}
// Internal methods.
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java
View file @
b30e2b96
...
...
@@ -265,10 +265,10 @@ public class DefaultSsChunkSource implements SsChunkSource {
@Override
public
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
blacklist
DurationMs
)
{
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
exclusion
DurationMs
)
{
return
cancelable
&&
blacklist
DurationMs
!=
C
.
TIME_UNSET
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
blacklist
DurationMs
);
&&
exclusion
DurationMs
!=
C
.
TIME_UNSET
&&
trackSelection
.
blacklist
(
trackSelection
.
indexOf
(
chunk
.
trackFormat
),
exclusion
DurationMs
);
}
// Private methods.
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java
View file @
b30e2b96
...
...
@@ -146,7 +146,7 @@ public final class FakeChunkSource implements ChunkSource {
@Override
public
boolean
onChunkLoadError
(
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
blacklist
DurationMs
)
{
Chunk
chunk
,
boolean
cancelable
,
Exception
e
,
long
exclusion
DurationMs
)
{
return
false
;
}
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackSelection.java
View file @
b30e2b96
...
...
@@ -137,7 +137,7 @@ public final class FakeTrackSelection implements TrackSelection {
}
@Override
public
boolean
blacklist
(
int
index
,
long
blacklist
DurationMs
)
{
public
boolean
blacklist
(
int
index
,
long
exclusion
DurationMs
)
{
assertThat
(
isEnabled
).
isTrue
();
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment