# TimeToFirstByteEstimator

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

*** ** * ** ***


```
@UnstableApi
public interface TimeToFirstByteEstimator
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/ExponentialWeightedAverageTimeToFirstByteEstimator` | Implementation of `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator` based on exponential weighted average. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/experimental/PercentileTimeToFirstByteEstimator` | Implementation of `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator` that returns a configured percentile of a sliding window of collected response times. |

*** ** * ** ***

Provides an estimate of the time to first byte of a transfer.

## Summary

| ### Public methods |
|---|---|
| `abstract long` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator#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. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator#onTransferInitializing(androidx.media3.datasource.DataSpec)(https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec)` Called when a transfer is being initialized. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator#onTransferStart(androidx.media3.datasource.DataSpec)(https://developer.android.com/reference/androidx/media3/datasource/DataSpec dataSpec)` Called when a transfer starts. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/TimeToFirstByteEstimator#reset()()` Resets the estimator. |

## Public methods

### getTimeToFirstByteEstimateUs

```
abstract 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

```
abstract 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

```
abstract 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

```
abstract void reset()
```

Resets the estimator.