|
|
/*
|
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2020. All rights reserved.
|
|
|
* Description: Define functions used to test function of venc driver
|
|
|
* Author: Hisilicon
|
|
|
* Create: 2019-11-26
|
|
|
*/
|
|
|
|
|
|
#ifndef __UAPI_VENC_H__
|
|
|
#define __UAPI_VENC_H__
|
|
|
|
|
|
#include "uapi_video.h"
|
|
|
#include "uapi_stream.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#define UAPI_VENC_TYPE_NUM 3
|
|
|
|
|
|
/*
|
|
|
* H264 NALU type
|
|
|
* CNcomment: H264 NALU类型
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_H264_NALU_SPS = 0, /* SPS NALU */
|
|
|
UAPI_VENC_H264_NALU_PPS, /* PPS NALU */
|
|
|
UAPI_VENC_H264_NALU_SEI, /* SEI NALU */
|
|
|
UAPI_VENC_H264_NALU_I_SLICE, /* I slice NALU */
|
|
|
UAPI_VENC_H264_NALU_P_SLICE, /* P slice NALU */
|
|
|
UAPI_VENC_H264_NALU_B_SLICE, /* B slice NALU */
|
|
|
UAPI_VENC_H264_NALU_MAX
|
|
|
} uapi_venc_h264_nalu_type;
|
|
|
|
|
|
/*
|
|
|
* H265 NALU type
|
|
|
* CNcomment: H265 NALU类型
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_H265_NALU_VPS = 0, /* VPS NALU */
|
|
|
UAPI_VENC_H265_NALU_SPS, /* SPS NALU */
|
|
|
UAPI_VENC_H265_NALU_PPS, /* PPS NALU */
|
|
|
UAPI_VENC_H265_NALU_SEI, /* SEI NALU */
|
|
|
UAPI_VENC_H265_NALU_P_SLICE, /* P slice NALU */
|
|
|
UAPI_VENC_H265_NALU_I_SLICE, /* I slice NALU */
|
|
|
UAPI_VENC_H265_NALU_B_SLICE, /* B slice NALU */
|
|
|
UAPI_VENC_H265_NALU_MAX
|
|
|
} uapi_venc_h265_nalu_type;
|
|
|
|
|
|
/*
|
|
|
* VENC Rate Control Type
|
|
|
* CNcomment: 编码器码率控制类型
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_RC_TYPE_CBR, /* Encoding in constant bit rate mode */ /* CNcomment: 恒定比特率方式进行编码 */
|
|
|
UAPI_VENC_RC_TYPE_AVBR, /* Encoding in variable bit rate mode */ /* CNcomment: 可变比特率方式进行编码 */
|
|
|
UAPI_VENC_RC_TYPE_MAX
|
|
|
} uapi_venc_rc_type;
|
|
|
|
|
|
/*
|
|
|
* Defines the source of input frame rate
|
|
|
* CNcomment: 定义编码器输入帧率来源类型的枚举
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_FRAME_RATE_TYPE_AUTO, /* Use the frame rate calculates from real-time statistics */
|
|
|
/* CNcomment: 内部统计校正实时收到的帧率 */
|
|
|
UAPI_VENC_FRAME_RATE_TYPE_STREAM, /* Use the frame rate comes from stream */
|
|
|
/* CNcomment: 采用码流信息中的帧率 */
|
|
|
UAPI_VENC_FRAME_RATE_TYPE_USER, /* Use the frame rate set by user */
|
|
|
/* CNcomment: 采用用户设置的帧率 */
|
|
|
UAPI_VENC_FRAME_RATE_TYPE_MAX
|
|
|
} uapi_venc_frame_rate_type;
|
|
|
|
|
|
/*
|
|
|
* Data type of the Encoder
|
|
|
* CNcomment: 编码器数据类型
|
|
|
*/
|
|
|
typedef union {
|
|
|
uapi_venc_h264_nalu_type h264_type; /* H264 encoding data */ /* CNcomment: H264编码数据 */
|
|
|
uapi_venc_h265_nalu_type h265_type; /* H265 encoding data */ /* CNcomment: H265编码数据 */
|
|
|
} uapi_venc_data_type;
|
|
|
|
|
|
/*
|
|
|
* Output stream attributes structure
|
|
|
* CNcomment: 输出码流属性结构体
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_stream_buf buf; /* Stream buf description */ /* CNcomment: 码流buffer描述信息 */
|
|
|
td_s64 pts_us; /* Presentation time stamp (PTS) */ /* CNcomment: 时间戳 */
|
|
|
td_bool frame_end; /* Frame end or not */ /* CNcomment: 标识是否为帧结束 */
|
|
|
uapi_venc_data_type data_type; /* Encoding data type */ /* CNcomment: 编码数据类型 */
|
|
|
} uapi_venc_stream;
|
|
|
|
|
|
typedef union {
|
|
|
uapi_h264_profile h264_profile; /* H264 profile */ /* CNcomment: H264编码档次 */
|
|
|
uapi_h265_profile h265_profile; /* H265 profile */ /* CNcomment: H265编码档次 */
|
|
|
} uapi_venc_profile;
|
|
|
|
|
|
/*
|
|
|
* Related configure of slice split
|
|
|
* CNcomment: slice划分相关配置
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_SPLIT_BY_BYTE, /* split slice by byte */ /* CNcomment: 按byte分slice */
|
|
|
UAPI_VENC_SPLIT_BY_LINE, /* split slice by LCU/MB line */ /* CNcomment: 按宏块行分slice */
|
|
|
UAPI_VENC_SPLIT_MAX
|
|
|
} uapi_split_mode;
|
|
|
|
|
|
typedef struct {
|
|
|
td_bool enable; /* slice split function switch */ /* CNcomment: slice划分功能开关 */
|
|
|
uapi_split_mode mode; /* slice split mode */ /* CNcomment: slice划分模式 */
|
|
|
td_u32 size; /* slice size, according to split_mode attribute, unit can be byte or line */
|
|
|
/* CNcomment: slice大小,根据split_mode属性,单位可以是byte或者line */
|
|
|
} uapi_venc_slice_split;
|
|
|
|
|
|
/*
|
|
|
* the gop mode
|
|
|
* CNcomment: GOP类型
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_GOP_MODE_NORMALP = 0, /* NORMALP: One reference frame and only forward reference
|
|
|
* adjacent I frame or P frame */
|
|
|
/* CNcomment: 单P帧模式,即一个参考帧且只前向参考相邻的I帧或者P帧 */
|
|
|
UAPI_VENC_GOP_MODE_DUALP, /* DUALP: Two forward reference frames */
|
|
|
/* CNcomment: 双P帧模式,即前向参考两帧 */
|
|
|
UAPI_VENC_GOP_MODE_SMARTP, /* SMARTP: Two forward reference frames, one of which is long-term reference */
|
|
|
/* CNcomment: SMARTP模式,两个前向参考帧,其中一个为长期参考帧 */
|
|
|
UAPI_VENC_GOP_MODE_MAX,
|
|
|
} uapi_venc_gop_mode;
|
|
|
|
|
|
typedef struct {
|
|
|
td_u32 width; /* Curent encode Width aligned 4-byte. */ /* CNcomment: 当前编码宽度, 4对齐 */
|
|
|
td_u32 height; /* Curent encode Height, 4-byte aligned */ /* CNcomment: 当前编码高度, 4对齐 */
|
|
|
td_u32 target_bitrate; /* RC parameter for the VENC, it is just valid for H264/H265 Encoder.
|
|
|
* See the development guide for the reference values. */
|
|
|
/* CNcomment: Venc下是RC参数,仅在编码H264/H265协议有效。部分参考值见开发指南 */
|
|
|
td_u32 target_frame_rate; /* Target frame rate. */ /* CNcomment: 目标帧率 */
|
|
|
td_u32 input_frame_rate; /* Input frame rate is less than or equal to the value of input_frame_rate.
|
|
|
* Attention: the configuration is invalid in the mode of attach source
|
|
|
* to encode the InputFrmRate */
|
|
|
/* CNcomment: 输入帧率, target_frame_rate <= input_frame_rate,
|
|
|
* 注意在绑定模式编码情况下用户配置的输入帧率将失效 */
|
|
|
td_u32 gop; /* GOP size,it is just valid for H264/H265 Encoder */
|
|
|
/* CNcomment: GOP大小,仅在编码H264/H265协议有效 */
|
|
|
td_bool quick_encode; /* Quick Encode Mode enable */ /* CNcomment:是否使能快速编码模式 */
|
|
|
td_u8 priority; /* the Priority Level of the channal, should be between 0 to
|
|
|
* the max num of channel minus 1. */
|
|
|
/* CNcomment: 编码通道的优先级属性,取值范围为0~最大通道数-1 */
|
|
|
td_u32 qfactor; /* The value ranges from 1 to 99 for the JPGE, it is just valid for JPEG Encoder. */
|
|
|
/* CNcomment: JPGE取值范围1-99,只在定义了JPEG编码器情况下才有效 */
|
|
|
td_u32 sp_interval; /* Interval of the special P frames that should be less than Gop and
|
|
|
* only needs to be configured when gop_mode == UAPI_VENC_GOP_MODE_DUALP.
|
|
|
* When the value is 0, there is no special P frame. */
|
|
|
/* CNcomment: 特殊P帧间隔,双P帧模式才需配置;值不能为1且小于GOP的大小。
|
|
|
* 当为0时,表示没有特殊P帧 */
|
|
|
uapi_venc_frame_rate_type input_frame_rate_type; /* input frame rate type */ /* CNcomment: 输入帧率类型 */
|
|
|
} uapi_venc_config;
|
|
|
|
|
|
/*
|
|
|
* Coding channal attributes structure
|
|
|
* CNcomment: 编码通道属性结构体
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_type venc_type; /* Encoder type */ /* CNcomment: 编码器类型 */
|
|
|
uapi_venc_profile profile; /* Profile type */ /* CNcomment: 编码档次 */
|
|
|
td_u32 max_width; /* Maximum width aligned 4-byte */ /* CNcomment: 最大宽,4字节对齐 */
|
|
|
td_u32 max_height; /* Maximum height aligned 4-byte */ /* CNcomment: 最大高,4字节对齐 */
|
|
|
td_u32 stream_buf_size; /* Stream buffer size, the value ranges from 32*1024 to 40*1024*1024.
|
|
|
* You'd better set larger streamBufferSize if you set larger target bitrate or Qlevel. */
|
|
|
/* CNcomment: 码流buffer大小,配置的码流buffer大小范围为32x1024到40x1024x1024,
|
|
|
* 如果设置了较高的码率或JPEG图像质量参数,建议适当增大码流buffer大小。 */
|
|
|
uapi_venc_slice_split slice_split; /* Slice split configure, which is for H264/H265 Encoder */
|
|
|
/* CNcomment: slice划分配置, 只在定义了H264/H265协议编码器情况下才有效 */
|
|
|
td_bool secure; /* Secure config, 1:secure encoder; 0:normal encoder */
|
|
|
/* CNcomment: 安全通路标志 1:安全编码器;0:非安编码器 */
|
|
|
uapi_venc_gop_mode gop_mode; /* Encoding GOP type */ /* CNcomment: GOP类型 */
|
|
|
uapi_venc_config config; /* Dynamically configurable attributes */ /* CNcomment: 可动态配置属性 */
|
|
|
} uapi_venc_attr;
|
|
|
|
|
|
/*
|
|
|
* VENC Capability Information Of One Resolution
|
|
|
* CNcomment: 某一分辨率的编码能力信息
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_u32 width; /* support width */ /* CNcomment: 宽度 */
|
|
|
td_u32 height; /* support height */ /* CNcomment: 高度 */
|
|
|
td_u32 max_frm_rate; /* support max frame rate */ /* CNcomment: 最大帧率 */
|
|
|
td_u32 max_bit_rate; /* support max bit rate */ /* CNcomment: 最大码率 */
|
|
|
td_u32 min_bit_rate; /* support min bit rate */ /* CNcomment: 最小码率 */
|
|
|
td_u32 min_buf_size; /* support min stream buffer size */ /* CNcomment: 最大能力级对应的最小码流buffer大小 */
|
|
|
} uapi_venc_cap_reso;
|
|
|
|
|
|
/*
|
|
|
* VENC Capability Information Of One Encode Type
|
|
|
* CNcomment: 某一编码协议的编码能力信息
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_vcodec_type code_type; /* support venc type */ /* CNcomment: 编码类型 */
|
|
|
td_u32 max_chan_num; /* support max channel num */ /* CNcomment: 最大通道数 */
|
|
|
uapi_venc_cap_reso max_reso; /* support capability information of max resolution */
|
|
|
/* CNcomment: 最大分辨率对应的能力信息 */
|
|
|
uapi_venc_cap_reso min_reso; /* support capability information of min resolution */
|
|
|
/* CNcomment: 最小分辨率对应的能力信息 */
|
|
|
} uapi_venc_cap_info;
|
|
|
|
|
|
/*
|
|
|
* VENC Capability Information
|
|
|
* CNcomment: 编码能力信息
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_u32 support_type_num; /* support venc type num */ /* CNcomment: 编码器支持的编码类型数量 */
|
|
|
uapi_venc_cap_info cap_info[UAPI_VENC_TYPE_NUM]; /* capability information for venc types */
|
|
|
/* CNcomment: 编码器不同编码类型的编码能力信息 */
|
|
|
} uapi_venc_cap;
|
|
|
|
|
|
/*
|
|
|
* Rate control advanced parameters
|
|
|
* CNcomment: 码率控制高级参数
|
|
|
*/
|
|
|
typedef struct {
|
|
|
uapi_venc_rc_type type; /* Rate Control Type */ /* CNcomment: 码率控制类型 */
|
|
|
td_u8 max_qp; /* Maximum QP */ /* CNcomment: 最大QP值 */
|
|
|
td_u8 min_qp; /* Minimum QP */ /* CNcomment: 最小QP值 */
|
|
|
} uapi_venc_rc_param;
|
|
|
|
|
|
/*
|
|
|
* VENC advanced parameter commands
|
|
|
* CNcomment: VENC高级参数命令
|
|
|
*/
|
|
|
typedef enum {
|
|
|
UAPI_VENC_INVOKE_SET_RC_PARAM = 0, /* Command to set rate control parameter */
|
|
|
/* CNcomment: 设置码率参数命令 */
|
|
|
UAPI_VENC_INVOKE_GET_RC_PARAM, /* Command to get rate control parameter */
|
|
|
/* CNcomment: 获取码率参数命令 */
|
|
|
UAPI_VENC_INVOKE_MAX
|
|
|
} uapi_venc_invoke_cmd;
|
|
|
|
|
|
typedef enum {
|
|
|
UAPI_VENC_FRAME_DROP_NORMAL = 0, /* Drop the frame directly when the instant bitrate exceeds the threshold */
|
|
|
/* CNcomment: 瞬时码率超过阈值时直接丢帧 */
|
|
|
UAPI_VENC_FRAME_DROP_SKIP_FRM, /* Encoded pskip frame when the instant bitrate exceeds the threshold */
|
|
|
/* CNcomment: 瞬时码率超过阈值时编码pskip帧 */
|
|
|
UAPI_VENC_FRAME_DROP_MAX,
|
|
|
} uapi_venc_frame_drop_mode;
|
|
|
|
|
|
/*
|
|
|
* Frame drop strategy
|
|
|
* CNcomment: 丢帧策略
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_bool enable; /* Drop frame enable flag */ /* CNcomment: 丢帧使能开关 */
|
|
|
td_u32 bit_rate_threshold; /* Encoder bitrate fluctuation threshold */
|
|
|
/* CNcomment: 编码器码率波动阈值 */
|
|
|
uapi_venc_frame_drop_mode mode; /* Drop frame mode */ /* CNcomment: 丢帧模式 */
|
|
|
td_u32 drop_gap; /* Maximum allowed consecutive frames drop */
|
|
|
/* CNcomment: 最大允许连续丢帧帧数 */
|
|
|
} uapi_venc_frame_drop_strategy;
|
|
|
|
|
|
/*
|
|
|
* VENC channel status
|
|
|
* CNcomment: VENC通道状态
|
|
|
*/
|
|
|
typedef struct {
|
|
|
td_bool is_start; /* Encode work status */ /* CNcomment: 编码器工作模式 */
|
|
|
td_u32 left_pics; /* The number of frames that the encoder has not yet encoded */
|
|
|
/* CNcomment: 编码器还没有编码的帧数 */
|
|
|
td_u32 left_stream_bytes; /* The left bytes of stream buffer */
|
|
|
/* CNcomment: 剩余的码流buffer字节数 */
|
|
|
td_u32 drop_frame_num; /* Total drop frames number */ /* CNcomment: 丢帧总数 */
|
|
|
} uapi_venc_chan_status;
|
|
|
|
|
|
/*
|
|
|
* brief Initializes the video encoder. CNcomment: 初始化视频编码器 CNend
|
|
|
* attention \n
|
|
|
* Before using the VENC, you must call this API. CNcomment: 调用VENC模块要求首先调用该接口 CNend
|
|
|
* param[in] N/A CNcomment: 无 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_DEV_NOT_EXIST No VENC device exists. CNcomment: 设备不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NOT_DEV_FILE The file is not a VENC file. CNcomment: 文件非设备 CNend
|
|
|
* retval ::SOC_ERR_VENC_DEV_OPEN_ERR The VENC device fails to start. CNcomment: 打开设备失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_init(td_void);
|
|
|
|
|
|
/*
|
|
|
* brief Deinitializes the video encoder. CNcomment: 去初始化视频编码器 CNend
|
|
|
* attention \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
* param[in] N/A CNcomment: 无 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_DEV_CLOSE_ERR The video encoder fails to stop. CNcomment: 关闭编码器失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_deinit(td_void);
|
|
|
|
|
|
/*
|
|
|
* brief Obtains the default attributes of a VENC channel. CNcomment: 获取编码通道默认属性 CNend
|
|
|
* attention \n
|
|
|
* By default, the encoding size is D1, encoding format is H.264, and a frame is a slice.
|
|
|
* CNcomment: 默认720P编码,H.264格式,一帧为一个Slice CNend
|
|
|
* param[out] attr Pointer to the attributes of a VENC channel. CNcomment: attr 指向编码通道属性的指针 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The input pointer parameter is null. CNcomment: 输入指针参数为空指针 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_get_default_attr(uapi_venc_attr *attr);
|
|
|
|
|
|
/*
|
|
|
* brief Creates a VENC channel. CNcomment: 创建视频编码通道 CNend
|
|
|
* attention \n
|
|
|
* You must create a VENC channel before video encoding.
|
|
|
* CNcomment: 进行视频编码要求首先创建编码通道 CNend
|
|
|
* param[in] attr Pointer to the attributes of a VENC channel. CNcomment: attr 指向编码通道属性的指针 CNend
|
|
|
* param[out] chan_id Pointer to the handle of a VENC channel. CNcomment: chan_id 指向编码通道句柄的指针 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The input pointer parameter is null. CNcomment: 输入指针参数有空指针 CNend
|
|
|
* retval ::SOC_ERR_VENC_CREATE_ERR The number of VENC channels exceeds the limit. CNcomment: 编码通道数已满 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_create(td_handle *chan_id, const uapi_venc_attr *attr);
|
|
|
|
|
|
/*
|
|
|
* brief Destroys a VENC channel. CNcomment: 销毁视频编码通道 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Handle of a VENC channel. CNcomment: CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No handle exists. CNcomment: 句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_destroy(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief Attaches a VENC channel to the video source. CNcomment: 绑定编码通道到视频源 CNend
|
|
|
* attention \n
|
|
|
* You must call this API before performing encoding and obtaining streams.
|
|
|
* CNcomment: 开始编码和获取码流之前需要首先调用该接口 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[in] src_id Data source handle CNcomment: src_id 视频源句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The video source is invalid. CNcomment: 视频源错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_attach_input(td_handle chan_id, td_handle src_id);
|
|
|
|
|
|
/*
|
|
|
* brief Detaches a VENC channel from the video source. CNcomment: 解绑定视频源 CNend
|
|
|
* attention \n
|
|
|
* You must stop encoding before calling this API.
|
|
|
* CNcomment: 调用该接口需要首先停止编码 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The video source is invalid. CNcomment: 视频源错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_INVALID_STAT Invalid state which the video encoder does not stop encoding.
|
|
|
* CNcomment: 异常状态,编码器未停止编码 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NO_ATTACH The VENC channel doesn't attach any source.
|
|
|
* CNcomment: 编码通道没有绑定任何源 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_detach_input(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief Starts to perform encoding. CNcomment: 开始编码 CNend
|
|
|
* attention \n
|
|
|
* You must initialize the video encoder, create a VENC channel, and attach the channel to the video source
|
|
|
* before calling this API.
|
|
|
* CNcomment: 调用该接口需要首先初始化编码器,创建编码通道,绑定视频源 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_start(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief Stops encoding. CNcomment: 停止编码 CNend
|
|
|
* attention \n
|
|
|
* You must initialize the video encoder, create a VENC channel, attach the channel to the video source,
|
|
|
* and start to perform encoding before calling this API.
|
|
|
* CNcomment: 调用该接口需要首先初始化编码器,创建编码通道,绑定视频源,已经开始编码 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_stop(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief Obtains VENC streams. CNcomment: 获取视频编码码流 CNend
|
|
|
* attention \n
|
|
|
* You must attach a VENC channel to the video source and start to perform encoding before calling this API.
|
|
|
* The block time (in ms) is configurable. If u32TimeOutMs is set to 0,
|
|
|
* the block time is 0; if timeout_ms is set to 0xFFFFFFFF, it indicates infinite wait. \n
|
|
|
* If the block time is reached but no data is received, ::SOC_ERR_VENC_BUF_EMPTY is returned.\n
|
|
|
* If the wait time is 0 and there is no data, ::SOC_ERR_VENC_BUF_EMPTY is returned.
|
|
|
* CNcomment: 调用该接口需要首先绑定视频源,开始编码
|
|
|
* 阻塞时间可以设置,时间单位为毫秒,设置为0不等待,设置为0xffffffff一直等待。\n
|
|
|
* 若超过阻塞时间,还没有数据到达,则返回::SOC_ERR_VENC_BUF_EMPTY\n
|
|
|
* 如果等待时间为0,且没有码流数据,则返回::SOC_ERR_VENC_BUF_EMPTY\n CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[out] stream Pointer to the structure for storing streams CNcomment: stream 存放码流结构的指针 CNend
|
|
|
* param[in] timeout_ms: Wait timeout, count in ms CNcomment: u32TimeoutMs:等待超时时间,单位ms CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The stream pointer is null. CNcomment: 码流指针为空 CNend
|
|
|
* retval ::SOC_ERR_VENC_BUF_EMPTY Streams fail to be obtained. CNcomment: 获取码流失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_acquire_stream(td_handle chan_id, uapi_venc_stream *stream, td_u32 timeout_ms);
|
|
|
|
|
|
/*
|
|
|
* brief Releases VENC streams. CNcomment: 释放视频编码码流 CNend
|
|
|
* attention \n
|
|
|
* You must obtain streams and keep the streams unchanged before calling this API.
|
|
|
* The stream which you get first should be release first.
|
|
|
* CNcomment: 调用该接口需要首先获取码流,且不能改变码流内容。
|
|
|
* 先获取的码流需要先释放。 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[in] stream Pointer to the structure for storing streams CNcomment: stream 存放码流结构的指针 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The stream pointer is null. CNcomment: 码流指针为空 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_RELEASE_ERR Streams fail to be released. CNcomment: 释放码流失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_release_stream(td_handle chan_id, const uapi_venc_stream *stream);
|
|
|
|
|
|
/*
|
|
|
* brief Sets the encoding channel dynamic attributes dynamically. CNcomment: 动态设置编码通道属性 CNend
|
|
|
* attention \n
|
|
|
* You must create a VENC channel before calling this API. You should still assign the real value to them
|
|
|
* at that time. It's better that you should call uapi_venc_get_attr() to obtain the attributes of a VENC channel
|
|
|
* before calling this API.
|
|
|
* CNcomment: 调用该接口需要首先创建编码通道,在调用该接口时你还是要给这些通道属性赋上当时的实际值。 CNend
|
|
|
* 最好在调用该接口之前调用uapi_venc_get_config()接口获取到当时的通道属性 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[in] config Encoding channel dynamic attribute CNcomment: config 编码通道动态属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The pointer is null. CNcomment: 指针为空 CNend
|
|
|
* retval ::SOC_ERR_VENC_NOT_SUPPORT This change of attributes dosen't be supported.
|
|
|
* CNcomment: 不支持该属性动态配置 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_set_config(td_handle chan_id, const uapi_venc_config *config);
|
|
|
|
|
|
/*
|
|
|
* brief Obtains the dynamic attributes of a VENC channel. CNcomment: 获取编码通道动态属性 CNend
|
|
|
* attention \n
|
|
|
* You must create a VENC channel before calling this API.
|
|
|
* CNcomment: 调用该接口需要首先创建编码通道 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[out] config Encoding channel dynamic attribute CNcomment: config 编码通道动态属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The pointer is null. CNcomment: 指针为空 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_get_config(td_handle chan_id, uapi_venc_config *config);
|
|
|
|
|
|
/*
|
|
|
* brief Applies for I frames. CNcomment: 请求I帧 CNend
|
|
|
* attention \n
|
|
|
* The video encoder encodes an I frame as soon as possible after you call this API.\n
|
|
|
* You can call this API when you set up a video call or fix errors.\n
|
|
|
* If you call this API repeatedly in a short period, I frames may be not generated each time.\n
|
|
|
* CNcomment: 调用该接口后,编码器会尽快编码出一个I帧来.\n
|
|
|
* 此接口一般用于可视电话场景的通话建立和错误恢复.\n
|
|
|
* 此接口只是"尽最大能力"尽快编码出一个I帧来,如果在短时间内多次调用此接口,
|
|
|
* 那么不能保证每次调用都能对应编码出一个I帧来.\n CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_request_i_frame(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief Input frame to VENC. CNcomment: 向编码器送帧 CNend
|
|
|
* attention \n
|
|
|
* You must create a VENC channel before calling this API.
|
|
|
* If the venc channel has already attach the source,::SOC_ERR_VENC_CHN_INVALID_STAT is returned.
|
|
|
* This API should be matched with the API: uapi_venc_dequeue_frame.
|
|
|
* uapi_venc_queue_frame is used to send frame data to Encoder for user and uapi_venc_dequeue_frame is used to call
|
|
|
* the Encoder to receive the frame data which has already be processed.
|
|
|
* CNcomment: 调用该接口需要首先创建编码通道.
|
|
|
* 如果编码通道已经绑定源,会返回SOC_ERR_VENC_CHN_INVALID_STAT 无效操作
|
|
|
* 该接口需要与 uapi_venc_dequeue_frame 接口配对使用。
|
|
|
* UAPI_VENC_QueueFrame接口用于为用户提供一个接口向编码器送帧供编码,
|
|
|
* uapi_venc_dequeue_frame接口是编码器归还已经处理的帧 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[in] frame_info Frame information struct CNcomment: 帧信息属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The pointer is null. CNcomment: 指针为空 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_INVALID_STAT Invalid state which the VENC channel has already attach source.
|
|
|
CNcomment: 异常状态,编码器通道已经绑定源 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_queue_frame(td_handle chan_id, uapi_video_frame_info *frame_info);
|
|
|
|
|
|
/*
|
|
|
* brief release frame from VENC. CNcomment: 向编码器还帧 CNend
|
|
|
* attention \n
|
|
|
* You must create a VENC channel before calling this API.
|
|
|
* If the venc channel has already attach the source,::SOC_ERR_VENC_CHN_INVALID_STAT is returned.
|
|
|
* Refer to the attention of the API: uapi_venc_queue_frame.
|
|
|
* If uapi_venc_dequeue_frame return TD_SUCCESS, it means the corresponding frame buffer could be set free by user.
|
|
|
* CNcomment: 调用该接口需要首先创建编码通道.
|
|
|
* 如果编码通道已经绑定源,会返回SOC_ERR_VENC_CHN_INVALID_STAT 无效操作
|
|
|
* 注意事项参照uapi_venc_queue_frame接口。如果uapi_venc_dequeue_frame接口返回成功,
|
|
|
* 意味着对应的帧存用户可以释放 CNend
|
|
|
* param[in] chan_id Handle of a VENC channel CNcomment: chan_id 编码通道句柄 CNend
|
|
|
* param[out] frame_info Frame information struct CNcomment: 帧信息属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The pointer is null. CNcomment: 指针为空 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_INVALID_STAT Invalid state which the VENC channel has already attach source.
|
|
|
CNcomment: 异常状态,编码器通道已经绑定源 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_dequeue_frame(td_handle chan_id, uapi_video_frame_info *frame_info);
|
|
|
|
|
|
/*
|
|
|
* brief get encoding capbility from VENC. CNcomment: 获取编码器的编码能力 CNend
|
|
|
* attention \n
|
|
|
* param[in] N/A CNcomment: 无 CNend
|
|
|
* param[out] capability Pointer to the capability of VENC CNcomment: capability 存放编码能力信息的指针 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_NULL_PTR The pointer is null. CNcomment: 指针为空 CNend
|
|
|
* retval ::TD_FAILURE Capability fail to be obtained. CNcomment: 获取编码能力信息失败 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_get_cap_ability(uapi_venc_cap *capability);
|
|
|
|
|
|
/*
|
|
|
* brief set frame drop strategy. CNcomment: 设置丢帧策略 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* param[in] frm_drop_param Frame drop parameter. CNcomment: 丢帧策略参数 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_set_frame_drop_strategy(td_handle chan_id, const uapi_venc_frame_drop_strategy *frm_drop_param);
|
|
|
|
|
|
/*
|
|
|
* brief get frame drop strategy. CNcomment: 获取丢帧策略 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* param[out] frm_drop_param Frame drop parameter. CNcomment: 丢帧策略参数 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_get_frame_drop_strategy(td_handle chan_id, uapi_venc_frame_drop_strategy *frm_drop_param);
|
|
|
|
|
|
/*
|
|
|
* brief venc extended function interface. CNcomment: Venc扩展功能接口 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* param[in] invode_cmd Command. CNcomment: 扩展命令 CNend
|
|
|
* param[in] param Input Parameter(determined by invode_cmd). CNcomment: 输入参数(invode_cmd决定) CNend
|
|
|
* param[in] param_len Parameter length. CNcomment: 参数结构体长度 CNend
|
|
|
* param[out] param Output parameter(determined by invode_cmd). CNcomment: 输出参数(invode_cmd决定) CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_invoke(td_handle chan_id, uapi_venc_invoke_cmd invoke_cmd, td_void *param, td_u32 param_len);
|
|
|
|
|
|
/*
|
|
|
* brief venc reset. CNcomment: 重置编码通道 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_reset(td_handle chan_id);
|
|
|
|
|
|
/*
|
|
|
* brief query channel status. CNcomment: 查询通道状态 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* param[out] status Current status. CNcomment: 当前通道状态 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_query_status(td_handle chan_id, uapi_venc_chan_status *status);
|
|
|
|
|
|
/*
|
|
|
* brief Obtains the attributes of a VENC channel. CNcomment: 获取编码通道属性 CNend
|
|
|
* attention \n
|
|
|
* param[in] chan_id Venc handle. CNcomment: Venc句柄 CNend
|
|
|
* param[out] attr Encoding channel attribute CNcomment: attr 编码通道属性 CNend
|
|
|
* retval ::TD_SUCCESS Success CNcomment: 成功 CNend
|
|
|
* retval ::SOC_ERR_VENC_CHN_NOT_EXIST No VENC channel handle exists. CNcomment: 编码通道句柄不存在 CNend
|
|
|
* retval ::SOC_ERR_VENC_INVALID_PARA The channel attributes are incorrect. CNcomment: 通道属性设置错误 CNend
|
|
|
* retval ::SOC_ERR_VENC_NO_INIT The video encoder is not initialized. CNcomment: 编码器未初始化 CNend
|
|
|
* see \n
|
|
|
* N/A CNcomment: 无 CNend
|
|
|
*/
|
|
|
td_s32 uapi_venc_get_attr(td_handle chan_id, uapi_venc_attr *attr);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
#if __cplusplus
|
|
|
}
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
#endif // __UAPI_VENC_H__
|