# BandwidthStatistic

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

*** ** * ** ***


```
@UnstableApi
public interface BandwidthStatistic
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageStatistic` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic` that calculates estimates using an exponential weighted average. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/SlidingPercentileBandwidthStatistic` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic` that calculates estimates based on a sliding window weighted percentile. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/SlidingWeightedAverageBandwidthStatistic` | A `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic` that calculates estimates based on a sliding window weighted average. |

*** ** * ** ***

The interface for different bandwidth estimation statistics.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic#addSample(long,long)(long bytes, long durationUs)` Adds a transfer sample to the statistic. |
| `abstract long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/BandwidthStatistic#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/BandwidthStatistic#reset()()` Resets the statistic. |

## Public methods

### addSample

```
abstract void addSample(long bytes, long durationUs)
```

Adds a transfer sample to the statistic.

| Parameters |
|---|---|
| `long bytes` | The number of bytes transferred. |
| `long durationUs` | The duration of the transfer, in microseconds. |

### 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.

### reset

```
abstract void reset()
```

Resets the statistic. The statistic should drop all samples and reset to its initial state, similar to right after construction.