VideoRendererEventListener


@UnstableApi
public interface VideoRendererEventListener


Listener of video Renderer events. All methods have no-op default implementations to allow selective overrides.

Summary

Nested types

Dispatches events to a VideoRendererEventListener.

Public methods

default void
onDroppedFrames(int count, long elapsedMs)

Called to report the number of frames dropped by the renderer.

default void
onRenderedFirstFrame(Object output, long renderTimeMs)

Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.

default void
onVideoCodecError(Exception videoCodecError)

Called when a video decoder encounters an error.

default void
onVideoDecoderInitialized(
    String decoderName,
    long initializedTimestampMs,
    long initializationDurationMs
)

Called when a decoder is created.

default void

Called when a decoder is released.

default void

Called when the renderer is disabled.

default void

Called when the renderer is enabled.

default void
onVideoFrameProcessingOffset(
    long totalProcessingOffsetUs,
    int frameCount
)

Called to report the video processing offset of video frames processed by the video renderer.

default void

This method is deprecated.

Use onVideoInputFormatChanged.

default void
onVideoInputFormatChanged(
    Format format,
    @Nullable DecoderReuseEvaluation decoderReuseEvaluation
)

Called when the format of the media being consumed by the renderer changes.

default void

Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size, rotation or pixel aspect ratio of the video being rendered.

Public methods

onDroppedFrames

default void onDroppedFrames(int count, long elapsedMs)

Called to report the number of frames dropped by the renderer. Dropped frames are reported whenever the renderer is stopped having dropped frames, and optionally, whenever the count reaches a specified threshold whilst the renderer is started.

Parameters
int count

The number of dropped frames.

long elapsedMs

The duration in milliseconds over which the frames were dropped. This duration is timed from when the renderer was started or from when dropped frames were last reported (whichever was more recent), and not from when the first of the reported drops occurred.

onRenderedFirstFrame

default void onRenderedFirstFrame(Object output, long renderTimeMs)

Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.

Parameters
Object output

The output of the video renderer. Normally a Surface, however some video renderers may have other output types (e.g., a VideoDecoderOutputBufferRenderer).

long renderTimeMs

The elapsedRealtime when the frame was rendered.

onVideoCodecError

default void onVideoCodecError(Exception videoCodecError)

Called when a video decoder encounters an error.

This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error. Hence applications should not implement this method to display a user visible error or initiate an application level retry. onPlayerError is the appropriate place to implement such behavior. This method is called to provide the application with an opportunity to log the error if it wishes to do so.

Parameters
Exception videoCodecError

The error. Typically a CodecException if the renderer uses MediaCodec, or a DecoderException if the renderer uses a software decoder.

onVideoDecoderInitialized

default void onVideoDecoderInitialized(
    String decoderName,
    long initializedTimestampMs,
    long initializationDurationMs
)

Called when a decoder is created.

Parameters
String decoderName

The decoder that was created.

long initializedTimestampMs

elapsedRealtime when initialization finished.

long initializationDurationMs

The time taken to initialize the decoder in milliseconds.

onVideoDecoderReleased

default void onVideoDecoderReleased(String decoderName)

Called when a decoder is released.

Parameters
String decoderName

The decoder that was released.

onVideoDisabled

default void onVideoDisabled(DecoderCounters counters)

Called when the renderer is disabled.

Parameters
DecoderCounters counters

DecoderCounters that were updated by the renderer.

onVideoEnabled

default void onVideoEnabled(DecoderCounters counters)

Called when the renderer is enabled.

Parameters
DecoderCounters counters

DecoderCounters that will be updated by the renderer for as long as it remains enabled.

onVideoFrameProcessingOffset

default void onVideoFrameProcessingOffset(
    long totalProcessingOffsetUs,
    int frameCount
)

Called to report the video processing offset of video frames processed by the video renderer.

Video processing offset represents how early a video frame is processed compared to the player's current position. For each video frame, the offset is calculated as Pvf - Ppl where Pvf is the presentation timestamp of the video frame and Ppl is the current position of the player. Positive values indicate the frame was processed early enough whereas negative values indicate that the player's position had progressed beyond the frame's timestamp when the frame was processed (and the frame was probably dropped).

The renderer reports the sum of video processing offset samples (one sample per processed video frame: dropped, skipped or rendered) and the total number of samples.

Parameters
long totalProcessingOffsetUs

The sum of all video frame processing offset samples for the video frames processed by the renderer in microseconds.

int frameCount

The number of samples included in the totalProcessingOffsetUs.

onVideoInputFormatChanged

default void onVideoInputFormatChanged(Format format)

onVideoInputFormatChanged

default void onVideoInputFormatChanged(
    Format format,
    @Nullable DecoderReuseEvaluation decoderReuseEvaluation
)

Called when the format of the media being consumed by the renderer changes.

Parameters
Format format

The new format.

@Nullable DecoderReuseEvaluation decoderReuseEvaluation

The result of the evaluation to determine whether an existing decoder instance can be reused for the new format, or null if the renderer did not have a decoder.

onVideoSizeChanged

default void onVideoSizeChanged(VideoSize videoSize)

Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size, rotation or pixel aspect ratio of the video being rendered.

Parameters
VideoSize videoSize

The new size of the video.