# ExponentialWeightedAverageTimeToFirstByteEstimator

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

*** ** * ** ***


```
@UnstableApi
public final class ExponentialWeightedAverageTimeToFirstByteEstimator implements TimeToFirstByteEstimator
```

<br />

*** ** * ** ***

Implementation of `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator` based on exponential weighted average.

## Summary

| ### Constants |
|---|---|
| `static final double` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#DEFAULT_SMOOTHING_FACTOR() = 0.85` The default smoothing factor. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#ExponentialWeightedAverageTimeToFirstByteEstimator()()` Creates an instance using the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#DEFAULT_SMOOTHING_FACTOR()`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#ExponentialWeightedAverageTimeToFirstByteEstimator(double)( double smoothingFactor )` Creates an instance. |

| ### Public methods |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#getTimeToFirstByteEstimateUs()()` Returns the estimated time to first byte of the response body, in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if no estimate is available. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#onTransferInitializing(androidx.media3.datasource.DataSpec)(https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec)` Called when a transfer is being initialized. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#onTransferStart(androidx.media3.datasource.DataSpec)(https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec)` Called when a transfer starts. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#reset()()` Resets the estimator. |

## Constants

### DEFAULT_SMOOTHING_FACTOR

```
public static final double DEFAULT_SMOOTHING_FACTOR = 0.85
```

The default smoothing factor.

## Public constructors

### ExponentialWeightedAverageTimeToFirstByteEstimator

```
public ExponentialWeightedAverageTimeToFirstByteEstimator()
```

Creates an instance using the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator#DEFAULT_SMOOTHING_FACTOR()`.

### ExponentialWeightedAverageTimeToFirstByteEstimator

```
public ExponentialWeightedAverageTimeToFirstByteEstimator(
    double smoothingFactor
)
```

Creates an instance.

| Parameters |
|---|---|
| `double smoothingFactor` | The exponential weighted average smoothing factor. |

## Public methods

### getTimeToFirstByteEstimateUs

```
public long getTimeToFirstByteEstimateUs()
```

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

### onTransferInitializing

```
public void onTransferInitializing(DataSpec dataSpec)
```

Called when a transfer is being initialized.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec` | Describes the data for which the transfer is initialized. |

### onTransferStart

```
public void onTransferStart(DataSpec dataSpec)
```

Called when a transfer starts.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec` | Describes the data being transferred. |

### reset

```
public void reset()
```

Resets the estimator.