VideoRendererEventListener


@UnstableApi
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 functions

Unit
onDroppedFrames(count: Int, elapsedMs: Long)

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

Unit
onRenderedFirstFrame(output: Any!, renderTimeMs: Long)

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.

Unit
onVideoCodecError(videoCodecError: Exception!)

Called when a video decoder encounters an error.

Unit
onVideoDecoderInitialized(
    decoderName: String!,
    initializedTimestampMs: Long,
    initializationDurationMs: Long
)

Called when a decoder is created.

Unit

Called when a decoder is released.

Unit

Called when the renderer is disabled.

Unit

Called when the renderer is enabled.

Unit
onVideoFrameProcessingOffset(
    totalProcessingOffsetUs: Long,
    frameCount: Int
)

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

Unit
onVideoInputFormatChanged(
    format: Format!,
    decoderReuseEvaluation: DecoderReuseEvaluation?
)

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

Unit

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 functions

onDroppedFrames

fun onDroppedFrames(count: Int, elapsedMs: Long): Unit

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
count: Int

The number of dropped frames.

elapsedMs: Long

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

fun onRenderedFirstFrame(output: Any!, renderTimeMs: Long): Unit

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
output: Any!

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

renderTimeMs: Long

The elapsedRealtime when the frame was rendered.

onVideoCodecError

fun onVideoCodecError(videoCodecError: Exception!): Unit

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
videoCodecError: Exception!

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

onVideoDecoderInitialized

fun onVideoDecoderInitialized(
    decoderName: String!,
    initializedTimestampMs: Long,
    initializationDurationMs: Long
): Unit

Called when a decoder is created.

Parameters
decoderName: String!

The decoder that was created.

initializedTimestampMs: Long

elapsedRealtime when initialization finished.

initializationDurationMs: Long

The time taken to initialize the decoder in milliseconds.

onVideoDecoderReleased

fun onVideoDecoderReleased(decoderName: String!): Unit

Called when a decoder is released.

Parameters
decoderName: String!

The decoder that was released.

onVideoDisabled

fun onVideoDisabled(counters: DecoderCounters!): Unit

Called when the renderer is disabled.

Parameters
counters: DecoderCounters!

DecoderCounters that were updated by the renderer.

onVideoEnabled

fun onVideoEnabled(counters: DecoderCounters!): Unit

Called when the renderer is enabled.

Parameters
counters: DecoderCounters!

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

onVideoFrameProcessingOffset

fun onVideoFrameProcessingOffset(
    totalProcessingOffsetUs: Long,
    frameCount: Int
): Unit

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
totalProcessingOffsetUs: Long

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

frameCount: Int

The number of samples included in the totalProcessingOffsetUs.

onVideoInputFormatChanged

fun onVideoInputFormatChanged(
    format: Format!,
    decoderReuseEvaluation: DecoderReuseEvaluation?
): Unit

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

Parameters
format: Format!

The new format.

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

fun onVideoSizeChanged(videoSize: VideoSize!): Unit

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.