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
c452d6df
authored
Apr 23, 2020
by
olly
Committed by
Ian Baker
Apr 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove deprecated LoadControl method
PiperOrigin-RevId: 308031992
parent
1699ab0d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
39 deletions
library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java
library/core/src/main/java/com/google/android/exoplayer2/LoadControl.java
library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/core/src/main/java/com/google/android/exoplayer2/DefaultLoadControl.java
View file @
c452d6df
...
...
@@ -370,7 +370,8 @@ public class DefaultLoadControl implements LoadControl {
}
@Override
public
boolean
shouldContinueLoading
(
long
bufferedDurationUs
,
float
playbackSpeed
)
{
public
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
)
{
boolean
targetBufferSizeReached
=
allocator
.
getTotalBytesAllocated
()
>=
targetBufferBytes
;
long
minBufferUs
=
this
.
minBufferUs
;
if
(
playbackSpeed
>
1
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/LoadControl.java
View file @
c452d6df
...
...
@@ -87,28 +87,20 @@ public interface LoadControl {
*/
boolean
retainBackBufferFromKeyframe
();
/** @deprecated Use {@link LoadControl#shouldContinueLoading(long, long, float)}. */
@Deprecated
default
boolean
shouldContinueLoading
(
long
bufferedDurationUs
,
float
playbackSpeed
)
{
return
false
;
}
/**
* Called by the player to determine whether it should continue to load the source.
*
* @param playbackPositionUs The current playback position in microseconds, relative to the start
* of the {@link Timeline.Period period} that will continue to be loaded if this method
* returns {@code true}. If
the playback for this period has not yet started, the value will
* returns {@code true}. If
playback of this period has not yet started, the value will be
* negative and equal in magnitude to the duration of any media in previous periods still to
* be played.
* @param bufferedDurationUs The duration of media that's currently buffered.
* @param playbackSpeed The current playback speed.
* @return Whether the loading should continue.
*/
default
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
)
{
return
shouldContinueLoading
(
bufferedDurationUs
,
playbackSpeed
);
}
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
);
/**
* Called repeatedly by the player when it's loading the source, has yet to start playback, and
...
...
library/core/src/test/java/com/google/android/exoplayer2/DefaultLoadControlTest.java
View file @
c452d6df
...
...
@@ -49,9 +49,16 @@ public class DefaultLoadControlTest {
public
void
shouldContinueLoading_untilMaxBufferExceeded
()
{
createDefaultLoadControl
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* bufferedDurationUs= */
0
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
-
1
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
/* bufferedDurationUs= */
0
,
SPEED
))
.
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
-
1
,
SPEED
))
.
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
SPEED
))
.
isFalse
();
}
@Test
...
...
@@ -63,10 +70,18 @@ public class DefaultLoadControlTest {
/* bufferForPlaybackAfterRebufferMs= */
0
);
createDefaultLoadControl
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
-
1
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
-
1
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
-
1
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
-
1
,
SPEED
))
.
isTrue
();
}
@Test
...
...
@@ -78,9 +93,14 @@ public class DefaultLoadControlTest {
/* bufferForPlaybackAfterRebufferMs= */
0
);
createDefaultLoadControl
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
5
*
C
.
MICROS_PER_SECOND
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
500L
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
5
*
C
.
MICROS_PER_SECOND
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
500L
,
SPEED
))
.
isTrue
();
}
@Test
...
...
@@ -94,10 +114,18 @@ public class DefaultLoadControlTest {
createDefaultLoadControl
();
makeSureTargetBufferBytesReached
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* bufferedDurationUs= */
0
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
-
1
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
/* bufferedDurationUs= */
0
,
SPEED
))
.
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
-
1
,
SPEED
))
.
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
SPEED
))
.
isFalse
();
}
@Test
...
...
@@ -107,13 +135,24 @@ public class DefaultLoadControlTest {
createDefaultLoadControl
();
// Put loadControl in buffering state.
assertThat
(
loadControl
.
shouldContinueLoading
(
/* bufferedDurationUs= */
0
,
SPEED
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
/* bufferedDurationUs= */
0
,
SPEED
))
.
isTrue
();
makeSureTargetBufferBytesReached
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* bufferedDurationUs= */
0
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
-
1
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
/* bufferedDurationUs= */
0
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
-
1
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
,
SPEED
))
.
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
SPEED
))
.
isFalse
();
}
@Test
...
...
@@ -126,16 +165,22 @@ public class DefaultLoadControlTest {
createDefaultLoadControl
();
// At normal playback speed, we stop buffering when the buffer reaches the minimum.
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
,
SPEED
)).
isFalse
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
,
SPEED
))
.
isFalse
();
// At double playback speed, we continue loading.
assertThat
(
loadControl
.
shouldContinueLoading
(
MIN_BUFFER_US
,
/* playbackSpeed= */
2
f
)).
isTrue
();
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MIN_BUFFER_US
,
/* playbackSpeed= */
2
f
))
.
isTrue
();
}
@Test
public
void
shouldNotContinueLoadingWithMaxBufferReached_inFastPlayback
()
{
createDefaultLoadControl
();
assertThat
(
loadControl
.
shouldContinueLoading
(
MAX_BUFFER_US
,
/* playbackSpeed= */
100
f
))
assertThat
(
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
MAX_BUFFER_US
,
/* playbackSpeed= */
100
f
))
.
isFalse
();
}
...
...
@@ -153,7 +198,8 @@ public class DefaultLoadControlTest {
loadControl
.
onTracksSelected
(
new
Renderer
[
0
],
TrackGroupArray
.
EMPTY
,
new
TrackSelectionArray
());
assertThat
(
loadControl
.
shouldContinueLoading
(
/* bufferedDurationUs= */
0
,
/* playbackSpeed= */
1
f
))
loadControl
.
shouldContinueLoading
(
/* playbackPositionUs= */
0
,
/* bufferedDurationUs= */
0
,
/* playbackSpeed= */
1
f
))
.
isTrue
();
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
c452d6df
...
...
@@ -3507,11 +3507,12 @@ public final class ExoPlayerTest {
// Disabled until the flag to throw exceptions for [internal: b/144538905] is enabled by default.
@Ignore
@Test
public
void
loadControlNeverWantsToLoad_throwsIllegalStateException
()
throws
Exception
{
public
void
loadControlNeverWantsToLoad_throwsIllegalStateException
()
{
LoadControl
neverLoadingLoadControl
=
new
DefaultLoadControl
()
{
@Override
public
boolean
shouldContinueLoading
(
long
bufferedDurationUs
,
float
playbackSpeed
)
{
public
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
)
{
return
false
;
}
...
...
@@ -3553,7 +3554,8 @@ public final class ExoPlayerTest {
LoadControl
loadControlWithMaxBufferUs
=
new
DefaultLoadControl
()
{
@Override
public
boolean
shouldContinueLoading
(
long
bufferedDurationUs
,
float
playbackSpeed
)
{
public
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
)
{
return
bufferedDurationUs
<
maxBufferUs
;
}
...
...
@@ -3623,7 +3625,8 @@ public final class ExoPlayerTest {
LoadControl
neverLoadingOrPlayingLoadControl
=
new
DefaultLoadControl
()
{
@Override
public
boolean
shouldContinueLoading
(
long
bufferedDurationUs
,
float
playbackSpeed
)
{
public
boolean
shouldContinueLoading
(
long
playbackPositionUs
,
long
bufferedDurationUs
,
float
playbackSpeed
)
{
return
true
;
}
...
...
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