BandwidthEstimator


@UnstableApi
public interface BandwidthEstimator

Known direct subclasses
CombinedParallelSampleBandwidthEstimator

A BandwidthEstimator that captures a transfer sample each time all parallel transfers end.

SplitParallelSampleBandwidthEstimator

A BandwidthEstimator that captures a transfer sample each time a transfer ends.


The interface for different bandwidth estimation strategies.

Summary

Constants

default static final long
ESTIMATE_NOT_AVAILABLE = -9223372036854775808

Public methods

abstract void
addEventListener(
    Handler eventHandler,
    BandwidthMeter.EventListener eventListener
)

Adds an BandwidthMeter.EventListener.

abstract long

Returns the bandwidth estimate in bits per second, or ESTIMATE_NOT_AVAILABLE if there is no estimate available yet.

abstract void
onBytesTransferred(DataSource source, int bytesTransferred)

Called incrementally during a transfer.

abstract void
onNetworkTypeChange(long newBandwidthEstimate)

Notifies this estimator that a network change has been detected.

abstract void

Called when a transfer ends.

abstract void

Called when a transfer is being initialized.

abstract void

Called when a transfer starts.

abstract void

Removes an BandwidthMeter.EventListener.

Constants

ESTIMATE_NOT_AVAILABLE

default static final long ESTIMATE_NOT_AVAILABLE = -9223372036854775808

Public methods

addEventListener

abstract void addEventListener(
    Handler eventHandler,
    BandwidthMeter.EventListener eventListener
)

Adds an BandwidthMeter.EventListener.

Parameters
Handler eventHandler

A handler for events.

BandwidthMeter.EventListener eventListener

A listener of events.

getBandwidthEstimate

abstract long getBandwidthEstimate()

Returns the bandwidth estimate in bits per second, or ESTIMATE_NOT_AVAILABLE if there is no estimate available yet.

onBytesTransferred

abstract void onBytesTransferred(DataSource source, int bytesTransferred)

Called incrementally during a transfer.

Parameters
DataSource source

The DataSource performing the transfer.

int bytesTransferred

The number of bytes transferred since the previous call to this method

onNetworkTypeChange

abstract void onNetworkTypeChange(long newBandwidthEstimate)

Notifies this estimator that a network change has been detected.

Parameters
long newBandwidthEstimate

The new initial bandwidth estimate based on network type.

onTransferEnd

abstract void onTransferEnd(DataSource source)

Called when a transfer ends.

Parameters
DataSource source

The DataSource performing the transfer.

onTransferInitializing

abstract void onTransferInitializing(DataSource source)

Called when a transfer is being initialized.

Parameters
DataSource source

The DataSource performing the transfer.

onTransferStart

abstract void onTransferStart(DataSource source)

Called when a transfer starts.

Parameters
DataSource source

The DataSource performing the transfer.

removeEventListener

abstract void removeEventListener(BandwidthMeter.EventListener eventListener)

Removes an BandwidthMeter.EventListener.

Parameters
BandwidthMeter.EventListener eventListener

The listener to be removed.