5#ifndef __TgCloudApi_h__
6#define __TgCloudApi_h__
39 TRANS_SERVICE_LIVE_AV = 0,
40 TRANS_SERVICE_AUDIO_PIC = 1,
41 TRANS_SERVICE_PIC_ONLY = 2,
74 TCOPT_TCP_CONNECTOR = 4,
106 TCOPT_NO_WX_EVENT = 10,
108 TCOPT_UNIFORMED_CALL_PROCESS = 11,
124#define TGSS_F_CS_INSERVICE 0x00000001
125#define TGSS_F_P2P_CONNECTED 0x00000002
126#define TGSS_F_P2P_STREAMING 0x00000004
127#define TGSS_F_P2P_INSETTING 0x00000008
128#define TGSS_F_BS_UPLOADING 0x00000010
129#define TGSS_F_CALL_PENDING 0x00000020
130#define TGSS_F_IN_CONVERSATION 0x00000040
301 int (*
snapshot)(
int type, uint8_t **ppJpg,
int *size);
308 int (*
set_wifi)(
int is_switching,
const char *ssid,
const char *key);
326 int (*
on_status)(
int status,
const void *pData,
int len);
360 void (*
ai_result)(
int type,
const uint8_t* pJpg,
int len);
378 int (*
log)(
int action,
char *logfile);
404 void (*
talkback_ex)(
int mt,
unsigned int ts,
const void *data,
int len,
unsigned int uFrameFlags);
504TG_PUBLIC
int TciInit(
const char *path,
const char *uuid);
515TG_PUBLIC
int TciStart(
int isBound,
unsigned int uCloudBuffSize);
526TG_PUBLIC
int TciStart2(
int isBound,
unsigned int uCloudBuffSize,
const char *uuid);
572TG_PUBLIC
void TciSetLogOption(
int b_output_to_console,
const char *log_path,
int max_log_size);
662TG_PUBLIC
int TciReportGpsInfo(
const unsigned int time,
const double longitude,
const double latitude,
663 double speed,
int angle ,
int signal_strength);
761#define TciSendPbSyncFrame(handle, utc_time, is_response_to_PLAY_START) TciSendPbMessage(handle, is_response_to_PLAY_START?RTM_SYNCTIME_RESPONSE_TO_USER:RTM_SYNCTIME, 0, utc_time, NULL, 0)
768#define TciSendPbTimelapseFlag(handle, flag) TciSendPbMessage(handle, RTM_TIME_LAPSED, flag, 0, NULL, 0)
773#define TciSendPbEndOfEvent(handle) TciSendPbMessage(handle, RTM_END_OF_EVENT, 0, 0, NULL, 0)
790TG_PUBLIC
int TciSendFrameEx(
int channel,
int stream,
TCMEDIA mt,
const uint8_t *pFrame,
int length, uint32_t ts,
int uFrameFlags);
805TG_PUBLIC
int TciSendLiveMessage(
int channel,
int stream,
RTMTYPE type,
unsigned int data1,
unsigned int data2,
const void *data,
int data_len);
809#define TciSendLiveMsg_ReachPsp(channel, psp_num) TciSendLiveMessage(channel, -1, RTM_REACH_PSP, channel, psp_num, NULL, 0)
813#define TciSendLiveMsg_LensSwitch(channel, stream) TciSendLiveMessage(channel, stream, RTM_LENS_SWITCH, channel, stream, NULL, 0)
818#define TciSendLensSwitchFlag(channel, stream) TciSendLiveMsg_LensSwitch(channel, stream)
1001TG_PUBLIC
void TciSetWakeupReason(time_t t_wakeup,
int r,
const char *user_reason,
int sig_lvl,
int sdc_rec);
1058void *
TciUduBegin2(
const char *evt, time_t tRecordStart,
const char *jpg_pic,
int pic_len);
1059#define TciUduBegin(evt, tRecordStart) TciUduBegin2(evt, tRecordStart, NULL, 0)
1087typedef void (*TCIONLIVEFRAMECB)(
int channel,
int stream,
TCMEDIA mt,
const uint8_t *pFrame, uint32_t size, uint32_t ts,
int uFrameFlags);
1088void TciRegisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1089void TciUnregisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1105char *TciGetDeviceInfoString(
void);
1188int TgPostLogFile(
const char *url,
const char *uuid,
const char *path,
int timeout);
1200int TgPostLogMem(
const char *url,
const char *uuid,
const void *mem,
int size,
const char *name,
int timeout);
1217TG_PUBLIC
int TciPutLogMem(
const void *mem,
int size,
const char *name,
int timeout);
1249typedef struct _IceConfig {
P2p Commands and Structures
P2p Commands and Structures
RTMTYPE
插入到媒体流(实时或回放)或命令通道中的消息类型.
@ PM_ALLON
常电模式。非低功耗设备的默认模式
@ PM_NETDOWN
主控正常工作,网络模块进入休眠模式
@ PM_SLEEPABLE
系统可休眠(会收到STATUS_IDLE状态回调。这是低功耗设备的默认模式)
@ TCOPT_PRERECORD_LENGTH
事件云存预录时间长度, 单位:秒.
@ TCOPT_MAX_DATAFILE_SIZE
最大云存data文件。超出的帧会丢弃.
@ TCOPT_ONLY_REPORT_AI_EVENT
仅上报AI事件(
@ TCOPT_NO_STREAMING_WITHOUT_ACCEPTING_CALL
用户没有应答不能拉流.
@ TCOPT_ENABLE_ADJUSTMENT_FOR_CS
开关云存码流调整功能.
@ TCOPT_TRANS_MEDIA_TYPE
传输内容 类型: int*:
@ TCOPT_DISABLE_UPLOAD_WHEN_VIEWING
有人观看时禁止上传 类型: int*
@ TCOPT_ONLY_REPORT_AI_EVENT2
在有AI服务时仅上报AI事件.
@ TCOPT_BUFFER_QUEUE_SIZE
云存储缓冲文件数.
@ TCOPT_BACKSTORE_SAVEDAYS
backstore 存储天数 类型 int*:
TG_PUBLIC int TciQueryForOta2(const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota)
查询第三方升级包.
TG_PUBLIC int TciPrepareHiberation(int *socks, int size)
准备休眠 本api建立到唤醒服务器的tcp连接,并且返回连接数.
TG_PUBLIC int TciReport4GInfoEx(const TG4GINFO *info, ECG4STATE state)
上报4G设备信息,代替 TciReport4GInfo()
TG_PUBLIC int TciQueryUserFile(const char *name, EcFileLink *flnk)
获取用户文件的下载地址.
TG_PUBLIC int TciSendUserData(const unsigned char *data, int len)
发送用户自定义数据到第三方平台.
TG_PUBLIC int TciSendFrameEx(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, int length, uint32_t ts, int uFrameFlags)
发送实时音视频帧, SDK内部会将数据分发到云端和APP.
TG_PUBLIC int TciSetMaxP2pClientsNum(int num)
设置最大p2p连接数.
TG_PUBLIC void TciFastRecoverP2p(void)
从NETDOWN模式下恢复网络后,调用本api使p2p快速上线
TG_PUBLIC int TciSetEventRecordLength(int erl)
设置用户定义低功耗设备的事件云录像时长.
TG_PUBLIC int TciSyncPlatConfig(const unsigned char *pData, int len)
同步从MCU来的数据.
TG_PUBLIC int TciSendLiveMessage(int channel, int stream, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len)
发送实时流消息.
TG_PUBLIC int TciGetUserFile(const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout)
查询并下载用户文件.
TG_PUBLIC int TciProcessRegInfo(const void *data)
处理从蓝牙收到的注册数据
TG_PUBLIC void TciSetRtState(ENUMRTSTATE state, void *pData)
报告系统运行时状态
TG_PUBLIC int TciReportBatteryStatus(int qoe, int qoe_low, int charging)
上报电池状态
TG_PUBLIC const void * TciGetRegisterConfiguration(int *len)
保存wifi注册信息.
TG_PUBLIC int TciStartInTestMode(const char *key_path)
开启p2p功能,进入厂测状态.
TG_PUBLIC int TciInit(const char *path, const char *uuid)
配置基本参数 在TciStart()之前调用
TG_PUBLIC int TciSendCmdRespStatus(p2phandle_t handle, unsigned int cmd, unsigned int status)
发送一个 Tcis_ErrorResp 结构作应答.
char * TciGetActivationAttrs(void)
获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
TG_PUBLIC int TciSendRtMsg(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len)
在命令通道上发送通知.
TG_PUBLIC int TciForceSleeping(SA_BOOL bDiscardFilesInQueue)
设备端准备强制休眠.
TG_PUBLIC int TciPerformOTA(DEVICEOTAINFO *ota)
执行下载过程,会调用回调里的 ota 接口.
TG_PUBLIC int TciGetLogConf(struct TgLogConf *pLogConf)
查询日志上传配置
TG_PUBLIC void * TciGetSessionUserData(p2phandle_t handle)
返回由TciSetSessionUserData()设置的应用私有数据指针
TG_PUBLIC void TcnIpChanged()
设备上线后IP发生变化时通知SDK, 用于立即更新长连接
TG_PUBLIC int TciStopEvent(ECEVENT evt)
停止事件, 仅少数事件才有意义.
TG_PUBLIC int TciConfigWifi(int mode)
开始配置WIFI.
TG_PUBLIC void TciSetLogLevel(int level)
设置SDK日志输出等级.
TG_PUBLIC int TciSendPbFrame(p2phandle_t handle, uint32_t id_mt, const uint8_t *frame, int len, uint32_t timestamp, int uFrameFlags)
回放时发送数据帧.
TG_PUBLIC int TciDownloadUserFile(const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout)
下载用户文件.
TG_PUBLIC int TciStopConfigWifi(int mode)
中止配网.
TG_PUBLIC void TciSelectEnvironment(int env)
用于选择调试环境
TG_PUBLIC int TciLocalStart(const char *url, const ICECONFIG *cfg, int size)
开启本地工作模式.
TG_PUBLIC int TciSetKeyVideoTime(int channel, int stream, time_t t)
告诉SDK下一个视频关键帧的实际发生时间(UTC).
TG_PUBLIC int TciStop(void)
停止服务
TG_PUBLIC void TciSetLogOption(int b_output_to_console, const char *log_path, int max_log_size)
控制日志输出.
TG_PUBLIC int TciCheckRegString(const char *s)
在sdk外部扫二维码.
TG_PUBLIC int TciSetCmdHandler(const TGCMDHANDLER cb)
注册通用命令回调 在回调里处理APP发来的命令请求
TG_PUBLIC void TciSetSessionUserData(p2phandle_t handle, void *pUser)
绑定应用私有数据指针到p2p handle
TG_PUBLIC int TciRejectInCall2()
拒接.
TG_PUBLIC int TciSendPbMessage(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len)
在回放流中插入消息.
TG_PUBLIC const uint8_t * TciPrepareAuthString(const char *randKey, int *len_of_authstring)
生成唤醒服务器登录命令.
TG_PUBLIC int TciSetCallback(const struct TciCB *cb)
注册回调 – sdk内部事件
TG_PUBLIC int TciUduPutFrame(void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags)
自定义上传过程,写入帧.
TG_PUBLIC unsigned int TciGetSdkState(void)
获取SDK内部状态.
TG_PUBLIC void TciBackStoreEnableUpload(int en)
允许或禁止后备上传.
TG_PUBLIC int TciGetWakeupServers(Ipv4Addr servers[3])
获取唤醒服务器ip地址
TG_PUBLIC int TciReportError(const char *name, const char *detail)
上报错误
void * TciUduBegin2(const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len)
开始一个用户定义上传.
TG_PUBLIC int TciSetRegInfo(const char *s)
手动处理注册信息
TG_PUBLIC int TciGetSysOption(TCSYSOPTION opt, void *pVal)
通用sdk工作选项获取接口.
TG_PUBLIC void TciSetWakeupReason(time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec)
设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
TG_PUBLIC int TciSwitchDeviceStatus(int status)
设置设备开关状态.
TG_PUBLIC void TciSetP2pDown(SA_BOOL bDown)
暂停或继续运行 P2P.
TG_PUBLIC int TciReportGpsInfo(const unsigned int time, const double longitude, const double latitude, double speed, int angle, int signal_strength)
上报GPS信息
TG_PUBLIC int TciAllocCloudBuffer(unsigned int uCloudBuffSize)
预分配云存储帧缓存空间.
void TciSetParamFileOps(struct paramf_ops *ops)
设置参数文件操作指针.
unsigned char * TciGetPlatConfig(int *pLen)
返回要同步到MCU的数据.
TG_PUBLIC int TciSendCmd(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令请求
TG_PUBLIC int TciPutLogFile(const char *local_path, int timeout)
上传日志文件.
int TgQueryUploadReq(const char *uuid, const char *model_id, char **ppUrl)
TG_PUBLIC void TciFlushCsCache()
等待录像缓冲区中的所有数据被消耗掉.
int TgPostLogFile(const char *url, const char *uuid, const char *path, int timeout)
TG_PUBLIC int TciStart2(int isBound, unsigned int uCloudBuffSize, const char *uuid)
启动服务.
TG_PUBLIC void TciSetPowerMode(PMODE mode)
设置低功耗设备的工作模式.
TG_PUBLIC int TciSetSysOption(TCSYSOPTION opt, const void *pVal)
通用sdk工作选项设置接口.
TG_PUBLIC int TciSetP2pInfo(const char *sss)
TG_PUBLIC void TciBackStoreEnable(int en)
这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
TG_PUBLIC int TciReport4GInfo(const char *imei, const char *iccid, ECG4STATE state)
int TgPostLogMem(const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout)
TG_PUBLIC int TciSetDoorbellEvent()
包装了门铃事件
TG_PUBLIC void TciUduEnd(void *hUdu)
结束自定义上传
TG_PUBLIC int TciQueryForOTA(const char *uuid, DEVICEOTAINFO *ota)
查询升级包.
TG_PUBLIC int TciSetLockEvent(int cls, int msg, int usrtyp, int usrid)
门锁事件上报。图片和录像都在内部处理了.
TG_PUBLIC int TciConfigWifiWithoutReset(int mode)
开始配置WIFI.
TG_PUBLIC int TciSendCmdResp(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令应答
TG_PUBLIC int TciClearCache(SA_BOOL bResetRemote)
清除SDK运行cache.
TG_PUBLIC void TciSetCloudStream(int channel, int stream)
设置云存储录像通道的码流
TG_PUBLIC int TciAcceptInCall2(ECALLFLAVOR flavor)
接听.
TG_PUBLIC int TciStart(int isBound, unsigned int uCloudBuffSize)
启动服务
TG_PUBLIC int TciSetBackStore(const char *sd_path, ECBUFFERHINT buffer_hint)
设置云存储后备存储目录和缓存策略.
TG_PUBLIC int TciSetEventEx(EVENTPARAM *evtp)
上报事件。本版本允许附带事件特定参数.
TG_PUBLIC int TciHangup(void)
挂断当前通话
TG_PUBLIC int TciCleanup(void)
释放资源
SA_BOOL TciSetRegisterConfiguration(const void *data, int len)
恢复wifi注册信息.
TG_PUBLIC int TciGetRevision(void)
获取SDK版本号 TciInit()之后调用
TG_PUBLIC int TciPutLogMem(const void *mem, int size, const char *name, int timeout)
上传内存中的日志
TG_PUBLIC int TciUpgradeOnTheAir(const char *subdev)
下载升级包
int(* on_ota_download_finished)(int status)
升级包下载结束
int(* on_status)(int status, const void *pData, int len)
sdk内部状态
int(* snapshot)(int type, uint8_t **ppJpg, int *size)
抓取图片.
unsigned short port
port, network byte-order
void(* trans_stat)(const struct TransStatUser *_stat)
网络传输统计回调
int msStatInterval
统计周期(单位: ms)
int(* get_feature)(const char *key, char *buf, int size)
设备能力.
void(* on_talkback_stop)(void)
结束对讲
unsigned int ip
ip, network byte-order
int(* set_time)(time_t time)
设置时间
int(* qrcode_get_y_data)(uint8_t **ppYBuff, int *width, int *height)
获取Y图片
int(* request_iframe_ex)(int channel, int vstream)
请求指定图像通道的I帧
int nBytesInBuff
位于发送缓冲区的字节数
int(* on_talkback_start)(void)
开始对讲
int(* log)(int action, char *logfile)
在平台端采集设备日志
int(* qrcode_start)(void)
二维码扫描开始 应用层在此开启取Y数据的通道
int(* talkback)(TCMEDIA at, const uint8_t *audio, int len)
对讲数据回调 格式在前面已经协商过
int(* on_ota_download_start)(const char *new_version, unsigned int size)
OTA升级开始
int(* set_wifi)(int is_switching, const char *ssid, const char *key)
设置wifi参数
char firmware_ver[10]
固件主版本,8个数字组成的字符串。like: "03020201", means 3.2.2.1.
void(* talkback_ex)(int mt, unsigned int ts, const void *data, int len, unsigned int uFrameFlags)
对讲数据回调.
void * mem
OUT: 指向sdk分配的内存
void(* free_buff)(SIMPLEBUFFER *buff)
释放参数缓冲区
time_t expiration
过期时间(utc)
int(* on_ota_download_data)(const uint8_t *buff, int size)
升级包数据 升级包下载过程中,sdk调用此回调将数据传给应用层
short is_igop
1:统计间隔为一个I帧间隔; 0:周期约为~1s
SIMCARDTYPE sim_type
sim卡类型
int(* get_state)(const char *key, char *buf, int size)
取设备当前状态或初始默认设置.
int(* request_iframe)(int vstream)
char vendor[16]
设备生产厂商 OEM
char device_type[16]
Not used
int(* save_buff)(const SIMPLEBUFFER *buff)
写参数文件
ECSERVICETYPE serviceType
云服务类型
int(* set_timezone)(const char *tzs)
设置时区
void(* switch_quality)(int channel, int stream, const char *qstr)
切换图像质量
void(* remove)(void)
删除参数文件(或者清空参数文件)。下一次读出时 len为0
int(* alloc_and_readall)(SIMPLEBUFFER *buff, int cbExtra)
分配缓冲区,并读出参数文件.
void(* qrcode_end)(uint8_t *pYBuff)
结束二维码扫描
char firmware_id[32]
ota 升级用的固件标识, 平台唯一.
time_t tValidUntil
0:diabled; >0:在此时间后无效
void(* ai_result)(int type, const uint8_t *pJpg, int len)
当AI识别成功,通过本回调通知应用.
int(* on_apmode_login)(const char *user, const char *key)
直连模式下用户登录帐号检查
int(* get_info)(TCIDEVICEINFO *info)
获取设备基本信息
int nBytesThrow
丢掉的字节数。丢包会持续到到一个I帧,这期间即使网络恢复也会丢,所以其值只能作为参考, 不能用于计算网速
void * p2phandle_t
p2p连接句柄.
int(* TGCMDHANDLER)(p2phandle_t handle, int cmd, const void *data, int len)
命令回调类型