加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Onvif.cpp 3.68 KB
一键复制 编辑 原始数据 按行查看 历史
zcy 提交于 2017-12-16 19:20 . q
#include "stdafx.h"
#include "Onvif.h"
#include "Soap\soapH.h"
#include "Soap\stdsoap2.h"
#include "Soap\soapStub.h"
#include "wsddapi.h"
#include "Soap/wsdd.nsmap"
#include<string.h>
#define __DEBUG
#ifdef __DEBUG
#define DBG(fmt,args,...) fprintf(stdout, fmt, ##args)
#else
#define DBG(fmt,args,...)
#endif
#define ERR(fmt,args,...) fprintf(stderr, fmt, ##args)
typedef struct _T_SoapInstance {
struct soap *soap;
}SoapInstance;
/*
SOAP初始化
*/
int UserInitSoap()
{
struct soap *soap;
struct wsdd__ProbeType req;
struct __wsdd__ProbeMatches resp;
struct wsdd__ScopesType sScope;
struct SOAP_ENV__Header header;
int count = 0;
int result = 0;
char guid_string[100] = {};
soap = soap_new();
if (soap == NULL)
{
return -1;
}
soap_set_namespaces(soap, namespaces);
soap->recv_timeout = 5; //超过5秒钟没有数据就退出
soap_default_SOAP_ENV__Header(soap, &header);
header.wsa__MessageID = guid_string;
header.wsa__To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
header.wsa__Action = "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
soap->header = &header;
soap_default_wsdd__ScopesType(soap, &sScope);
sScope.__item = "";
soap_default_wsdd__ProbeType(soap, &req);
req.Scopes = &sScope;
req.Types = "tds:Device";
result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
if (result != SOAP_OK) {
printf("soap error!\n");
char p[12] = "";
sprintf_s(p, "%d", soap->error);
MessageBox(NULL,(p), 0, 0);
}
do {
result = soap_recv___wsdd__ProbeMatches(soap, &resp);
if (soap->error)
{
printf("soap error!\n");
result = soap->error;
break;
}
else
{
printf("=================================\n");
printf("%d\n", resp.wsdd__ProbeMatches->__sizeProbeMatch);
printf("%d\n", resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
printf("%s\n", resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item);
printf("QName:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->Types);
printf("xsd:string:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address);
//printf("xsd:QName:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.PortType);
//printf("wsa:ServiceNameType:%s\n"resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.ServiceName);
//printf("sequence of elements:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__size);
printf("xsd:anyType:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__anyAttribute);
//printf("endpoint any:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__any);
printf("wsdd:UriListType:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs);
printf("============================\n");
}
} while (1);
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
return result;
return 0;
}
/*
SOAP释放
*/
int UserReleaseSoap(struct soap *soap)
{
//soap_free(soap);
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
soap_del(soap);
/*
The gSOAP engine uses a memory management method to allocate and deallocate memory.
The deallocation is performed with soap_destroy() followed by soap_end().
However, when you compile with -DDEBUG or -DSOAP_MEM_DEBUG then no memory
is released until soap_done() is invoked. This ensures that the gSOAP engine
can track all malloced data to verify leaks and double frees in debug mode.
Use -DSOAP_DEBUG to use the normal debugging facilities without memory debugging.
Note that some compilers have DEBUG enabled in the debug configuration, so this behavior
should be expected unless you compile in release config
*/
return 0;
}
OnvifDeviceInfo *Onvif::Device_Detect(void){
return NULL;
}
Onvif::Onvif()
{
}
Onvif::~Onvif()
{
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化