# ConstantRateTimestampIterator

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

*** ** * ** ***


```
@UnstableApi
public final class ConstantRateTimestampIterator implements TimestampIterator
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/common/util/TimestampIterator` that generates monotonically increasing timestamps (in microseconds) distributed evenly over the given `durationUs` based on the given `frameRate`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#ConstantRateTimestampIterator(long,float)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long durationUs, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float frameRate )` Creates an instance that outputs timestamps from `0`. |
| `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#ConstantRateTimestampIterator(long,long,float)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long startPositionUs, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long endPositionUs, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float frameRate )` Creates an instance that outputs timestamps from `startTimeUs`. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator` | `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#copyOf()()` Returns fresh copy of the iterator. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#getLastTimestampUs()()` Returns the last (final) timestamp this iterator generates, in microseconds. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#hasNext()()` Returns whether there is another element. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/util/ConstantRateTimestampIterator#next()()` Returns the next timestamp. |

## Public constructors

### ConstantRateTimestampIterator

```
public ConstantRateTimestampIterator(
    @IntRange(from = 1) long durationUs,
    @FloatRange(from = 0, fromInclusive = false) float frameRate
)
```

Creates an instance that outputs timestamps from `0`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long durationUs` | The duration the timestamps should span over, in microseconds. |
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float frameRate` | The frame rate in frames per second. |

### ConstantRateTimestampIterator

```
public ConstantRateTimestampIterator(
    @IntRange(from = 0) long startPositionUs,
    @IntRange(from = 1) long endPositionUs,
    @FloatRange(from = 0, fromInclusive = false) float frameRate
)
```

Creates an instance that outputs timestamps from `startTimeUs`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long startPositionUs` | The start position in microseconds. The first timestamp generated will be equal to `startPositionUs`. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long endPositionUs` | The end position at which the timestamps finish, in microseconds. The generated timestamps are less or equal to the end position. |
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float frameRate` | The frame rate in frames per second. |

## Public methods

### copyOf

```
public ConstantRateTimestampIterator copyOf()
```

Returns fresh copy of the iterator.

### getLastTimestampUs

```
public long getLastTimestampUs()
```

Returns the last (final) timestamp this iterator generates, in microseconds.

This method returns `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the last timestamp is unknown, or when no timestamp will be generated.

### hasNext

```
public boolean hasNext()
```

Returns whether there is another element.

### next

```
public long next()
```

Returns the next timestamp.