mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
@Override
|
||||||
public synchronized void onTransferStart(
|
public synchronized void onTransferStart(
|
||||||
DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
||||||
if (!isNetwork) {
|
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (streamCount == 0) {
|
if (streamCount == 0) {
|
||||||
|
|
@ -338,7 +338,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onBytesTransferred(
|
public synchronized void onBytesTransferred(
|
||||||
DataSource source, DataSpec dataSpec, boolean isNetwork, int bytes) {
|
DataSource source, DataSpec dataSpec, boolean isNetwork, int bytes) {
|
||||||
if (!isNetwork) {
|
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sampleBytesTransferred += bytes;
|
sampleBytesTransferred += bytes;
|
||||||
|
|
@ -346,7 +346,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
public synchronized void onTransferEnd(DataSource source, DataSpec dataSpec, boolean isNetwork) {
|
||||||
if (!isNetwork) {
|
if (!isTransferAtFullNetworkSpeed(dataSpec, isNetwork)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assertions.checkState(streamCount > 0);
|
Assertions.checkState(streamCount > 0);
|
||||||
|
|
@ -420,6 +420,10 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList
|
||||||
return initialBitrateEstimate;
|
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
|
* 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).
|
* be made non-static, since doing so adds a strong reference (i.e. DefaultBandwidthMeter.this).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue