EasyCVR接入华为视频云系统eSDK过程——资源准备接口的使用
作者:互联网
目前我们对EasyCVR私有协议SDK的开发已经进入了测试阶段,EasyCVR可以通过私有协议SDK的形式(eSDK)接入华为视频平台,接入的第一步就是资源准备接口,下面提供华为视频平台对接第一步资源准备接口的使用方法。
一、初始化和释放
1、设置eSDK日志文件路径,日志文件缺省路径为“…/log/sdk”
适用以下操作系统:
Windows 7专业版 32位、Windows 7专业版 64位、Windows Server 2008 R2 64位、Windows Server 2016
SUSE Linux 11 SP1(2.6.16.21以上) 64位、Euler Linux(2.8以上) 64位、CentOS Linux(7.6以上)64 位、Ubuntu(16.04)64位、CentOS7.6_arm 64位
如果调用该接口设置日志文件路径,需要在初始化接口之前完成。也可以通过修改配置文件设置日志文件路径,配置文件所在目录“\bin\config\log.xml”。
//cpp code
IVS_INT32 iRet = IVS_SDK_SetLogPath("..\\ivs_log");
if (IVS_SUCCEED == iRet)
{
//成功
}
2、对整个SDK系统进行初始化,内存预分配等操作
//cpp code
IVS_INT32 iRet = IVS_SDK_Init();
if (IVS_SUCCEED == iRet)
{
//初始化SDK成功
}
3、释放SDK资源
//cpp code
IVS_INT32 iRet = IVS_SDK_Cleanup();
if (IVS_SUCCEED == iRet)
{
//释放SDK成功
}
二、设置回调函数
1、设置事件回调函数
//cpp code
/*回调函数,此处只举例处理录像下载的回调事件*/
void _stdcall EventCallBackFunc(IVS_INT32 iEventType, IVS_VOID* pEventBuf, IVS_UINT32 uiBufSize, IVS_VOID* pUserData)
{
if (IVS_EVENT_DOWNLOAD_FAILED == iEventType)//事件类型定义参见宏定义
{
STREAM_EXCEPTION_INFO* ExceptionInfo = (STREAM_EXCEPTION_INFO*)pEventBuf;
if (NULL == ExceptionInfo)
{
return;
}
/*把RTSP连接正常结束作为下载完成的信号*/
if (IVS_PLAYER_RET_RTSP_NORMAL_STOP == ExceptionInfo->iExceptionCode)
{
CIVSDownLoadPage* pDownloadPage = (CIVSDownLoadPage*)pUserData;
pDownloadPage->PostMessage(WM_DOWNLOADSUCCESS);//异步处理
}
}
}
/*设置回调函数,使用上面实现了的回调函数*/
IVS_SDK_SetEventCallBack(iSessionID, (EventCallBack)EventCallBackFunc, &m_DownLoadPage);
2、设置视频元数据回调函数
//cpp code
void ProcessMetaTlvL1(char *data, unsigned int size)
{
TLV *tlv1 = (TLV *)data;
if (tlv1->type != METADATA_TYPE || tlv1->length + 8 > size)
{
return;
}
ProcessMetaTlvL2(tlv1->data, tlv1->length);
}
void ProcessMetaTlvL2(char *base, unsigned int size)
{
unsigned int off = 0;
while ((off + 8) < size)
{
TLV *tlv = (TLV *)(base + off);
off += (8 + tlv->length);
if (!tlv->length || off > size)
{
return;
}
switch (tlv->type)
{
case COMMON:
case TARGET:
ProcessMetaTlvL3(tlv->data, tlv->length);
break;
case RULE:
ProcessMetaTlvL3(tlv->data, tlv->length);
break;
default:
break;
}
}
}
void ProcessMetaTlvL3(char *base, unsigned int size)
{
unsigned int uiStatus = 0;
unsigned int uiTmpObjectID = 0;
unsigned int off = 0;
while ((off + 8) < size)
{
TLV *tlv = (TLV *)(base + off);
off += (8 + tlv->length);
if (!tlv->length || off > size)
{
return;
}
switch (tlv->type)
{
case OBJ_ID:
// TODO OBJ_ID process
break;
case OBJ_POS:
// TODO OBJ_POS process
break;
case OBJ_STATUS:
// TODO OBJ_STATUS process
break;
default:
// TODO default process
break;
}
}
}
/*回调函数,此处只举例处理录像下载的回调事件*/
void _stdcall pfnMetadataCallbackFunc(IVS_UINT32 uiTimeStamp, IVS_VOID* pData, IVS_UINT32 uiLen, IVS_VOID* pUser);
{
if (0xAA == *((unsigned char*)pData)) //解析单包
{
ProcessMetaTlvL1((char*)pData+1, uiLen-1);
}
return;
}
/*设置回调函数,使用上面实现了的回调函数*/
IVS_SDK_SetVideoMetadataCallBack(iSessionID,ulPlayHandle,pfnMetadataCallbackFunc,pUserData
标签:off,tlv,length,EasyCVR,unsigned,华为,IVS,eSDK,SDK 来源: https://www.cnblogs.com/easycvr/p/15459566.html