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
1051580a
authored
Oct 21, 2020
by
bachinger
Committed by
Oliver Woodman
Oct 21, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Improve naming of the methods of LivePlaybackSpeedControl
PiperOrigin-RevId: 338232327
parent
54506b50
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java
library/core/src/main/java/com/google/android/exoplayer2/LivePlaybackSpeedControl.java
library/core/src/test/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControlTest.java
library/core/src/main/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControl.java
View file @
1051580a
...
@@ -181,19 +181,19 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
...
@@ -181,19 +181,19 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
}
}
@Override
@Override
public
void
update
LiveConfiguration
(
LiveConfiguration
liveConfiguration
)
{
public
void
set
LiveConfiguration
(
LiveConfiguration
liveConfiguration
)
{
this
.
mediaConfiguration
=
liveConfiguration
;
this
.
mediaConfiguration
=
liveConfiguration
;
lastPlaybackSpeedUpdateMs
=
C
.
TIME_UNSET
;
lastPlaybackSpeedUpdateMs
=
C
.
TIME_UNSET
;
}
}
@Override
@Override
public
void
overrideTargetLiveOffset
Us
(
long
liveOffsetUs
)
{
public
void
setTargetLiveOffsetOverride
Us
(
long
liveOffsetUs
)
{
this
.
targetLiveOffsetOverrideUs
=
liveOffsetUs
;
this
.
targetLiveOffsetOverrideUs
=
liveOffsetUs
;
lastPlaybackSpeedUpdateMs
=
C
.
TIME_UNSET
;
lastPlaybackSpeedUpdateMs
=
C
.
TIME_UNSET
;
}
}
@Override
@Override
public
float
adjust
PlaybackSpeed
(
long
liveOffsetUs
)
{
public
float
getAdjusted
PlaybackSpeed
(
long
liveOffsetUs
)
{
long
targetLiveOffsetUs
=
getTargetLiveOffsetUs
();
long
targetLiveOffsetUs
=
getTargetLiveOffsetUs
();
if
(
targetLiveOffsetUs
==
C
.
TIME_UNSET
)
{
if
(
targetLiveOffsetUs
==
C
.
TIME_UNSET
)
{
return
1
f
;
return
1
f
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java
View file @
1051580a
...
@@ -870,7 +870,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
...
@@ -870,7 +870,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
if
(
playbackInfo
.
playWhenReady
if
(
playbackInfo
.
playWhenReady
&&
isCurrentPeriodInMovingLiveWindow
()
&&
isCurrentPeriodInMovingLiveWindow
()
&&
playbackInfo
.
playbackParameters
.
speed
==
1
f
)
{
&&
playbackInfo
.
playbackParameters
.
speed
==
1
f
)
{
float
adjustedSpeed
=
livePlaybackSpeedControl
.
adjustPlaybackSpeed
(
getCurrentLiveOffsetUs
());
float
adjustedSpeed
=
livePlaybackSpeedControl
.
getAdjustedPlaybackSpeed
(
getCurrentLiveOffsetUs
());
if
(
mediaClock
.
getPlaybackParameters
().
speed
!=
adjustedSpeed
)
{
if
(
mediaClock
.
getPlaybackParameters
().
speed
!=
adjustedSpeed
)
{
mediaClock
.
setPlaybackParameters
(
playbackInfo
.
playbackParameters
.
withSpeed
(
adjustedSpeed
));
mediaClock
.
setPlaybackParameters
(
playbackInfo
.
playbackParameters
.
withSpeed
(
adjustedSpeed
));
}
}
...
@@ -1798,9 +1799,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
...
@@ -1798,9 +1799,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
}
int
windowIndex
=
newTimeline
.
getPeriodByUid
(
newPeriodId
.
periodUid
,
period
).
windowIndex
;
int
windowIndex
=
newTimeline
.
getPeriodByUid
(
newPeriodId
.
periodUid
,
period
).
windowIndex
;
newTimeline
.
getWindow
(
windowIndex
,
window
);
newTimeline
.
getWindow
(
windowIndex
,
window
);
livePlaybackSpeedControl
.
update
LiveConfiguration
(
window
.
mediaItem
.
liveConfiguration
);
livePlaybackSpeedControl
.
set
LiveConfiguration
(
window
.
mediaItem
.
liveConfiguration
);
if
(
positionForTargetOffsetOverrideUs
!=
C
.
TIME_UNSET
)
{
if
(
positionForTargetOffsetOverrideUs
!=
C
.
TIME_UNSET
)
{
livePlaybackSpeedControl
.
overrideTargetLiveOffset
Us
(
livePlaybackSpeedControl
.
setTargetLiveOffsetOverride
Us
(
getLiveOffsetUs
(
newTimeline
,
newPeriodId
.
periodUid
,
positionForTargetOffsetOverrideUs
));
getLiveOffsetUs
(
newTimeline
,
newPeriodId
.
periodUid
,
positionForTargetOffsetOverrideUs
));
}
else
{
}
else
{
Object
windowUid
=
window
.
uid
;
Object
windowUid
=
window
.
uid
;
...
@@ -1811,7 +1812,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
...
@@ -1811,7 +1812,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
}
if
(!
Util
.
areEqual
(
oldWindowUid
,
windowUid
))
{
if
(!
Util
.
areEqual
(
oldWindowUid
,
windowUid
))
{
// Reset overridden target live offset to media values if window changes.
// Reset overridden target live offset to media values if window changes.
livePlaybackSpeedControl
.
overrideTargetLiveOffset
Us
(
C
.
TIME_UNSET
);
livePlaybackSpeedControl
.
setTargetLiveOffsetOverride
Us
(
C
.
TIME_UNSET
);
}
}
}
}
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/LivePlaybackSpeedControl.java
View file @
1051580a
...
@@ -24,20 +24,21 @@ import com.google.android.exoplayer2.MediaItem.LiveConfiguration;
...
@@ -24,20 +24,21 @@ import com.google.android.exoplayer2.MediaItem.LiveConfiguration;
public
interface
LivePlaybackSpeedControl
{
public
interface
LivePlaybackSpeedControl
{
/**
/**
*
Update
s the live configuration defined by the media.
*
Set
s the live configuration defined by the media.
*
*
* @param liveConfiguration The {@link LiveConfiguration} as defined by the media.
* @param liveConfiguration The {@link LiveConfiguration} as defined by the media.
*/
*/
void
update
LiveConfiguration
(
LiveConfiguration
liveConfiguration
);
void
set
LiveConfiguration
(
LiveConfiguration
liveConfiguration
);
/**
/**
* Overrides the {@link #updateLiveConfiguration configured} target live offset in microseconds,
* Sets the target live offset in microseconds that overrides the live offset {@link
* or {@code C.TIME_UNSET} to delete a previous override.
* #setLiveConfiguration configured} by the media. Passing {@code C.TIME_UNSET} deletes a previous
* override.
*
*
* <p>If no target live offset is configured by {@link #
updateLiveConfiguration}, this override
* <p>If no target live offset is configured by {@link #
setLiveConfiguration}, this override has
*
has
no effect.
* no effect.
*/
*/
void
overrideTargetLiveOffset
Us
(
long
liveOffsetUs
);
void
setTargetLiveOffsetOverride
Us
(
long
liveOffsetUs
);
/**
/**
* Returns the adjusted playback speed in order get closer towards the {@link
* Returns the adjusted playback speed in order get closer towards the {@link
...
@@ -46,7 +47,7 @@ public interface LivePlaybackSpeedControl {
...
@@ -46,7 +47,7 @@ public interface LivePlaybackSpeedControl {
* @param liveOffsetUs The current live offset, in microseconds.
* @param liveOffsetUs The current live offset, in microseconds.
* @return The adjusted playback speed.
* @return The adjusted playback speed.
*/
*/
float
adjust
PlaybackSpeed
(
long
liveOffsetUs
);
float
getAdjusted
PlaybackSpeed
(
long
liveOffsetUs
);
/**
/**
* Returns the current target live offset, in microseconds, or {@link C#TIME_UNSET} if no target
* Returns the current target live offset, in microseconds, or {@link C#TIME_UNSET} if no target
...
...
library/core/src/test/java/com/google/android/exoplayer2/DefaultLivePlaybackSpeedControlTest.java
View file @
1051580a
This diff is collapsed.
Click to expand it.
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