onvif(二) 客户端——设备发现

onvif(二) 客户端——设备发现

1.onvif源码

以下为生成的onvif源码,onvif.h为临时文件,".nsmap"后缀文件为命名空间文件,"Proxy"后缀为client端源码,"Service"为server源码,"soapC"为公用文件

DeviceBinding.nsmap                 soapImagingBindingProxy.h      soapPullPointSubscriptionBindingProxy.cpp
ImagingBinding.nsmap                soapImagingBindingService.cpp  soapPullPointSubscriptionBindingProxy.h
Media2Binding.nsmap                 soapImagingBindingService.h    soapPullPointSubscriptionBindingService.cpp
MediaBinding.nsmap                  soapMedia2BindingProxy.cpp     soapPullPointSubscriptionBindingService.h
onvif.h                             soapMedia2BindingProxy.h       soapRemoteDiscoveryBindingProxy.cpp
PTZBinding.nsmap                    soapMedia2BindingService.cpp   soapRemoteDiscoveryBindingProxy.h
PullPointSubscriptionBinding.nsmap  soapMedia2BindingService.h     soapRemoteDiscoveryBindingService.cpp
RemoteDiscoveryBinding.nsmap        soapMediaBindingProxy.cpp      soapRemoteDiscoveryBindingService.h
soapC.cpp                           soapMediaBindingProxy.h        soapStub.h
soapDeviceBindingProxy.cpp          soapMediaBindingService.cpp    soapwsddProxy.cpp
soapDeviceBindingProxy.h            soapMediaBindingService.h      soapwsddProxy.h
soapDeviceBindingService.cpp        soapPTZBindingProxy.cpp        soapwsddService.cpp
soapDeviceBindingService.h          soapPTZBindingProxy.h          soapwsddService.h
soapH.h                             soapPTZBindingService.cpp      wsdd.nsmap
soapImagingBindingProxy.cpp         soapPTZBindingService.h

2.设备发现实现

1)源码添加

本例程使用的gsoap源码文件包括:stdsoap2.cpp tdsoap2.h dom.cpp

2)设备发现

int onvif_cli_dev_discovery(int timeout) {
    int ret     = 0;
    int count   = 0;
    wsddProxy discovery;
    struct wsdd__ProbeType req;
    struct __wsdd__ProbeMatches resp;

    // 设置超时时间
    discovery.soap->send_timeout = timeout;
    discovery.soap->recv_timeout = timeout;

    ret = discovery.send_Probe(&req);
    if (ret != 0)
        return -1;

    do {
        ret = discovery.recv_ProbeMatches(resp);
        if (ret != SOAP_OK) {
            log_i("Find %d onvif devices!", count);
            break;
        }
        if (!resp.wsdd__ProbeMatches || !resp.wsdd__ProbeMatches->ProbeMatch ||
            resp.wsdd__ProbeMatches->__sizeProbeMatch == 0) {
            continue;
        }
        printf("%s\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs);
        count ++;
    } while (1);
    ret = count;

    return ret;
}

3)编译

除上述文件外,onvif源码只需编译包括:soapC.cpp soapwsddProxy.cpp

----------------源码:https://github.com/Ghazigq/onvif.git-----------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值