# BandwidthMeter

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/BandwidthMeter.java+class:androidx.media3.exoplayer.upstream.BandwidthMeter)

*** ** * ** ***


```
@UnstableApi
interface BandwidthMeter
```

<br />

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

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter` | Estimates bandwidth by listening to data transfers. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/experimental/ExperimentalBandwidthMeter` | An experimental `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` that estimates bandwidth by listening to data transfers. |

*** ** * ** ***

Provides estimates of the currently available bandwidth.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener` A listener of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` events. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener.EventDispatcher` Event dispatcher which allows listener registration. |

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#NO_OP()` A no-op `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` that doesn't do estimation. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#addEventListener(android.os.Handler,androidx.media3.exoplayer.upstream.BandwidthMeter.EventListener)( eventHandler: https://developer.android.com/reference/android/os/Handler.html!, eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener! )` Adds an `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#getBitrateEstimate()()` Returns the estimated bitrate. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#getTimeToFirstByteEstimateUs()()` Returns the estimated time to first byte, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if no estimate is available. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#getTransferListener()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener` that this instance uses to gather bandwidth information from data transfers. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter#removeEventListener(androidx.media3.exoplayer.upstream.BandwidthMeter.EventListener)(eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener!)` Removes an `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter.EventListener`. |

## Constants

### NO_OP

```
const val NO_OP: BandwidthMeter!
```

A no-op `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter` that doesn't do estimation.

## Public functions

### addEventListener

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

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

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

### getBitrateEstimate

```
fun getBitrateEstimate(): Long
```

Returns the estimated bitrate.

### getTimeToFirstByteEstimateUs

```
fun getTimeToFirstByteEstimateUs(): Long
```

Returns the estimated time to first byte, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if no estimate is available.

### getTransferListener

```
fun getTransferListener(): TransferListener?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener` that this instance uses to gather bandwidth information from data transfers. May be null if the implementation does not listen to data transfers.

### removeEventListener

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

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

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