DefaultDecoderFactory


@UnstableApi
class DefaultDecoderFactory : Codec.DecoderFactory


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

Summary

Nested types

Listener for decoder factory events.

Public constructors

Creates a new factory that selects the most preferred decoder for the format.

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.

Public functions

DefaultCodec!

Returns a Codec for audio decoding.

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

Returns a Codec for video decoding.

Public constructors

DefaultDecoderFactory

DefaultDecoderFactory(context: Context!)

Creates a new factory that selects the most preferred decoder for the format.

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.