MediaCodecVideoRenderer.Builder


class MediaCodecVideoRenderer.Builder


A builder to create MediaCodecVideoRenderer instances.

Summary

Public constructors

Builder(context: Context!)

Creates a new builder.

Public functions

MediaCodecVideoRenderer!

Builds the MediaCodecVideoRenderer.

MediaCodecVideoRenderer.Builder!

Sets whether the BUFFER_FLAG_DECODE_ONLY flag will be included when queuing decode-only input buffers to the decoder.

MediaCodecVideoRenderer.Builder!

Sets the late threshold for rendered output buffers, in microseconds, after which decoder input buffers may be dropped.

MediaCodecVideoRenderer.Builder!

Sets whether VIDEO_AV1 bitstream parsing for sample dependency information is enabled.

MediaCodecVideoRenderer.Builder!

Sets the maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.

MediaCodecVideoRenderer.Builder!
@CanIgnoreReturnValue
setAssumedMinimumCodecOperatingRate(
    assumedMinimumCodecOperatingRate: Float
)

Sets a codec operating rate that all codecs instantiated by this renderer are assumed to meet implicitly (i.e. without the operating rate being set explicitly using KEY_OPERATING_RATE).

MediaCodecVideoRenderer.Builder!

Sets the MediaCodecAdapter.Factory used to create MediaCodecAdapter instances.

MediaCodecVideoRenderer.Builder!

Sets whether to enable fallback to lower-priority decoders if decoder initialization fails.

MediaCodecVideoRenderer.Builder!

Sets whether the getDurationToProgressUs is enabled.

MediaCodecVideoRenderer.Builder!

Sets a handler to use when delivering events to eventListener.

MediaCodecVideoRenderer.Builder!

Sets a listener for VideoRendererEventListener events.

MediaCodecVideoRenderer.Builder!

Sets the maximum number of frames that can be dropped between invocations of onDroppedFrames.

MediaCodecVideoRenderer.Builder!

Sets the decoder selector.

MediaCodecVideoRenderer.Builder!

Sets a VideoSink to consume the frames.

Public constructors

Builder

Builder(context: Context!)

Creates a new builder.

Parameters
context: Context!

A context.

Public functions

build

fun build(): MediaCodecVideoRenderer!

Builds the MediaCodecVideoRenderer. Must only be called once per Builder instance.

Throws IllegalStateException if the event handler and the event listener are neither both null nor both non- null.

experimentalSetEnableMediaCodecBufferDecodeOnlyFlag

@RequiresApi(value = 34)
@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetEnableMediaCodecBufferDecodeOnlyFlag(
    enableMediaCodecBufferDecodeOnlyFlag: Boolean
): MediaCodecVideoRenderer.Builder!

Sets whether the BUFFER_FLAG_DECODE_ONLY flag will be included when queuing decode-only input buffers to the decoder.

If false, then only if the decoder is set up in tunneling mode will decode-only input buffers be queued with the BUFFER_FLAG_DECODE_ONLY flag. The default value is false.

Requires API 34.

This method is experimental and will be renamed or removed in a future release.

experimentalSetLateThresholdToDropDecoderInputUs

@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetLateThresholdToDropDecoderInputUs(
    lateThresholdToDropDecoderInputUs: Long
): MediaCodecVideoRenderer.Builder!

Sets the late threshold for rendered output buffers, in microseconds, after which decoder input buffers may be dropped.

The default value is DEFAULT_LATE_THRESHOLD_TO_DROP_DECODER_INPUT_US and therefore input buffers that are predicted to be rendered late will be dropped.

If TIME_UNSET is passed, decoder input buffers will not be dropped.

This method is experimental and will be renamed or removed in a future release.

Parameters
lateThresholdToDropDecoderInputUs: Long

The threshold in microseconds to drop decoder input buffers, or TIME_UNSET to disable dropping decoder input buffers.

experimentalSetParseAv1SampleDependencies

@CanIgnoreReturnValue
@ExperimentalApi
fun experimentalSetParseAv1SampleDependencies(
    parseAv1SampleDependencies: Boolean
): MediaCodecVideoRenderer.Builder!

Sets whether VIDEO_AV1 bitstream parsing for sample dependency information is enabled. Knowing which input frames are not depended on can speed up seeking and reduce dropped frames.

Defaults to true.

This method is experimental and will be renamed or removed in a future release.

setAllowedJoiningTimeMs

@CanIgnoreReturnValue
fun setAllowedJoiningTimeMs(allowedJoiningTimeMs: Long): MediaCodecVideoRenderer.Builder!

Sets the maximum duration in milliseconds for which this video renderer can attempt to seamlessly join an ongoing playback.

setAssumedMinimumCodecOperatingRate

@CanIgnoreReturnValue
fun setAssumedMinimumCodecOperatingRate(
    assumedMinimumCodecOperatingRate: Float
): MediaCodecVideoRenderer.Builder!

Sets a codec operating rate that all codecs instantiated by this renderer are assumed to meet implicitly (i.e. without the operating rate being set explicitly using KEY_OPERATING_RATE).

setCodecAdapterFactory

@CanIgnoreReturnValue
fun setCodecAdapterFactory(codecAdapterFactory: MediaCodecAdapter.Factory!): MediaCodecVideoRenderer.Builder!

Sets the MediaCodecAdapter.Factory used to create MediaCodecAdapter instances.

setEnableDecoderFallback

@CanIgnoreReturnValue
fun setEnableDecoderFallback(enableDecoderFallback: Boolean): MediaCodecVideoRenderer.Builder!

Sets whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.

setEnableDurationToProgressUs

@CanIgnoreReturnValue
@ExperimentalApi
fun setEnableDurationToProgressUs(enableDurationToProgressUs: Boolean): MediaCodecVideoRenderer.Builder!

Sets whether the getDurationToProgressUs is enabled.

When ExoPlayer's dynamic scheduling is enabled, ExoPlayer uses getDurationToProgressUs to better align when it wakes the CPU with when player progress can be made.

If true, then if the MediaCodec decoder is set up in asynchronous mode with a registered MediaCodec.Callback listener, getDurationToProgressUs will return durations based on the next output frame's presentation time. This will increase CPU Idle time thereby reducing power consumption. The default value is false.

This method is experimental and will be renamed or removed in a future release.

setEventHandler

@CanIgnoreReturnValue
fun setEventHandler(eventHandler: Handler?): MediaCodecVideoRenderer.Builder!

Sets a handler to use when delivering events to eventListener.

The event handler and event listener are linked in that both should be set to either null or non-null values.

setEventListener

@CanIgnoreReturnValue
fun setEventListener(eventListener: VideoRendererEventListener?): MediaCodecVideoRenderer.Builder!

Sets a listener for VideoRendererEventListener events.

The event handler and event listener are linked in that both should be set to either null or non-null values.

setMaxDroppedFramesToNotify

@CanIgnoreReturnValue
fun setMaxDroppedFramesToNotify(maxDroppedFramesToNotify: Int): MediaCodecVideoRenderer.Builder!

Sets the maximum number of frames that can be dropped between invocations of onDroppedFrames.

setVideoSink

@CanIgnoreReturnValue
fun setVideoSink(videoSink: VideoSink?): MediaCodecVideoRenderer.Builder!

Sets a VideoSink to consume the frames.

If a VideoSink is not set and effects are set, a VideoSink produced by a PlaybackVideoGraphWrapper with its default configuration will be used to apply effects and render the frames on the output.