native_avcodec_audiodecoder.h
Overview
The file declares the native APIs used for audio decoding.
File to include: <multimedia/player_framework/native_avcodec_audiodecoder.h>
Library: libnative_media_adec.so
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Development suggestions: All APIs of the current module have been deprecated. You can use native_avcodec_audiocodec.h instead. For details about the API mappings before and after the deprecation, see the API reference.
Related module: AudioDecoder
Summary
Functions
| Name | Description |
|---|---|
| OH_AVCodec *OH_AudioDecoder_CreateByMime(const char *mime) | Creates an audio decoder instance based on a MIME type. This function is recommended in most cases. (It is deprecated from API version 11.) |
| OH_AVCodec *OH_AudioDecoder_CreateByName(const char *name) | Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Destroy(OH_AVCodec *codec) | Clears the internal resources of an audio decoder and destroys the decoder instance. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This function must be called prior to Prepare. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format) | Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container. This function must be called prior to Prepare. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Prepare(OH_AVCodec *codec) | Prepares internal resources for an audio decoder. This function must be called after Configure. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Start(OH_AVCodec *codec) | Starts an audio decoder after it is prepared successfully. After being started, the decoder starts to report the OH_AVCodecOnNeedInputData event. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Stop(OH_AVCodec *codec) | Stops an audio decoder. After the decoder is stopped, you can call Start to start it again. If you have passed specific data in the previous Start for the decoder, you must pass it again. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Flush(OH_AVCodec *codec) | Clears the input and output data in the internal buffer of an audio decoder. This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_Reset(OH_AVCodec *codec) | Resets an audio decoder. To continue decoding, you must call Configure to configure the decoder again. (It is deprecated from API version 11.) |
| OH_AVFormat *OH_AudioDecoder_GetOutputDescription(OH_AVCodec *codec) | Obtains the description information about the output data of an audio decoder. The caller must manually release the OH_AVFormat instance in the return value. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format) | Sets dynamic parameters for an audio decoder. This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr) | Notifies the audio decoder that the input data has been written to the buffer identified by index. The OH_AVCodecOnNeedInputData callback reports the available input buffer and the index. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the OH_AVCodecOnNeedInputData callback. In addition, some decoders require the input of specific data to initialize the decoding process. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index) | Frees an output buffer of an audio decoder. (It is deprecated from API version 11.) |
| OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid) | Checks whether an audio decoder instance is valid. This function is used to check the decoder validity when the background recovers from a fault or an application is switched from the background. (It is deprecated from API version 11.) |
Function Description
OH_AudioDecoder_CreateByMime()
OH_AVCodec *OH_AudioDecoder_CreateByMime(const char *mime)
Description
Creates an audio decoder instance based on a MIME type. This function is recommended in most cases.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_CreateByMime
Parameters
| Name | Description |
|---|---|
| const char *mime | Pointer to a string that describes the MIME type. For details, see AVCODEC_MIMETYPE. |
Returns
| Type | Description |
|---|---|
| OH_AVCodec * | Pointer to an OH_AVCodec instance. |
OH_AudioDecoder_CreateByName()
OH_AVCodec *OH_AudioDecoder_CreateByName(const char *name)
Description
Creates an audio decoder instance based on a decoder name. To use this function, you must know the exact name of the decoder.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_CreateByName
Parameters
| Name | Description |
|---|---|
| const char *name | Pointer to an audio decoder name. |
Returns
| Type | Description |
|---|---|
| OH_AVCodec * | Pointer to an OH_AVCodec instance. |
OH_AudioDecoder_Destroy()
OH_AVErrCode OH_AudioDecoder_Destroy(OH_AVCodec *codec)
Description
Clears the internal resources of an audio decoder and destroys the decoder instance.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Destroy
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_SetCallback()
OH_AVErrCode OH_AudioDecoder_SetCallback(OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData)
Description
Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This function must be called prior to Prepare.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_RegisterCallback
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| OH_AVCodecAsyncCallback callback | Callback function. |
| void *userData | User-specific data. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Configure()
OH_AVErrCode OH_AudioDecoder_Configure(OH_AVCodec *codec, OH_AVFormat *format)
Description
Configures an audio decoder. Typically, you need to configure the audio description information that can be extracted from the container. This function must be called prior to Prepare.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Configure
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| OH_AVFormat *format | Pointer to the OH_AVFormat instance, which provides the description information about the audio track to be decoded. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Prepare()
OH_AVErrCode OH_AudioDecoder_Prepare(OH_AVCodec *codec)
Description
Prepares internal resources for an audio decoder. This function must be called after Configure.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Prepare
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Start()
OH_AVErrCode OH_AudioDecoder_Start(OH_AVCodec *codec)
Description
Starts an audio decoder after it is prepared successfully. After being started, the decoder starts to report the OH_AVCodecOnNeedInputData event.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Start
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Stop()
OH_AVErrCode OH_AudioDecoder_Stop(OH_AVCodec *codec)
Description
Stops an audio decoder.
After the decoder is stopped, you can call Start to start it again. If you have passed specific data in the previous Start for the decoder, you must pass it again.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Stop
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Flush()
OH_AVErrCode OH_AudioDecoder_Flush(OH_AVCodec *codec)
Description
Clears the input and output data in the internal buffer of an audio decoder.
This function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Flush
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_Reset()
OH_AVErrCode OH_AudioDecoder_Reset(OH_AVCodec *codec)
Description
Resets an audio decoder. To continue decoding, you must call Configure to configure the decoder again.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_Reset
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_GetOutputDescription()
OH_AVFormat *OH_AudioDecoder_GetOutputDescription(OH_AVCodec *codec)
Description
Obtains the description information about the output data of an audio decoder.
The caller must manually release the OH_AVFormat instance in the return value.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_GetOutputDescription
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
Returns
| Type | Description |
|---|---|
| OH_AVFormat * | Handle to an OH_AVFormat instance. The lifecycle of this instance is refreshed when GetOutputDescription is called again and destroyed when the OH_AVCodec instance is destroyed. |
OH_AudioDecoder_SetParameter()
OH_AVErrCode OH_AudioDecoder_SetParameter(OH_AVCodec *codec, OH_AVFormat *format)
Description
Sets dynamic parameters for an audio decoder.
This function can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_SetParameter
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| OH_AVFormat *format | Handle to an OH_AVFormat instance. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_PushInputData()
OH_AVErrCode OH_AudioDecoder_PushInputData(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr)
Description
Notifies the audio decoder that the input data has been written to the buffer identified by index.
The OH_AVCodecOnNeedInputData callback reports the available input buffer and the index. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the OH_AVCodecOnNeedInputData callback.
In addition, some decoders require the input of specific data to initialize the decoding process.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_PushInputBuffer
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| uint32_t index | Index of the input buffer. |
| OH_AVCodecBufferAttr attr | Description information about the data in the buffer. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_FreeOutputData()
OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index)
Description
Frees an output buffer of an audio decoder.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 9
Deprecated from: 11
Substitute: OH_AudioCodec_FreeOutputBuffer
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| uint32_t index | Index of the output buffer. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |
OH_AudioDecoder_IsValid()
OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid)
Description
Checks whether an audio decoder instance is valid. This function is used to check the decoder validity when the background recovers from a fault or an application is switched from the background.
System capability: SystemCapability.Multimedia.Media.AudioDecoder
Since: 10
Deprecated from: 11
Substitute: OH_AudioCodec_IsValid
Parameters
| Name | Description |
|---|---|
| OH_AVCodec *codec | Pointer to an OH_AVCodec instance. |
| bool *isValid | Pointer to an instance of the Boolean type. The value true means that the decoder instance is valid and false means the opposite. |
Returns
| Type | Description |
|---|---|
| OH_AVErrCode | AV_ERR_OK if the operation is successful; a specific error code otherwise. |