FixedFrameRateEstimator


@UnstableApi
public final class FixedFrameRateEstimator


Attempts to detect and refine a fixed frame rate estimate based on frame presentation timestamps.

Summary

Nested types

A listener for frame rate estimate updates.

Constants

static final int

The number of consecutive matching frame durations required to detect a fixed frame rate.

Public fields

long

Public constructors

Creates a new estimator.

Public methods

long

The currently detected fixed frame duration estimate in nanoseconds, or TIME_UNSET if the estimator has not detected a fixed frame rate.

long

Returns the current frame index.

void
onFormatChanged(float formatFrameRate)

Called when the output format changes.

void
onNextFrame(long framePresentationTimeNs)

Called with each frame presentation timestamp.

Constants

CONSECUTIVE_MATCHING_FRAME_DURATIONS_FOR_SYNC

public static final int CONSECUTIVE_MATCHING_FRAME_DURATIONS_FOR_SYNC = 15

The number of consecutive matching frame durations required to detect a fixed frame rate.

Public fields

frameIndex

public long frameIndex

Public constructors

FixedFrameRateEstimator

public FixedFrameRateEstimator(FixedFrameRateEstimator.Listener listener)

Creates a new estimator.

Parameters
FixedFrameRateEstimator.Listener listener

The listener to notify when the frame rate estimate changes.

Public methods

getFrameDurationNs

public long getFrameDurationNs()

The currently detected fixed frame duration estimate in nanoseconds, or TIME_UNSET if the estimator has not detected a fixed frame rate. Whilst synced, the estimate is refined each time onNextFrame is called with a new frame presentation timestamp.

getFrameIndex

public long getFrameIndex()

Returns the current frame index. The index increases monotonically for each new frame timestamp given to onNextFrame.

onFormatChanged

public void onFormatChanged(float formatFrameRate)

Called when the output format changes.

Parameters
float formatFrameRate

The format's frame rate, or NO_VALUE if unknown.

onNextFrame

public void onNextFrame(long framePresentationTimeNs)

Called with each frame presentation timestamp.

Parameters
long framePresentationTimeNs

The frame presentation timestamp, in nanoseconds.