Commit 7c8ab133 by tonihei Committed by Oliver Woodman

Move playback speed adjustment of available bandwidth.

When comparing stream bitrate with available (allocated) bandwidth,
we need to take the playback speed into account. In the current
calculation, this can happen on both sides of the equation, but we
take the time to first byte into account, we need to move the speed
into the available, allocated bandwidth.

This change moves the speed adjustment to the bandwidth calculation
side in AdaptiveTrackSelection.

PiperOrigin-RevId: 362540071
parent e14180e5
...@@ -422,14 +422,12 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -422,14 +422,12 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
* @param format The {@link Format} of the candidate track. * @param format The {@link Format} of the candidate track.
* @param trackBitrate The estimated bitrate of the track. May differ from {@link Format#bitrate} * @param trackBitrate The estimated bitrate of the track. May differ from {@link Format#bitrate}
* if a more accurate estimate of the current track bitrate is available. * if a more accurate estimate of the current track bitrate is available.
* @param playbackSpeed The current factor by which playback is sped up.
* @param effectiveBitrate The bitrate available to this selection. * @param effectiveBitrate The bitrate available to this selection.
* @return Whether this {@link Format} can be selected. * @return Whether this {@link Format} can be selected.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected boolean canSelectFormat( protected boolean canSelectFormat(Format format, int trackBitrate, long effectiveBitrate) {
Format format, int trackBitrate, float playbackSpeed, long effectiveBitrate) { return trackBitrate <= effectiveBitrate;
return Math.round(trackBitrate * playbackSpeed) <= effectiveBitrate;
} }
/** /**
...@@ -468,7 +466,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -468,7 +466,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (nowMs == Long.MIN_VALUE || !isBlacklisted(i, nowMs)) { if (nowMs == Long.MIN_VALUE || !isBlacklisted(i, nowMs)) {
Format format = getFormat(i); Format format = getFormat(i);
if (canSelectFormat(format, format.bitrate, playbackSpeed, effectiveBitrate)) { if (canSelectFormat(format, format.bitrate, effectiveBitrate)) {
return i; return i;
} else { } else {
lowestBitrateAllowedIndex = i; lowestBitrateAllowedIndex = i;
...@@ -487,7 +485,8 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { ...@@ -487,7 +485,8 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
} }
private long getAllocatedBandwidth() { private long getAllocatedBandwidth() {
long totalBandwidth = (long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction); long totalBandwidth =
(long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction / playbackSpeed);
if (adaptationCheckpoints.isEmpty()) { if (adaptationCheckpoints.isEmpty()) {
return totalBandwidth; return totalBandwidth;
} }
......
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