MediaCodecVideoRenderer.Builder


public final class MediaCodecVideoRenderer.Builder


A builder to create MediaCodecVideoRenderer instances.

Summary

Public constructors

Builder(Context context)

Creates a new builder.

Public methods

MediaCodecVideoRenderer

Builds the MediaCodecVideoRenderer.

MediaCodecVideoRenderer.Builder

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

MediaCodecVideoRenderer.Builder
@CanIgnoreReturnValue
setAllowedJoiningTimeMs(long allowedJoiningTimeMs)

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

MediaCodecVideoRenderer.Builder
@CanIgnoreReturnValue
setAssumedMinimumCodecOperatingRate(
    float assumedMinimumCodecOperatingRate
)

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 the threshold for how early a frame may be scheduled for release on the surface.

MediaCodecVideoRenderer.Builder
@CanIgnoreReturnValue
setEnableDecoderFallback(boolean enableDecoderFallback)

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

MediaCodecVideoRenderer.Builder

Sets a handler to use when delivering events to eventListener.

MediaCodecVideoRenderer.Builder

Sets a listener for VideoRendererEventListener events.

MediaCodecVideoRenderer.Builder
@CanIgnoreReturnValue
setMaxDroppedFramesToNotify(int maxDroppedFramesToNotify)

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

MediaCodecVideoRenderer.Builder

Sets the decoder selector.

MediaCodecVideoRenderer.Builder
@CanIgnoreReturnValue
setSkipBuffersWithIdenticalReleaseTime(
    boolean skipBuffersWithIdenticalReleaseTime
)

Sets whether to skip buffers that have an identical release time as the previous released buffer.

MediaCodecVideoRenderer.Builder

Sets a VideoSink to consume the frames.

Public constructors

Builder

public Builder(Context context)

Creates a new builder.

Parameters
Context context

A context.

Public methods

build

public MediaCodecVideoRenderer build()

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.

experimentalSetLateThresholdToDropDecoderInputUs

@CanIgnoreReturnValue
@ExperimentalApi
public MediaCodecVideoRenderer.Builder experimentalSetLateThresholdToDropDecoderInputUs(
    long lateThresholdToDropDecoderInputUs
)

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
long lateThresholdToDropDecoderInputUs

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

setAllowedJoiningTimeMs

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setAllowedJoiningTimeMs(long allowedJoiningTimeMs)

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

setAssumedMinimumCodecOperatingRate

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setAssumedMinimumCodecOperatingRate(
    float assumedMinimumCodecOperatingRate
)

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
public MediaCodecVideoRenderer.Builder setCodecAdapterFactory(MediaCodecAdapter.Factory codecAdapterFactory)

Sets the MediaCodecAdapter.Factory used to create MediaCodecAdapter instances.

setEarlySchedulingThresholdUs

@CanIgnoreReturnValue
@ExperimentalApi
public MediaCodecVideoRenderer.Builder setEarlySchedulingThresholdUs(long earlySchedulingThresholdUs)

Sets the threshold for how early a frame may be scheduled for release on the surface.

This value is in microseconds. The default value is DEFAULT_EARLY_SCHEDULING_THRESHOLD_US.

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

Parameters
long earlySchedulingThresholdUs

The maximum early time threshold in microseconds.

setEnableDecoderFallback

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setEnableDecoderFallback(boolean enableDecoderFallback)

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.

setEventHandler

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setEventHandler(@Nullable Handler eventHandler)

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
public MediaCodecVideoRenderer.Builder setEventListener(@Nullable VideoRendererEventListener eventListener)

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
public MediaCodecVideoRenderer.Builder setMaxDroppedFramesToNotify(int maxDroppedFramesToNotify)

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

setSkipBuffersWithIdenticalReleaseTime

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setSkipBuffersWithIdenticalReleaseTime(
    boolean skipBuffersWithIdenticalReleaseTime
)

Sets whether to skip buffers that have an identical release time as the previous released buffer.

Parameters
boolean skipBuffersWithIdenticalReleaseTime

Whether to skip buffers with identical release time.

Returns
MediaCodecVideoRenderer.Builder

This builder.

setVideoSink

@CanIgnoreReturnValue
public MediaCodecVideoRenderer.Builder setVideoSink(@Nullable VideoSink videoSink)

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.