File: onvifdiscover.cpp

package info (click to toggle)
kdsoap-ws-discovery-client 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 356 kB
  • sloc: cpp: 794; sh: 8; makefile: 5
file content (55 lines) | stat: -rw-r--r-- 1,787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-FileCopyrightText: 2019 Casper Meijn <casper@meijn.net>
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */
#include "onvifdiscover.h"

#include <QDebug>
#include <QSharedPointer>
#include <WSDiscoveryClient>
#include <WSDiscoveryProbeJob>
#include <WSDiscoveryServiceAggregator>
#include <WSDiscoveryTargetService>

OnvifDiscover::OnvifDiscover(QObject *parent)
    : QObject(parent)
{
    m_client = new WSDiscoveryClient(this);

    m_probeJob = new WSDiscoveryProbeJob(m_client);

    m_aggregator = new WSDiscoveryServiceAggregator(this);

    connect(m_probeJob, &WSDiscoveryProbeJob::matchReceived, m_aggregator, &WSDiscoveryServiceAggregator::updateService);
    connect(m_aggregator, &WSDiscoveryServiceAggregator::serviceUpdated, this, &OnvifDiscover::matchReceived);

    KDQName type("tdn:NetworkVideoTransmitter");
    type.setNameSpace("http://www.onvif.org/ver10/network/wsdl");
    m_probeJob->addType(type);
}

OnvifDiscover::~OnvifDiscover() = default;

void OnvifDiscover::start()
{
    m_client->start();
    m_probeJob->start();
}

void OnvifDiscover::matchReceived(const QSharedPointer<WSDiscoveryTargetService> &matchedService)
{
    qDebug() << "ProbeMatch received:";
    qDebug() << "  Endpoint reference:" << matchedService->endpointReference();
    const auto &typeList = matchedService->typeList();
    for (const auto &type : typeList) {
        qDebug() << "  Type:" << type.localName() << "in namespace" << type.nameSpace();
    }
    const auto &scopeList = matchedService->scopeList();
    for (const auto &scope : scopeList) {
        qDebug() << "  Scope:" << scope.toString();
    }
    const auto &xAddrList = matchedService->xAddrList();
    for (const auto &xAddr : xAddrList) {
        qDebug() << "  XAddr:" << xAddr.toString();
    }
}