public class DefaultBandwidthMeter
extends java.lang.Object
The bandwidth estimate is calculated using a SlidingPercentile and is updated each
time a transfer ends. The initial estimate is based on the current operator's network country
code or the locale of the user, as well as the network connection type. This can be configured in
the DefaultBandwidthMeter.Builder.
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultBandwidthMeter.Builder
Builder for a bandwidth meter.
|
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_INITIAL_BITRATE_ESTIMATE
Default initial bitrate estimate used when the device is offline or the network type cannot be
determined, in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_2G
Default initial 2G bitrate estimates in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_3G
Default initial 3G bitrate estimates in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
Default initial 4G bitrate estimates in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_NSA
Default initial 5G-NSA bitrate estimates in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_SA
Default initial 5G-SA bitrate estimates in bits per second.
|
static <any> |
DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
Default initial Wifi bitrate estimate in bits per second.
|
static int |
DEFAULT_SLIDING_WINDOW_MAX_WEIGHT
Default maximum weight for the sliding window.
|
static float |
DEFAULT_SLIDING_WINDOW_PERCENTILE
Default percentile for the sliding window.
|
| Constructor and Description |
|---|
DefaultBandwidthMeter()
Deprecated.
Use
DefaultBandwidthMeter.Builder instead. |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(android.os.Handler eventHandler,
EventListener eventListener) |
void |
addSample(int dataSize,
int sampleElapsedTimeMs) |
long |
getBitrateEstimate() |
static DefaultBandwidthMeter |
getSingletonInstance(android.content.Context context)
Returns a singleton instance of a
DefaultBandwidthMeter with default configuration. |
TransferListener |
getTransferListener() |
void |
onBytesTransferred(DataSource source,
DataSpec dataSpec,
boolean isNetwork,
int bytesTransferred) |
void |
onTransferEnd(DataSource source,
DataSpec dataSpec,
boolean isNetwork) |
void |
onTransferInitializing(DataSource source,
DataSpec dataSpec,
boolean isNetwork) |
void |
onTransferStart(DataSource source,
DataSpec dataSpec,
boolean isNetwork) |
void |
removeEventListener(EventListener eventListener) |
void |
setNetworkTypeOverride(int networkType)
Overrides the network type.
|
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_WIFI
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_2G
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_3G
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_4G
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_NSA
public static final <any> DEFAULT_INITIAL_BITRATE_ESTIMATES_5G_SA
public static final long DEFAULT_INITIAL_BITRATE_ESTIMATE
public static final int DEFAULT_SLIDING_WINDOW_MAX_WEIGHT
public static final float DEFAULT_SLIDING_WINDOW_PERCENTILE
@Deprecated public DefaultBandwidthMeter()
DefaultBandwidthMeter.Builder instead.public static DefaultBandwidthMeter getSingletonInstance(android.content.Context context)
DefaultBandwidthMeter with default configuration.context - A Context.public void setNetworkTypeOverride(int networkType)
Applications should not normally call this method. It is intended for testing purposes.
networkType - The overriding network type.public long getBitrateEstimate()
public TransferListener getTransferListener()
public void addEventListener(android.os.Handler eventHandler,
EventListener eventListener)
public void removeEventListener(EventListener eventListener)
public void onTransferInitializing(DataSource source,
DataSpec dataSpec,
boolean isNetwork)
public void onTransferStart(DataSource source,
DataSpec dataSpec,
boolean isNetwork)
public void onBytesTransferred(DataSource source,
DataSpec dataSpec,
boolean isNetwork,
int bytesTransferred)
public void onTransferEnd(DataSource source,
DataSpec dataSpec,
boolean isNetwork)
public void addSample(int dataSize,
int sampleElapsedTimeMs)