MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SSDP Class Reference

#include <ssdp.h>

Inheritance diagram for SSDP:
Inheritance graph
[legend]
Collaboration diagram for SSDP:
Collaboration graph
[legend]

Public Member Functions

 ~SSDP () override
 
void RequestTerminate (void)
 
void PerformSearch (const QString &sST, std::chrono::seconds timeout=2s)
 
void EnableNotifications (int nServicePort)
 
void DisableNotifications ()
 
- Public Member Functions inherited from MThread
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority p=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 

Static Public Member Functions

static SSDPInstance ()
 
static void Shutdown ()
 
static void AddListener (QObject *listener)
 
static void RemoveListener (QObject *listener)
 
static SSDPCacheEntriesFind (const QString &sURI)
 
static DeviceLocationFind (const QString &sURI, const QString &sUSN)
 
- Static Public Member Functions inherited from MThread
static void ThreadSetup (const QString &name)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 

Protected Member Functions

bool ProcessSearchRequest (const QStringMap &sHeaders, const QHostAddress &peerAddress, quint16 peerPort) const
 
bool IsTermRequested ()
 
void ProcessData (MSocketDevice *pSocket)
 
SSDPRequestType ProcessRequestLine (const QString &sLine)
 
void run () override
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 

Static Protected Member Functions

static bool ProcessSearchResponse (const QStringMap &sHeaders)
 
static bool ProcessNotify (const QStringMap &sHeaders)
 
static QString GetHeaderValue (const QStringMap &headers, const QString &sKey, const QString &sDefault)
 
- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > time)
 

Private Member Functions

 SSDP ()
 

Private Attributes

QRegularExpression m_procReqLineExp {"\\s+"}
 
std::array< MSocketDevice *, kNumberOfSocketsm_sockets {nullptr,nullptr,nullptr}
 
int m_nPort {SSDP_PORT}
 
int m_nSearchPort {SSDP_SEARCHPORT}
 
int m_nServicePort {0}
 
UPnpNotifyTaskm_pNotifyTask {nullptr}
 
bool m_bAnnouncementsEnabled {false}
 
bool m_bTermRequested {false}
 
QMutex m_lock
 

Static Private Attributes

static SSDPg_pSSDP = nullptr
 
constexpr static int kNumberOfSockets = 3
 

Additional Inherited Members

- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Detailed Description

Definition at line 63 of file ssdp.h.

Constructor & Destructor Documentation

◆ SSDP()

SSDP::SSDP ( )
private

Definition at line 76 of file ssdp.cpp.

Referenced by Instance().

◆ ~SSDP()

SSDP::~SSDP ( )
override

Definition at line 118 of file ssdp.cpp.

Member Function Documentation

◆ ProcessSearchRequest()

bool SSDP::ProcessSearchRequest ( const QStringMap sHeaders,
const QHostAddress &  peerAddress,
quint16  peerPort 
) const
protected

Definition at line 515 of file ssdp.cpp.

Referenced by ProcessData().

◆ ProcessSearchResponse()

bool SSDP::ProcessSearchResponse ( const QStringMap sHeaders)
staticprotected

Definition at line 603 of file ssdp.cpp.

Referenced by ProcessData().

◆ ProcessNotify()

bool SSDP::ProcessNotify ( const QStringMap sHeaders)
staticprotected

Definition at line 637 of file ssdp.cpp.

Referenced by ProcessData().

◆ IsTermRequested()

bool SSDP::IsTermRequested ( )
protected

◆ GetHeaderValue()

QString SSDP::GetHeaderValue ( const QStringMap headers,
const QString &  sKey,
const QString &  sDefault 
)
staticprotected

Definition at line 500 of file ssdp.cpp.

Referenced by ProcessNotify(), ProcessSearchRequest(), and ProcessSearchResponse().

◆ ProcessData()

void SSDP::ProcessData ( MSocketDevice *  pSocket)
protected

Definition at line 316 of file ssdp.cpp.

Referenced by run().

◆ ProcessRequestLine()

SSDPRequestType SSDP::ProcessRequestLine ( const QString &  sLine)
protected

Definition at line 469 of file ssdp.cpp.

Referenced by ProcessData().

◆ run()

void SSDP::run ( )
overrideprotectedvirtual

Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 248 of file ssdp.cpp.

◆ Instance()

SSDP * SSDP::Instance ( )
static

◆ Shutdown()

void SSDP::Shutdown ( )
static

Definition at line 65 of file ssdp.cpp.

Referenced by MythContext::~MythContext().

◆ RequestTerminate()

void SSDP::RequestTerminate ( void  )

Definition at line 139 of file ssdp.cpp.

Referenced by cleanup(), and ~SSDP().

◆ PerformSearch()

void SSDP::PerformSearch ( const QString &  sST,
std::chrono::seconds  timeout = 2s 
)

◆ EnableNotifications()

void SSDP::EnableNotifications ( int  nServicePort)

Definition at line 148 of file ssdp.cpp.

Referenced by UPnp::EnableNotificatins(), and UPnp::Start().

◆ DisableNotifications()

void SSDP::DisableNotifications ( )

Definition at line 188 of file ssdp.cpp.

Referenced by UPnp::CleanUp(), UPnp::DisableNotifications(), and ~SSDP().

◆ AddListener()

static void SSDP::AddListener ( QObject *  listener)
inlinestatic

Definition at line 127 of file ssdp.h.

Referenced by BackendSelection::Load(), and UPNPScanner::Start().

◆ RemoveListener()

static void SSDP::RemoveListener ( QObject *  listener)
inlinestatic

Definition at line 129 of file ssdp.h.

Referenced by UPNPScanner::Stop(), and BackendSelection::~BackendSelection().

◆ Find() [1/2]

static SSDPCacheEntries* SSDP::Find ( const QString &  sURI)
inlinestatic

◆ Find() [2/2]

static DeviceLocation* SSDP::Find ( const QString &  sURI,
const QString &  sUSN 
)
inlinestatic

Definition at line 134 of file ssdp.h.

Member Data Documentation

◆ g_pSSDP

SSDP * SSDP::g_pSSDP = nullptr
staticprivate

Definition at line 67 of file ssdp.h.

Referenced by Instance(), and Shutdown().

◆ m_procReqLineExp

QRegularExpression SSDP::m_procReqLineExp {"\\s+"}
private

Definition at line 69 of file ssdp.h.

Referenced by ProcessRequestLine().

◆ kNumberOfSockets

constexpr static int SSDP::kNumberOfSockets = 3
staticconstexprprivate

Definition at line 70 of file ssdp.h.

Referenced by run().

◆ m_sockets

std::array<MSocketDevice*,kNumberOfSockets> SSDP::m_sockets {nullptr,nullptr,nullptr}
private

Definition at line 71 of file ssdp.h.

Referenced by PerformSearch(), run(), SSDP(), and ~SSDP().

◆ m_nPort

int SSDP::m_nPort {SSDP_PORT}
private

Definition at line 73 of file ssdp.h.

Referenced by SSDP().

◆ m_nSearchPort

int SSDP::m_nSearchPort {SSDP_SEARCHPORT}
private

Definition at line 74 of file ssdp.h.

Referenced by SSDP().

◆ m_nServicePort

int SSDP::m_nServicePort {0}
private

Definition at line 75 of file ssdp.h.

Referenced by EnableNotifications(), and ProcessSearchRequest().

◆ m_pNotifyTask

UPnpNotifyTask* SSDP::m_pNotifyTask {nullptr}
private

Definition at line 77 of file ssdp.h.

Referenced by DisableNotifications(), EnableNotifications(), ProcessData(), and ~SSDP().

◆ m_bAnnouncementsEnabled

bool SSDP::m_bAnnouncementsEnabled {false}
private

Definition at line 78 of file ssdp.h.

Referenced by DisableNotifications(), and EnableNotifications().

◆ m_bTermRequested

bool SSDP::m_bTermRequested {false}
private

Definition at line 80 of file ssdp.h.

Referenced by ProcessData(), RequestTerminate(), and run().

◆ m_lock

QMutex SSDP::m_lock
private

Definition at line 81 of file ssdp.h.


The documentation for this class was generated from the following files: