Skip to main content
Version: 14 Oct 2024

MLMediaCodecCallbacksEx

Module: Media Player

Callbacks for notifying asynchronously of various codec events to the user/client. If user intends to use codec in asynchronous mode, then the user/client is expected to implement these callbacks and take proper actions where appropriate. More...

#include <ml_media_codec.h>

Public Attributes

TypeName
uint32_tversion
void()(MLHandle media_codec, const MLMediaCodecInputBufferInfo info)on_input_buffer_available
This callback function is invoked when an input buffer becomes available.
void()(MLHandle media_codec, const MLMediaCodecOutputBufferInfo info)on_output_buffer_available
This callback function is invoked when an output buffer.
void()(MLHandle media_codec, const MLMediaCodecOutputFormatInfo info)on_output_format_changed
This callback function is invoked when the output format has changed.
void()(MLHandle media_codec, const MLMediaCodecErrorInfo info)on_error
This callback function is invoked when MLMediaCodec encountered an error.

Detailed Description

struct MLMediaCodecCallbacksEx;

Callbacks for notifying asynchronously of various codec events to the user/client. If user intends to use codec in asynchronous mode, then the user/client is expected to implement these callbacks and take proper actions where appropriate.

Deprecated

Deprecated since 1.4.0. Scheduled for removal.

API Level:

  • 20

Public Attributes Documentation

version

uint32_t version;

Version of this structure.


on_input_buffer_available

void(*)(MLHandle media_codec, const MLMediaCodecInputBufferInfo *info) on_input_buffer_available;

This callback function is invoked when an input buffer becomes available.

TypeDescription
void()(MLHandle media_codec, const MLMediaCodecInputBufferInfo info))(MLHandle media_codec, const MLMediaCodecInputBufferInfo *info)

Parameters

media_codecMLMediaCodec instance for which callback was called.
infoInput buffer info as MLMediaCodecInputBufferInfo().

This should not be set to NULL as codec will not function properly if client has no means to specify incoming input buffers.

note

Client should not call MLMediaCodec APIs from within this callback but rather set internal flags or use synchronization mechanisms to wake up another thread that will queue encoded data into decoder.


on_output_buffer_available

void(*)(MLHandle media_codec, const MLMediaCodecOutputBufferInfo *info) on_output_buffer_available;

This callback function is invoked when an output buffer.

TypeDescription
void()(MLHandle media_codec, const MLMediaCodecOutputBufferInfo info))(MLHandle media_codec, const MLMediaCodecOutputBufferInfo *info)

Parameters

media_codecMLMediaCodec instance for which callback was called.
infoOutput buffer info as MLMediaCodecOutputBufferInfo.

This should not be set to NULL as codec will not function properly. Typical implementation on on_output_buffer_available is simply to 1) render the buffer to audio subsystem [if codec is audio] 2) release-and-render-to-surface with MLMediaCodecReleaseOutputBuffer(.., true) [if codec is video].

note

Client should not call MLMediaCodec APIs from within this callback but rather set internal flags or use synchronization mechanisms to wake up another thread that will dequeue and release the buffer.


on_output_format_changed

void(*)(MLHandle media_codec, const MLMediaCodecOutputFormatInfo *info) on_output_format_changed;

This callback function is invoked when the output format has changed.

TypeDescription
void()(MLHandle media_codec, const MLMediaCodecOutputFormatInfo info))(MLHandle media_codec, const MLMediaCodecOutputFormatInfo *info)

Parameters

media_codecMLMediaCodec instance for which callback was called.
infoOutput format info as MLMediaCodecOutputFormatInfo.

This can be set to NULL if client is not interested in receiving this callback.

note

Client should not call MLMediaCodec APIs from within this callback but rather set internal flags or use synchronization mechanisms to wake up another thread that will handle the change.


on_error

void(*)(MLHandle media_codec, const MLMediaCodecErrorInfo *info) on_error;

This callback function is invoked when MLMediaCodec encountered an error.

TypeDescription
void()(MLHandle media_codec, const MLMediaCodecErrorInfo info))(MLHandle media_codec, const MLMediaCodecErrorInfo *info)

Parameters

media_codecMLMediaCodec instance for which callback was called.
infoCodec error info as MLMediaCodecErrorInfo.

This can be set to NULL if client is not interested in receiving this callback.

note

Client should not call MLMediaCodec APIs from within this callback.