12#include "icam_struct.h"
19#ifdef ICAMP2P_C_EXPORTS
20#define ICAMP2P_C_EXPORTS
22#define ICAMP2P_C_EXPORTS
25#define ICAMP2P_C_EXPORTS
32typedef struct P2PRAW *HP2PRAW;
38#define P2PCONN_TYPE_LAN 1
39#define P2PCONN_TYPE_P2P 2
40#define P2PCONN_TYPE_RELAY 3
41ICAMP2P_C_EXPORTS
const char *iCamP2pGetConnTypeName(
int connType);
80#define MAKE_CONNFLAGS(bLanSearch, iP2pTryTime, bRelay) ((bLanSearch?1:0) | (bRelay?0:0x20) | ( ((iP2pTryTime==0?15:iP2pTryTime) & 0x1f) << 1 ) )
82ICAMP2P_C_EXPORTS
int iCamRawConnect(
const char *server,
const char *did,
int fConnFlags, HP2PRAW *phP2pRaw);
83ICAMP2P_C_EXPORTS
int iCamRawGetConnType(HP2PRAW hRaw);
84ICAMP2P_C_EXPORTS
int iCamRawDisconnect(HP2PRAW hRaw);
87ICAMP2P_C_EXPORTS
int iCamRawCheckBuffer(HP2PRAW,
int chn,
unsigned int to_send,
int *fill_percent);
89ICAMP2P_C_EXPORTS
int iCamRawRecv(HP2PRAW hRaw,
int avIndex,
void *buff,
int size,
int timeout);
90ICAMP2P_C_EXPORTS
int iCamRawSend(HP2PRAW hRaw,
int avIndex,
const void *buff,
size_t len);
91ICAMP2P_C_EXPORTS
int iCamRawSendV(HP2PRAW hRaw,
int avIndex,
struct iovec *v,
int size);
101ICAMP2P_C_EXPORTS
int iCamRawRecvN(HP2PRAW handle,
int avIndex,
void *buff,
int size,
int timeout);
109ICAMP2P_C_EXPORTS
int iCamRawRecvN2(HP2PRAW handle,
int avIndex,
void *buff,
int size,
const SA_BOOL *b_run);
162ICAMP2P_C_EXPORTS
int iCamRawSendCmd(HP2PRAW handle,
int cmd,
const void *req,
int len);
163ICAMP2P_C_EXPORTS
int iCamRawSendMedia(HP2PRAW hRaw,
TCMEDIA mt, uint32_t ts, uint32_t uFrameFlags,
const uint8_t *pData,
int size);
165ICAMP2P_C_EXPORTS SA_BOOL iCamP2pCheckValid(
HP2PCLT hClt);
168ICAMP2P_C_EXPORTS
int iCamP2pSendCmd(
HP2PCLT hClt,
int cmd,
const void *data,
int len);
172ICAMP2P_C_EXPORTS
const char *iCamP2pGetErrorString(
int err);
174typedef void (*ICAMEVENTCALLBACK)(
const RTMSG_t *msg,
int len,
HP2PCLT hClt,
void *pUser);
175typedef void (*ICAMCMDDATACALLBACK)(
const void *data,
int len,
HP2PCLT hClt,
void *pUser);
184ICAMP2P_C_EXPORTS
int iCamP2pConnect(
const char *server_cfg,
const char *did,
const char *key,
185 int fConnFlags,
HP2PCLT *phP2pClt);
206ICAMP2P_C_EXPORTS
int iCamP2pConnectByToken(
const char *token,
int fConnFlags,
HP2PCLT *hP2pClt);
219 int n_vchn, n_streams_per_vchn;
220 unsigned char types[32];
226ICAMP2P_C_EXPORTS
int iCamP2pVerifyPassword(
HP2PCLT hClt,
const char *password);
250ICAMP2P_C_EXPORTS
int iCamP2pPause(
HP2PCLT hClt);
251ICAMP2P_C_EXPORTS
int iCamP2pContinue(
HP2PCLT hClt);
321typedef int (*RESPCALLBACK)(
const void *body,
int len,
void *pUser);
324typedef struct RespProcessor {
335typedef struct iCamAutoCmd {
346struct RespWaitBundle;
348ICAMP2P_C_EXPORTS
int _iCamP2pExecute(
HP2PCLT hClt,
int cmd,
const void *pReq,
int lenReqData,
349 RESPPROCESSOR *rp,
int timeout,
struct RespWaitBundle **ppPoll);
350ICAMP2P_C_EXPORTS SA_BOOL RwbPoll(
struct RespWaitBundle *rwb,
int timeout,
int *status);
351ICAMP2P_C_EXPORTS
void RwbFree(
struct RespWaitBundle *rwb,
HP2PCLT hClt);
353ICAMP2P_C_EXPORTS
int iCamP2pExecute(
HP2PCLT hClt,
int cmd,
const void *pReq,
int lenReq,
void *pResp,
int sizeResp,
int timeout);
355ICAMP2P_C_EXPORTS
int iCamP2pSetBatchMode(
HP2PCLT hClt);
356ICAMP2P_C_EXPORTS
int iCamP2pBatchModeFlush(
HP2PCLT hClt,
int timeout);
370ICAMP2P_C_EXPORTS
int iCamP2pAnswerToCall(
HP2PCLT hClt,
int state);
P2p Commands and Structures
P2p Commands and Structures
ICAMP2P_C_EXPORTS SA_BOOL iCamRawCheckValid(HP2PRAW hRaw)
检查当前连接是否仍有效
ICAMP2P_C_EXPORTS int iCamP2pDisconnect(HP2PCLT hClt)
断开连接
ICAMP2P_C_EXPORTS void iCamP2pBreakConnecting()
中断当前正在进行中连接过程
ICAMP2P_C_EXPORTS void iCamP2pPlaybackStart(HP2PCLT hClt, FRAMECALLBACK cb_v, void *pUser_v, FRAMECALLBACK cb_a, void *pUser_a)
开始sd卡回放.
ICAMP2P_C_EXPORTS int iCamP2pSetMaxAwakeTime(HP2PCLT hClt, int maxAwakeTime)
设置低功耗摄像头的最大工作时长
ICAMP2P_C_EXPORTS int iCamP2pPlaybackSetRate(HP2PCLT hClt, int rate)
设置回放倍速.
ICAMP2P_C_EXPORTS int iCamP2pRebootDev(HP2PCLT hClt)
设备重启
ICAMP2P_C_EXPORTS int iCamP2pGetCloudVideoQuality(HP2PCLT hClt)
获取云录像清晰度设置
ICAMP2P_C_EXPORTS int iCamP2pStopLiveAudio(HP2PCLT hClt)
停止音频传输
ICAMP2P_C_EXPORTS int iCamP2pEnterSetup(HP2PCLT hClt)
通知低功耗设备app进入设置界面,不要休眠
ICAMP2P_C_EXPORTS int iCamP2pStartLiveVideo(HP2PCLT hClt, int channel, FRAMECALLBACK cb, void *pUser)
开启实时图像.
ICAMP2P_C_EXPORTS int iCamP2pConnect2(const char *server_cfg, const char *did, int fConnFlags, HP2PCLT *phP2pClt)
连接设备但不执行口令认证.
ICAMP2P_C_EXPORTS int iCamP2pSetDeviceStatus(HP2PCLT hClt, int status)
设置设备开关状态.
unsigned char flags
For video frame, is of ENUM_FRAMEFLAG.
ICAMP2P_C_EXPORTS int iCamP2pInit()
初始化p2p库.
ICAMP2P_C_EXPORTS int iCamP2pPlaybackPause(HP2PCLT hClt, int bPause)
回放暂停
int resp_size
out: bytes filled in {resp}
ICAMP2P_C_EXPORTS int iCamRawRecvN2(HP2PRAW handle, int avIndex, void *buff, int size, const SA_BOOL *b_run)
无超时读取N字节.
int size
memory size pointed by {frame}
ICAMP2P_C_EXPORTS int iCamP2pStopLiveVideo(HP2PCLT hClt, int channel)
停止视频传输
ICAMP2P_C_EXPORTS int iCamP2pChangePassword(HP2PCLT hClt, const char *oldpasswd, const char *newpasswd)
修改直接模式密码
ICAMP2P_C_EXPORTS int iCamP2pSetCallback(HP2PCLT hClt, ICAMEVENTCALLBACK event_cb, ICAMCMDDATACALLBACK data_cb, void *pUser)
设备连接的消息/数据回调.
ICAMP2P_C_EXPORTS int iCamP2pStopTalk(HP2PCLT hClt)
停止对讲
ICAMP2P_C_EXPORTS int iCamRawRecvN(HP2PRAW handle, int avIndex, void *buff, int size, int timeout)
带超时读取N字节.
ICAMP2P_C_EXPORTS int iCamP2pStartLiveAudio(HP2PCLT hClt, FRAMECALLBACK cb, void *pUser)
开启实时音频.
unsigned int frame_size
Size of frame
ICAMP2P_C_EXPORTS int iCamP2pSelectStream(HP2PCLT hClt, int channel, int stream)
选择码流.
void * pUser
Private data for cb_resp
ICAMP2P_C_EXPORTS int iCamP2pPlaybackLocate(HP2PCLT hClt, time_t t)
sd卡回放定位.
unsigned char * req
命令请求数据
ICAMP2P_C_EXPORTS int iCamP2pGetRecordList2(HP2PCLT hClt, time_t t_start, int tlen, SAvEvent2 **ppEvents, unsigned int *pNEvents)
查询sd卡录像列表.
ICAMP2P_C_EXPORTS int iCamRawRecvFramePkt(HP2PRAW hRaw, int avIndex, struct FramePkt *pkt, int timeout, SA_BOOL *pbRun)
在通道上读一个完整帧.
RESPCALLBACK cb_resp
if {cb_resp} is not NULL, {resp} and {resp_size} are passed as the 1st and 2nd parameters
ICAMP2P_C_EXPORTS int iCamP2pSendMedia(HP2PCLT hClt, TCMEDIA mt, uint32_t ts, uint32_t uFrameFlags, const uint8_t *pMedia, int size)
发关对讲音视频
int resp_buf_size
in: size of the buffer pointed by {resp}
ICAMP2P_C_EXPORTS int iCamP2pStartTalk(HP2PCLT hClt)
开始对讲.
ICAMP2P_C_EXPORTS void iCamP2pPlaybackStop(HP2PCLT hClt)
停止回放
ICAMP2P_C_EXPORTS int iCamP2pGetDeviceStatus(HP2PCLT hClt)
获取当前设备状态.
ICAMP2P_C_EXPORTS int iCamP2pLeaveSetup(HP2PCLT hClt)
通知低功耗设备app离开设置界面,可以休眠
ICAMP2P_C_EXPORTS int iCamRawReadCmdPkt(HP2PRAW hRaw, struct CmdPkt *pkt, int timeout, SA_BOOL *pbRun)
在命令通道上读一个完整包.
ICAMP2P_C_EXPORTS int iCamP2pSetCloudVideoQuality(HP2PCLT hClt, int quality)
设置云录像清晰度
ICAMP2P_C_EXPORTS void iCamP2pDeinit()
清除p2p库
ICAMP2P_C_EXPORTS int iCamP2pGetFeatures(HP2PCLT hClt, CAMFEATURES *pFeatures)
获取设备能力集.
unsigned int timestamp
Timestamp of the frame, in milliseconds
ICAMP2P_C_EXPORTS int iCamP2pConnect(const char *server_cfg, const char *did, const char *key, int fConnFlags, HP2PCLT *phP2pClt)
连接设备.
void(* FRAMECALLBACK)(FRAMEHEAD_t *fi, unsigned char *data, void *pUser)
音视频视回调.
unsigned short codec_id
非0时, 低8位为 TCMEDIA, 高8位为视频通道号.
ICAMP2P_C_EXPORTS int iCamP2pBatchExecute(HP2PCLT hClt, ICAMAUTOCMD *cmds, int nCmds, int timeout)
执行多条命令
unsigned char seq_no[3]
1~0xffffff. sequency number for frame, used internally by sdk to detect frame loss.
struct P2PCLT * HP2PCLT
p2p连接句柄
unsigned char cam_index
0 (>0 may be used in future)
unsigned char rt_flags
当帧类型为视频时,bit0 为是否在录像的标志
RESPPROCESSOR rspProc
responsed data processor
ICAMP2P_C_EXPORTS int iCamP2pGetMaxAwakeTime(HP2PCLT hClt)
获取低功耗摄像同的最大工作时长
unsigned char * resp
cb_resp == NULL 时为原始响应数据缓冲区。否则忽略
ICAMP2P_C_EXPORTS int iCamP2pSendAudio(HP2PCLT hClt, const uint8_t *pAudio, int size)
Audio/Video Frame Header Info