SplitParallelSampleBandwidthEstimator


@UnstableApi
public class SplitParallelSampleBandwidthEstimator implements BandwidthEstimator


A BandwidthEstimator that captures a transfer sample each time a transfer ends. When parallel transfers are happening at the same time, the transferred bytes are aggregated in a single sample.

Summary

Nested types

A builder to create SplitParallelSampleBandwidthEstimator instances.

Public fields

long

Public methods

void
addEventListener(
    Handler eventHandler,
    BandwidthMeter.EventListener 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.

void
onBytesTransferred(DataSource source, int bytesTransferred)

Called incrementally during a transfer.

void
onNetworkTypeChange(long newBandwidthEstimate)

Notifies this estimator that a network change has been detected.

void

Called when a transfer ends.

void

Called when a transfer is being initialized.

void

Called when a transfer starts.

void

Removes an BandwidthMeter.EventListener.

Inherited Constants

From androidx.media3.exoplayer.upstream.experimental.BandwidthEstimator
static final long
ESTIMATE_NOT_AVAILABLE = -9223372036854775808

Public fields

bandwidthEstimate

public long bandwidthEstimate

Public methods

addEventListener

public 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

public long getBandwidthEstimate()

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

onBytesTransferred

public 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

public 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

public void onTransferEnd(DataSource source)

Called when a transfer ends.

Parameters
DataSource source

The DataSource performing the transfer.

onTransferInitializing

public void onTransferInitializing(DataSource source)

Called when a transfer is being initialized.

Parameters
DataSource source

The DataSource performing the transfer.

onTransferStart

public void onTransferStart(DataSource source)

Called when a transfer starts.

Parameters
DataSource source

The DataSource performing the transfer.

removeEventListener

public void removeEventListener(BandwidthMeter.EventListener eventListener)

Removes an BandwidthMeter.EventListener.

Parameters
BandwidthMeter.EventListener eventListener

The listener to be removed.