mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Ignore throttled network requests in DefaultBandwidthMeter.
These are not useful for estimating the network speed and should be ignored. PiperOrigin-RevId: 285400948
This commit is contained in:
parent
2edf985797
commit
71036a6973
1 changed files with 7 additions and 3 deletions
|
|
@ -326,7 +326,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
|||
@Override
|
||||
public synchronized void onTransferStart(
|
||||
DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
||||
if (!isNetwork) {
|
||||
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||
return;
|
||||
}
|
||||
if (streamCount == 0) {
|
||||
|
|
@ -338,7 +338,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
|||
@Override
|
||||
public synchronized void onBytesTransferred(
|
||||
DataSource source, DataSpec dataSpec, boolean isNetwork, int bytes) {
|
||||
if (!isNetwork) {
|
||||
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||
return;
|
||||
}
|
||||
sampleBytesTransferred += bytes;
|
||||
|
|
@ -346,7 +346,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
|||
|
||||
@Override
|
||||
public synchronized void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
||||
if (!isNetwork) {
|
||||
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||
return;
|
||||
}
|
||||
Assertions.checkState(streamCount > 0);
|
||||
|
|
@ -420,6 +420,10 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
|||
return initialBitrateEstimate;
|
||||
}
|
||||
|
||||
private static boolean isTransferAtFullNetworkSpeed(DataSpec dataSpec, boolean isNetwork) {
|
||||
return isNetwork && !dataSpec.isFlagSet(DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: This class only holds a weak reference to DefaultBandwidthMeter instances. It should not
|
||||
* be made non-static, since doing so adds a strong reference (i.e. DefaultBandwidthMeter.this).
|
||||
|
|
|
|||
Loading…
Reference in a new issue