ConstantRateTimestampIterator


@UnstableApi
public final class ConstantRateTimestampIterator implements TimestampIterator


A TimestampIterator that generates monotonically increasing timestamps (in microseconds) distributed evenly over the given durationUs based on the given frameRate.

Summary

Public constructors

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

Creates an instance that outputs timestamps from 0.

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.

Public methods

ConstantRateTimestampIterator

Returns fresh copy of the iterator.

long

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

boolean

Returns whether there is another element.

long

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
@IntRange(from = 1) long durationUs

The duration the timestamps should span over, in microseconds.

@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
@IntRange(from = 0) long startPositionUs

The start position in microseconds. The first timestamp generated will be equal to startPositionUs.

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

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