MythTV master
ssdp.h
Go to the documentation of this file.
1
2// Program Name: ssdp.h
3// Created : Oct. 1, 2005
4//
5// Purpose : SSDP Discovery Service Implmenetation
6//
7// Copyright (c) 2005 David Blain <dblain@mythtv.org>
8//
9// Licensed under the GPL v2 or later, see LICENSE for details
10//
12
13#ifndef SSDP_H
14#define SSDP_H
15
16#include <chrono>
17using namespace std::chrono_literals;
18#include <cstdint>
19
20#include <QHostAddress>
21#include <QString>
22#include <QUdpSocket>
23
24#include "upnpexp.h"
25
26static constexpr const char* SSDP_GROUP { "239.255.255.250" };
27static constexpr uint16_t SSDP_PORT { 1900 };
28
29enum SSDPRequestType : std::uint8_t
30{
34 SSDP_Notify = 3
35};
36
37class SSDPReceiver : public QObject
38{
39 Q_OBJECT
40
41 public:
43
44 void performSearch(const QString &sST, std::chrono::seconds timeout = 2s);
45
46 private slots:
48
49 private:
50 QUdpSocket m_socket;
52 const QHostAddress m_groupAddress {SSDP_GROUP};
53};
54
56{
57 private:
58 // Singleton instance used by all.
59 static SSDP* g_pSSDP;
60
61 int m_nServicePort {0};
62
63 class UPnpNotifyTask* m_pNotifyTask {nullptr};
64
66
67 private:
68
69 // ------------------------------------------------------------------
70 // Private so the singleton pattern can be enforced.
71 // ------------------------------------------------------------------
72
73 SSDP ();
74
75 public:
76
77 static inline const QString kBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
78
79 static SSDP* Instance();
80 static void Shutdown();
81
82 ~SSDP();
83
86 void PerformSearch(const QString &sST, std::chrono::seconds timeout = 2s);
87
88 void EnableNotifications ( int nServicePort );
89 void DisableNotifications();
91 {
92 if (m_pNotifyTask != nullptr)
93 {
94 return m_nServicePort;
95 }
96 return 0;
97 }
98};
99
100#endif // SSDP_H
QUdpSocket m_socket
Definition: ssdp.h:50
void processPendingDatagrams()
Definition: ssdp.cpp:400
const QHostAddress m_groupAddress
Definition: ssdp.h:52
const uint16_t m_port
Definition: ssdp.h:51
void performSearch(const QString &sST, std::chrono::seconds timeout=2s)
Definition: ssdp.cpp:159
SSDPReceiver()
Definition: ssdp.cpp:391
Definition: ssdp.h:56
int getNotificationPort() const
Definition: ssdp.h:90
SSDPReceiver m_receiver
Definition: ssdp.h:65
static SSDP * g_pSSDP
Definition: ssdp.h:59
unsigned short uint16_t
Definition: iso6937tables.h:3
static constexpr uint16_t SSDP_PORT
Definition: ssdp.h:27
static constexpr const char * SSDP_GROUP
Definition: ssdp.h:26
SSDPRequestType
Definition: ssdp.h:30
@ SSDP_Notify
Definition: ssdp.h:34
@ SSDP_MSearchResp
Definition: ssdp.h:33
@ SSDP_Unknown
Definition: ssdp.h:31
@ SSDP_MSearch
Definition: ssdp.h:32
#define UPNP_PUBLIC
Definition: upnpexp.h:9