mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add experimental option to subtract non-allocatable bandwidth.
This allows to account for bandwidth used by fixed track selections. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=222383736
This commit is contained in:
parent
10eaa7d748
commit
1699fbfa74
1 changed files with 20 additions and 1 deletions
|
|
@ -380,6 +380,18 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
||||||
this.trackBitrateEstimator = trackBitrateEstimator;
|
this.trackBitrateEstimator = trackBitrateEstimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the non-allocatable bandwidth, which shouldn't be considered available.
|
||||||
|
*
|
||||||
|
* <p>This method is experimental, and will be renamed or removed in a future release.
|
||||||
|
*
|
||||||
|
* @param nonAllocatableBandwidth The non-allocatable bandwidth in bits per second.
|
||||||
|
*/
|
||||||
|
public void experimental_setNonAllocatableBandwidth(long nonAllocatableBandwidth) {
|
||||||
|
((DefaultBandwidthProvider) bandwidthProvider)
|
||||||
|
.experimental_setNonAllocatableBandwidth(nonAllocatableBandwidth);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
public void enable() {
|
||||||
lastBufferEvaluationMs = C.TIME_UNSET;
|
lastBufferEvaluationMs = C.TIME_UNSET;
|
||||||
|
|
@ -571,6 +583,8 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
||||||
private final BandwidthMeter bandwidthMeter;
|
private final BandwidthMeter bandwidthMeter;
|
||||||
private final float bandwidthFraction;
|
private final float bandwidthFraction;
|
||||||
|
|
||||||
|
private long nonAllocatableBandwidth;
|
||||||
|
|
||||||
/* package */ DefaultBandwidthProvider(BandwidthMeter bandwidthMeter, float bandwidthFraction) {
|
/* package */ DefaultBandwidthProvider(BandwidthMeter bandwidthMeter, float bandwidthFraction) {
|
||||||
this.bandwidthMeter = bandwidthMeter;
|
this.bandwidthMeter = bandwidthMeter;
|
||||||
this.bandwidthFraction = bandwidthFraction;
|
this.bandwidthFraction = bandwidthFraction;
|
||||||
|
|
@ -578,7 +592,12 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getAllocatedBandwidth() {
|
public long getAllocatedBandwidth() {
|
||||||
return (long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction);
|
long totalBandwidth = (long) (bandwidthMeter.getBitrateEstimate() * bandwidthFraction);
|
||||||
|
return Math.max(0L, totalBandwidth - nonAllocatableBandwidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* package */ void experimental_setNonAllocatableBandwidth(long nonAllocatableBandwidth) {
|
||||||
|
this.nonAllocatableBandwidth = nonAllocatableBandwidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue