Commit 86ae7eba by tonihei Committed by kim-vde

Decrease target live offset if safely possible.

To check what is safely possible we keep track of the live offset
corresponding to the buffered duration and only deecrease the
target offset to a safe margin from the buffered duration.

Also, while still possible (i.e. while the actual offset is larger
than the safe margin), we increase the target offset to the safe
margin to avoid rebuffers to start with.

Issue: #4904
PiperOrigin-RevId: 341396492
parent b03df4e8
......@@ -872,7 +872,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
&& isCurrentPeriodInMovingLiveWindow()
&& playbackInfo.playbackParameters.speed == 1f) {
float adjustedSpeed =
livePlaybackSpeedControl.getAdjustedPlaybackSpeed(getCurrentLiveOffsetUs());
livePlaybackSpeedControl.getAdjustedPlaybackSpeed(
getCurrentLiveOffsetUs(), getTotalBufferedDurationUs());
if (mediaClock.getPlaybackParameters().speed != adjustedSpeed) {
mediaClock.setPlaybackParameters(playbackInfo.playbackParameters.withSpeed(adjustedSpeed));
}
......
......@@ -53,9 +53,10 @@ public interface LivePlaybackSpeedControl {
* #getTargetLiveOffsetUs() target live offset}.
*
* @param liveOffsetUs The current live offset, in microseconds.
* @param bufferedDurationUs The duration of media that's currently buffered, in microseconds.
* @return The adjusted playback speed.
*/
float getAdjustedPlaybackSpeed(long liveOffsetUs);
float getAdjustedPlaybackSpeed(long liveOffsetUs, long bufferedDurationUs);
/**
* Returns the current target live offset, in microseconds, or {@link C#TIME_UNSET} if no target
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment