Onvif/RTSP摄像头直播中云台控制

LiveNVR支持预置位控制,包括转到指定预置位,设置指定预置位,删除指定预置位

预置位在安防领域有较为普遍的应用,可以进行很多既定位置的跳转,很方便

之前我们说过如何用Onvif协议进行设备的发现,探测,以及云台控制等,今天我们来说一下如何使用Onvif进行预置位的操作

流程

获取设备能力Capabilities

获取设备的能力,并且可以获取到Media和PTZ的URI,使用这两个URL可以进行流和预置位操作,这里如果PTZ URI获取不到意味着这个设备无法支持预置位控制

_tds__GetCapabilities* capabilities = soap_new__tds__GetCapabilities(proxyDevice, -1);
tt__CapabilityCategory* category = new tt__CapabilityCategory;
capabilities->Category = category;
*(capabilities->Category) = tt__CapabilityCategory__All;
_tds__GetCapabilitiesResponse* response = soap_new__tds__GetCapabilitiesResponse(proxyDevice, -1);
if (SOAP_OK == proxyDevice->GetCapabilities(capabilities, response))
{
    if (response->Capabilities)
    {
        //Media URI: response->Capabilities->Media->XAddr;
        //PTZ URI: response->Capabilities->PTZ->XAddr;
    }
}

获取Media Profile

_trt__GetProfiles* getProfiles = soap_new__trt__GetProfiles(proxyMedia, -1);
_trt__GetProfilesResponse* response = soap_new__trt__GetProfilesResponse(proxyMedia, -1);
if (SOAP_OK == proxyMedia->GetProfiles(getProfiles, response))
{
    int size = response->__sizeProfiles;
    for (int i = 0; i < size; ++i)
    {
        if (response->Profiles[i])
        {
            //Media Profile Token: response->Profiles[i]->token;
            //一般设备包含多个Profile Token,包含主码流、子码流、第三码流
        }
    }
}

预置位控制

bool result = false;

   PTZBindingProxy* ptzProxy = new PTZBindingProxy;
   ptzProxy->soap_endpoint = ptzUrl.c_str();

   if (!security(ptzProxy, username, password))
   {
       delete ptzProxy;
       return result;
   }

   char presetToken[8];
   itoa(index, presetToken, 10);

   if (command == PRESET_GOTO)
   {
       _tptz__GotoPreset* preset = soap_new__tptz__GotoPreset(ptzProxy, -1);
       _tptz__GotoPresetResponse* response = soap_new__tptz__GotoPresetResponse(ptzProxy, -1);
       preset->ProfileToken = const_cast<char*>(profile.c_str());
       preset->PresetToken = presetToken;

       if (SOAP_OK == ptzProxy->GotoPreset(preset, response))
           result = true;

       if (response)
           soap_delete__tptz__GotoPresetResponse(ptzProxy, response);

       if (preset)
           soap_delete__tptz__GotoPreset(ptzProxy, preset);
   }
   else if (command == PRESET_SET)
   {
       _tptz__SetPreset* preset = soap_new__tptz__SetPreset(ptzProxy, -1);
       _tptz__SetPresetResponse* response = soap_new__tptz__SetPresetResponse(ptzProxy, -1);
       preset->ProfileToken = const_cast<char*>(profile.c_str());
       preset->PresetToken = presetToken;

       if (SOAP_OK == ptzProxy->SetPreset(preset, response))
           result = true;

       if (response)
           soap_delete__tptz__SetPresetResponse(ptzProxy, response);

       if (preset)
           soap_delete__tptz__SetPreset(ptzProxy, preset);
   }
   else if (command == PRESET_REMOVE)
   {
       _tptz__RemovePreset* preset = soap_new__tptz__RemovePreset(ptzProxy, -1);
       _tptz__RemovePresetResponse* response = soap_new__tptz__RemovePresetResponse(ptzProxy, -1);
       preset->ProfileToken = const_cast<char*>(profile.c_str());
       preset->PresetToken = presetToken;

       if (SOAP_OK == ptzProxy->RemovePreset(preset, response))
           result = true;

       if (response)
           soap_delete__tptz__RemovePresetResponse(ptzProxy, response);

       if (preset)
           soap_delete__tptz__RemovePreset(ptzProxy, preset);
   }

   delete ptzProxy;

   return result;

关于LiveNVR

LiveNVR能够通过简单的网络摄像机通道配置,将传统监控行业里面的高清网络摄像机IP Camera、NVR等具有RTSP协议输出的设备接入到LiveNVR,LiveNVR能够将这些视频源的音视频数据进行拉取,转换为RTMP/HLS,进行全平台终端H5直播(Web、Android、iOS),并且LiveNVR能够将视频源的直播数据对接到第三方CDN网络,实现互联网级别的直播分发;

获取更多信息

邮件:support@liveqing.com

技术交流QQ群:947137753

咨询电话:15156896292(同微信)

试用下载: https://www.liveqing.com/docs/download/LiveNVR.html

LiveQing视频流媒体无插件直播方案:www.liveqing.com

上一篇:Qt编写安防视频监控系统18-云台控制


下一篇:海康相机之onvif测试工具使用