Back to Exoplayer

MediaCodecAdapter (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/mediacodec/MediaCodecAdapter.html

latest16.7 KB
Original Source

Package com.google.android.exoplayer2.mediacodec

Interface MediaCodecAdapter

  • All Known Implementing Classes:SynchronousMediaCodecAdapter

[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public interfaceMediaCodecAdapter

Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.

Abstracts MediaCodec operations.

MediaCodecAdapter offers a common interface to interact with a MediaCodec regardless of the mode the MediaCodec is operating in.

Nested Class Summary

Nested Classes | Modifier and Type | Interface | Description | | --- | --- | --- | | static class | MediaCodecAdapter.Configuration | Deprecated.

Configuration parameters for a MediaCodecAdapter. | | static interface | MediaCodecAdapter.Factory | Deprecated.

A factory for MediaCodecAdapter instances. | | static interface | MediaCodecAdapter.OnFrameRenderedListener | Deprecated.

Listener to be called when an output frame has rendered on the output surface. |

Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | int | dequeueInputBufferIndex() | Deprecated.

Returns the next available input buffer index from the underlying MediaCodec or MediaCodec.INFO_TRY_AGAIN_LATER if no such buffer exists. | | int | dequeueOutputBufferIndex​(MediaCodec.BufferInfo bufferInfo) | Deprecated.

Returns the next available output buffer index from the underlying MediaCodec. | | void | flush() | Deprecated.

Flushes the adapter and the underlying MediaCodec. | | ByteBuffer | getInputBuffer​(int index) | Deprecated.

Returns a writable ByteBuffer object for a dequeued input buffer index. | | PersistableBundle | getMetrics() | Deprecated.

Returns metrics data about the current codec instance. | | ByteBuffer | getOutputBuffer​(int index) | Deprecated.

Returns a read-only ByteBuffer for a dequeued output buffer index. | | MediaFormat | getOutputFormat() | Deprecated.

Gets the MediaFormat that was output from the MediaCodec. | | boolean | needsReconfiguration() | Deprecated.

Whether the adapter needs to be reconfigured before it is used. | | void | queueInputBuffer​(int index, int offset, int size, long presentationTimeUs, int flags) | Deprecated.

Submit an input buffer for decoding. | | void | queueSecureInputBuffer​(int index, int offset, CryptoInfo info, long presentationTimeUs, int flags) | Deprecated.

Submit an input buffer that is potentially encrypted for decoding. | | void | release() | Deprecated.

Releases the adapter and the underlying MediaCodec. | | void | releaseOutputBuffer​(int index, boolean render) | Deprecated.

Returns the buffer to the MediaCodec. | | void | releaseOutputBuffer​(int index, long renderTimeStampNs) | Deprecated.

Updates the output buffer's surface timestamp and sends it to the MediaCodec to render it on the output surface. | | void | setOnFrameRenderedListener​(MediaCodecAdapter.OnFrameRenderedListener listener, Handler handler) | Deprecated.

Registers a callback to be invoked when an output frame is rendered on the output surface. | | void | setOutputSurface​(Surface surface) | Deprecated.

Dynamically sets the output surface of a MediaCodec. | | void | setParameters​(Bundle params) | Deprecated.

Communicate additional parameter changes to the MediaCodec instance. | | void | setVideoScalingMode​(@com.google.android.exoplayer2.C.VideoScalingMode int scalingMode) | Deprecated.

Specifies the scaling mode to use, if a surface was specified when the codec was created. |

Method Detail

- 

dequeueInputBufferIndex

int dequeueInputBufferIndex()

Deprecated.

Returns the next available input buffer index from the underlying MediaCodec or MediaCodec.INFO_TRY_AGAIN_LATER if no such buffer exists. Throws:IllegalStateException - If the underlying MediaCodec raised an error.

- 

dequeueOutputBufferIndex

int dequeueOutputBufferIndex​([MediaCodec.BufferInfo](https://developer.android.com/reference/android/media/MediaCodec.BufferInfo.html "class or interface in android.media")bufferInfo)

Deprecated.

Returns the next available output buffer index from the underlying MediaCodec. If the next available output is a MediaFormat change, it will return MediaCodec.INFO_OUTPUT_FORMAT_CHANGED and you should call getOutputFormat() to get the format. If there is no available output, this method will return MediaCodec.INFO_TRY_AGAIN_LATER. Throws:IllegalStateException - If the underlying MediaCodec raised an error.

- 

getOutputFormat

[MediaFormat](https://developer.android.com/reference/android/media/MediaFormat.html "class or interface in android.media")getOutputFormat()

Deprecated.

Gets the MediaFormat that was output from the MediaCodec.

Call this method if a previous call to dequeueOutputBufferIndex(android.media.MediaCodec.BufferInfo) returned MediaCodec.INFO_OUTPUT_FORMAT_CHANGED.

- 

getInputBuffer

@Nullable[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html "class or interface in java.nio")getInputBuffer​(int index)

Deprecated.

Returns a writable ByteBuffer object for a dequeued input buffer index. See Also:MediaCodec.getInputBuffer(int)

- 

getOutputBuffer

@Nullable[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html "class or interface in java.nio")getOutputBuffer​(int index)

Deprecated.

Returns a read-only ByteBuffer for a dequeued output buffer index. See Also:MediaCodec.getOutputBuffer(int)

- 

queueInputBuffer

void queueInputBuffer​(int index,
                      int offset,
                      int size,
                      long presentationTimeUs,
                      int flags)

Deprecated.

Submit an input buffer for decoding.

The index must be an input buffer index that has been obtained from a previous call to dequeueInputBufferIndex().

See Also:MediaCodec.queueInputBuffer(int, int, int, long, int)

- 

queueSecureInputBuffer

void queueSecureInputBuffer​(int index,
                            int offset,[CryptoInfo](../decoder/CryptoInfo.html "class in com.google.android.exoplayer2.decoder")info,
                            long presentationTimeUs,
                            int flags)

Deprecated.

Submit an input buffer that is potentially encrypted for decoding.

The index must be an input buffer index that has been obtained from a previous call to dequeueInputBufferIndex().

This method behaves like MediaCodec.queueSecureInputBuffer(int, int, android.media.MediaCodec.CryptoInfo, long, int), with the difference that info is of type CryptoInfo and not MediaCodec.CryptoInfo.

See Also:MediaCodec.queueSecureInputBuffer(int, int, android.media.MediaCodec.CryptoInfo, long, int)

- 

releaseOutputBuffer

void releaseOutputBuffer​(int index,
                         boolean render)

Deprecated.

Returns the buffer to the MediaCodec. If the MediaCodec was configured with an output surface, setting render to true will first send the buffer to the output surface. The surface will release the buffer back to the codec once it is no longer used/displayed. See Also:MediaCodec.releaseOutputBuffer(int, boolean)

- 

releaseOutputBuffer

@RequiresApi(21)
void releaseOutputBuffer​(int index,
                         long renderTimeStampNs)

Deprecated.

Updates the output buffer's surface timestamp and sends it to the MediaCodec to render it on the output surface. If the MediaCodec is not configured with an output surface, this call will simply return the buffer to the MediaCodec. See Also:MediaCodec.releaseOutputBuffer(int, long)

- 

flush

void flush()

Deprecated.

Flushes the adapter and the underlying MediaCodec.

- 

release

void release()

Deprecated.

Releases the adapter and the underlying MediaCodec.

- 

setOnFrameRenderedListener

@RequiresApi(23)
void setOnFrameRenderedListener​([MediaCodecAdapter.OnFrameRenderedListener](MediaCodecAdapter.OnFrameRenderedListener.html "interface in com.google.android.exoplayer2.mediacodec")listener,[Handler](https://developer.android.com/reference/android/os/Handler.html "class or interface in android.os")handler)

Deprecated.

Registers a callback to be invoked when an output frame is rendered on the output surface. See Also:MediaCodec.setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener, android.os.Handler)

- 

setOutputSurface

@RequiresApi(23)
void setOutputSurface​([Surface](https://developer.android.com/reference/android/view/Surface.html "class or interface in android.view")surface)

Deprecated.

Dynamically sets the output surface of a MediaCodec. See Also:MediaCodec.setOutputSurface(Surface)

- 

setParameters

@RequiresApi(19)
void setParameters​([Bundle](https://developer.android.com/reference/android/os/Bundle.html "class or interface in android.os")params)

Deprecated.

Communicate additional parameter changes to the MediaCodec instance. See Also:MediaCodec.setParameters(Bundle)

- 

setVideoScalingMode

void setVideoScalingMode​([@VideoScalingMode](../C.VideoScalingMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.C.VideoScalingMode int scalingMode)

Deprecated.

Specifies the scaling mode to use, if a surface was specified when the codec was created. See Also:MediaCodec.setVideoScalingMode(int)

- 

needsReconfiguration

boolean needsReconfiguration()

Deprecated.

Whether the adapter needs to be reconfigured before it is used.

- 

getMetrics

@RequiresApi(26)[PersistableBundle](https://developer.android.com/reference/android/os/PersistableBundle.html "class or interface in android.os")getMetrics()

Deprecated.

Returns metrics data about the current codec instance. See Also:MediaCodec.getMetrics()