DefaultDecoderFactory


@UnstableApi
class DefaultDecoderFactory : Codec.DecoderFactory


Default implementation of Codec.DecoderFactory that uses MediaCodec for decoding.

Summary

Nested types

A builder for DefaultDecoderFactory instances.

Listener for decoder factory events.

Public constructors

This function is deprecated.

Use Builder instead.

DefaultDecoderFactory(
    context: Context!,
    enableDecoderFallback: Boolean,
    listener: DefaultDecoderFactory.Listener!
)

This function is deprecated.

Use Builder instead.

Public functions

DefaultCodec!

Returns a Codec for audio decoding.

DefaultCodec!
createForVideoDecoding(
    format: Format!,
    outputSurface: Surface!,
    requestSdrToneMapping: Boolean
)

Returns a Codec for video decoding.

Boolean

Returns whether decoder dynamic scheduling is enabled.

Public constructors

DefaultDecoderFactory

DefaultDecoderFactory(context: Context!)

DefaultDecoderFactory

DefaultDecoderFactory(
    context: Context!,
    enableDecoderFallback: Boolean,
    listener: DefaultDecoderFactory.Listener!
)

Creates a new factory that selects the most preferred decoder, optionally falling back to less preferred decoders if initialization fails.

Parameters
context: Context!

The context.

enableDecoderFallback: Boolean

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

listener: DefaultDecoderFactory.Listener!

Listener for codec initialization errors.

Public functions

createForAudioDecoding

fun createForAudioDecoding(format: Format!): DefaultCodec!

Returns a Codec for audio decoding.

Parameters
format: Format!

The Format (of the input data) used to determine the underlying decoder and its configuration values.

Returns
DefaultCodec!

A Codec for audio decoding.

Throws
androidx.media3.transformer.ExportException

If no suitable Codec can be created.

createForVideoDecoding

fun createForVideoDecoding(
    format: Format!,
    outputSurface: Surface!,
    requestSdrToneMapping: Boolean
): DefaultCodec!

Returns a Codec for video decoding.

Parameters
format: Format!

The Format (of the input data) used to determine the underlying decoder and its configuration values.

outputSurface: Surface!

The Surface to which the decoder output is rendered.

requestSdrToneMapping: Boolean

Whether to request tone-mapping to SDR.

Returns
DefaultCodec!

A Codec for video decoding.

Throws
androidx.media3.transformer.ExportException

If no suitable Codec can be created.

isDynamicSchedulingEnabled

fun isDynamicSchedulingEnabled(): Boolean

Returns whether decoder dynamic scheduling is enabled.

See experimentalSetDynamicSchedulingEnabled.