MythTV
master
|
#include <upnpscanner.h>
Public Member Functions | |
~UPNPScanner () override | |
void | StartFullScan (void) |
void | GetInitialMetadata (VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
void | GetMetadata (VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
Fill the given metadata_list and meta_dir_node with the metadata of content retrieved from known media servers. More... | |
bool | GetMetadata (QVariant &data) |
QMap< QString, QString > | ServerList (void) |
Static Public Member Functions | |
static void | Enable (bool enable, UPNPSubscription *sub=nullptr) |
static UPNPScanner * | Instance (UPNPSubscription *sub=nullptr) |
Protected Member Functions | |
void | customEvent (QEvent *event) override |
Processes subscription and SSDP cache update events. More... | |
void | timerEvent (QTimerEvent *event) override |
Private Slots | |
void | Start () |
void | Stop (void) |
void | Update (void) |
void | CheckStatus (void) |
void | replyFinished (QNetworkReply *reply) |
Private Member Functions | |
UPNPScanner (UPNPSubscription *sub) | |
void | ScheduleUpdate (void) |
void | CheckFailure (const QUrl &url) |
void | Debug (void) |
void | BrowseNextContainer (void) |
void | SendBrowseRequest (const QUrl &url, const QString &objectid) |
void | AddServer (const QString &usn, const QString &url) |
void | RemoveServer (const QString &usn) |
void | ScheduleRenewal (const QString &usn, std::chrono::seconds timeout) |
Creates a QTimer to trigger a subscription renewal for a given media server. More... | |
void | ParseBrowse (const QUrl &url, QNetworkReply *reply) |
void | FindItems (const QDomNode &n, MediaServerItem &content, bool &resetparent) |
QDomDocument * | FindResult (const QDomNode &n, uint &num, uint &total, uint &updateid) |
bool | ParseDescription (const QUrl &url, QNetworkReply *reply) |
void | GetServerContent (QString &usn, MediaServerItem *content, VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
Static Private Member Functions | |
static void | ParseDevice (QDomElement &element, QString &controlURL, QString &eventURL, QString &friendlyName) |
static void | ParseServiceList (QDomElement &element, QString &controlURL, QString &eventURL) |
static void | ParseService (QDomElement &element, QString &controlURL, QString &eventURL) |
Private Attributes | |
UPNPSubscription * | m_subscription {nullptr} |
QRecursiveMutex | m_lock |
QHash< QString, UpnpMediaServer * > | m_servers |
QNetworkAccessManager * | m_network {nullptr} |
QMultiMap< QUrl, QNetworkReply * > | m_descriptionRequests |
QMultiMap< QUrl, QNetworkReply * > | m_browseRequests |
QTimer * | m_updateTimer {nullptr} |
QTimer * | m_watchdogTimer {nullptr} |
QString | m_masterHost |
int | m_masterPort {0} |
bool | m_scanComplete {false} |
bool | m_fullscan {false} |
Static Private Attributes | |
static UPNPScanner * | gUPNPScanner = nullptr |
static bool | gUPNPScannerEnabled = false |
static MThread * | gUPNPScannerThread = nullptr |
static QRecursiveMutex * | gUPNPScannerLock = new QRecursiveMutex() |
UPnPScanner detects UPnP Media Servers available on the local network (via the UPnP SSDP cache), requests the device description from those devices and, if the device description is successfully parsed, will request a a subscription to the device's event control url in order to receive notifications when the available media has changed. The subscription is renewed at an appropriate time before it expires. The available media for each device can then be queried by sending browse requests as needed.
Definition at line 49 of file upnpscanner.h.
|
override |
Definition at line 144 of file upnpscanner.cpp.
|
inlineexplicitprivate |
Definition at line 79 of file upnpscanner.h.
Referenced by Instance().
|
static |
Creates or destroys the global UPNPScanner instance.
Definition at line 153 of file upnpscanner.cpp.
Referenced by MediaRenderer::MediaRenderer(), and MediaRenderer::~MediaRenderer().
|
static |
Returns the global UPNPScanner instance if it has been enabled or nullptr if UPNPScanner is currently disabled.
Definition at line 165 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList(), Enable(), and VideoListImp::refreshNode().
void UPNPScanner::StartFullScan | ( | void | ) |
Instruct the UPNPScanner thread to start a full scan of metadata from known media servers.
Definition at line 203 of file upnpscanner.cpp.
Referenced by GetMetadata().
void UPNPScanner::GetInitialMetadata | ( | VideoMetadataListManager::metadata_list * | list, |
meta_dir_node * | node | ||
) |
Fill the given metadata_list and meta_dir_node with the root media server metadata (i.e. the MediaServers) and any additional metadata that that has already been scanned and cached.
Definition at line 216 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList().
void UPNPScanner::GetMetadata | ( | VideoMetadataListManager::metadata_list * | list, |
meta_dir_node * | node | ||
) |
Fill the given metadata_list and meta_dir_node with the metadata of content retrieved from known media servers.
A full scan is triggered.
Definition at line 248 of file upnpscanner.cpp.
bool UPNPScanner::GetMetadata | ( | QVariant & | data | ) |
Definition at line 290 of file upnpscanner.cpp.
QMap< QString, QString > UPNPScanner::ServerList | ( | void | ) |
Returns a list of valid Media Servers discovered on the network. The returned map is a QString pair of USNs and friendly names.
Definition at line 400 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), and GetMetadata().
|
overrideprotected |
Processes subscription and SSDP cache update events.
Definition at line 648 of file upnpscanner.cpp.
|
overrideprotected |
Handles subscription renewal timer events.
Definition at line 730 of file upnpscanner.cpp.
|
privateslot |
Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanning.
Definition at line 419 of file upnpscanner.cpp.
Referenced by Instance().
|
privateslot |
|
privateslot |
Iterates through the list of known servers and initialises a connection by requesting the device description.
Definition at line 516 of file upnpscanner.cpp.
Referenced by Start().
|
privateslot |
Removes media servers that can no longer be found in the SSDP cache.
Definition at line 564 of file upnpscanner.cpp.
Referenced by Start().
|
privateslot |
Validates network responses against known requests and parses expected responses for the required data.
Definition at line 592 of file upnpscanner.cpp.
Referenced by Start().
|
private |
Definition at line 766 of file upnpscanner.cpp.
Referenced by AddServer(), replyFinished(), and Update().
|
private |
Updates the logs for failed server connections.
Definition at line 778 of file upnpscanner.cpp.
Referenced by replyFinished().
|
private |
Definition at line 797 of file upnpscanner.cpp.
Referenced by CheckFailure(), customEvent(), ParseBrowse(), ParseDescription(), and RemoveServer().
|
private |
For each known media server, find the next container which needs to be browsed and trigger sending of the browse request (with a maximum of one active browse request for each server). Once all containers have been browsed, the scan is considered complete. N.B. failed browse requests are ignored.
Definition at line 833 of file upnpscanner.cpp.
Referenced by customEvent(), and replyFinished().
|
private |
Formulates and sends a ContentDirectory Service Browse Request to the given control URL, requesting data for the object identified by objectid.
Definition at line 878 of file upnpscanner.cpp.
Referenced by BrowseNextContainer(), and customEvent().
|
private |
Adds the server identified by usn and reachable via url to the list of known media servers and schedules an update to initiate a connection.
Definition at line 924 of file upnpscanner.cpp.
Referenced by customEvent().
|
private |
Definition at line 959 of file upnpscanner.cpp.
Referenced by AddServer().
|
private |
Creates a QTimer to trigger a subscription renewal for a given media server.
Definition at line 981 of file upnpscanner.cpp.
Referenced by ParseDescription(), and timerEvent().
|
private |
Parse the XML returned from Content Directory Service browse request.
Definition at line 997 of file upnpscanner.cpp.
Referenced by replyFinished().
|
private |
Definition at line 1090 of file upnpscanner.cpp.
Referenced by ParseBrowse().
|
private |
Definition at line 1172 of file upnpscanner.cpp.
Referenced by ParseBrowse().
|
private |
Parse the device description XML return my a media server.
Definition at line 1217 of file upnpscanner.cpp.
Referenced by replyFinished().
|
staticprivate |
Definition at line 1345 of file upnpscanner.cpp.
Referenced by ParseDescription().
|
staticprivate |
Definition at line 1363 of file upnpscanner.cpp.
Referenced by ParseDevice().
|
staticprivate |
Definition at line 1377 of file upnpscanner.cpp.
Referenced by ParseServiceList().
|
private |
Recursively search a MediaServerItem for video metadata and add it to the metadata_list and meta_dir_node.
Definition at line 354 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), and GetMetadata().
|
staticprivate |
Definition at line 112 of file upnpscanner.h.
Referenced by Instance().
Definition at line 113 of file upnpscanner.h.
Referenced by Enable(), and Instance().
|
staticprivate |
Definition at line 114 of file upnpscanner.h.
Referenced by Instance().
|
staticprivate |
Definition at line 118 of file upnpscanner.h.
Referenced by Enable(), and Instance().
|
private |
Definition at line 121 of file upnpscanner.h.
Referenced by ParseDescription(), RemoveServer(), Start(), Stop(), and timerEvent().
|
private |
Definition at line 125 of file upnpscanner.h.
Referenced by AddServer(), BrowseNextContainer(), CheckFailure(), CheckStatus(), customEvent(), Debug(), GetInitialMetadata(), GetMetadata(), ParseBrowse(), ParseDescription(), RemoveServer(), replyFinished(), ScheduleRenewal(), ScheduleUpdate(), SendBrowseRequest(), ServerList(), Start(), Stop(), timerEvent(), and Update().
|
private |
Definition at line 127 of file upnpscanner.h.
Referenced by AddServer(), BrowseNextContainer(), CheckFailure(), CheckStatus(), customEvent(), Debug(), GetInitialMetadata(), GetMetadata(), ParseBrowse(), ParseDescription(), RemoveServer(), ScheduleRenewal(), ServerList(), Stop(), timerEvent(), and Update().
|
private |
Definition at line 128 of file upnpscanner.h.
Referenced by SendBrowseRequest(), Start(), Stop(), and Update().
|
private |
Definition at line 131 of file upnpscanner.h.
Referenced by replyFinished(), Stop(), and Update().
|
private |
Definition at line 132 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), SendBrowseRequest(), and Stop().
|
private |
Definition at line 134 of file upnpscanner.h.
Referenced by ScheduleUpdate(), Start(), and Stop().
|
private |
Definition at line 135 of file upnpscanner.h.
|
private |
Definition at line 137 of file upnpscanner.h.
Referenced by AddServer(), and Start().
|
private |
Definition at line 138 of file upnpscanner.h.
Referenced by AddServer(), and Start().
Definition at line 140 of file upnpscanner.h.
Referenced by BrowseNextContainer(), customEvent(), GetMetadata(), ParseBrowse(), and ParseDescription().
Definition at line 141 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), and StartFullScan().