mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
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
This commit is contained in:
parent
e14180e532
commit
7c8ab133e9
1 changed files with 5 additions and 6 deletions
|
|
@ -422,14 +422,12 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
|||
* @param format The {@link Format} of the candidate track.
|
||||
* @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.
|
||||
* @param playbackSpeed The current factor by which playback is sped up.
|
||||
* @param effectiveBitrate The bitrate available to this selection.
|
||||
* @return Whether this {@link Format} can be selected.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected boolean canSelectFormat(
|
||||
Format format, int trackBitrate, float playbackSpeed, long effectiveBitrate) {
|
||||
return Math.round(trackBitrate * playbackSpeed) <= effectiveBitrate;
|
||||
protected boolean canSelectFormat(Format format, int trackBitrate, long effectiveBitrate) {
|
||||
return trackBitrate <= effectiveBitrate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -468,7 +466,7 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
|||
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)) {
|
||||
if (canSelectFormat(format, format.bitrate, effectiveBitrate)) {
|
||||
return i;
|
||||
} else {
|
||||
lowestBitrateAllowedIndex = i;
|
||||
|
|
@ -487,7 +485,8 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
|||
}
|
||||
|
||||
private long getAllocatedBandwidth() {
|
||||
long totalBandwidth = (long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction);
|
||||
long totalBandwidth =
|
||||
(long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction / playbackSpeed);
|
||||
if (adaptationCheckpoints.isEmpty()) {
|
||||
return totalBandwidth;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue