ONVIF怎么写发现设备?

shyzzjf 2016-10-20 10:10:38
用ONVIF写发现同网段的IPC设备,怎么也发现不了,是什么原因?
//struct soap discovery_soap;
struct soap *soap;
int result = 0;
struct d__ProbeType req;
struct d__ProbeMatchesType resp;
struct d__ScopesType sScope;
struct SOAP_ENV__Header header;
int count = 0;
// struct SOAP_ENV__Header header;
// char guid_string[100];
// uuid_t uuid;
UUID uuid;
unsigned char *uuid_cstr = NULL;
UuidCreate(&uuid);
UuidToStringA(&uuid, &uuid_cstr);


//soap_init(&discovery_soap);
//soap = &discovery_soap;
soap = soap_new();
if(soap==NULL)
return -1;

////////////////////////////////////////////////////////////////////////////
// discovery test
// uuid_generate(uuid);
// uuid_unparse(uuid, guid_string);

// soap_omode(soap, SOAP_IO_FLUSH|SOAP_IO_STORE);
soap_set_namespaces(soap, namespaces);
//超过5秒钟没有数据就退出
soap->recv_timeout = 5;

soap_default_SOAP_ENV__Header(soap, &header);

header.wsa__MessageID = (LPCSTR)uuid_cstr;
RpcStringFreeA(&uuid_cstr);

header.wsa__To = "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
header.wsa__Action = "http://schemas.xmllocal_soap.org/ws/2005/04/discovery/Probe";
soap->header = &header;

soap_default_d__ScopesType(soap, &sScope);
sScope.__item = "";
//sScope.__item = "onvif://www.onvif.org";

soap_default_d__ProbeType(soap, &req);
req.Scopes = &sScope;
req.Types = "";
//req.Types = "dn:NetworkVideoTransmitter";

do
{
soap_call___dndl__Probe(soap, "soap.udp://239.255.255.250:3702/", NULL, &req, &resp);

if (soap->error) {
printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
result = soap->error;
break;
}
else
{
printf("soap_call___dndl__Probe __sizeProbeMatch=%d\r\n",resp.__sizeProbeMatch);
printf("Target EP Address : %s\r\n", resp.ProbeMatch[0].wsa__EndpointReference.Address);
printf("Target Type : %s\r\n", resp.ProbeMatch[0].Types);
printf("Target Service Address : %s\r\n", resp.ProbeMatch[0].XAddrs);
printf("Target Metadata Version : %d\r\n", resp.ProbeMatch[0].MetadataVersion);
printf("Target Scopes Address : %s\r\n", resp.ProbeMatch[0].Scopes->__item);
}
}while(0);

soap_destroy(soap); // remove deserialized class instances (C++ only)
soap_end(soap); // clean up and remove deserialized data

////////////////////////////////////////////////////////////////////////////
failed:
soap_free(soap);//detach and free runtime context
soap_done(soap); // detach context (last use and no longer in scope)
...全文
696 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧