native_avcodec_audioencoder.h

Overview

Declares the native APIs used for audio encoding.

Since: 9

Related Modules:

AudioEncoder

Summary

Functions

Name Description
OH_AudioEncoder_CreateByMime (const char *mime) Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases.
OH_AudioEncoder_CreateByName (const char *name) Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder.
OH_AudioEncoder_Destroy (OH_AVCodec *codec) Clears the internal resources of an audio encoder and destroys the audio encoder instance.
OH_AudioEncoder_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 encoder. This API must be called prior to Prepare.
OH_AudioEncoder_Configure (OH_AVCodec *codec, OH_AVFormat *format) Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to Prepare.
OH_AudioEncoder_Prepare (OH_AVCodec *codec) Prepares internal resources for an audio encoder. This API must be called after Configure.
OH_AudioEncoder_Start (OH_AVCodec *codec) Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the OH_AVCodecOnNeedInputData event.
OH_AudioEncoder_Stop (OH_AVCodec *codec) Stops an audio encoder. After the encoder is stopped, you can call Start to start it again.
OH_AudioEncoder_Flush (OH_AVCodec *codec) Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required.
OH_AudioEncoder_Reset (OH_AVCodec *codec) Resets an audio encoder. To continue encoding, you must call Configure and Start to configure and start the encoder again.
OH_AudioEncoder_GetOutputDescription (OH_AVCodec *codec) Obtains the attributes of the output data of an audio encoder. The caller must manually release the OH_AVFormat instance in the return value.
OH_AudioEncoder_SetParameter (OH_AVCodec *codec, OH_AVFormat *format) Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure.
OH_AudioEncoder_PushInputData (OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr) Pushes the input buffer filled with data to an audio encoder. The OH_AVCodecOnNeedInputData callback reports available input buffers and their indexes. 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.
OH_AudioEncoder_FreeOutputData (OH_AVCodec *codec, uint32_t index) Frees an output buffer of an audio encoder.