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

#include <libmythupnp/ssdp.h>

Inheritance diagram for SSDP:
[legend]
Collaboration diagram for SSDP:
[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)
 

Static Public Attributes

static const QString kBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1"
 

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
virtual void run (void)
 Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead. More...
 
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
 
static constexpr 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 66 of file ssdp.h.

Constructor & Destructor Documentation

◆ SSDP()

SSDP::SSDP ( )
private

Definition at line 123 of file ssdp.cpp.

Referenced by Instance().

◆ ~SSDP()

SSDP::~SSDP ( )
override

Definition at line 165 of file ssdp.cpp.

Member Function Documentation

◆ AddListener()

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

Definition at line 132 of file ssdp.h.

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

◆ DisableNotifications()

void SSDP::DisableNotifications ( )

Definition at line 235 of file ssdp.cpp.

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

◆ EnableNotifications()

void SSDP::EnableNotifications ( int  nServicePort)

Definition at line 195 of file ssdp.cpp.

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

◆ 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 139 of file ssdp.h.

◆ GetHeaderValue()

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

Definition at line 538 of file ssdp.cpp.

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

◆ Instance()

SSDP * SSDP::Instance ( )
static

◆ IsTermRequested()

bool SSDP::IsTermRequested ( )
protected

◆ PerformSearch()

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

◆ ProcessData()

void SSDP::ProcessData ( MSocketDevice *  pSocket)
protected

Definition at line 363 of file ssdp.cpp.

Referenced by run().

◆ ProcessNotify()

bool SSDP::ProcessNotify ( const QStringMap sHeaders)
staticprotected

Definition at line 676 of file ssdp.cpp.

Referenced by ProcessData().

◆ ProcessRequestLine()

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

Definition at line 511 of file ssdp.cpp.

Referenced by ProcessData().

◆ ProcessSearchRequest()

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

Definition at line 553 of file ssdp.cpp.

Referenced by ProcessData().

◆ ProcessSearchResponse()

bool SSDP::ProcessSearchResponse ( const QStringMap sHeaders)
staticprotected

Definition at line 641 of file ssdp.cpp.

Referenced by ProcessData().

◆ RemoveListener()

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

Definition at line 134 of file ssdp.h.

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

◆ RequestTerminate()

void SSDP::RequestTerminate ( void  )

Definition at line 186 of file ssdp.cpp.

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

◆ run()

void SSDP::run ( void  )
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 295 of file ssdp.cpp.

◆ Shutdown()

void SSDP::Shutdown ( void  )
static

Definition at line 112 of file ssdp.cpp.

Referenced by MythContext::~MythContext().

Member Data Documentation

◆ g_pSSDP

SSDP * SSDP::g_pSSDP = nullptr
staticprivate

Definition at line 70 of file ssdp.h.

Referenced by Instance(), and Shutdown().

◆ kBackendURI

const QString SSDP::kBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1"
inlinestatic

◆ kNumberOfSockets

constexpr int SSDP::kNumberOfSockets = 3
staticconstexprprivate

Definition at line 73 of file ssdp.h.

Referenced by run().

◆ m_bAnnouncementsEnabled

bool SSDP::m_bAnnouncementsEnabled {false}
private

Definition at line 81 of file ssdp.h.

Referenced by DisableNotifications(), and EnableNotifications().

◆ m_bTermRequested

bool SSDP::m_bTermRequested {false}
private

Definition at line 83 of file ssdp.h.

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

◆ m_lock

QMutex SSDP::m_lock
private

Definition at line 84 of file ssdp.h.

◆ m_nPort

int SSDP::m_nPort {SSDP_PORT}
private

Definition at line 76 of file ssdp.h.

Referenced by SSDP().

◆ m_nSearchPort

int SSDP::m_nSearchPort {SSDP_SEARCHPORT}
private

Definition at line 77 of file ssdp.h.

Referenced by SSDP().

◆ m_nServicePort

int SSDP::m_nServicePort {0}
private

Definition at line 78 of file ssdp.h.

Referenced by EnableNotifications(), and ProcessSearchRequest().

◆ m_pNotifyTask

UPnpNotifyTask* SSDP::m_pNotifyTask {nullptr}
private

Definition at line 80 of file ssdp.h.

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

◆ m_procReqLineExp

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

Definition at line 72 of file ssdp.h.

Referenced by ProcessRequestLine().

◆ m_sockets

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

Definition at line 74 of file ssdp.h.

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


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