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