EasyCVR可以通过私有协议SDK的形式(eSDK)接入华为视频平台,上一篇我们讲了第一步就是资源准备接口,接入之后我们比较常用的需求就是进行设备管理,下面提供华为视频平台对接第二步设备管理接口。
1、获取域路由信息 获取用户拥有权限的整个系统中的域路由信息,域最大数目为128*8。
//cpp code
IVS_UINT32 uiBufSize = sizeof(IVS_DOMAIN_ROUTE_LIST) + 127*sizeof(IVS_DOMAIN_ROUTE);//最多128个
IVS_DOMAIN_ROUTE_LIST* pDomainRouteList = (IVS_DOMAIN_ROUTE_LIST*)(new IVS_CHAR[uiBufSize]);
CHECK_POINTER_VOID(pDomainRouteList)//指针判空
memset(pDomainRouteList, 0, uiBufSize);
IVS_INT32 iRet = IVS_SDK_GetDomainRoute(iSessionID, pDomainRouteList, uiBufSize);
if (IVS_SUCCEED == iRet)
{
//成功
}
delete[] pDomainRouteList;
pDomainRouteList = NULL;
2、获取域路由扩展信息 获取用户拥有权限的整个系统中的域路由扩展信息,包括转发域信息,域最大数目为128*8。
//cpp code
IVS_DOMAIN_ROUTE_LIST_EX m_stDomainRouteList;
memset(&m_stDomainRouteList, 0, sizeof(IVS_DOMAIN_ROUTE_LIST_EX));
IVS_INT32 iRet = IVS_SDK_GetDomainRouteEx(iSessionID, &m_stDomainRouteList, sizeof(IVS_DOMAIN_ROUTE_LIST_EX));
if (IVS_SUCCEED == iRet)
{
//成功
}
3、设置转发域 设置转发域,包括设置或取消支持转发域功能的域为转发域。 当多个用户通过转发域访问同一路实况时,转发域只需向接入域获取一路码流,然后将该路实况码流分发给多个用户。
//cpp code
const IVS_CHAR DomainCode[33]="9ab732022a694065add3df928382123c";
IVS_BOOL bIsSupportProgressionTransmit = True;
IVS_INT32 iRet = IVS_SDK_SetProgressionTransmit(iSessionID, bIsSupportProgressionTransmit, DomainCode);
if (IVS_SUCCEED == iRet)
{
//成功
}
4、获取域列表 查询当前登录域、下级域的域列表、网元列表及信息。
//cpp code
iRet = IVS_SDK_GetDomainList(m_iSessionID,&pRspXml);
if (NULL != pRspXml)
{
AfxMessageBox(pRspXml);//处理返回结果
IVS_SDK_ReleaseBuffer(pRspXml);//释放SDK申请的内存
pRspXml = NULL;
}
1、增加设备 增加设备,包括摄像机设备(TEYES协议、ONVIF协议、HWSDK协议和HIKSDK协议)和DVR/DVS设备,一次支持增加一个或者多个设备。推荐单次不超过1000个设备添加。如果需要获取设备列表中的互联编码,和VCN作为外域推送给第三方平台的互联编码相同时,需要在添加设备时,互联编码和设备编码保持一致,且互联编码满足国标规范。
IVS_DEVICE_OPER_INFO DevInfo = {0};
DevInfo.uiSequence = 1;
strncpy(DevInfo.stDeviceCfg.cProtocolType, "HIKSDK", IVS_MAX_PROTOCOLTYPE_NAME_LEN);
strncpy(DevInfo.stDeviceCfg.cNvrCode, "ec7bac2727c548ce8c0d0caf25a43519", IVS_NVR_CODE_LEN);
strncpy(DevInfo.stDeviceCfg.cDevUser, "admin", IVS_NAME_LEN);
strncpy(DevInfo.stDeviceCfg.cDevPasswd, "12345", IVS_PWD_LEN);
DevInfo.stDeviceCfg.stDeviceInfo.uiType = DEVICE_IPC;
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.cSerialNumber, "DS-2DF1-617H-B0020110120BCWR402633188WC", IVS_DEV_SERIALNO_LEN);//通过IVS_SDK_VerifyDevice获取
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.cName, "617Neo", IVS_DEVICE_NAME_LEN);
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.cDomainCode, "ec7bac2727c548ce8c0d0caf25a43519", IVS_DOMAIN_CODE_LEN);
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.cVendorType, "HIK", IVS_MAX_VENDOR_TYPE_NAME_LEN);
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.cModel, "HIKSDK", IVS_DEV_MODEL_LEN);
DevInfo.stDeviceCfg.stDeviceInfo.stIP.uiIPType = IP_V4;
DevInfo.stDeviceCfg.stDeviceInfo.uiPort = 8000;
strncpy(DevInfo.stDeviceCfg.stDeviceInfo.stIP.cIP, "10.170.54.48", IVS_IP_LEN);//设备IP
IVS_DEVICE_OPER_RESULT_LIST ResultInfo = {0};//只添加一个设备,所以结果列表只含一个结果
iRet = IVS_SDK_AddDevice(iSessionID, "ec7bac2727c548ce8c0d0caf25a43519", 1, &DevInfo, &ResultInfo, sizeof(ResultInfo));
if (IVS_SUCCEED == iRet)
{
//成功
}
2、删除设备 删除设备,支持一次删除多个设备。 注意在新版本中,该接口功能是一个软删除接口,即延迟删除设备,被删除的设备实际仍然存在,可在设备回收站中调用恢复设备接口进行恢复。恢复设备接口为IVS_SDK_RollBackDevice。 设备软删除后的30天后没进行恢复,设备会自动彻底删除,30内若想对已软删除的设备进行彻底删除,需调用彻底删除接口IVS_SDK_DeleteDeviceCompletely。
//cpp code
IVS_DEVICE_CODE DeviceCode = {0};
strncpy(DeviceCode.cDevCode, "08005720000000000000", IVS_DEV_CODE_LEN);
IVS_RESULT_LIST ResultInfo = {0};
iRet = IVS_SDK_DeleteDevice(iSessionID, "ec7bac2727c548ce8c0d0caf25a43519", 1, &DeviceCode, &ResultInfo, sizeof(ResultInfo));//删除一个设备
if (IVS_SUCCEED == iRet)
{
//成功
}
3、设置设备参数 设置设备参数,如下:
//cpp code
IVS_CAMERA_SNAPSHOT_CFG SnapshotConfig = {0};//抓拍参数
SnapshotConfig.uiSnapCount = 5;
SnapshotConfig.uiSnapInterval = 2;
IVS_INT32 iRet = IVS_SDK_SetDeviceConfig(iSessionID, strCameraCode, CONFIG_CAMERA_SNAPSHOT_CFG, &SnapshotConfig, sizeof(SnapshotConfig));//设置摄像机抓拍参数,每次5张,每2秒一张
if (IVS_SUCCEED == iRet)
{
//成功
}
1、新增影子摄像机
//cpp code
//添加影子摄像机
const IVS_CHAR *pDomainCode = "904956f64b3c48e48671856357ca23f4";
IVS_SHADOW_IPC_INFO stShadowDevInfo;
memset( &stShadowDevInfo, 0, sizeof(stShadowDevInfo));
strcpy_s(stShadowDevInfo.cDevCode, sizeof(stShadowDevInfo.cDevCode), "01146170000000000000");
strcpy_s(stShadowDevInfo.cDevName, sizeof(stShadowDevInfo.cDevName), "IPC6621_125_001");
strncpy(stShadowDevInfo.cNVRCode, "904956f64b3c48e48671856357ca23f4", IVS_NVR_CODE_LEN);
strcpy_s(stShadowDevInfo.cDevProtocolType, sizeof(stShadowDevInfo.cDevProtocolType), "HWSDK");
strcpy_s(stShadowDevInfo.cOrigDevCode, sizeof(stShadowDevInfo.cOrigDevCode), "05725360000000000000#58d80ccd682243dfabe125a4d586ccea");
IVS_INT32 iRet = IVS_SDK_AddShadowIPC(m_iSessionID, pDomainCode, &stShadowDevInfo);
if (IVS_SUCCEED == iRet)
{
//成功
}
2、手动同步影子摄像机
//cpp code
//手动同步影子摄像机
const IVS_UINT32 uiNum = 1;
IVS_UINT32 uiBufSize = sizeof(IVS_SHADOW_IPC_LIST) + sizeof(IVS_SHADOW_IPC_INFO) * (uiNum - 1);
IVS_CHAR *pBuf = NULL;
try
{
pBuf = new IVS_CHAR[uiBufSize];
}
catch (...)
{
return;
}
memset(pBuf, 0, uiBufSize);
IVS_SHADOW_IPC_LIST *pShadowIPCList = reinterpret_cast<IVS_SHADOW_IPC_LIST *>(pBuf);
pShadowIPCList->uiNum = uiNum;
strcpy_s(pShadowIPCList->stCodeList[0].cDevCode, sizeof(pShadowIPCList->stCodeList[0].cDevCode), "01146170000000000000#904956f64b3c48e48671856357ca23f4");
IVS_INT32 iRet = IVS_SDK_SYNC_ShadowIPC(m_iSessionID, pShadowIPCList);
if (IVS_SUCCEED == iRet)
{
//成功
}
3、重启前端设备
//cpp code
iRet = IVS_SDK_RebootDevice(iSessionID, strMainDevCode, 0);//重启
if (IVS_SUCCEED == iRet)
{
//成功
}
4、搜索前端设备
//cpp code
CString strReqXml = "";
strReqXml += "<Content>";
strReqXml += "<SearchInfo>";
strReqXml += "<ProtocolType>HWSDK</ProtocolType>";
strReqXml += "<DevModelType>DS-2DF1-617H-B-14</DevModelType>";
strReqXml += "<ServerCode>089d6ae965674667bf7f9e5339f8e76b</ServerCode>";
strReqXml += "<IPList>";
strReqXml += "<IPInfo>";
strReqXml += "<DevIPFrom>192.168.1.120</DevIPFrom>";
strReqXml += "<DevIPTo>192.168.1.240</DevIPTo>";
strReqXml += "<DevPort>8000</DevPort>";
strReqXml += "</IPInfo>";
strReqXml += "</IPList>";
strReqXml += "</SearchInfo>";
strReqXml += "</Content>";
iRet = IVS_SDK_StartSearchDevice(m_iSessionID, "089d6ae965674667bf7f9e5339f8e76b", strReqXml);
if (IVS_SUCCEED == iRet)
{
//成功
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。