Commit 71036a69 by tonihei Committed by Oliver Woodman

Ignore throttled network requests in DefaultBandwidthMeter.

These are not useful for estimating the network speed and should be
ignored.

PiperOrigin-RevId: 285400948
parent 2edf9857
......@@ -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).
......
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