|
MythTV master
|
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. More...
#include <mythfrontend/upnpscanner.h>
Public Member Functions | |
| ~UPNPScanner () override | |
| void | StartFullScan (void) |
| Instruct the UPNPScanner thread to start a full scan of metadata from known media servers. More... | |
| void | 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. More... | |
| 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) |
| Returns a list of valid Media Servers discovered on the network. More... | |
Static Public Member Functions | |
| static void | Enable (bool enable, UPNPSubscription *sub=nullptr) |
| Creates or destroys the global UPNPScanner instance. More... | |
| static UPNPScanner * | Instance (UPNPSubscription *sub=nullptr) |
| Returns the global UPNPScanner instance if it has been enabled or nullptr if UPNPScanner is currently disabled. More... | |
Protected Member Functions | |
| void | customEvent (QEvent *event) override |
| Processes subscription and SSDP cache update events. More... | |
| void | timerEvent (QTimerEvent *event) override |
| Handles subscription renewal timer events. More... | |
Private Slots | |
| void | Start () |
| Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanning. More... | |
| void | Stop (void) |
| Stops scanning. More... | |
| void | Update (void) |
| Iterates through the list of known servers and initialises a connection by requesting the device description. More... | |
| void | CheckStatus (void) |
| Removes media servers that can no longer be found in the SSDP cache. More... | |
| void | replyFinished (QNetworkReply *reply) |
| Validates network responses against known requests and parses expected responses for the required data. More... | |
Private Member Functions | |
| UPNPScanner (UPNPSubscription *sub) | |
| void | ScheduleUpdate (void) |
| void | CheckFailure (const QUrl &url) |
| Updates the logs for failed server connections. More... | |
| void | Debug (void) |
| void | BrowseNextContainer (void) |
| 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). More... | |
| void | SendBrowseRequest (const QUrl &url, const QString &objectid) |
| Formulates and sends a ContentDirectory Service Browse Request to the given control URL, requesting data for the object identified by objectid. More... | |
| void | AddServer (const QString &usn, const QString &url) |
| 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. More... | |
| 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) |
| Parse the XML returned from Content Directory Service browse request. More... | |
| 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) |
| Parse the device description XML return my a media server. More... | |
| void | GetServerContent (QString &usn, MediaServerItem *content, VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
| Recursively search a MediaServerItem for video metadata and add it to the metadata_list and meta_dir_node. More... | |
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 45 of file upnpscanner.h.
|
override |
Definition at line 140 of file upnpscanner.cpp.
|
inlineexplicitprivate |
Definition at line 75 of file upnpscanner.h.
Referenced by Instance().
|
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 |
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 |
Updates the logs for failed server connections.
Definition at line 776 of file upnpscanner.cpp.
Referenced by replyFinished().
|
privateslot |
Removes media servers that can no longer be found in the SSDP cache.
Definition at line 560 of file upnpscanner.cpp.
Referenced by Start().
|
overrideprotected |
Processes subscription and SSDP cache update events.
Definition at line 646 of file upnpscanner.cpp.
|
private |
Definition at line 795 of file upnpscanner.cpp.
Referenced by CheckFailure(), customEvent(), ParseBrowse(), ParseDescription(), and RemoveServer().
|
static |
Creates or destroys the global UPNPScanner instance.
Definition at line 149 of file upnpscanner.cpp.
Referenced by MediaRenderer::MediaRenderer(), and MediaRenderer::~MediaRenderer().
|
private |
Definition at line 1103 of file upnpscanner.cpp.
Referenced by FindItems(), and ParseBrowse().
|
private |
Definition at line 1185 of file upnpscanner.cpp.
Referenced by FindResult(), and ParseBrowse().
| 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 212 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList().
| bool UPNPScanner::GetMetadata | ( | QVariant & | data | ) |
Definition at line 286 of file upnpscanner.cpp.
| 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 244 of file upnpscanner.cpp.
|
private |
Recursively search a MediaServerItem for video metadata and add it to the metadata_list and meta_dir_node.
Definition at line 350 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), GetMetadata(), and GetServerContent().
|
static |
Returns the global UPNPScanner instance if it has been enabled or nullptr if UPNPScanner is currently disabled.
Definition at line 161 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList(), Enable(), and VideoListImp::refreshNode().
|
private |
Parse the XML returned from Content Directory Service browse request.
Definition at line 997 of file upnpscanner.cpp.
Referenced by replyFinished().
|
private |
Parse the device description XML return my a media server.
Definition at line 1245 of file upnpscanner.cpp.
Referenced by replyFinished().
|
staticprivate |
Definition at line 1387 of file upnpscanner.cpp.
Referenced by ParseDescription().
|
staticprivate |
Definition at line 1419 of file upnpscanner.cpp.
Referenced by ParseServiceList().
|
staticprivate |
Definition at line 1405 of file upnpscanner.cpp.
Referenced by ParseDevice().
|
private |
Definition at line 959 of file upnpscanner.cpp.
Referenced by AddServer().
|
privateslot |
Validates network responses against known requests and parses expected responses for the required data.
Definition at line 588 of file upnpscanner.cpp.
Referenced by Start().
|
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 |
Definition at line 764 of file upnpscanner.cpp.
Referenced by AddServer(), replyFinished(), and Update().
|
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().
| 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 396 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), and GetMetadata().
|
privateslot |
Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanning.
Definition at line 415 of file upnpscanner.cpp.
Referenced by Instance().
| void UPNPScanner::StartFullScan | ( | void | ) |
Instruct the UPNPScanner thread to start a full scan of metadata from known media servers.
Definition at line 199 of file upnpscanner.cpp.
Referenced by GetMetadata().
|
privateslot |
|
overrideprotected |
Handles subscription renewal timer events.
Definition at line 728 of file upnpscanner.cpp.
|
privateslot |
Iterates through the list of known servers and initialises a connection by requesting the device description.
Definition at line 512 of file upnpscanner.cpp.
Referenced by Start().
|
staticprivate |
Definition at line 108 of file upnpscanner.h.
Referenced by Instance().
Definition at line 109 of file upnpscanner.h.
Referenced by Enable(), and Instance().
|
staticprivate |
Definition at line 111 of file upnpscanner.h.
Referenced by Enable(), and Instance().
|
staticprivate |
Definition at line 110 of file upnpscanner.h.
Referenced by Instance().
|
private |
Definition at line 120 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), SendBrowseRequest(), and Stop().
|
private |
Definition at line 119 of file upnpscanner.h.
Referenced by replyFinished(), Stop(), and Update().
Definition at line 129 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), and StartFullScan().
|
private |
Definition at line 114 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 125 of file upnpscanner.h.
Referenced by AddServer(), and Start().
|
private |
Definition at line 126 of file upnpscanner.h.
Referenced by AddServer(), and Start().
|
private |
Definition at line 116 of file upnpscanner.h.
Referenced by SendBrowseRequest(), Start(), Stop(), and Update().
Definition at line 128 of file upnpscanner.h.
Referenced by BrowseNextContainer(), customEvent(), GetMetadata(), ParseBrowse(), and ParseDescription().
|
private |
Definition at line 115 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 113 of file upnpscanner.h.
Referenced by ParseDescription(), RemoveServer(), Start(), Stop(), and timerEvent().
|
private |
Definition at line 122 of file upnpscanner.h.
Referenced by ScheduleUpdate(), Start(), and Stop().
|
private |
Definition at line 123 of file upnpscanner.h.