Class DefaultMediaCodecAdapterFactory
- java.lang.Object
-
- com.google.android.exoplayer2.mediacodec.DefaultMediaCodecAdapterFactory
-
- All Implemented Interfaces:
MediaCodecAdapter.Factory
public final class DefaultMediaCodecAdapterFactory extends Object implements MediaCodecAdapter.Factory
The defaultMediaCodecAdapter.Factory.By default, this factory
createsAsynchronousMediaCodecAdapterinstances on devices with API level >= 31 (Android 12+). For devices with older API versions, the default behavior is to createSynchronousMediaCodecAdapterinstances. The factory offers APIs to force the creation ofAsynchronousMediaCodecAdapter(applicable for devices with API >= 23) orSynchronousMediaCodecAdapterinstances.
-
-
Field Summary
-
Fields inherited from interface com.google.android.exoplayer2.mediacodec.MediaCodecAdapter.Factory
DEFAULT
-
-
Constructor Summary
Constructors Constructor Description DefaultMediaCodecAdapterFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MediaCodecAdaptercreateAdapter(MediaCodecAdapter.Configuration configuration)Creates aMediaCodecAdapterinstance.voidexperimentalSetImmediateCodecStartAfterFlushEnabled(boolean enabled)Enable callingMediaCodec.start()immediately afterMediaCodec.flush()on the playback thread, when operating the codec in asynchronous mode.voidexperimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(boolean enabled)Enable synchronizing codec interactions with asynchronous buffer queueing.DefaultMediaCodecAdapterFactoryforceDisableAsynchronous()Forces the factory to always createSynchronousMediaCodecAdapterinstances.DefaultMediaCodecAdapterFactoryforceEnableAsynchronous()Forces this factory to always createAsynchronousMediaCodecAdapterinstances, provided the device API level is >= 23.
-
-
-
Method Detail
-
forceEnableAsynchronous
public DefaultMediaCodecAdapterFactory forceEnableAsynchronous()
Forces this factory to always createAsynchronousMediaCodecAdapterinstances, provided the device API level is >= 23. For devices with API level < 23, the factory will createSynchronousMediaCodecAdapters.- Returns:
- This factory, for convenience.
-
forceDisableAsynchronous
public DefaultMediaCodecAdapterFactory forceDisableAsynchronous()
Forces the factory to always createSynchronousMediaCodecAdapterinstances.- Returns:
- This factory, for convenience.
-
experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled
public void experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(boolean enabled)
Enable synchronizing codec interactions with asynchronous buffer queueing.This method is experimental, and will be renamed or removed in a future release.
- Parameters:
enabled- Whether codec interactions will be synchronized with asynchronous buffer queueing.
-
experimentalSetImmediateCodecStartAfterFlushEnabled
public void experimentalSetImmediateCodecStartAfterFlushEnabled(boolean enabled)
Enable callingMediaCodec.start()immediately afterMediaCodec.flush()on the playback thread, when operating the codec in asynchronous mode. If disabled,MediaCodec.start()will be called by the callback thread after pending callbacks are handled.By default, this feature is enabled.
This method is experimental, and will be renamed or removed in a future release.
- Parameters:
enabled- WhetherMediaCodec.start()will be called on the playback thread immediately afterMediaCodec.flush().
-
createAdapter
public MediaCodecAdapter createAdapter(MediaCodecAdapter.Configuration configuration) throws IOException
Description copied from interface:MediaCodecAdapter.FactoryCreates aMediaCodecAdapterinstance.- Specified by:
createAdapterin interfaceMediaCodecAdapter.Factory- Throws:
IOException
-
-