基于Gsoap 的ONVIF C++ 库

简介:

https://github.com/xsmart/onvifcpplib

该库支持ProfileS 和ProfileG,目前正在开发哪些,现拥有支持Event

下面是一个client样本

int _tmain(int argc, _TCHAR* argv[])
{
	int ret;
	/* 192.168.1.1 is the NVT, 192.168.1.234 is the NVC */
	string url = "http://192.168.1.1/onvif/device_service";
	/* Below is where to receive the event */
	string eventNotify = "http://192.168.1.234:9090/subscription-2";
	string user = "admin";
	string pass =  "admin";
	OnvifClientDevice onvifDevice(url, user, pass);
	_tds__GetCapabilitiesResponse capabilitiesResponse;

	onvifDevice.GetCapabilities();

	OnvifClientMedia media(onvifDevice);
	_trt__GetProfilesResponse profiles;
	media.GetProfiles(profiles);

	OnvifClientEvent onvifEvent(onvifDevice);

	onvifEvent.Subscribe(eventNotify);
	
	OnvifClientEventNotify notify(soap_new());
	
    if ((ret = soap_bind(&notify, NULL, 9090, 100) == SOAP_INVALID_SOCKET ) ) 
	{
        printf("OnvifClientEventNotify::soap_bind Binding on %d port failed", 9090);
        return 0;
    }

	//Loop to recevie the event
	while(1)
	{
        if( (ret = soap_accept(&notify)) == SOAP_INVALID_SOCKET) {
            printf("soap_accept accepting failed");
            return 0;
        }

        if ( (soap_begin_serve(&notify)) != SOAP_OK) {
            printf("soap_begin_serve serve %d failed", ret);
            continue;
        }

        ret = notify.dispatch();
        continue;
	}
	return 0;
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。





本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4711979.html,如需转载请自行联系原作者


相关文章
|
5天前
|
编译器 API C语言
超级好用的C++实用库之跨平台实用方法
超级好用的C++实用库之跨平台实用方法
18 6
|
5天前
|
安全 C++
超级好用的C++实用库之环形内存池
超级好用的C++实用库之环形内存池
20 5
|
5天前
|
XML JSON 网络协议
超级好用的C++实用库之字节流解析器
超级好用的C++实用库之字节流解析器
|
5天前
|
存储 自然语言处理 API
超级好用的C++实用库之字符编码转换
超级好用的C++实用库之字符编码转换
12 2
|
5天前
|
Linux API C++
超级好用的C++实用库之互斥锁
超级好用的C++实用库之互斥锁
11 2
|
5天前
|
缓存 网络协议 Linux
超级好用的C++实用库之套接字
超级好用的C++实用库之套接字
19 1
|
5天前
|
存储 算法 安全
超级好用的C++实用库之sha256算法
超级好用的C++实用库之sha256算法
10 1
|
5天前
|
存储 算法 安全
超级好用的C++实用库之国密sm4算法
超级好用的C++实用库之国密sm4算法
15 0
|
5天前
|
网络协议 Linux C++
超级好用的C++实用库之网络
超级好用的C++实用库之网络
15 0
|
5天前
|
算法 安全 Serverless
超级好用的C++实用库之国密sm3算法
超级好用的C++实用库之国密sm3算法
11 0
下一篇
无影云桌面