# BandwidthEstimator

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator.java+class:androidx.media3.exoplayer.upstream.experimental.BandwidthEstimator)

*** ** * ** ***


```
@UnstableApi
public interface BandwidthEstimator
```

<br />

Known direct subclasses [CombinedParallelSampleBandwidthEstimator](https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/CombinedParallelSampleBandwidthEstimator), [SplitParallelSampleBandwidthEstimator](https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/SplitParallelSampleBandwidthEstimator)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/CombinedParallelSampleBandwidthEstimator` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator` that captures a transfer sample each time all parallel transfers end. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/SplitParallelSampleBandwidthEstimator` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator` that captures a transfer sample each time a transfer ends. |

*** ** * ** ***

The interface for different bandwidth estimation strategies.

## Summary

| ### Constants |
|---|---|
| `default static final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE() = -9223372036854775808` |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#addEventListener(android.os.Handler,androidx.media3.exoplayer.upstream.BandwidthMeter.EventListener)( https://developer.android.com/reference/android/os/Handler.html eventHandler, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener eventListener )` Adds an `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener`. |
| `abstract long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#getBandwidthEstimate()()` Returns the bandwidth estimate in bits per second, or `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE()` if there is no estimate available yet. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#onBytesTransferred(androidx.media3.datasource.DataSource,int)(https://developer.android.com/reference/androidx/media3/datasource/DataSource source, int bytesTransferred)` Called incrementally during a transfer. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#onNetworkTypeChange(long)(long newBandwidthEstimate)` Notifies this estimator that a network change has been detected. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#onTransferEnd(androidx.media3.datasource.DataSource)(https://developer.android.com/reference/androidx/media3/datasource/DataSource source)` Called when a transfer ends. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#onTransferInitializing(androidx.media3.datasource.DataSource)(https://developer.android.com/reference/androidx/media3/datasource/DataSource source)` Called when a transfer is being initialized. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#onTransferStart(androidx.media3.datasource.DataSource)(https://developer.android.com/reference/androidx/media3/datasource/DataSource source)` Called when a transfer starts. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#removeEventListener(androidx.media3.exoplayer.upstream.BandwidthMeter.EventListener)(https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener eventListener)` Removes an `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/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 `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html eventHandler` | A handler for events. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener eventListener` | A listener of events. |

### getBandwidthEstimate

```
abstract long getBandwidthEstimate()
```

Returns the bandwidth estimate in bits per second, or `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthEstimator#ESTIMATE_NOT_AVAILABLE()` if there is no estimate available yet.

### onBytesTransferred

```
abstract void onBytesTransferred(DataSource source, int bytesTransferred)
```

Called incrementally during a transfer.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource source` | The `https://developer.android.com/reference/androidx/media3/datasource/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource source` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSource` performing the transfer. |

### onTransferInitializing

```
abstract void onTransferInitializing(DataSource source)
```

Called when a transfer is being initialized.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource source` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSource` performing the transfer. |

### onTransferStart

```
abstract void onTransferStart(DataSource source)
```

Called when a transfer starts.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSource source` | The `https://developer.android.com/reference/androidx/media3/datasource/DataSource` performing the transfer. |

### removeEventListener

```
abstract void removeEventListener(BandwidthMeter.EventListener eventListener)
```

Removes an `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener eventListener` | The listener to be removed. |