19#include <QHostAddress>
33 Task(
"UPnpNotifyTask"),
34 m_nServicePort(nServicePort),
41 QString uniqueServiceName = sNT;
42 if (sUDN.length() > 0)
43 uniqueServiceName = sUDN +
"::" + uniqueServiceName;
45 QByteArray data = QString(
"Server: %1\r\n"
49 "CACHE-CONTROL: max-age=%6\r\n"
50 "Content-Length: 0\r\n\r\n")
58 LOG(VB_UPNP, LOG_INFO,
59 QString(
"UPnpNotifyTask::SendNotifyMsg : %1:%2 : %3 : %4")
61 sNT, uniqueServiceName
66 for (
const auto & addr : std::as_const(addressList))
68 if (addr.toString().isEmpty())
70 LOG(VB_GENERAL, LOG_ERR,
71 "UPnpNotifyTask::SendNotifyMsg - NULL in address list");
75 QHostAddress ip = addr;
79 ip.setScopeId(QString());
81 QString ipaddress = ip.toString();
84 if (ipaddress.contains(
":"))
85 ipaddress =
"[" + ipaddress +
"]";
88 QString(
"NOTIFY * HTTP/1.1\r\n"
90 "LOCATION: http://%3:%4/getDeviceDesc\r\n")
100 std::this_thread::sleep_for(std::chrono::milliseconds(
MythRandom(0, 250)));
110 socket.bind(QHostAddress(QHostAddress::AnyIPv4), 0);
111 socket.setSocketOption(QAbstractSocket::MulticastTtlOption, 4);
140 for (
const auto* embedded_device : std::as_const(device.
m_listDevices))
static QString GetServerVersion(void)
void AddTask(std::chrono::milliseconds msec, Task *pTask)
Add a task to run in the future.
QString GetUDN(void) const
UPnpServiceList m_listServices
UPnpDeviceList m_listDevices
std::chrono::seconds m_nMaxAge
UPnpNotifyTask(int nServicePort)
void ProcessDevice(QUdpSocket &socket, const UPnpDevice &device)
void SendNotifyMsg(QUdpSocket &socket, const QString &sNT, const QString &sUDN)
void Execute(TaskQueue *pQueue) override
static QList< QHostAddress > g_IPAddrList
static UPnpDeviceDesc g_UPnpDeviceDesc
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Convenience inline random number generator functions.
uint32_t MythRandom()
generate 32 random bits
static constexpr uint16_t SSDP_PORT
static constexpr const char * SSDP_GROUP