/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved. * Description: IAPI header file for Huanglong audio encode module * Author: Hisilicon * Create: 2019-05-30 */ #ifndef __UAPI_AENC_H__ #define __UAPI_AENC_H__ #include "uapi_audio.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ #define UAPI_AENC_MAX_TYPE 1 /* AENC Capability Description */ /* CNcomment: 编码能力描述 */ typedef struct { uapi_acodec_id codec_type; /* support aenc type */ } uapi_aenc_cap_info; typedef struct { td_u32 support_type_num; /* support aenc type num */ td_u32 max_aenc_instance; /* maximum running aenc encoder */ uapi_aenc_cap_info cap_info[UAPI_AENC_MAX_TYPE]; /* capability information for each aenc type */ } uapi_aenc_cap; /* \brief Initializes audio encoder. CNcomment:初始化音频编码器 CNend \attention \n Call the interface before calling UAPI_AENC_Open. CNcomment:UAPI_AENC_Open接口前调用 CNend \param N/A \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::TD_FAILURE Failure CNcomment:失败 CNend \see \n N/A */ td_s32 uapi_aenc_init(td_void); /* \brief Deinitializes audio encoder. CNcomment:去初始化音频编码器 CNend \attention \n N/A \param N/A \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT Invalid operation CNcomment:SOC_ERR_AENC_CH_NOT_SUPPORT 无效的操作 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \see \n N/A */ td_s32 uapi_aenc_deinit(td_void); /* \brief Create audio encoder. CNcomment:创建音频编码器 CNend \attention \n Before calling the interface, you must configure the encoder. Now AENC only supports 16-bit and 2 channels, and support 16K, 22K, 24K, 32K, 44K, or 48Ksample rate. CNcomment:调用该接口前,必须配置编码器,目前AENC只支持16位2声道,且采样率为:16K 22K 24K 32K 44K和48K CNend \param[in] aenc_attr Attribute structure of the audio encoder. CNcomment:音频编码器属性结构 CNend \param[out] ph_aenc Obtain the handle of the audio encoder. CNcomment:得到音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::TD_FAILURE Failure CNcomment:失败 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \retval ::SOC_ERR_AENC_CREATECH_FAIL The encoder fails to be created. CNcomment:创建编码器失败 CNend \see \n N/A */ td_s32 uapi_aenc_create(const uapi_aenc_attr *aenc_attr, td_handle *aenc); /* \brief Destroy the audio encoder. CNcomment:销毁音频编码器 CNend \attention \n \param[in] aenc the handle of the audio encoder CNcomment:音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_CH_NOT_OPEN The audio encoder is not opened. CNcomment:音频编码器没有打开 CNend \see \n N/A */ td_s32 uapi_aenc_destroy(td_handle aenc); /* \brief Copy data to the encoder for encoding. CNcomment:向编码器拷贝数据以供编码 CNend \attention \n \param[in] aenc The audio encoder handle CNcomment:音频编码器句柄 CNend \param[in] ao_frame Send a frame of data to the encoder. CNcomment:向音频编码器送一帧数据 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_IN_BUF_FULL The input buffer of the encoder is full. CNcomment:编码器输入缓冲满 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \see \n N/A */ td_s32 uapi_aenc_send_frame(td_handle aenc, const uapi_audio_frame *ao_frame); /* \brief Obtain data from a output buffer of the encoder and write the data into the file. CNcomment:从编码器的一个输出缓冲中取出数据以供写入文件 CNend \attention \n \param[in] aenc The audio encoder handle CNcomment:音频编码器句柄 CNend \param[in] stream The data in a output buffer of the audio encoder CNcomment:音频编码器一个输出缓冲中的数据 CNend \param[in] timeout_ms allowable timeout CNcomment:获取编码数据允许的超时 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_OUT_BUF_EMPTY The output buffer of the encoder is empty. CNcomment:编码器输出缓冲为空 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \see \n N/A */ td_s32 uapi_aenc_acquire_stream(td_handle aenc, uapi_es_buf *stream, td_u32 timeout_ms); /* \brief Destroy the data in a output buffer of the encoder. CNcomment:销毁编码器一个输出缓冲中的数据 CNend \attention \n Call the interface after calling uapi_aenc_acquire_stream. CNcomment:在uapi_aenc_acquire_stream之后调用 CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \param[out] stream The data in a output buffer of the audio encoder CNcomment:音频编码器一个输出缓冲中的数据 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_OUT_BUF_BAD The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_IN_BUF_UNEMPTY The input buffer is empty. CNcomment:输入缓冲非空 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \see \n N/A */ td_s32 uapi_aenc_release_stream(td_handle aenc, const uapi_es_buf *stream); /* \brief Register dynamic audio encoding libraries. CNcomment:注册音频动态编码库 CNend \attention \n \param[in] encoder_name The file name of audio encoding library CNcomment:encoder_name 音频编码库文件名 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::TD_FAILURE Failure CNcomment:失败 CNend \see \n N/A */ td_s32 uapi_aenc_register_encoder(const td_char *encoder_name); /* \brief Attach audio encoder with audio track. CNcomment:绑定音频编码器和音频Track 通路 CNend \attention \n Before obtaining the streams and encoding, you must call the interface. CNcomment:开始编码和获取码流之前需要首先调用该接口 CNend \param[in] src The handle of audio track CNcomment:资源句柄 CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \retval ::SOC_ERR_AVPLAY_INVALID_OPT The operation is invalid. CNcomment:操作非法 CNend \see \n N/A */ td_s32 uapi_aenc_attach_input(td_handle aenc, td_handle src); /* \brief Detach audio encoder with audio track. CNcomment:解除音频编码器和音频Track 通路的绑定 CNend \attention \n Before calling the interface, stop the encoding. CNcomment:调用该接口需要首先停止编码 CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_CH_NOT_SUPPORT The operation is invalid. CNcomment:无效的操作 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \retval ::SOC_ERR_AVPLAY_INVALID_OPT The operation is invalid. CNcomment:操作非法 CNend \see \n N/A */ td_s32 uapi_aenc_detach_input(td_handle aenc); /* \brief Start to encode. CNcomment:开始编码 CNend \attention \n Before calling the interface, you need to initialize the encoder, create an encoding channel and attach the player. CNcomment:调用该接口需要首先初始化编码器,创建编码通道,绑定播放器 CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \retval ::SOC_ERR_AVPLAY_INVALID_OPT The operation is invalid. CNcomment:操作非法 CNend \see \n N/A */ td_s32 uapi_aenc_start(td_handle aenc); /* \brief Stop to encode. CNcomment:停止编码 CNend \attention \n Before calling the interface, you need to initialize the encoder, create an encoding channel, attach the player, and start the encoding. CNcomment:调用该接口需要首先初始化编码器,创建编码通道,绑定播放器,已经开始编码 CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \retval ::SOC_ERR_AVPLAY_INVALID_OPT The operation is invalid. CNcomment:操作非法 CNend \see \n N/A */ td_s32 uapi_aenc_stop(td_handle aenc); /* \brief Set the attribution of encode. CNcomment:设置编码属性 CNend \attention \n Before calling the interface, you need to stop the encoder. CNcomment:调用该接口需要首先停止编码CNend \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \param[in] attr The attribution of audio encoder CNcomment:音频编码属性 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \see \n N/A */ td_s32 uapi_aenc_set_attr(td_handle aenc, const uapi_aenc_attr *attr); /* \brief Set the attribution of encode. CNcomment:获取编码属性 CNend \attention \n \param[in] aenc The handle of audio encoder CNcomment:音频编码器句柄 CNend \param[out] attr The attribution of audio encoder CNcomment:音频编码属性 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::SOC_ERR_AENC_INVALID_PARA The parameter is invalid. CNcomment:无效的参数 CNend \retval ::SOC_ERR_AENC_NULL_PTR The pointer is null. CNcomment:指针为空 CNend \see \n N/A */ td_s32 uapi_aenc_get_attr(td_handle aenc, uapi_aenc_attr *attr); /* \brief get AENC capability. CNcomment:获取编码能力集 CNend \attention \n \param[in] capability The returned capability of AENC CNcomment:capability 编码能力集描述结构体 CNend \retval ::TD_SUCCESS Success CNcomment:成功 CNend \retval ::TD_FAILURE Failure CNcomment:失败 CNend \see \n N/A */ td_s32 uapi_aenc_get_capability(uapi_aenc_cap *capability); #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */ #endif /* __UAPI_AENC_H__ */