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 <upnpscanner.h>
Public Member Functions | |
| ~UPNPScanner () | |
| void | StartFullScan (void) |
| Instruct the UPNPScanner thread to start a full scan of metadata from known media servers. | |
| void | GetInitialMetadata (VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
| void | GetMetadata (VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
| bool | GetMetadata (QVariant &data) |
| QMap< QString, QString > | ServerList (void) |
| Returns a list of valid Media Servers discovered on the network. | |
Static Public Member Functions | |
| static void | Enable (bool enable, UPNPSubscription *sub=NULL) |
| Creates or destroys the global UPNPScanner instance. | |
| static UPNPScanner * | Instance (UPNPSubscription *sub=NULL) |
| Returns the global UPNPScanner instance if it has been enabled or NULL if UPNPScanner is currently disabled. | |
Protected Member Functions | |
| virtual void | customEvent (QEvent *event) |
| virtual void | timerEvent (QTimerEvent *event) |
| Handles subscription renewal timer events. | |
Private Slots | |
| void | Start () |
| Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanning. | |
| void | Stop (void) |
| Stops scanning. | |
| void | Update (void) |
| Iterates through the list of known servers and initialises a connection by requesting the device description. | |
| void | CheckStatus (void) |
| Removes media servers that can no longer be found in the SSDP cache. | |
| void | replyFinished (QNetworkReply *reply) |
Private Member Functions | |
| UPNPScanner (UPNPSubscription *sub) | |
| void | ScheduleUpdate (void) |
| void | CheckFailure (const QUrl &url) |
| Updates the logs for failed server connections. | |
| 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). | |
| 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. | |
| 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. | |
| void | RemoveServer (const QString &usn) |
| void | ScheduleRenewal (const QString &usn, int timeout) |
| Creates a QTimer to trigger a subscription renewal for a given media server. | |
| void | ParseBrowse (const QUrl &url, QNetworkReply *reply) |
| Parse the XML returned from Content Directory Service browse request. | |
| 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. | |
| void | ParseDevice (QDomElement &element, QString &controlURL, QString &eventURL, QString &friendlyName) |
| void | ParseServiceList (QDomElement &element, QString &controlURL, QString &eventURL) |
| void | ParseService (QDomElement &element, QString &controlURL, QString &eventURL) |
| void | GetServerContent (QString &usn, MediaServerItem *content, VideoMetadataListManager::metadata_list *list, meta_dir_node *node) |
Private Attributes | |
| UPNPSubscription * | m_subscription |
| QMutex | m_lock |
| QHash< QString, MediaServer * > | m_servers |
| QNetworkAccessManager * | m_network |
| QMultiMap< QUrl, QNetworkReply * > | m_descriptionRequests |
| QMultiMap< QUrl, QNetworkReply * > | m_browseRequests |
| QTimer * | m_updateTimer |
| QTimer * | m_watchdogTimer |
| QString | m_masterHost |
| int | m_masterPort |
| bool | m_scanComplete |
| bool | m_fullscan |
Static Private Attributes | |
| static UPNPScanner * | gUPNPScanner = NULL |
| static bool | gUPNPScannerEnabled = false |
| static MThread * | gUPNPScannerThread = NULL |
| static QMutex * | gUPNPScannerLock = new QMutex(QMutex::Recursive) |
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 41 of file upnpscanner.h.
| UPNPScanner::~UPNPScanner | ( | ) |
Definition at line 141 of file upnpscanner.cpp.
| UPNPScanner::UPNPScanner | ( | UPNPSubscription * | sub | ) | [private] |
Definition at line 133 of file upnpscanner.cpp.
Referenced by Instance().
| void UPNPScanner::Enable | ( | bool | enable, | |
| UPNPSubscription * | sub = NULL | |||
| ) | [static] |
Creates or destroys the global UPNPScanner instance.
Definition at line 150 of file upnpscanner.cpp.
Referenced by MediaRenderer::MediaRenderer(), and MediaRenderer::~MediaRenderer().
| UPNPScanner * UPNPScanner::Instance | ( | UPNPSubscription * | sub = NULL |
) | [static] |
Returns the global UPNPScanner instance if it has been enabled or NULL if UPNPScanner is currently disabled.
Definition at line 162 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList(), Enable(), VideoListImp::refreshNode(), Start(), and Stop().
| void UPNPScanner::StartFullScan | ( | void | ) |
Instruct the UPNPScanner thread to start a full scan of metadata from known media servers.
Definition at line 200 of file upnpscanner.cpp.
Referenced by GetMetadata().
| void UPNPScanner::GetInitialMetadata | ( | VideoMetadataListManager::metadata_list * | list, | |
| meta_dir_node * | node | |||
| ) |
Definition at line 213 of file upnpscanner.cpp.
Referenced by VideoListImp::buildFsysList().
| void UPNPScanner::GetMetadata | ( | VideoMetadataListManager::metadata_list * | list, | |
| meta_dir_node * | node | |||
| ) |
Definition at line 246 of file upnpscanner.cpp.
Referenced by VideoListImp::refreshNode().
| bool UPNPScanner::GetMetadata | ( | QVariant & | data | ) |
Definition at line 288 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 398 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), and GetMetadata().
| void UPNPScanner::customEvent | ( | QEvent * | event | ) | [protected, virtual] |
Definition at line 648 of file upnpscanner.cpp.
| void UPNPScanner::timerEvent | ( | QTimerEvent * | event | ) | [protected, virtual] |
Handles subscription renewal timer events.
Definition at line 726 of file upnpscanner.cpp.
| void UPNPScanner::Start | ( | void | ) | [private, slot] |
Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanning.
Definition at line 417 of file upnpscanner.cpp.
Referenced by Instance().
| void UPNPScanner::Stop | ( | void | ) | [private, slot] |
| void UPNPScanner::Update | ( | void | ) | [private, slot] |
Iterates through the list of known servers and initialises a connection by requesting the device description.
Definition at line 515 of file upnpscanner.cpp.
Referenced by Start().
| void UPNPScanner::CheckStatus | ( | void | ) | [private, slot] |
Removes media servers that can no longer be found in the SSDP cache.
Definition at line 563 of file upnpscanner.cpp.
Referenced by Start().
| void UPNPScanner::replyFinished | ( | QNetworkReply * | reply | ) | [private, slot] |
Definition at line 591 of file upnpscanner.cpp.
Referenced by Start().
| void UPNPScanner::ScheduleUpdate | ( | void | ) | [private] |
Definition at line 762 of file upnpscanner.cpp.
Referenced by AddServer(), replyFinished(), and Update().
| void UPNPScanner::CheckFailure | ( | const QUrl & | url | ) | [private] |
Updates the logs for failed server connections.
Definition at line 774 of file upnpscanner.cpp.
Referenced by replyFinished().
| void UPNPScanner::Debug | ( | void | ) | [private] |
Definition at line 794 of file upnpscanner.cpp.
Referenced by CheckFailure(), customEvent(), ParseBrowse(), ParseDescription(), and RemoveServer().
| void UPNPScanner::BrowseNextContainer | ( | void | ) | [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 830 of file upnpscanner.cpp.
Referenced by customEvent(), and replyFinished().
| void UPNPScanner::SendBrowseRequest | ( | const QUrl & | url, | |
| const QString & | objectid | |||
| ) | [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 875 of file upnpscanner.cpp.
Referenced by BrowseNextContainer(), and customEvent().
| void UPNPScanner::AddServer | ( | const QString & | usn, | |
| const QString & | url | |||
| ) | [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 917 of file upnpscanner.cpp.
Referenced by customEvent().
| void UPNPScanner::RemoveServer | ( | const QString & | usn | ) | [private] |
Definition at line 953 of file upnpscanner.cpp.
Referenced by AddServer().
| void UPNPScanner::ScheduleRenewal | ( | const QString & | usn, | |
| int | timeout | |||
| ) | [private] |
Creates a QTimer to trigger a subscription renewal for a given media server.
Definition at line 976 of file upnpscanner.cpp.
Referenced by ParseDescription(), and timerEvent().
| void UPNPScanner::ParseBrowse | ( | const QUrl & | url, | |
| QNetworkReply * | reply | |||
| ) | [private] |
Parse the XML returned from Content Directory Service browse request.
Definition at line 995 of file upnpscanner.cpp.
Referenced by replyFinished().
| void UPNPScanner::FindItems | ( | const QDomNode & | n, | |
| MediaServerItem & | content, | |||
| bool & | resetparent | |||
| ) | [private] |
Definition at line 1088 of file upnpscanner.cpp.
Referenced by ParseBrowse().
| QDomDocument * UPNPScanner::FindResult | ( | const QDomNode & | n, | |
| uint & | num, | |||
| uint & | total, | |||
| uint & | updateid | |||
| ) | [private] |
Definition at line 1170 of file upnpscanner.cpp.
Referenced by ParseBrowse().
| bool UPNPScanner::ParseDescription | ( | const QUrl & | url, | |
| QNetworkReply * | reply | |||
| ) | [private] |
Parse the device description XML return my a media server.
Definition at line 1215 of file upnpscanner.cpp.
Referenced by replyFinished().
| void UPNPScanner::ParseDevice | ( | QDomElement & | element, | |
| QString & | controlURL, | |||
| QString & | eventURL, | |||
| QString & | friendlyName | |||
| ) | [private] |
Definition at line 1343 of file upnpscanner.cpp.
Referenced by ParseDescription().
| void UPNPScanner::ParseServiceList | ( | QDomElement & | element, | |
| QString & | controlURL, | |||
| QString & | eventURL | |||
| ) | [private] |
Definition at line 1361 of file upnpscanner.cpp.
Referenced by ParseDevice().
| void UPNPScanner::ParseService | ( | QDomElement & | element, | |
| QString & | controlURL, | |||
| QString & | eventURL | |||
| ) | [private] |
Definition at line 1375 of file upnpscanner.cpp.
Referenced by ParseServiceList().
| void UPNPScanner::GetServerContent | ( | QString & | usn, | |
| MediaServerItem * | content, | |||
| VideoMetadataListManager::metadata_list * | list, | |||
| meta_dir_node * | node | |||
| ) | [private] |
Definition at line 352 of file upnpscanner.cpp.
Referenced by GetInitialMetadata(), and GetMetadata().
UPNPScanner * UPNPScanner::gUPNPScanner = NULL [static, private] |
Definition at line 103 of file upnpscanner.h.
Referenced by Instance().
bool UPNPScanner::gUPNPScannerEnabled = false [static, private] |
Definition at line 104 of file upnpscanner.h.
Referenced by Enable(), and Instance().
MThread * UPNPScanner::gUPNPScannerThread = NULL [static, private] |
Definition at line 105 of file upnpscanner.h.
Referenced by Instance().
QMutex * UPNPScanner::gUPNPScannerLock = new QMutex(QMutex::Recursive) [static, private] |
Definition at line 106 of file upnpscanner.h.
Referenced by Enable(), and Instance().
UPNPSubscription* UPNPScanner::m_subscription [private] |
Definition at line 108 of file upnpscanner.h.
Referenced by ParseDescription(), RemoveServer(), Start(), Stop(), and timerEvent().
QMutex UPNPScanner::m_lock [private] |
Definition at line 109 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().
QHash<QString,MediaServer*> UPNPScanner::m_servers [private] |
Definition at line 110 of file upnpscanner.h.
Referenced by AddServer(), BrowseNextContainer(), CheckFailure(), CheckStatus(), customEvent(), Debug(), GetInitialMetadata(), GetMetadata(), ParseBrowse(), ParseDescription(), RemoveServer(), ScheduleRenewal(), ServerList(), Stop(), timerEvent(), and Update().
QNetworkAccessManager* UPNPScanner::m_network [private] |
Definition at line 111 of file upnpscanner.h.
Referenced by SendBrowseRequest(), Start(), Stop(), and Update().
QMultiMap<QUrl, QNetworkReply*> UPNPScanner::m_descriptionRequests [private] |
Definition at line 114 of file upnpscanner.h.
Referenced by replyFinished(), Stop(), and Update().
QMultiMap<QUrl, QNetworkReply*> UPNPScanner::m_browseRequests [private] |
Definition at line 115 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), SendBrowseRequest(), and Stop().
QTimer* UPNPScanner::m_updateTimer [private] |
Definition at line 117 of file upnpscanner.h.
Referenced by ScheduleUpdate(), Start(), and Stop().
QTimer* UPNPScanner::m_watchdogTimer [private] |
Definition at line 118 of file upnpscanner.h.
QString UPNPScanner::m_masterHost [private] |
Definition at line 120 of file upnpscanner.h.
Referenced by AddServer(), and Start().
int UPNPScanner::m_masterPort [private] |
Definition at line 121 of file upnpscanner.h.
Referenced by AddServer(), and Start().
bool UPNPScanner::m_scanComplete [private] |
Definition at line 123 of file upnpscanner.h.
Referenced by BrowseNextContainer(), customEvent(), GetMetadata(), ParseBrowse(), and ParseDescription().
bool UPNPScanner::m_fullscan [private] |
Definition at line 124 of file upnpscanner.h.
Referenced by BrowseNextContainer(), replyFinished(), and StartFullScan().
1.6.3