DefaultMediaCodecAdapterFactory


@UnstableApi
public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter.Factory


The default MediaCodecAdapter.Factory.

By default, this factory createsAsynchronousMediaCodecAdapter instances on devices with API level >= 31 (Android 12+). For devices with older API versions, the default behavior is to create SynchronousMediaCodecAdapter instances. The factory offers APIs to force the creation of AsynchronousMediaCodecAdapter (applicable for devices with API >= 23) or SynchronousMediaCodecAdapter instances.

Summary

Public constructors

This method is deprecated.

Use DefaultMediaCodecAdapterFactory instead.

Creates the default media codec adapter factory.

Public methods

MediaCodecAdapter

Creates a MediaCodecAdapter instance.

DefaultMediaCodecAdapterFactory

Sets whether to enable CONFIGURE_FLAG_USE_CRYPTO_ASYNC on API 34 and above for AsynchronousMediaCodecAdapter instances.

DefaultMediaCodecAdapterFactory

Forces the factory to always create SynchronousMediaCodecAdapter instances.

DefaultMediaCodecAdapterFactory

Forces this factory to always create AsynchronousMediaCodecAdapter instances, provided the device API level is >= 23.

Inherited Constants

From androidx.media3.exoplayer.mediacodec.MediaCodecAdapter.Factory
static final MediaCodecAdapter.Factory

This field is deprecated.

Use getDefault instead.

Inherited methods

From androidx.media3.exoplayer.mediacodec.MediaCodecAdapter.Factory
static MediaCodecAdapter.Factory

Returns the default factory that should be used in most cases.

Public constructors

DefaultMediaCodecAdapterFactory

public DefaultMediaCodecAdapterFactory()

DefaultMediaCodecAdapterFactory

public DefaultMediaCodecAdapterFactory(Context context)

Creates the default media codec adapter factory.

Parameters
Context context

A Context.

Public methods

createAdapter

public MediaCodecAdapter createAdapter(MediaCodecAdapter.Configuration configuration)

Creates a MediaCodecAdapter instance.

experimentalSetAsyncCryptoFlagEnabled

@CanIgnoreReturnValue
public DefaultMediaCodecAdapterFactory experimentalSetAsyncCryptoFlagEnabled(boolean enableAsyncCryptoFlag)

Sets whether to enable CONFIGURE_FLAG_USE_CRYPTO_ASYNC on API 34 and above for AsynchronousMediaCodecAdapter instances.

This method is experimental. Its default value may change, or it may be renamed or removed in a future release.

forceDisableAsynchronous

@CanIgnoreReturnValue
public DefaultMediaCodecAdapterFactory forceDisableAsynchronous()

Forces the factory to always create SynchronousMediaCodecAdapter instances.

Returns
DefaultMediaCodecAdapterFactory

This factory, for convenience.

forceEnableAsynchronous

@CanIgnoreReturnValue
public DefaultMediaCodecAdapterFactory forceEnableAsynchronous()

Forces this factory to always create AsynchronousMediaCodecAdapter instances, provided the device API level is >= 23. For devices with API level <23, the factory will create SynchronousMediaCodecAdapters.

Returns
DefaultMediaCodecAdapterFactory

This factory, for convenience.