BandwidthEstimator


@UnstableApi
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

const Long
ESTIMATE_NOT_AVAILABLE = -9223372036854775808

Public functions

Unit
addEventListener(
    eventHandler: Handler!,
    eventListener: BandwidthMeter.EventListener!
)

Adds an BandwidthMeter.EventListener.

Long

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

Unit
onBytesTransferred(source: DataSource!, bytesTransferred: Int)

Called incrementally during a transfer.

Unit
onNetworkTypeChange(newBandwidthEstimate: Long)

Notifies this estimator that a network change has been detected.

Unit

Called when a transfer ends.

Unit

Called when a transfer is being initialized.

Unit

Called when a transfer starts.

Unit

Removes an BandwidthMeter.EventListener.

Constants

ESTIMATE_NOT_AVAILABLE

const val ESTIMATE_NOT_AVAILABLE = -9223372036854775808: Long

Public functions

addEventListener

fun addEventListener(
    eventHandler: Handler!,
    eventListener: BandwidthMeter.EventListener!
): Unit

Adds an BandwidthMeter.EventListener.

Parameters
eventHandler: Handler!

A handler for events.

eventListener: BandwidthMeter.EventListener!

A listener of events.

getBandwidthEstimate

fun getBandwidthEstimate(): Long

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

onBytesTransferred

fun onBytesTransferred(source: DataSource!, bytesTransferred: Int): Unit

Called incrementally during a transfer.

Parameters
source: DataSource!

The DataSource performing the transfer.

bytesTransferred: Int

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

onNetworkTypeChange

fun onNetworkTypeChange(newBandwidthEstimate: Long): Unit

Notifies this estimator that a network change has been detected.

Parameters
newBandwidthEstimate: Long

The new initial bandwidth estimate based on network type.

onTransferEnd

fun onTransferEnd(source: DataSource!): Unit

Called when a transfer ends.

Parameters
source: DataSource!

The DataSource performing the transfer.

onTransferInitializing

fun onTransferInitializing(source: DataSource!): Unit

Called when a transfer is being initialized.

Parameters
source: DataSource!

The DataSource performing the transfer.

onTransferStart

fun onTransferStart(source: DataSource!): Unit

Called when a transfer starts.

Parameters
source: DataSource!

The DataSource performing the transfer.

removeEventListener

fun removeEventListener(eventListener: BandwidthMeter.EventListener!): Unit

Removes an BandwidthMeter.EventListener.

Parameters
eventListener: BandwidthMeter.EventListener!

The listener to be removed.