360 lines
13 KiB
C
360 lines
13 KiB
C
|
/**
|
|||
|
@file
|
|||
|
*/
|
|||
|
|
|||
|
#ifndef _AW_VIDEOINPUT_H_
|
|||
|
#define _AW_VIDEOINPUT_H_
|
|||
|
|
|||
|
#include <stdint.h>
|
|||
|
#include <stdio.h>
|
|||
|
#include <media/rt-media/uapi_rt_media.h>
|
|||
|
#include <media/sunxi_camera_v2.h>
|
|||
|
|
|||
|
// 一般API int 返回值表示:0)成功; <0)失败;
|
|||
|
|
|||
|
#define WAIT_CSI_TIMEOUT_TIME 5*1000*1000
|
|||
|
|
|||
|
// H264视频采集回调
|
|||
|
// tv 定义为采集时的时间戳,gettimeofday(&tv, NULL); 必须真实 ,根据平台不一样,可以改为long long(8byte) ms单位数据(从1970开始).。
|
|||
|
// 时间戳为实现时问,与osd时间显示一致。
|
|||
|
// data 为NALU数据(以 00 00 00 01开始的)
|
|||
|
// keyframe 为关键帧标志。如果是关键帧,data需要同时包含NALU SPS、PPS
|
|||
|
// SDK h264等编码数据不需要buffer,回调返回再encode下一帧。
|
|||
|
typedef struct AWVideoInput_StreamInfo {
|
|||
|
uint64_t pts; //unit:us
|
|||
|
unsigned char *data0;
|
|||
|
unsigned char *data1;
|
|||
|
unsigned char *data2;
|
|||
|
unsigned int size0;
|
|||
|
unsigned int size1;
|
|||
|
unsigned int size2;
|
|||
|
unsigned char* sps_pps_buf;
|
|||
|
int sps_pps_size;
|
|||
|
int b_insert_sps_pps;
|
|||
|
int keyframe_flag;
|
|||
|
int channel_id;
|
|||
|
STREAM_DATA_INFO* stream_data;
|
|||
|
} AWVideoInput_StreamInfo;
|
|||
|
|
|||
|
typedef void (*Video_Input_cb)(const AWVideoInput_StreamInfo* stream_info);
|
|||
|
typedef void (*Channel_Thread_exit)(void);
|
|||
|
|
|||
|
typedef enum AWVideoInput_EventType
|
|||
|
{
|
|||
|
AWVideoInput_Event_None = 0,
|
|||
|
AWVideoInput_Event_DropFrame, //kernel rtmedia drop frame, so notify app. nData1 = dropNum
|
|||
|
AWVideoInput_Event_StreamReady, // AWVideoInput_StreamInfo*
|
|||
|
/**
|
|||
|
channel thread meet serious error and wait to exit, so notify app to do exit procedure through this event, then
|
|||
|
channel thread wait app to destroy it.
|
|||
|
*/
|
|||
|
AWVideoInput_Event_WaitErrorExit,
|
|||
|
} AWVideoInput_EventType;
|
|||
|
typedef int (*AWVideoInputCallbackType)(void *pAppData, int channel, AWVideoInput_EventType event, int nData1, int nData2, void *pEventData);
|
|||
|
|
|||
|
typedef void (*AWTdmBufferDoneCallback)(struct vin_isp_tdm_event_status *status);
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
VIDEO_NIGHT = 0,
|
|||
|
VIDEO_DAY,
|
|||
|
}VIDEO_HASLIGHT;
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
IR_MODE_AUTO = 0, // 自动红外。由SDK层自动切换
|
|||
|
IR_MODE_ON = 1, // 强制开红外,SDK层不自动切换
|
|||
|
IR_MODE_OFF = 2, // 强制关红外,SDK层不自动切换
|
|||
|
}IR_MODE;
|
|||
|
|
|||
|
typedef struct VideoChannelInfo
|
|||
|
{
|
|||
|
VideoInputConfig mConfig;
|
|||
|
int state;
|
|||
|
}VideoChannelInfo;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
int enable_wbyuv;
|
|||
|
FILE *wbyuv_file;
|
|||
|
unsigned char *yuvBuf;
|
|||
|
unsigned int yuvSize;
|
|||
|
int get_num;
|
|||
|
}WbYuvFuncInfo;
|
|||
|
|
|||
|
typedef struct VideoYuvFrame
|
|||
|
{
|
|||
|
int widht;
|
|||
|
int height;
|
|||
|
unsigned char* phyAddr[3];
|
|||
|
unsigned char* virAddr[3];
|
|||
|
}VideoYuvFrame;
|
|||
|
|
|||
|
typedef enum AWVideoInput_State
|
|||
|
{
|
|||
|
VIDEO_INPUT_STATE_IDLE = 0,
|
|||
|
VIDEO_INPUT_STATE_CONFIGED = 1,
|
|||
|
VIDEO_INPUT_STATE_EXCUTING = 2,
|
|||
|
VIDEO_INPUT_STATE_PAUSE = 3,
|
|||
|
}AWVideoInput_State;
|
|||
|
|
|||
|
typedef struct sps_pps_data_info {
|
|||
|
unsigned char* buf;
|
|||
|
int size;
|
|||
|
int bInit;
|
|||
|
}sps_pps_data_info;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
int x;
|
|||
|
int y;
|
|||
|
} AWVideoInput_VideoPoint;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
unsigned short src_width;
|
|||
|
unsigned short src_height;
|
|||
|
} AWVideoInput_VideoSrcRes;
|
|||
|
|
|||
|
typedef struct {
|
|||
|
RTVencRect face_roi_rgn[RT_AE_FACE_MAX_NUM];
|
|||
|
unsigned char enable;
|
|||
|
unsigned char vaild_face_num;
|
|||
|
short face_ae_tolerance;
|
|||
|
short face_ae_speed;
|
|||
|
short face_ae_target;
|
|||
|
short face_ae_delay_cnt;
|
|||
|
unsigned short face_up_percent;
|
|||
|
unsigned short face_down_percent;
|
|||
|
unsigned short ae_face_block_num_thrd;
|
|||
|
unsigned short ae_face_block_weight;
|
|||
|
unsigned short ae_over_face_max_exp_control;
|
|||
|
unsigned short ae_face_win_weight[RT_AE_FACE_WIN_WEIGHT_LENGTH];
|
|||
|
int ae_face_pos_weight[RT_AE_FACE_POS_WEIGHT_LENGTH];
|
|||
|
} AWVideoInput_FaceAeInfo;
|
|||
|
|
|||
|
// 一般使用流程:Init -> Configure()等-->CallBack()-->Start(). 最终用完 DeInit();
|
|||
|
int AWVideoInput_Init(void);
|
|||
|
int AWVideoInput_Configure(int channel, VideoInputConfig *pCfg);//随时可被调用,sdk处理时需过滤掉与当前相同的参数。
|
|||
|
int AWVideoInput_CallBack(int channel, Video_Input_cb cb, int bAppendSpspps);//bAppendSpspps = 1, will insert spspps every I frame
|
|||
|
int AWVideoInput_SetChannelThreadExitCb(int channel, Channel_Thread_exit cb);
|
|||
|
int AWVideoInput_SetChannelCallback(int channel, AWVideoInputCallbackType cb, void* pAppData);
|
|||
|
int AWVideoInput_AppendSpspps(int channel, int bAppendSpspps);
|
|||
|
int AWVideoInput_Start(int channel,int bStart); //开始与停止
|
|||
|
int AWVideoInput_DeInit(void);
|
|||
|
int AWVideoInput_Check_Wait_Start(int channel);
|
|||
|
/// (operate isp)
|
|||
|
int AWVideoInput_Get_csi_status(int channel);
|
|||
|
AWVideoInput_State AWVideoInput_Get_channel_state(int channel);
|
|||
|
/// 强制下次出I帧 //随时可被调用
|
|||
|
int AWVideoInput_SetIFrame(int channel);
|
|||
|
|
|||
|
/// (operate venc), set overlay or cover to venc. 初始化或随时可被调用
|
|||
|
int AWVideoInput_SetOSD(int channel, VideoInputOSD *pOsdInfo);
|
|||
|
|
|||
|
/// 抓图配置,随时可被调用
|
|||
|
int AWVideoInput_CatchJpegConfig(catch_jpeg_config *jpg_conf);
|
|||
|
/**
|
|||
|
抓图.
|
|||
|
随时可被调用
|
|||
|
@param[in,out] bufLen 输入参数为buf最大长度。输出参数为实际长度
|
|||
|
*/
|
|||
|
int AWVideoInput_CatchJpeg(char *buf, int *bufLen, int channel_id);
|
|||
|
/// (operate isp) Get YUV frame
|
|||
|
int AWVideoInput_GetYuvFrame(int channel, VideoYuvFrame* pYuvFrame);
|
|||
|
/// (operate isp) Release YUV frame
|
|||
|
int AWVideoInput_ReleaseYuvFrame(int channel, VideoYuvFrame* pYuvFrame);
|
|||
|
|
|||
|
|
|||
|
// buf: 用于存放bin image data的 内存
|
|||
|
// bufLen: buf 长度;
|
|||
|
// return: 返回 data 的实际长度
|
|||
|
//int AWVideoInput_GetBinImageData(int channel, char *buf, int bufLen);
|
|||
|
|
|||
|
// buf: 用于存放mv info data的 内存
|
|||
|
// bufLen: buf 长度;
|
|||
|
// return: 返回 data 的实际长度
|
|||
|
//int AWVideoInput_GetMvInfoData(int channel, char *buf, int bufLen);
|
|||
|
|
|||
|
int AWVideoInput_GetLuminance(int channel);
|
|||
|
|
|||
|
//Grey:0 彩色模式 1 黑白模式
|
|||
|
//return :0 成功,other 错误码
|
|||
|
int AWVideoInput_SetIrParam(int channel, RTIrParam* pIrParam);
|
|||
|
|
|||
|
//hist: 直方图数组,数量为256
|
|||
|
//return :0 成功,other 错误码
|
|||
|
int AWVideoInput_GetHist(int channel, unsigned int *hist);
|
|||
|
|
|||
|
/**
|
|||
|
(operate isp) get isp exp gain.
|
|||
|
@param[in] expgain:曝光、模拟增益、rgain、bgain
|
|||
|
@return 0 成功,other 错误码
|
|||
|
*/
|
|||
|
int AWVideoInput_GetExpGain(int channel, RTIspExpGain *expgain);
|
|||
|
|
|||
|
//水平翻转 -- bflip: 0 非翻转, 1 翻转
|
|||
|
int AWVideoInput_SetHFlip(int channel, int bflip);
|
|||
|
|
|||
|
/**
|
|||
|
(operate venc) set encpp sharp to venc.
|
|||
|
It can be called after AWVideoInput_Configure(), before or after AWVideoInput_Start().
|
|||
|
It can be called before or after VencInit().
|
|||
|
@param bsharp
|
|||
|
1:enable encpp sharp of venc
|
|||
|
0:disable encpp sharp of venc
|
|||
|
*/
|
|||
|
int AWVideoInput_SetSharp(int channel, int bsharp);
|
|||
|
|
|||
|
//垂直翻转 -- bflip: 0 非翻转, 1 翻转
|
|||
|
int AWVideoInput_SetVFlip(int channel, int bflip);
|
|||
|
|
|||
|
//设置 power line frequency
|
|||
|
int AWVideoInput_SetPowerLineFreq(int channel, RT_POWER_LINE_FREQUENCY power_line_freq);
|
|||
|
|
|||
|
//设置 isp特效接口
|
|||
|
int AWVideoInput_SetBrightness(int channel, int brightness_level);
|
|||
|
int AWVideoInput_SetContrast(int channel, int contrast_level);
|
|||
|
int AWVideoInput_SetSaturation(int channel, int saturation_level);
|
|||
|
int AWVideoInput_SetHue(int channel, int hue_level);
|
|||
|
int AWVideoInput_SetSharpness(int channel, int sharpness_level);
|
|||
|
|
|||
|
//获取当前使用的Sensor名字, char[40]
|
|||
|
int AWVideoInput_GetSensorName(int channel, char *name);
|
|||
|
//获取Sensor支持的最大分辨率
|
|||
|
int AWVideoInput_GetSensorResolution(int channel, RTSensorResolution *sensor_resolution);
|
|||
|
|
|||
|
//设置 ae metering mode
|
|||
|
int AWVideoInput_SetAeMeteringMode(int channel, RT_AE_METERING_MODE ae_metering_mode);
|
|||
|
int AWVideoInput_SetAeMode(int channel, int ae_mode);
|
|||
|
int AWVideoInput_SetSensorExp(int channel, int exp_time);
|
|||
|
int AWVideoInput_SetSensorGain(int channel, int gain);
|
|||
|
|
|||
|
/**
|
|||
|
设置 isp attr cfg.
|
|||
|
*/
|
|||
|
int AWVideoInput_SetIspAttrCfg(int channel, RTIspCtrlAttr *isp_ctrl_attr);
|
|||
|
int AWVideoInput_GetIspAttrCfg(int channel, RTIspCtrlAttr *isp_ctrl_attr);
|
|||
|
int AWVideoInput_SetIspFaceAeCfg(int channel, AWVideoInput_FaceAeInfo FaceAeInfo, AWVideoInput_VideoSrcRes Res);
|
|||
|
int AWVideoInput_GetIspFaceAeCfg(int channel, AWVideoInput_FaceAeInfo *FaceAeInfo);
|
|||
|
|
|||
|
/// (operate isp) 设置 isp orl
|
|||
|
int AWVideoInput_SetIspOrl(int channel, RTIspOrl *isp_orl);
|
|||
|
|
|||
|
//动态切换编码器类型,编码类型:0)h264 1)mjpeg 2)h265
|
|||
|
//切换编码器前需暂停视频通道,即使用流程如下:
|
|||
|
// AWVideoInput_Start(0, 0) --> AWVideoInput_ResetEncoderType() --> AWVideoInput_Start(0, 1)
|
|||
|
int AWVideoInput_ResetEncoderType(int channel, int encoderType);
|
|||
|
|
|||
|
//reset ve buffer
|
|||
|
int AWVideoInput_ResetInOutBuffer(int channel);
|
|||
|
int AWVideoInput_SetKernelRtMediaStart(int channel);
|
|||
|
int AWVideoInput_SetKernelRtMediaPause(int channel);
|
|||
|
int AWVideoInput_ReturnStreamData(int channel, STREAM_DATA_INFO *p_stream_data);
|
|||
|
/**
|
|||
|
动态切换分辨率.
|
|||
|
切换分辨率前需暂停视频通道,即使用流程如下:
|
|||
|
AWVideoInput_Start(0, 0) --> AWVideoInput_ResetSize() --> AWVideoInput_Start(0, 1)
|
|||
|
*/
|
|||
|
int AWVideoInput_ResetSize(int channel, int widht, int height);
|
|||
|
|
|||
|
int AWVideoInput_GetChannelInfo(int channel, VideoChannelInfo *pChannelInfo);
|
|||
|
|
|||
|
//* 动态设置 qp
|
|||
|
int AWVideoInput_SetQpRange(int channel, video_qp_range* qp_range);
|
|||
|
int AWVideoInput_SetFixQp(int channel, RTVencFixQP* fix_qp);
|
|||
|
int AWVideoInput_GetQpRange(int channel, video_qp_range* qp_range);
|
|||
|
|
|||
|
//* 动态设置码率, 单位:kbps
|
|||
|
int AWVideoInput_SetBitrate(int channel, int bitrate /* kbps */);
|
|||
|
|
|||
|
int AWVideoInput_SetJpgQuality(int channel, int nQuality);
|
|||
|
int AWVideoInput_SetEnIFrmMbRcMoveStatus(int channel, int nMbRcMoveStatus);
|
|||
|
int AWVideoInput_SetH264VideoTiming(int channel, RTVencH264VideoTiming* H264VideoTiming);
|
|||
|
int AWVideoInput_SetH265VideoTiming(int channel, RTVencH265TimingS* H265VideoTiming);
|
|||
|
|
|||
|
//* 获取码率, 单位:kbps
|
|||
|
int AWVideoInput_GetBitrate(int channel);
|
|||
|
|
|||
|
//* set the frameRate, such as 1 ~ 15 fps;
|
|||
|
int AWVideoInput_SetFps(int channel, int fps);
|
|||
|
|
|||
|
int AWVideoInput_GetFps(int channel);
|
|||
|
|
|||
|
int AWVideoInput_SetVbrParam(int channel, RTVencVbrParam *pvbr_param);
|
|||
|
|
|||
|
int AWVideoInput_GetVbrParam(int channel, RTVencVbrParam *pvbr_param);
|
|||
|
|
|||
|
int AWVideoInput_GetSumMad(int channel);
|
|||
|
|
|||
|
int AWVideoInput_GetMotionSearchResult(int channel, RTVencMotionSearchResult* pMotionSearchResult);
|
|||
|
|
|||
|
int AWVideoInput_SetSuperFrameParam(int channel, RTVencSuperFrameConfig* pSuperFrameConfig);
|
|||
|
|
|||
|
int AWVideoInput_SetMotionSearchParam(int channel, RTVencMotionSearchParam* pMotionSearchParam);
|
|||
|
|
|||
|
int AWVideoInput_SetRoi(int channel, RTVencROIConfig* pRoiConfig);
|
|||
|
|
|||
|
int AWVideoInput_SetGdc(int channel, RTsGdcParam* pGdcConfig);
|
|||
|
|
|||
|
int AWVideoInput_SetRotate(int channel, int rotate_angle);
|
|||
|
|
|||
|
int AWVideoInput_GetSpsPpsInfo(int channel, sps_pps_data_info *pSpsPpsInfo);
|
|||
|
int AWVideoInput_SetChmoraGray(int channel, int enable_gray);
|
|||
|
|
|||
|
int AWVideoInput_SetWbYuv(int channel, WbYuvFuncInfo *pWbYuvFuncInfo, RTsWbYuvParam *pWbYuvParam, int dst_w, int dst_h);
|
|||
|
int AWVideoInput_SaveWbYuv(int channel, WbYuvFuncInfo *pWbYuvFuncInfo);
|
|||
|
int AWVideoInput_DeInitWbYuv(int channel, WbYuvFuncInfo *pWbYuvFuncInfo);
|
|||
|
|
|||
|
int AWVideoInput_Set2dNR(int channel, RTs2DfilterParam* p_2dnr_param);
|
|||
|
int AWVideoInput_Set3dNR(int channel, RTs3DfilterParam* p_3dnr_param);
|
|||
|
|
|||
|
int AWVideoInput_SetPIntraRefresh(int channel, RTVencCyclicIntraRefresh* pIntraRefresh);
|
|||
|
|
|||
|
int AWVideoInput_SetRecRefLbcMode(int channel, RTeVeLbcMode rec_lbc_mode);
|
|||
|
|
|||
|
int AWVideoInput_SetWeakTextTh(int channel, RTVenWeakTextTh *pWeakTextureTh);
|
|||
|
|
|||
|
int AWVideoInput_SetRegionD3DParam(int channel, RTVencRegionD3DParam *pRegionD3DParam);
|
|||
|
|
|||
|
int AWVideoInput_GetRegionD3DResult(int channel, RTVencRegionD3DResult *pRegionD3DResult);
|
|||
|
|
|||
|
int AWVideoInput_SetChromaQPOffset(int channel, int nChromaQpOffset);
|
|||
|
|
|||
|
int AWVideoInput_SetH264ConstraintFlag(int channel, RTVencH264ConstraintFlag *pConstraintFlag);
|
|||
|
|
|||
|
int AWVideoInput_SetVe2IspD2DLimit(int channel, RTVencVe2IspD2DLimit *pD2DLimit);
|
|||
|
|
|||
|
int AWVideoInput_EnableSmallSearchRange(int channel, int enable);
|
|||
|
|
|||
|
int AWVideoInput_SetForceConfWin(int channel, RTVencForceConfWin *pConfWin);
|
|||
|
|
|||
|
int AWVideoInput_SetRotVe2Isp(int channel, RTVencRotVe2Isp *pRotVe2Isp);
|
|||
|
|
|||
|
int AWVideoInput_SetInsertData(int channel, RTVencInsertData *pInsertData);
|
|||
|
|
|||
|
int AWVideoInput_GetInsertDataBufStatus(int channel, RT_VENC_BUF_STATUS *pStatus);
|
|||
|
|
|||
|
int AWVideoInput_DropFrame(int channel, int nDropNum);
|
|||
|
|
|||
|
//* for debug, caller should not care
|
|||
|
int AWVideoInput_RequestEmptyYuvFrame(int channel, VideoYuvFrame* pYuvFrame);
|
|||
|
|
|||
|
//* for debug, caller should not care
|
|||
|
int AWVideoInput_SubmitFilledYuvFrame(int channel, VideoYuvFrame* pYuvFrame, int yuv_size);
|
|||
|
|
|||
|
int AWVideoInput_SetCameraMoveStatus(int channel, RT_VENC_CAMERA_MOVE_STATUS camera_move_status);
|
|||
|
|
|||
|
//setting crop info, crop_info->enable_crop = 0 will disable crop
|
|||
|
int AWVideoInput_SetCrop(int channel, RTCropInfo *crop_info);
|
|||
|
int AWVideoInput_SetVencTargetBitsClipParam(int channel, RT_VENC_TARGET_BITS_CLIP_PARAM *target_bits_clop_param);
|
|||
|
|
|||
|
//tdm related api.
|
|||
|
int AWVideoInput_RegisterTdmBufDoneCallback(int channel, void *cb);
|
|||
|
int AWVideoInput_ReturnTdmBuf(int channel, struct vin_isp_tdm_event_status* p_tdm_status);
|
|||
|
int AWVideoInput_GetTdmData(int channel, struct vin_isp_tdm_data *p_tdm_data);
|
|||
|
int AWVideoInput_StartProcessTdmBuf(int channel);
|
|||
|
|
|||
|
int AWVideoInput_SetEncAndDecCase(int channel, int bEncAndDecCase);
|
|||
|
|
|||
|
int AWVideoInput_GetISPReg(int channel, VIN_ISP_REG_GET_CFG *cfg_ptr);
|
|||
|
|
|||
|
#endif
|