代码拉取完成,页面将自动刷新
同步操作将从 刘军/24041智能安防 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "myonvif.h"
MyOnvif::MyOnvif(QObject *parent) : QObject(parent)
{/*
this->DISCOVERY_PORT = 3702;
this->DISCOVERY_TIMEOUT = 6000; // 6 seconds
this->DISCOVERY_MESSAGE = QByteArray(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" "
"xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">"
"<s:Header>"
"<a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>"
"<a:MessageID>uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
"<a:To s:mustUnderstand=\"1\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>"
"</s:Header>"
"<s:Body>"
"<Probe xmlns=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\">"
"<Types>dn:NetworkVideoTransmitter</Types>"
"<Scopes>onvif://www.onvif.org/Profile/S</Scopes>"
"</Probe>"
"</s:Body>"
"</s:Envelope>");*/
}
int MyOnvif::searchOnvifCamera()
{
const quint16 DISCOVERY_PORT = 3702;
const quint16 DISCOVERY_TIMEOUT = 6000; // 3 seconds
const QByteArray DISCOVERY_MESSAGE = QByteArray(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\" "
"xmlns:a=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\">"
"<s:Header>"
"<a:Action s:mustUnderstand=\"1\">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</a:Action>"
"<a:MessageID>uuid:00000000-0000-0000-0000-000000000000</a:MessageID>"
"<a:To s:mustUnderstand=\"1\">urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To>"
"</s:Header>"
"<s:Body>"
"<Probe xmlns=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\">"
"<Types>dn:NetworkVideoTransmitter</Types>"
"<Scopes>onvif://www.onvif.org/Profile/S</Scopes>"
"</Probe>"
"</s:Body>"
"</s:Envelope>");
qDebug() << "into searchOnvifCamera:" ;
QUdpSocket socket;
QTimer timer;
// Bind the socket to the discovery port
if (!socket.bind(QHostAddress::AnyIPv4, DISCOVERY_PORT, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
qWarning() << "Failed to bind to port" << DISCOVERY_PORT;
return -1;
}
// Set up a timer to stop discovery after a certain period
QObject::connect(&timer, &QTimer::timeout, [&]() {
socket.close();
qInfo() << "Discovery finished.";
QCoreApplication::quit();
});
// Connect the readyRead signal to a slot that processes incoming datagrams
QObject::connect(&socket, &QUdpSocket::readyRead, [&]() {
while (socket.hasPendingDatagrams()) {
QNetworkDatagram datagram = socket.receiveDatagram();
QString message = QString::fromUtf8(datagram.data());
qDebug() << "Received message from" << datagram.senderAddress().toString() << ":" << datagram.senderPort();
qDebug() << "Message:" << message;
}
});
// Join the multicast group after binding
QNetworkInterface interface = QNetworkInterface::interfaceFromName("eth0"); // Use your actual interface name
socket.joinMulticastGroup(QHostAddress("239.255.255.250"), interface);
// Send the discovery message to the multicast address
socket.writeDatagram(DISCOVERY_MESSAGE, QHostAddress("239.255.255.250"), DISCOVERY_PORT);
// Start the timer
timer.start(DISCOVERY_TIMEOUT);
qDebug() << "leave searchOnvifCamera:";
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。