MythTV  master
upnpscanner.cpp
Go to the documentation of this file.
1 #include <QCoreApplication>
2 #include <QTextCodec>
3 
4 #include "mythcorecontext.h"
5 #include "mythlogging.h"
6 #include "ssdp.h"
7 #include "upnpscanner.h"
8 
9 #include <chrono> // for milliseconds
10 #include <thread> // for sleep_for
11 #include <utility>
12 
13 using namespace std::chrono_literals;
14 
15 #define LOC QString("UPnPScan: ")
16 #define ERR QString("UPnPScan error: ")
17 
18 #define MAX_ATTEMPTS 5
19 #define MAX_REQUESTS 1
20 
22 {
23  // items don't need scanning
24  if (!m_url.isEmpty())
25  return QString();
26 
27  // scan this container
28  if (!m_scanned)
29  return m_id;
30 
31  // scan children
32  QMutableMapIterator<QString,MediaServerItem> it(m_children);
33  while (it.hasNext())
34  {
35  it.next();
36  QString result = it.value().NextUnbrowsed();
37  if (!result.isEmpty())
38  return result;
39  }
40 
41  return QString();
42 }
43 
45 {
46  if (m_id == id)
47  return this;
48 
49  QMutableMapIterator<QString,MediaServerItem> it(m_children);
50  while (it.hasNext())
51  {
52  it.next();
53  MediaServerItem* result = it.value().Find(id);
54  if (result)
55  return result;
56  }
57 
58  return nullptr;
59 }
60 
62 {
63  if (m_id == item.m_parentid)
64  {
65  m_children.insert(item.m_id, item);
66  return true;
67  }
68  return false;
69 }
70 
72 {
73  m_children.clear();
74  m_scanned = false;
75 }
76 
81 class MediaServer : public MediaServerItem
82 {
83  public:
85  : MediaServerItem(QString("0"), QString(), QString(), QString()),
86  m_eventSubPath(QString()),
87  m_friendlyName(QString("Unknown"))
88  {
89  }
90  explicit MediaServer(QUrl URL)
91  : MediaServerItem(QString("0"), QString(), QString(), QString()),
92  m_serverURL(std::move(URL)), m_eventSubPath(QString()),
93  m_friendlyName(QString("Unknown"))
94  {
95  }
96 
97  bool ResetContent(int new_id)
98  {
99  bool result = true;
100  if (m_systemUpdateID != -1)
101  {
102  result = false;
103  Reset();
104  }
105  m_systemUpdateID = new_id;
106  return result;
107  }
108 
110  int m_connectionAttempts {0};
113  QString m_eventSubPath;
114  QString m_friendlyName;
115  bool m_subscribed {false};
116  int m_renewalTimerId {0};
117  int m_systemUpdateID {-1};
118 };
119 
123 QMutex* UPNPScanner::gUPNPScannerLock = new QMutex(QMutex::Recursive);
124 
136 {
137  Stop();
138 }
139 
144 void UPNPScanner::Enable(bool enable, UPNPSubscription *sub)
145 {
146  QMutexLocker locker(gUPNPScannerLock);
147  gUPNPScannerEnabled = enable;
148  Instance(sub);
149 }
150 
157 {
158  QMutexLocker locker(gUPNPScannerLock);
159  if (!gUPNPScannerEnabled)
160  {
161  if (gUPNPScannerThread)
162  {
163  gUPNPScannerThread->quit();
164  gUPNPScannerThread->wait();
165  }
166  delete gUPNPScannerThread;
167  gUPNPScannerThread = nullptr;
168  delete gUPNPScanner;
169  gUPNPScanner = nullptr;
170  return nullptr;
171  }
172 
173  if (!gUPNPScannerThread)
174  gUPNPScannerThread = new MThread("UPnPScanner");
175  if (!gUPNPScanner)
176  gUPNPScanner = new UPNPScanner(sub);
177 
178  if (!gUPNPScannerThread->isRunning())
179  {
180  gUPNPScanner->moveToThread(gUPNPScannerThread->qthread());
181  QObject::connect(
182  gUPNPScannerThread->qthread(), &QThread::started,
183  gUPNPScanner, &UPNPScanner::Start);
184  gUPNPScannerThread->start(QThread::LowestPriority);
185  }
186 
187  return gUPNPScanner;
188 }
195 {
196  m_fullscan = true;
197  auto *me = new MythEvent(QString("UPNP_STARTSCAN"));
198  qApp->postEvent(this, me);
199 }
200 
208  meta_dir_node *node)
209 {
210  // nothing to see..
211  QMap<QString,QString> servers = ServerList();
212  if (servers.isEmpty())
213  return;
214 
215  // Add MediaServers
216  LOG(VB_GENERAL, LOG_INFO, QString("Adding MediaServer metadata."));
217 
218  smart_dir_node mediaservers = node->addSubDir(tr("Media Servers"));
219  mediaservers->setPathRoot();
220 
221  m_lock.lock();
222  QMutableHashIterator<QString,MediaServer*> it(m_servers);
223  while (it.hasNext())
224  {
225  it.next();
226  if (!it.value()->m_subscribed)
227  continue;
228 
229  QString usn = it.key();
230  GetServerContent(usn, it.value(), list, mediaservers.get());
231  }
232  m_lock.unlock();
233 }
234 
240  meta_dir_node *node)
241 {
242  // nothing to see..
243  QMap<QString,QString> servers = ServerList();
244  if (servers.isEmpty())
245  return;
246 
247  // Start scanning if it isn't already running
248  StartFullScan();
249 
250  // wait for the scanner to complete - with a 30 second timeout
251  LOG(VB_GENERAL, LOG_INFO, LOC + "Waiting for scan to complete.");
252 
253  int count = 0;
254  while (!m_scanComplete && (count++ < 300))
255  std::this_thread::sleep_for(std::chrono::milliseconds(100));
256 
257  // some scans may just take too long (PlayOn)
258  if (!m_scanComplete)
259  LOG(VB_GENERAL, LOG_ERR, LOC + "MediaServer scan is incomplete.");
260  else
261  LOG(VB_GENERAL, LOG_INFO, LOC + "MediaServer scanning finished.");
262 
263 
264  smart_dir_node mediaservers = node->addSubDir(tr("Media Servers"));
265  mediaservers->setPathRoot();
266 
267  m_lock.lock();
268  QMutableHashIterator<QString,MediaServer*> it(m_servers);
269  while (it.hasNext())
270  {
271  it.next();
272  if (!it.value()->m_subscribed)
273  continue;
274 
275  QString usn = it.key();
276  GetServerContent(usn, it.value(), list, mediaservers.get());
277  }
278  m_lock.unlock();
279 }
280 
281 bool UPNPScanner::GetMetadata(QVariant &data)
282 {
283  // we need a USN and objectID
284  if (!data.canConvert(QVariant::StringList))
285  return false;
286 
287  QStringList list = data.toStringList();
288  if (list.size() != 2)
289  return false;
290 
291  QString usn = list[0];
292  QString object = list[1];
293 
294  m_lock.lock();
295  bool valid = m_servers.contains(usn);
296  if (valid)
297  {
298  MediaServerItem* item = m_servers[usn]->Find(object);
299  valid = item ? !item->m_scanned : false;
300  }
301  m_lock.unlock();
302  if (!valid)
303  return false;
304 
305  auto *me = new MythEvent("UPNP_BROWSEOBJECT", list);
306  qApp->postEvent(this, me);
307 
308  int count = 0;
309  bool found = false;
310  LOG(VB_GENERAL, LOG_INFO, "START");
311  while (!found && (count++ < 100)) // 10 seconds
312  {
313  std::this_thread::sleep_for(std::chrono::milliseconds(100));
314  m_lock.lock();
315  if (m_servers.contains(usn))
316  {
317  MediaServerItem *item = m_servers[usn]->Find(object);
318  if (item)
319  {
320  found = item->m_scanned;
321  }
322  else
323  {
324  LOG(VB_GENERAL, LOG_INFO, QString("Item went away..."));
325  found = true;
326  }
327  }
328  else
329  {
330  LOG(VB_GENERAL, LOG_INFO,
331  QString("Server went away while browsing."));
332  found = true;
333  }
334  m_lock.unlock();
335  }
336  LOG(VB_GENERAL, LOG_INFO, "END");
337  return true;
338 }
339 
348  meta_dir_node *node)
349 {
350  if (!content->m_scanned)
351  {
352  smart_dir_node subnode = node->addSubDir(content->m_name);
353 
354  QStringList data;
355  data << usn;
356  data << content->m_id;
357  subnode->SetData(data);
358 
360  item->SetTitle(QString("Dummy"));
361  list->push_back(item);
362  subnode->addEntry(smart_meta_node(new meta_data_node(item.get())));
363  return;
364  }
365 
366  node->SetData(QVariant());
367 
368  if (content->m_url.isEmpty())
369  {
370  smart_dir_node container = node->addSubDir(content->m_name);
371  QMutableMapIterator<QString,MediaServerItem> it(content->m_children);
372  while (it.hasNext())
373  {
374  it.next();
375  GetServerContent(usn, &it.value(), list, container.get());
376  }
377  return;
378  }
379 
381  item->SetTitle(content->m_name);
382  list->push_back(item);
383  node->addEntry(smart_meta_node(new meta_data_node(item.get())));
384 }
385 
391 QMap<QString,QString> UPNPScanner::ServerList(void)
392 {
393  QMap<QString,QString> servers;
394  m_lock.lock();
395  QHashIterator<QString,MediaServer*> it(m_servers);
396  while (it.hasNext())
397  {
398  it.next();
399  servers.insert(it.key(), it.value()->m_friendlyName);
400  }
401  m_lock.unlock();
402  return servers;
403 }
404 
411 {
412  m_lock.lock();
413 
414  // create our network handler
415  m_network = new QNetworkAccessManager();
416  connect(m_network, &QNetworkAccessManager::finished,
418 
419  // listen for SSDP updates
420  SSDP::AddListener(this);
421 
422  // listen for subscriptions and events
423  if (m_subscription)
424  m_subscription->addListener(this);
425 
426  // create our update timer (driven by AddServer and ParseDescription)
427  m_updateTimer = new QTimer(this);
428  m_updateTimer->setSingleShot(true);
429  connect(m_updateTimer, &QTimer::timeout, this, &UPNPScanner::Update);
430 
431  // create our watchdog timer (checks for stale servers)
432  m_watchdogTimer = new QTimer(this);
433  connect(m_watchdogTimer, &QTimer::timeout, this, &UPNPScanner::CheckStatus);
434  m_watchdogTimer->start(10s);
435 
436  // avoid connecting to the master backend
437  m_masterHost = gCoreContext->GetMasterServerIP();
438  m_masterPort = gCoreContext->GetMasterServerStatusPort();
439 
440  m_lock.unlock();
441  LOG(VB_GENERAL, LOG_INFO, LOC + "Started");
442 }
443 
449 {
450  m_lock.lock();
451 
452  // stop listening
453  SSDP::RemoveListener(this);
454  if (m_subscription)
455  m_subscription->removeListener(this);
456 
457  // disable updates
458  if (m_updateTimer)
459  m_updateTimer->stop();
460  if (m_watchdogTimer)
461  m_watchdogTimer->stop();
462 
463  // cleanup our servers and subscriptions
464  QHashIterator<QString,MediaServer*> it(m_servers);
465  while (it.hasNext())
466  {
467  it.next();
468  if (m_subscription && it.value()->m_subscribed)
469  m_subscription->Unsubscribe(it.key());
470  if (it.value()->m_renewalTimerId)
471  killTimer(it.value()->m_renewalTimerId);
472  delete it.value();
473  }
474  m_servers.clear();
475 
476  // cleanup the network
477  for (QNetworkReply *reply : qAsConst(m_descriptionRequests))
478  {
479  reply->abort();
480  delete reply;
481  }
482  m_descriptionRequests.clear();
483  for (QNetworkReply *reply : qAsConst(m_browseRequests))
484  {
485  reply->abort();
486  delete reply;
487  }
488  m_browseRequests.clear();
489  delete m_network;
490  m_network = nullptr;
491 
492  // delete the timers
493  delete m_updateTimer;
494  delete m_watchdogTimer;
495  m_updateTimer = nullptr;
496  m_watchdogTimer = nullptr;
497 
498  m_lock.unlock();
499  LOG(VB_GENERAL, LOG_INFO, LOC + "Finished");
500 }
501 
508 {
509  // decide which servers still need to be checked
510  m_lock.lock();
511  if (m_servers.isEmpty())
512  {
513  m_lock.unlock();
514  return;
515  }
516 
517  // if our network queue is full, then we may need to come back later
518  bool reschedule = false;
519 
520  QHashIterator<QString,MediaServer*> it(m_servers);
521  while (it.hasNext())
522  {
523  it.next();
524  if ((it.value()->m_connectionAttempts < MAX_ATTEMPTS) &&
525  (it.value()->m_controlURL.isEmpty()))
526  {
527  bool sent = false;
528  QUrl url = it.value()->m_url;
529  if (!m_descriptionRequests.contains(url) &&
530  (m_descriptionRequests.empty()) &&
531  url.isValid())
532  {
533  QNetworkReply *reply = m_network->get(QNetworkRequest(url));
534  if (reply)
535  {
536  sent = true;
537  m_descriptionRequests.insert(url, reply);
538  it.value()->m_connectionAttempts++;
539  }
540  }
541  if (!sent)
542  reschedule = true;
543  }
544  }
545 
546  if (reschedule)
547  ScheduleUpdate();
548  m_lock.unlock();
549 }
550 
556 {
557  // FIXME
558  // Remove stale servers - the SSDP cache code does not send out removal
559  // notifications for expired (rather than explicitly closed) connections
560  m_lock.lock();
561  QMutableHashIterator<QString,MediaServer*> it(m_servers);
562  while (it.hasNext())
563  {
564  it.next();
565  // FIXME UPNP version comparision done wrong, we are using urn:schemas-upnp-org:device:MediaServer:4 ourselves
566  if (!SSDP::Find("urn:schemas-upnp-org:device:MediaServer:1", it.key()))
567  {
568  LOG(VB_UPNP, LOG_INFO, LOC + QString("%1 no longer in SSDP cache. Removing")
569  .arg(it.value()->m_serverURL.toString()));
570  MediaServer* last = it.value();
571  it.remove();
572  delete last;
573  }
574  }
575  m_lock.unlock();
576 }
577 
583 void UPNPScanner::replyFinished(QNetworkReply *reply)
584 {
585  if (!reply)
586  return;
587 
588  QUrl url = reply->url();
589  bool valid = reply->error() == QNetworkReply::NoError;
590 
591  if (!valid)
592  {
593  LOG(VB_UPNP, LOG_ERR, LOC +
594  QString("Network request for '%1' returned error '%2'")
595  .arg(url.toString()).arg(reply->errorString()));
596  }
597 
598  bool description = false;
599  bool browse = false;
600 
601  m_lock.lock();
602  if (m_descriptionRequests.contains(url, reply))
603  {
604  m_descriptionRequests.remove(url, reply);
605  description = true;
606  }
607  else if (m_browseRequests.contains(url, reply))
608  {
609  m_browseRequests.remove(url, reply);
610  browse = true;
611  }
612  m_lock.unlock();
613 
614  if (browse && valid)
615  {
616  ParseBrowse(url, reply);
617  if (m_fullscan)
618  BrowseNextContainer();
619  }
620  else if (description)
621  {
622  if (!valid || !ParseDescription(url, reply))
623  {
624  // if there will be no more attempts, update the logs
625  CheckFailure(url);
626  // try again
627  ScheduleUpdate();
628  }
629  }
630  else
631  LOG(VB_UPNP, LOG_ERR, LOC + "Received unknown reply");
632 
633  reply->deleteLater();
634 }
635 
639 void UPNPScanner::customEvent(QEvent *event)
640 {
641  if (event->type() != MythEvent::MythEventMessage)
642  return;
643 
644  // UPnP events
645  auto *me = dynamic_cast<MythEvent *>(event);
646  if (me == nullptr)
647  return;
648 
649  const QString& ev = me->Message();
650 
651  if (ev == "UPNP_STARTSCAN")
652  {
653  BrowseNextContainer();
654  return;
655  }
656  if (ev == "UPNP_BROWSEOBJECT")
657  {
658  if (me->ExtraDataCount() == 2)
659  {
660  QUrl url;
661  const QString& usn = me->ExtraData(0);
662  const QString& objectid = me->ExtraData(1);
663  m_lock.lock();
664  if (m_servers.contains(usn))
665  {
666  url = m_servers[usn]->m_controlURL;
667  LOG(VB_GENERAL, LOG_INFO, QString("UPNP_BROWSEOBJECT: %1->%2")
668  .arg(m_servers[usn]->m_friendlyName).arg(objectid));
669  }
670  m_lock.unlock();
671  if (!url.isEmpty())
672  SendBrowseRequest(url, objectid);
673  }
674  return;
675  }
676  if (ev == "UPNP_EVENT")
677  {
678  auto *info = (MythInfoMapEvent*)event;
679  if (!info)
680  return;
681  if (!info->GetInfoMap())
682  return;
683 
684  QString usn = info->GetInfoMap()->value("usn");
685  QString id = info->GetInfoMap()->value("SystemUpdateID");
686  if (usn.isEmpty() || id.isEmpty())
687  return;
688 
689  m_lock.lock();
690  if (m_servers.contains(usn))
691  {
692  int newid = id.toInt();
693  if (m_servers[usn]->m_systemUpdateID != newid)
694  {
695  m_scanComplete &= m_servers[usn]->ResetContent(newid);
696  LOG(VB_GENERAL, LOG_INFO, LOC +
697  QString("New SystemUpdateID '%1' for %2").arg(id).arg(usn));
698  Debug();
699  }
700  }
701  m_lock.unlock();
702  return;
703  }
704 
705  // process SSDP cache updates
706  QString uri = me->ExtraDataCount() > 0 ? me->ExtraData(0) : QString();
707  QString usn = me->ExtraDataCount() > 1 ? me->ExtraData(1) : QString();
708 
709  // FIXME UPNP version comparision done wrong, we are using urn:schemas-upnp-org:device:MediaServer:4 ourselves
710  if (uri == "urn:schemas-upnp-org:device:MediaServer:1")
711  {
712  QString url = (ev == "SSDP_ADD") ? me->ExtraData(2) : QString();
713  AddServer(usn, url);
714  }
715 }
716 
721 void UPNPScanner::timerEvent(QTimerEvent * event)
722 {
723  int id = event->timerId();
724  if (id)
725  killTimer(id);
726 
727  int timeout = 0;
728  QString usn;
729 
730  m_lock.lock();
731  QHashIterator<QString,MediaServer*> it(m_servers);
732  while (it.hasNext())
733  {
734  it.next();
735  if (it.value()->m_renewalTimerId == id)
736  {
737  it.value()->m_renewalTimerId = 0;
738  usn = it.key();
739  if (m_subscription)
740  timeout = m_subscription->Renew(usn);
741  }
742  }
743  m_lock.unlock();
744 
745  if (timeout > 0)
746  {
747  ScheduleRenewal(usn, timeout);
748  LOG(VB_GENERAL, LOG_INFO, LOC +
749  QString("Re-subscribed for %1 seconds to %2")
750  .arg(timeout).arg(usn));
751  }
752 }
753 
758 {
759  m_lock.lock();
760  if (m_updateTimer && !m_updateTimer->isActive())
761  m_updateTimer->start(200ms);
762  m_lock.unlock();
763 }
764 
769 void UPNPScanner::CheckFailure(const QUrl &url)
770 {
771  m_lock.lock();
772  QHashIterator<QString,MediaServer*> it(m_servers);
773  while (it.hasNext())
774  {
775  it.next();
776  if (it.value()->m_serverURL == url && it.value()->m_connectionAttempts == MAX_ATTEMPTS)
777  {
778  Debug();
779  break;
780  }
781  }
782  m_lock.unlock();
783 }
784 
789 {
790  m_lock.lock();
791  LOG(VB_UPNP, LOG_INFO, LOC + QString("%1 media servers discovered:")
792  .arg(m_servers.size()));
793  QHashIterator<QString,MediaServer*> it(m_servers);
794  while (it.hasNext())
795  {
796  it.next();
797  QString status = "Probing";
798  if (it.value()->m_controlURL.toString().isEmpty())
799  {
800  if (it.value()->m_connectionAttempts >= MAX_ATTEMPTS)
801  status = "Failed";
802  }
803  else
804  status = "Yes";
805  LOG(VB_UPNP, LOG_INFO, LOC +
806  QString("'%1' Connected: %2 Subscribed: %3 SystemUpdateID: "
807  "%4 timerId: %5")
808  .arg(it.value()->m_friendlyName).arg(status)
809  .arg(it.value()->m_subscribed ? "Yes" : "No")
810  .arg(it.value()->m_systemUpdateID)
811  .arg(it.value()->m_renewalTimerId));
812  }
813  m_lock.unlock();
814 }
815 
825 {
826  QMutexLocker locker(&m_lock);
827 
828  QHashIterator<QString,MediaServer*> it(m_servers);
829  bool complete = true;
830  while (it.hasNext())
831  {
832  it.next();
833  if (it.value()->m_subscribed)
834  {
835  // limit browse requests to one active per server
836  if (m_browseRequests.contains(it.value()->m_controlURL))
837  {
838  complete = false;
839  continue;
840  }
841 
842  QString next = it.value()->NextUnbrowsed();
843  if (!next.isEmpty())
844  {
845  complete = false;
846  SendBrowseRequest(it.value()->m_controlURL, next);
847  continue;
848  }
849 
850  LOG(VB_UPNP, LOG_INFO, LOC + QString("Scan completed for %1")
851  .arg(it.value()->m_friendlyName));
852  }
853  }
854 
855  if (complete)
856  {
857  LOG(VB_GENERAL, LOG_INFO, LOC +
858  QString("Media Server scan is complete."));
859  m_scanComplete = true;
860  m_fullscan = false;
861  }
862 }
863 
869 void UPNPScanner::SendBrowseRequest(const QUrl &url, const QString &objectid)
870 {
871  QNetworkRequest req = QNetworkRequest(url);
872  req.setRawHeader("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
873  req.setRawHeader("SOAPACTION",
874  "\"urn:schemas-upnp-org:service:ContentDirectory:1#Browse\"");
875 #if 0
876  req.setRawHeader("MAN", "\"http://schemasxmlsoap.org/soap/envelope/\"");
877  req.setRawHeader("01-SOAPACTION",
878  "\"urn:schemas-upnp-org:service:ContentDirectory:1#Browse\"");
879 #endif
880 
881  QByteArray body;
882  QTextStream data(&body);
883  data.setCodec(QTextCodec::codecForName("UTF-8"));
884  data << "<?xml version=\"1.0\"?>\r\n";
885  data << "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n";
886  data << " <s:Body>\r\n";
887  data << " <u:Browse xmlns:u=\"urn:schemas-upnp-org:service:ContentDirectory:1\">\r\n";
888  data << " <ObjectID>" << objectid.toUtf8() << "</ObjectID>\r\n";
889  data << " <BrowseFlag>BrowseDirectChildren</BrowseFlag>\r\n";
890  data << " <Filter>*</Filter>\r\n";
891  data << " <StartingIndex>0</StartingIndex>\r\n";
892  data << " <RequestedCount>0</RequestedCount>\r\n";
893  data << " <SortCriteria></SortCriteria>\r\n";
894  data << " </u:Browse>\r\n";
895  data << " </s:Body>\r\n";
896  data << "</s:Envelope>\r\n";
897  data.flush();
898 
899  m_lock.lock();
900  QNetworkReply *reply = m_network->post(req, body);
901  if (reply)
902  m_browseRequests.insert(url, reply);
903  m_lock.unlock();
904 }
905 
911 void UPNPScanner::AddServer(const QString &usn, const QString &url)
912 {
913  if (url.isEmpty())
914  {
915  RemoveServer(usn);
916  return;
917  }
918 
919  // sometimes initialisation is too early and m_masterHost is empty
920  if (m_masterHost.isEmpty())
921  {
922  m_masterHost = gCoreContext->GetMasterServerIP();
923  m_masterPort = gCoreContext->GetMasterServerStatusPort();
924  }
925 
926  QUrl qurl(url);
927  if (qurl.host() == m_masterHost && qurl.port() == m_masterPort)
928  {
929  LOG(VB_UPNP, LOG_INFO, LOC + "Ignoring master backend.");
930  return;
931  }
932 
933  m_lock.lock();
934  if (!m_servers.contains(usn))
935  {
936  m_servers.insert(usn, new MediaServer(url));
937  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding: %1").arg(usn));
938  ScheduleUpdate();
939  }
940  m_lock.unlock();
941 }
942 
946 void UPNPScanner::RemoveServer(const QString &usn)
947 {
948  m_lock.lock();
949  if (m_servers.contains(usn))
950  {
951  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Removing: %1").arg(usn));
952  MediaServer* old = m_servers[usn];
953  if (old->m_renewalTimerId)
954  killTimer(old->m_renewalTimerId);
955  m_servers.remove(usn);
956  delete old;
957  if (m_subscription)
958  m_subscription->Remove(usn);
959  }
960  m_lock.unlock();
961 
962  Debug();
963 }
964 
969 void UPNPScanner::ScheduleRenewal(const QString &usn, int timeout)
970 {
971  // sanitise the timeout
972  int renew = timeout - 10;
973  if (renew < 10)
974  renew = 10;
975  if (renew > 43200)
976  renew = 43200;
977 
978  m_lock.lock();
979  if (m_servers.contains(usn))
980  m_servers[usn]->m_renewalTimerId = startTimer(renew * 1000);
981  m_lock.unlock();
982 }
983 
988 void UPNPScanner::ParseBrowse(const QUrl &url, QNetworkReply *reply)
989 {
990  QByteArray data = reply->readAll();
991  if (data.isEmpty())
992  return;
993 
994  // Open the response for parsing
995  auto *parent = new QDomDocument();
996  QString errorMessage;
997  int errorLine = 0;
998  int errorColumn = 0;
999  if (!parent->setContent(data, false, &errorMessage, &errorLine,
1000  &errorColumn))
1001  {
1002  LOG(VB_GENERAL, LOG_ERR, LOC +
1003  QString("DIDL Parse error, Line: %1 Col: %2 Error: '%3'")
1004  .arg(errorLine).arg(errorColumn).arg(errorMessage));
1005  delete parent;
1006  return;
1007  }
1008 
1009  LOG(VB_UPNP, LOG_INFO, "\n\n" + parent->toString(4) + "\n\n");
1010 
1011  // pull out the actual result
1012  QDomDocument *result = nullptr;
1013  uint num = 0;
1014  uint total = 0;
1015  uint updateid = 0;
1016  QDomElement docElem = parent->documentElement();
1017  QDomNode n = docElem.firstChild();
1018  if (!n.isNull())
1019  result = FindResult(n, num, total, updateid);
1020  delete parent;
1021 
1022  if (!result || num < 1 || total < 1)
1023  {
1024  LOG(VB_GENERAL, LOG_ERR, LOC +
1025  QString("Failed to find result for %1") .arg(url.toString()));
1026  return;
1027  }
1028 
1029  // determine the 'server' which requested the browse
1030  m_lock.lock();
1031 
1032  MediaServer* server = nullptr;
1033  QHashIterator<QString,MediaServer*> it(m_servers);
1034  while (it.hasNext())
1035  {
1036  it.next();
1037  if (url == it.value()->m_controlURL)
1038  {
1039  server = it.value();
1040  break;
1041  }
1042  }
1043 
1044  // discard unmatched responses
1045  if (!server)
1046  {
1047  m_lock.unlock();
1048  LOG(VB_GENERAL, LOG_ERR, LOC +
1049  QString("Received unknown response for %1").arg(url.toString()));
1050  return;
1051  }
1052 
1053  // check the update ID
1054  if (server->m_systemUpdateID != (int)updateid)
1055  {
1056  // if this is not the root container, this browse will now fail
1057  // as the appropriate parentID will not be found
1058  LOG(VB_GENERAL, LOG_ERR, LOC +
1059  QString("%1 updateID changed during browse (old %2 new %3)")
1060  .arg(server->m_friendlyName).arg(server->m_systemUpdateID)
1061  .arg(updateid));
1062  m_scanComplete &= server->ResetContent(updateid);
1063  Debug();
1064  }
1065 
1066  // find containers (directories) and actual items and add them and reset
1067  // the parent when we have found the first item
1068  bool reset = true;
1069  docElem = result->documentElement();
1070  n = docElem.firstChild();
1071  while (!n.isNull())
1072  {
1073  FindItems(n, *server, reset);
1074  n = n.nextSibling();
1075  }
1076  delete result;
1077 
1078  m_lock.unlock();
1079 }
1080 
1082  bool &resetparent)
1083 {
1084  QDomElement node = n.toElement();
1085  if (node.isNull())
1086  return;
1087 
1088  if (node.tagName() == "container")
1089  {
1090  QString title = "ERROR";
1091  QDomNode next = node.firstChild();
1092  while (!next.isNull())
1093  {
1094  QDomElement container = next.toElement();
1095  if (!container.isNull() && container.tagName() == "title")
1096  title = container.text();
1097  next = next.nextSibling();
1098  }
1099 
1100  QString thisid = node.attribute("id", "ERROR");
1101  QString parentid = node.attribute("parentID", "ERROR");
1102  MediaServerItem container =
1103  MediaServerItem(thisid, parentid, title, QString());
1104  MediaServerItem *parent = content.Find(parentid);
1105  if (parent)
1106  {
1107  if (resetparent)
1108  {
1109  parent->Reset();
1110  resetparent = false;
1111  }
1112  parent->m_scanned = true;
1113  parent->Add(container);
1114  }
1115  return;
1116  }
1117 
1118  if (node.tagName() == "item")
1119  {
1120  QString title = "ERROR";
1121  QString url = "ERROR";
1122  QDomNode next = node.firstChild();
1123  while (!next.isNull())
1124  {
1125  QDomElement item = next.toElement();
1126  if (!item.isNull())
1127  {
1128  if(item.tagName() == "res")
1129  url = item.text();
1130  if(item.tagName() == "title")
1131  title = item.text();
1132  }
1133  next = next.nextSibling();
1134  }
1135 
1136  QString thisid = node.attribute("id", "ERROR");
1137  QString parentid = node.attribute("parentID", "ERROR");
1138  MediaServerItem item =
1139  MediaServerItem(thisid, parentid, title, url);
1140  item.m_scanned = true;
1141  MediaServerItem *parent = content.Find(parentid);
1142  if (parent)
1143  {
1144  if (resetparent)
1145  {
1146  parent->Reset();
1147  resetparent = false;
1148  }
1149  parent->m_scanned = true;
1150  parent->Add(item);
1151  }
1152  return;
1153  }
1154 
1155  QDomNode next = node.firstChild();
1156  while (!next.isNull())
1157  {
1158  FindItems(next, content, resetparent);
1159  next = next.nextSibling();
1160  }
1161 }
1162 
1163 QDomDocument* UPNPScanner::FindResult(const QDomNode &n, uint &num,
1164  uint &total, uint &updateid)
1165 {
1166  QDomDocument *result = nullptr;
1167  QDomElement node = n.toElement();
1168  if (node.isNull())
1169  return nullptr;
1170 
1171  if (node.tagName() == "NumberReturned")
1172  num = node.text().toUInt();
1173  if (node.tagName() == "TotalMatches")
1174  total = node.text().toUInt();
1175  if (node.tagName() == "UpdateID")
1176  updateid = node.text().toUInt();
1177  if (node.tagName() == "Result" && !result)
1178  {
1179  QString errorMessage;
1180  int errorLine = 0;
1181  int errorColumn = 0;
1182  result = new QDomDocument();
1183  if (!result->setContent(node.text(), true, &errorMessage, &errorLine, &errorColumn))
1184  {
1185  LOG(VB_GENERAL, LOG_ERR, LOC +
1186  QString("DIDL Parse error, Line: %1 Col: %2 Error: '%3'")
1187  .arg(errorLine).arg(errorColumn).arg(errorMessage));
1188  delete result;
1189  result = nullptr;
1190  }
1191  }
1192 
1193  QDomNode next = node.firstChild();
1194  while (!next.isNull())
1195  {
1196  QDomDocument *res = FindResult(next, num, total, updateid);
1197  if (res)
1198  result = res;
1199  next = next.nextSibling();
1200  }
1201  return result;
1202 }
1203 
1208 bool UPNPScanner::ParseDescription(const QUrl &url, QNetworkReply *reply)
1209 {
1210  if (url.isEmpty() || !reply)
1211  return false;
1212 
1213  QByteArray data = reply->readAll();
1214  if (data.isEmpty())
1215  {
1216  LOG(VB_GENERAL, LOG_ERR, LOC +
1217  QString("%1 returned an empty device description.")
1218  .arg(url.toString()));
1219  return false;
1220  }
1221 
1222  // parse the device description
1223  QString controlURL = QString();
1224  QString eventURL = QString();
1225  QString friendlyName = QString("Unknown");
1226  QString URLBase = QString();
1227 
1228  QDomDocument doc;
1229  QString errorMessage;
1230  int errorLine = 0;
1231  int errorColumn = 0;
1232  if (!doc.setContent(data, false, &errorMessage, &errorLine, &errorColumn))
1233  {
1234  LOG(VB_GENERAL, LOG_ERR, LOC +
1235  QString("Failed to parse device description from %1")
1236  .arg(url.toString()));
1237  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Line: %1 Col: %2 Error: '%3'")
1238  .arg(errorLine).arg(errorColumn).arg(errorMessage));
1239  return false;
1240  }
1241 
1242  QDomElement docElem = doc.documentElement();
1243  QDomNode n = docElem.firstChild();
1244  while (!n.isNull())
1245  {
1246  QDomElement e1 = n.toElement();
1247  if (!e1.isNull())
1248  {
1249  if(e1.tagName() == "device")
1250  ParseDevice(e1, controlURL, eventURL, friendlyName);
1251  if (e1.tagName() == "URLBase")
1252  URLBase = e1.text();
1253  }
1254  n = n.nextSibling();
1255  }
1256 
1257  if (controlURL.isEmpty())
1258  {
1259  LOG(VB_UPNP, LOG_ERR, LOC +
1260  QString("Failed to parse device description for %1")
1261  .arg(url.toString()));
1262  return false;
1263  }
1264 
1265  // if no URLBase was provided, use the known url
1266  if (URLBase.isEmpty())
1267  URLBase = url.toString(QUrl::RemovePath | QUrl::RemoveFragment |
1268  QUrl::RemoveQuery);
1269 
1270  // strip leading slashes off the controlURL
1271  while (!controlURL.isEmpty() && controlURL.startsWith("/"))
1272  controlURL = controlURL.mid(1);
1273 
1274  // strip leading slashes off the eventURL
1275  //while (!eventURL.isEmpty() && eventURL.startsWith("/"))
1276  // eventURL = eventURL.mid(1);
1277 
1278  // strip trailing slashes off URLBase
1279  while (!URLBase.isEmpty() && URLBase.endsWith("/"))
1280  URLBase = URLBase.mid(0, URLBase.size() - 1);
1281 
1282  controlURL = URLBase + "/" + controlURL;
1283  QString fulleventURL = URLBase + "/" + eventURL;
1284 
1285  LOG(VB_UPNP, LOG_INFO, LOC + QString("Control URL for %1 at %2")
1286  .arg(friendlyName).arg(controlURL));
1287  LOG(VB_UPNP, LOG_INFO, LOC + QString("Event URL for %1 at %2")
1288  .arg(friendlyName).arg(fulleventURL));
1289 
1290  // update the server details. If the server has gone away since the request
1291  // was posted, this will silently fail and we won't try again
1292  QString usn;
1293  QUrl qeventurl = QUrl(fulleventURL);
1294  int timeout = 0;
1295 
1296  m_lock.lock();
1297  QHashIterator<QString,MediaServer*> it(m_servers);
1298  while (it.hasNext())
1299  {
1300  it.next();
1301  if (it.value()->m_serverURL == url)
1302  {
1303  usn = it.key();
1304  QUrl qcontrolurl(controlURL);
1305  it.value()->m_controlURL = qcontrolurl;
1306  it.value()->m_eventSubURL = qeventurl;
1307  it.value()->m_eventSubPath = eventURL;
1308  it.value()->m_friendlyName = friendlyName;
1309  it.value()->m_name = friendlyName;
1310  break;
1311  }
1312  }
1313 
1314  if (m_subscription && !usn.isEmpty())
1315  {
1316  timeout = m_subscription->Subscribe(usn, qeventurl, eventURL);
1317  m_servers[usn]->m_subscribed = (timeout > 0);
1318  }
1319  m_lock.unlock();
1320 
1321  if (timeout > 0)
1322  {
1323  LOG(VB_GENERAL, LOG_INFO, LOC +
1324  QString("Subscribed for %1 seconds to %2") .arg(timeout).arg(usn));
1325  ScheduleRenewal(usn, timeout);
1326  // we only scan servers we are subscribed to - and the scan is now
1327  // incomplete
1328  m_scanComplete = false;
1329  }
1330 
1331  Debug();
1332  return true;
1333 }
1334 
1335 
1336 void UPNPScanner::ParseDevice(QDomElement &element, QString &controlURL,
1337  QString &eventURL, QString &friendlyName)
1338 {
1339  QDomNode dev = element.firstChild();
1340  while (!dev.isNull())
1341  {
1342  QDomElement e = dev.toElement();
1343  if (!e.isNull())
1344  {
1345  if (e.tagName() == "friendlyName")
1346  friendlyName = e.text();
1347  if (e.tagName() == "serviceList")
1348  ParseServiceList(e, controlURL, eventURL);
1349  }
1350  dev = dev.nextSibling();
1351  }
1352 }
1353 
1354 void UPNPScanner::ParseServiceList(QDomElement &element, QString &controlURL,
1355  QString &eventURL)
1356 {
1357  QDomNode list = element.firstChild();
1358  while (!list.isNull())
1359  {
1360  QDomElement e = list.toElement();
1361  if (!e.isNull())
1362  if (e.tagName() == "service")
1363  ParseService(e, controlURL, eventURL);
1364  list = list.nextSibling();
1365  }
1366 }
1367 
1368 void UPNPScanner::ParseService(QDomElement &element, QString &controlURL,
1369  QString &eventURL)
1370 {
1371  bool iscds = false;
1372  QString control_url = QString();
1373  QString event_url = QString();
1374  QDomNode service = element.firstChild();
1375 
1376  while (!service.isNull())
1377  {
1378  QDomElement e = service.toElement();
1379  if (!e.isNull())
1380  {
1381  if (e.tagName() == "serviceType")
1382  // FIXME UPNP version comparision done wrong, we are using urn:schemas-upnp-org:device:MediaServer:4 ourselves
1383  iscds = (e.text() == "urn:schemas-upnp-org:service:ContentDirectory:1");
1384  if (e.tagName() == "controlURL")
1385  control_url = e.text();
1386  if (e.tagName() == "eventSubURL")
1387  event_url = e.text();
1388  }
1389  service = service.nextSibling();
1390  }
1391 
1392  if (iscds)
1393  {
1394  controlURL = control_url;
1395  eventURL = event_url;
1396  }
1397 }
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1420
VideoMetadata
Definition: videometadata.h:25
MediaServerItem::Add
bool Add(const MediaServerItem &item)
Definition: upnpscanner.cpp:61
UPNPScanner::customEvent
void customEvent(QEvent *event) override
Processes subscription and SSDP cache update events.
Definition: upnpscanner.cpp:639
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:73
meta_dir_node::SetData
void SetData(const QVariant &data)
Definition: videometadatalistmanager.cpp:317
MAX_ATTEMPTS
#define MAX_ATTEMPTS
Definition: upnpscanner.cpp:18
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
UPNPScanner::timerEvent
void timerEvent(QTimerEvent *event) override
Handles subscription renewal timer events.
Definition: upnpscanner.cpp:721
UPNPScanner::gUPNPScanner
static UPNPScanner * gUPNPScanner
Definition: upnpscanner.h:108
MediaServerItem
Definition: upnpscanner.h:25
UPNPScanner::ScheduleUpdate
void ScheduleUpdate(void)
Definition: upnpscanner.cpp:757
MediaServer
A simple wrapper containing details about a UPnP Media Server.
Definition: mediaserver.h:33
meta_node::setPathRoot
void setPathRoot(bool is_root=true)
Definition: videometadatalistmanager.cpp:223
UPNPScanner::gUPNPScannerLock
static QMutex * gUPNPScannerLock
Definition: upnpscanner.h:111
doc
QDomDocument doc("MYTHARCHIVEITEM")
UPNPScanner::GetInitialMetadata
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....
Definition: upnpscanner.cpp:207
ssdp.h
MediaServer::m_serverURL
QUrl m_serverURL
Definition: upnpscanner.cpp:109
UPNPSubscription
Definition: upnpsubscription.h:10
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:636
simple_ref_ptr< meta_dir_node >
smart_meta_node
simple_ref_ptr< meta_data_node > smart_meta_node
Definition: videometadatalistmanager.h:77
build_compdb.content
content
Definition: build_compdb.py:38
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
arg
arg(title).arg(filename).arg(doDelete))
SSDP::Find
static SSDPCacheEntries * Find(const QString &sURI)
Definition: ssdp.h:126
meta_dir_node
Definition: videometadatalistmanager.h:83
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
meta_dir_node::addEntry
void addEntry(const smart_meta_node &entry)
Definition: videometadatalistmanager.cpp:372
MediaServerItem::m_id
QString m_id
Definition: upnpscanner.h:37
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
MythCoreContext::GetMasterServerStatusPort
int GetMasterServerStatusPort(void)
Returns the Master Backend status port If no master server status port has been defined in the databa...
Definition: mythcorecontext.cpp:1014
MediaServer::m_controlURL
QUrl m_controlURL
Definition: upnpscanner.cpp:111
UPNPScanner::StartFullScan
void StartFullScan(void)
Instruct the UPNPScanner thread to start a full scan of metadata from known media servers.
Definition: upnpscanner.cpp:194
MediaServer::m_friendlyName
QString m_friendlyName
Definition: upnpscanner.cpp:114
UPNPScanner::GetServerContent
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_...
Definition: upnpscanner.cpp:345
UPNPScanner::Stop
void Stop(void)
Stops scanning.
Definition: upnpscanner.cpp:448
UPNPScanner
UPnPScanner detects UPnP Media Servers available on the local network (via the UPnP SSDP cache),...
Definition: upnpscanner.h:46
UPNPScanner::FindResult
QDomDocument * FindResult(const QDomNode &n, uint &num, uint &total, uint &updateid)
Definition: upnpscanner.cpp:1163
mythlogging.h
meta_dir_node::addSubDir
smart_dir_node addSubDir(const QString &subdir, const QString &name="", const QString &host="", const QString &prefix="", const QVariant &data=QVariant())
Definition: videometadatalistmanager.cpp:332
MediaServer::ResetContent
bool ResetContent(int new_id)
Definition: upnpscanner.cpp:97
MythCoreContext::GetMasterServerIP
QString GetMasterServerIP(void)
Returns the Master Backend IP address If the address is an IPv6 address, the scope Id is removed.
Definition: mythcorecontext.cpp:987
MediaServer::MediaServer
MediaServer(QUrl URL)
Definition: upnpscanner.cpp:90
UPNPScanner::ServerList
QMap< QString, QString > ServerList(void)
Returns a list of valid Media Servers discovered on the network.
Definition: upnpscanner.cpp:391
MediaServer::m_eventSubURL
QUrl m_eventSubURL
Definition: upnpscanner.cpp:112
UPNPScanner::RemoveServer
void RemoveServer(const QString &usn)
Definition: upnpscanner.cpp:946
UPNPScanner::AddServer
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 schedu...
Definition: upnpscanner.cpp:911
UPNPScanner::ParseBrowse
void ParseBrowse(const QUrl &url, QNetworkReply *reply)
Parse the XML returned from Content Directory Service browse request.
Definition: upnpscanner.cpp:988
uint
unsigned int uint
Definition: compat.h:141
UPNPScanner::SendBrowseRequest
void SendBrowseRequest(const QUrl &url, const QString &objectid)
Formulates and sends a ContentDirectory Service Browse Request to the given control URL,...
Definition: upnpscanner.cpp:869
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MediaServerItem::Find
MediaServerItem * Find(QString &id)
Definition: upnpscanner.cpp:44
MediaServer::m_systemUpdateID
int m_systemUpdateID
Definition: upnpscanner.cpp:117
MediaServer::MediaServer
MediaServer()
Definition: upnpscanner.cpp:84
UPNPScanner::gUPNPScannerThread
static MThread * gUPNPScannerThread
Definition: upnpscanner.h:110
UPNPScanner::replyFinished
void replyFinished(QNetworkReply *reply)
Validates network responses against known requests and parses expected responses for the required dat...
Definition: upnpscanner.cpp:583
MediaServerItem::Reset
void Reset(void)
Definition: upnpscanner.cpp:71
MythInfoMapEvent
Definition: mythevent.h:115
UPNPScanner::ParseDescription
bool ParseDescription(const QUrl &url, QNetworkReply *reply)
Parse the device description XML return my a media server.
Definition: upnpscanner.cpp:1208
meta_data_node
Definition: videometadatalistmanager.h:61
mythcorecontext.h
UPNPScanner::Start
void Start()
Initialises the scanner, hooks it up to the subscription service and the SSDP cache and starts scanni...
Definition: upnpscanner.cpp:410
UPNPScanner::Instance
static UPNPScanner * Instance(UPNPSubscription *sub=nullptr)
Returns the global UPNPScanner instance if it has been enabled or nullptr if UPNPScanner is currently...
Definition: upnpscanner.cpp:156
UPNPScanner::ParseDevice
static void ParseDevice(QDomElement &element, QString &controlURL, QString &eventURL, QString &friendlyName)
Definition: upnpscanner.cpp:1336
UPNPScanner::~UPNPScanner
~UPNPScanner() override
Definition: upnpscanner.cpp:135
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:49
MediaServerItem::NextUnbrowsed
QString NextUnbrowsed(void)
Definition: upnpscanner.cpp:21
UPNPScanner::Update
void Update(void)
Iterates through the list of known servers and initialises a connection by requesting the device desc...
Definition: upnpscanner.cpp:507
UPNPScanner::Enable
static void Enable(bool enable, UPNPSubscription *sub=nullptr)
Creates or destroys the global UPNPScanner instance.
Definition: upnpscanner.cpp:144
MediaServer::m_eventSubPath
QString m_eventSubPath
Definition: upnpscanner.cpp:113
VideoMetadataListManager::metadata_list
std::list< VideoMetadataPtr > metadata_list
Definition: videometadatalistmanager.h:14
MediaServerItem::m_scanned
bool m_scanned
Definition: upnpscanner.h:41
UPNPScanner::ScheduleRenewal
void ScheduleRenewal(const QString &usn, int timeout)
Creates a QTimer to trigger a subscription renewal for a given media server.
Definition: upnpscanner.cpp:969
SSDP::AddListener
static void AddListener(QObject *listener)
Definition: ssdp.h:121
UPNPScanner::FindItems
void FindItems(const QDomNode &n, MediaServerItem &content, bool &resetparent)
Definition: upnpscanner.cpp:1081
MediaServer::m_renewalTimerId
int m_renewalTimerId
Definition: upnpscanner.cpp:116
UPNPScanner::CheckFailure
void CheckFailure(const QUrl &url)
Updates the logs for failed server connections.
Definition: upnpscanner.cpp:769
upnpscanner.h
UPNPScanner::BrowseNextContainer
void BrowseNextContainer(void)
For each known media server, find the next container which needs to be browsed and trigger sending of...
Definition: upnpscanner.cpp:824
LOC
#define LOC
Definition: upnpscanner.cpp:15
UPNPScanner::ParseServiceList
static void ParseServiceList(QDomElement &element, QString &controlURL, QString &eventURL)
Definition: upnpscanner.cpp:1354
UPNPScanner::gUPNPScannerEnabled
static bool gUPNPScannerEnabled
Definition: upnpscanner.h:109
SSDP::RemoveListener
static void RemoveListener(QObject *listener)
Definition: ssdp.h:123
MediaServerItem::m_parentid
QString m_parentid
Definition: upnpscanner.h:38
simple_ref_ptr::get
T * get() const
Definition: quicksp.h:73
UPNPScanner::CheckStatus
void CheckStatus(void)
Removes media servers that can no longer be found in the SSDP cache.
Definition: upnpscanner.cpp:555
UPNPScanner::GetMetadata
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 medi...
Definition: upnpscanner.cpp:239
UPNPScanner::ParseService
static void ParseService(QDomElement &element, QString &controlURL, QString &eventURL)
Definition: upnpscanner.cpp:1368
UPNPScanner::Debug
void Debug(void)
Definition: upnpscanner.cpp:788