MythTV  master
satipstreamhandler.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 // C++ headers
4 #include <chrono>
5 #include <thread>
6 
7 // Qt headers
8 #include <QString>
9 #include <QMap>
10 #include <QMutex>
11 #include <QMutexLocker>
12 #include <QUdpSocket>
13 
14 // MythTV headers
16 
17 #include "cardutil.h"
18 #include "dtvsignalmonitor.h"
19 #include "rtp/rtptsdatapacket.h"
20 #include "satiputils.h"
21 #include "satipchannel.h"
22 #include "satipstreamhandler.h"
23 #include "satiprtcppacket.h"
24 
25 #define LOC QString("SatIPSH[%1]: ").arg(m_inputId)
26 
27 // For implementing Get & Return
28 QMap<QString, SatIPStreamHandler*> SatIPStreamHandler::s_handlers;
29 QMap<QString, uint> SatIPStreamHandler::s_handlersRefCnt;
31 
32 SatIPStreamHandler *SatIPStreamHandler::Get(const QString &devname, int inputid)
33 {
34  QMutexLocker locker(&s_handlersLock);
35 
36  QMap<QString, SatIPStreamHandler*>::iterator it = s_handlers.find(devname);
37 
38  if (it == s_handlers.end())
39  {
40  auto *newhandler = new SatIPStreamHandler(devname, inputid);
41  newhandler->Open();
42  s_handlers[devname] = newhandler;
43  s_handlersRefCnt[devname] = 1;
44 
45  LOG(VB_RECORD, LOG_INFO,
46  QString("SatIPSH[%1]: Creating new stream handler for %2")
47  .arg(inputid).arg(devname));
48  }
49  else
50  {
51  s_handlersRefCnt[devname]++;
52  uint rcount = s_handlersRefCnt[devname];
53  (*it)->m_inputId = inputid;
54 
55  LOG(VB_RECORD, LOG_INFO,
56  QString("SatIPSH[%1]: Using existing stream handler for %2").arg(inputid).arg(devname) +
57  QString(" (%1 users)").arg(rcount));
58  }
59 
60  return s_handlers[devname];
61 }
62 
64 {
65  QMutexLocker locker(&s_handlersLock);
66 
67  QString devname = ref->m_device;
68 
69  QMap<QString, uint>::iterator rit = s_handlersRefCnt.find(devname);
70  if (rit == s_handlersRefCnt.end())
71  {
72  LOG(VB_RECORD, LOG_ERR, QString("SatIPSH[%1]: Return(%2) not found")
73  .arg(inputid).arg(devname));
74  return;
75  }
76 
77  LOG(VB_RECORD, LOG_INFO, QString("SatIPSH[%1]: Return stream handler for %2 (%3 users)")
78  .arg(inputid).arg(devname).arg(*rit));
79 
80  if (*rit > 1)
81  {
82  ref = nullptr;
83  (*rit)--;
84  return;
85  }
86 
87  QMap<QString, SatIPStreamHandler*>::iterator it = s_handlers.find(devname);
88  if ((it != s_handlers.end()) && (*it == ref))
89  {
90  LOG(VB_RECORD, LOG_INFO, QString("SatIPSH[%1]: Closing handler for %2")
91  .arg(inputid).arg(devname));
92  (*it)->Stop();
93  (*it)->Close();
94  delete *it;
95  s_handlers.erase(it);
96  }
97  else
98  {
99  LOG(VB_GENERAL, LOG_ERR,
100  QString("SatIPSH[%1] Error: Couldn't find handler for %2")
101  .arg(inputid).arg(devname));
102  }
103 
104  s_handlersRefCnt.erase(rit);
105  ref = nullptr;
106 }
107 
108 SatIPStreamHandler::SatIPStreamHandler(const QString &device, int inputid)
109  : StreamHandler(device, inputid)
110  , m_inputId(inputid)
111  , m_device(device)
112 {
113  setObjectName("SatIPStreamHandler");
114 
115  LOG(VB_RECORD, LOG_DEBUG, LOC +
116  QString("ctor for %2").arg(device));
117 
118  // Find the port to use for receiving the RTP data.
119  // First try a fixed even port number outside the range of dynamically allocated ports.
120  // If this fails try to get a dynamically allocated port.
121  uint preferred_port = 26420 + 2*inputid;
122  m_dsocket = new QUdpSocket(nullptr);
123  if (m_dsocket->bind(QHostAddress::AnyIPv4,
124  preferred_port,
125  QAbstractSocket::DefaultForPlatform))
126  {
127  m_dport = m_dsocket->localPort();
128  }
129  else
130  {
131  if (m_dsocket->bind(QHostAddress::AnyIPv4,
132  0,
133  QAbstractSocket::DefaultForPlatform))
134  {
135  m_dport = m_dsocket->localPort();
136  }
137  }
138 
139  // Messages
140  if (m_dport == preferred_port)
141  {
142  LOG(VB_GENERAL, LOG_INFO, LOC +
143  QString("RTP socket bound to requested port %1").arg(m_dport));
144  }
145  else if (m_dport > 0)
146  {
147  LOG(VB_GENERAL, LOG_WARNING, LOC +
148  QString("Requested port %1 but RTP socket bound to port %2")
149  .arg(preferred_port).arg(m_dport));
150  }
151  else
152  {
153  LOG(VB_GENERAL, LOG_ERR, LOC +
154  QString("Failed to bind RTP socket"));
155  return;
156  }
157 
158  // ------------------------------------------------------------------------
159 
160  // Control socket is next higher port; if we cannot bind do this port
161  // then try to bind to a port from the dynamic range
162  preferred_port = m_dport + 1;
163  m_csocket = new QUdpSocket(nullptr);
164 
165  if (m_csocket->bind(QHostAddress::AnyIPv4,
166  preferred_port,
167  QAbstractSocket::DefaultForPlatform))
168  {
169  m_cport = m_csocket->localPort();
170  }
171  else
172  {
173  if (m_csocket->bind(QHostAddress::AnyIPv4,
174  0,
175  QAbstractSocket::DefaultForPlatform))
176  {
177  m_cport = m_csocket->localPort();
178  }
179  }
180 
181  // Messages
182  if (m_cport == preferred_port)
183  {
184  LOG(VB_GENERAL, LOG_INFO, LOC +
185  QString("RTCP socket bound to requested port %1").arg(m_cport));
186  }
187  else if (m_cport > 0)
188  {
189  LOG(VB_GENERAL, LOG_WARNING, LOC +
190  QString("Requested port %1 but RTCP socket bound to port %2")
191  .arg(preferred_port).arg(m_cport));
192  }
193  else
194  {
195  LOG(VB_GENERAL, LOG_ERR, LOC +
196  QString("Failed to bind RTCP socket"));
197  }
198 
199  // If the second port is not one more than the first port we are violating the SatIP standard.
200  // Possibly we should then redo the complete port binding.
201 
202  // Increase receive packet buffer size for the RTP data stream to prevent packet loss
203  // Set UDP socket buffer size big enough to avoid buffer overrun.
204  // Buffer size can be reduced if and when the readhelper is running on a separate thread.
205  const uint desiredsize = 8*1000*1000;
206  const uint newsize = SatIPStreamHandler::SetUDPReceiveBufferSize(m_dsocket, desiredsize);
207  if (newsize < desiredsize)
208  {
209  static bool msgdone = false;
210 
211  if (!msgdone)
212  {
213  LOG(VB_GENERAL, LOG_INFO, LOC + "RTP UDP socket receive buffer too small\n" +
214  QString("\tRTP UDP socket receive buffer size set to %1 but requested %2\n").arg(newsize).arg(desiredsize) +
215  QString("\tTo prevent UDP packet loss increase net.core.rmem_max e.g. with this command:\n") +
216  QString("\tsudo sysctl -w net.core.rmem_max=%1\n").arg(desiredsize) +
217  QString("\tand restart mythbackend."));
218  msgdone = true;
219  }
220  }
221  else
222  {
223  LOG(VB_RECORD, LOG_INFO, LOC + QString("RTP UDP socket receive buffer size is %1").arg(newsize));
224  }
225 
226  // Create the read helpers
229 
230  // Create the RTSP handler
231  m_rtsp = new SatIPRTSP(m_inputId);
232 }
233 
235 {
236 #ifdef DEBUG_PID_FILTERS
237  LOG(VB_RECORD, LOG_DEBUG, LOC + "UpdateFilters()");
238 #endif // DEBUG_PID_FILTERS
239  QMutexLocker locker(&m_pidLock);
240 
241  QStringList pids;
242 
243  if (m_pidInfo.contains(0x2000))
244  {
245  pids.append("all");
246  }
247  else
248  {
249  for (auto it = m_pidInfo.cbegin(); it != m_pidInfo.cend(); ++it)
250  pids.append(QString("%1").arg(it.key()));
251  }
252 #ifdef DEBUG_PID_FILTERS
253  QString msg = QString("PIDS: '%1'").arg(pids.join(","));
254  LOG(VB_RECORD, LOG_DEBUG, LOC + msg);
255 #endif // DEBUG_PID_FILTERS
256 
257  bool rval = true;
258  if (m_rtsp && m_oldpids != pids)
259  {
260  QString pids_str = QString("pids=%1").arg(!pids.empty() ? pids.join(",") : "none");
261  LOG(VB_RECORD, LOG_INFO, LOC + "Play(pids_str) " + pids_str);
262 
263  // Telestar Digibit R1 Sat>IP box cannot handle a lot of pids
264  if (pids.size() > 32)
265  {
266  LOG(VB_RECORD, LOG_INFO, LOC +
267  QString("Receive full TS, number of PIDs:%1 is more than 32").arg(pids.size()));
268  LOG(VB_RECORD, LOG_DEBUG, LOC + pids_str);
269  pids_str = QString("pids=all");
270  }
271 
272  rval = m_rtsp->Play(pids_str);
273  m_oldpids = pids;
274  }
275 
276  return rval;
277 }
278 
280 {
281  RunProlog();
282 
283  SetRunning(true, false, false);
284 
285  LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): begin");
286 
287  QElapsedTimer last_update;
288 
289  while (m_runningDesired && !m_bError)
290  {
291  {
292  QMutexLocker locker(&m_tunelock);
293 
295  {
296  if (m_setupinvoked)
297  {
298  m_rtsp->Teardown();
299  m_setupinvoked = false;
300  }
301 
303  {
305  m_setupinvoked = true;
306  }
307 
308  last_update.restart();
309  }
310  }
311 
312  // Update the PID filters every 100 milliseconds
313  auto elapsed = !last_update.isValid()
314  ? -1ms : std::chrono::milliseconds(last_update.elapsed());
315  elapsed = (elapsed < 0ms) ? 1s : elapsed;
316  if (elapsed > 100ms)
317  {
319  UpdateFilters();
320  last_update.restart();
321  }
322 
323  // Delay to avoid busy wait loop
324  std::this_thread::sleep_for(20ms);
325 
326  }
327  LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "shutdown");
328 
330 
331  // TEARDOWN command
332  if (m_setupinvoked)
333  {
334  QMutexLocker locker(&m_tunelock);
335  m_rtsp->Teardown();
336  m_setupinvoked = false;
337  m_oldtuningurl = "";
338  }
339 
340  LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): end");
341  SetRunning(false, false, false);
342  RunEpilog();
343 }
344 
346 {
347  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Tune %1").arg(tuning.m_frequency));
348 
349  QMutexLocker locker(&m_tunelock);
350 
351  // Build the query string
352  QStringList qry;
353 
355  {
356  qry.append(QString("fe=%1").arg(m_frontend+1));
357  qry.append(QString("freq=%1").arg(SatIP::freq(tuning.m_frequency)));
358  qry.append(QString("sr=%1").arg(tuning.m_symbolRate / 1000)); // symbolrate in ksymb/s
359  qry.append("msys=dvbc");
360  qry.append(QString("mtype=%1").arg(SatIP::mtype(tuning.m_modulation)));
361  }
363  {
364  qry.append(QString("fe=%1").arg(m_frontend+1));
365  qry.append(QString("freq=%1").arg(SatIP::freq(tuning.m_frequency)));
366  qry.append(QString("bw=%1").arg(SatIP::bw(tuning.m_bandwidth)));
367  qry.append(QString("msys=%1").arg(SatIP::msys(tuning.m_modSys)));
368  qry.append(QString("tmode=%1").arg(SatIP::tmode(tuning.m_transMode)));
369  qry.append(QString("mtype=%1").arg(SatIP::mtype(tuning.m_modulation)));
370  qry.append(QString("gi=%1").arg(SatIP::gi(tuning.m_guardInterval)));
371  qry.append(QString("fec=%1").arg(SatIP::fec(tuning.m_fec)));
372  }
374  {
375  qry.append(QString("fe=%1").arg(m_frontend+1));
376  qry.append(QString("src=%1").arg(m_satipsrc));
377  qry.append(QString("freq=%1").arg(SatIP::freq(tuning.m_frequency*1000))); // frequency in Hz
378  qry.append(QString("pol=%1").arg(SatIP::pol(tuning.m_polarity)));
379  qry.append(QString("ro=%1").arg(SatIP::ro(tuning.m_rolloff)));
380  qry.append(QString("msys=%1").arg(SatIP::msys(tuning.m_modSys)));
381  qry.append(QString("mtype=%1").arg(SatIP::mtype(tuning.m_modulation)));
382  qry.append(QString("sr=%1").arg(tuning.m_symbolRate / 1000)); // symbolrate in ksymb/s
383  qry.append(QString("fec=%1").arg(SatIP::fec(tuning.m_fec)));
384  qry.append(QString("plts=auto")); // pilot tones
385  }
386  else
387  {
388  LOG(VB_RECORD, LOG_ERR, LOC + QString("Unhandled m_tunerType %1 %2").arg(m_tunerType).arg(m_tunerType.toString()));
389  return false;
390  }
391 
392  QUrl url = QUrl(m_baseurl);
393  url.setQuery(qry.join("&"));
394 
395  m_tuningurl = url;
396 
397  LOG(VB_RECORD, LOG_INFO, LOC + QString("Tune url:%1").arg(url.toString()));
398 
400  {
401  LOG(VB_RECORD, LOG_INFO, LOC + QString("Skip tuning, already tuned to this url"));
402  return true;
403  }
404 
405  // Need SETUP and PLAY (with pids=none) to get RTSP packets with tuner lock info
406  if (m_rtsp)
407  {
408  bool rval = true;
409 
410  // TEARDOWN command
411  if (m_setupinvoked)
412  {
413  rval = m_rtsp->Teardown();
414  m_setupinvoked = false;
415  }
416 
417  // SETUP command
418  if (rval)
419  {
421  }
422  if (rval)
423  {
425  m_setupinvoked = true;
426  }
427 
428  // PLAY command
429  if (rval)
430  {
431  m_rtsp->Play("pids=none");
432  m_oldpids = QStringList();
433  }
434  return rval;
435  }
436  return true;
437 }
438 
440 {
441  QUrl url;
442  url.setScheme("rtsp");
443  url.setPort(554);
444  url.setPath("/");
445 
446  // Discover the device using SSDP
447  QStringList devinfo = m_device.split(":");
448  if (devinfo.value(0).toUpper() == "UUID")
449  {
450  QString deviceId = QString("uuid:%1").arg(devinfo.value(1));
451  m_frontend = devinfo.value(3).toUInt();
452 
453  QString ip = SatIP::findDeviceIP(deviceId);
454  if (ip != nullptr)
455  {
456  LOG(VB_RECORD, LOG_INFO, LOC + QString("Discovered device %1 at %2").arg(deviceId, ip));
457  }
458  else
459  {
460  LOG(VB_RECORD, LOG_ERR, LOC + QString("Failed to discover device %1, no IP found").arg(deviceId));
461  return false;
462  }
463 
464  url.setHost(ip);
465  }
466  else
467  {
468  // TODO: Handling of manual IP devices
469  }
470 
472  m_baseurl = url;
473 
474  return true;
475 }
476 
478 {
479  delete m_rtsp;
480  m_rtsp = nullptr;
481  m_baseurl = nullptr;
482 }
483 
485 {
486  QMutexLocker locker(&m_sigmonLock);
487  return m_hasLock;
488 }
489 
491 {
492  QMutexLocker locker(&m_sigmonLock);
493  return m_signalStrength;
494 }
495 
496 void SatIPStreamHandler::SetSigmonValues(bool lock, int level)
497 {
498  QMutexLocker locker(&m_sigmonLock);
499  m_hasLock = lock;
500  m_signalStrength = level;
501 }
502 
503 // === RTP DataReadHelper ===================================================
504 //
505 // Read RTP stream data from the UDP socket and store it in the packet buffer
506 // and write the packets immediately to the listeners.
507 //
508 // TODO
509 // This has to be created in a separate thread to achieve minimum
510 // minimum latency and so to avoid overflow of the UDP input buffers.
511 // N.B. Then also with the socket that is now in the streamhandler.
512 // ---------------------------------------------------------------------------
513 
514 #define LOC_DRH QString("SH_DRH[%1]: ").arg(m_streamHandler->m_inputId)
515 
517  : m_streamHandler(handler)
518  , m_socket(handler->m_dsocket)
519 {
520  LOG(VB_RECORD, LOG_INFO, LOC_DRH +
521  QString("Starting data read helper for RTP UDP socket"));
522 
523  // Call ReadPending when there are RTP data packets received on m_socket
524  connect(m_socket, &QIODevice::readyRead,
526 
527  // Number of RTP packets to discard at start.
528  // This is to flush the RTP packets that might still be in transit
529  // from the previously tuned channel.
530  m_count = 3;
531  m_valid = false;
532 
533  LOG(VB_RECORD, LOG_DEBUG, LOC_DRH + QString("Init flush count to %1").arg(m_count));
534 }
535 
537 {
538  LOG(VB_RECORD, LOG_INFO, LOC_DRH + QString("%1").arg(__func__));
539 }
540 
542 {
543 #if 0
544  LOG(VB_RECORD, LOG_INFO, LOC_RH + QString("%1").arg(__func__));
545 #endif
546 
547  RTPDataPacket pkt;
548 
549  while (m_socket->hasPendingDatagrams())
550  {
551 #if 0
552  LOG(VB_RECORD, LOG_INFO, LOC_DRH + QString("%1 hasPendingDatagrams").arg(__func__));
553 #endif
554  QHostAddress sender;
555  quint16 senderPort = 0;
556 
557  QByteArray &data = pkt.GetDataReference();
558  data.resize(m_socket->pendingDatagramSize());
559  m_socket->readDatagram(data.data(), data.size(), &sender, &senderPort);
560 
562  {
563  RTPTSDataPacket ts_packet(pkt);
564 
565  if (!ts_packet.IsValid())
566  {
567  continue;
568  }
569 
570  // Check the packet sequence number
571  uint expectedSequenceNumber = (m_sequenceNumber + 1) & 0xFFFF;
572  m_sequenceNumber = ts_packet.GetSequenceNumber();
573  if ((expectedSequenceNumber != m_sequenceNumber) && m_valid)
574  {
575  LOG(VB_RECORD, LOG_ERR, LOC_DRH +
576  QString("Sequence number error -- Expected:%1 Received:%2")
577  .arg(expectedSequenceNumber).arg(m_sequenceNumber));
578  }
579 
580  // Flush the first few packets after start
581  if (m_count > 0)
582  {
583  LOG(VB_RECORD, LOG_INFO, LOC_DRH + QString("Flushing RTP packet, %1 to do").arg(m_count));
584  m_count--;
585  }
586  else
587  {
588  m_valid = true;
589  }
590 
591  // Send the packet data to all listeners
592  if (m_valid)
593  {
594  int remainder = 0;
595  {
596  QMutexLocker locker(&m_streamHandler->m_listenerLock);
597  auto streamDataList = m_streamHandler->m_streamDataList;
598  if (!streamDataList.isEmpty())
599  {
600  const unsigned char *data_buffer = ts_packet.GetTSData();
601  size_t data_length = ts_packet.GetTSDataSize();
602 
603  for (auto sit = streamDataList.cbegin(); sit != streamDataList.cend(); ++sit)
604  {
605  remainder = sit.key()->ProcessData(data_buffer, data_length);
606  }
607 
608  m_streamHandler->WriteMPTS(data_buffer, data_length - remainder);
609  }
610  }
611 
612  if (remainder != 0)
613  {
614  LOG(VB_RECORD, LOG_INFO, LOC_DRH +
615  QString("RTP data_length = %1 remainder = %2")
616  .arg(ts_packet.GetTSDataSize()).arg(remainder));
617  }
618  }
619  }
620  }
621 }
622 
623 
624 // === RTSP RTCP ControlReadHelper ===========================================
625 //
626 // Read RTCP packets with control messages from the UDP socket.
627 // Determine tuner state: lock and signal strength
628 // ---------------------------------------------------------------------------
629 
630 #define LOC_CRH QString("SatIP_CRH[%1]: ").arg(m_streamHandler->m_inputId)
631 
633  : m_streamHandler(handler)
634  , m_socket(handler->m_csocket)
635 {
636  LOG(VB_RECORD, LOG_INFO, LOC_CRH +
637  QString("Starting read helper for RTCP UDP socket"));
638 
639  // Call ReadPending when there is a message received on m_socket
640  connect(m_socket, &QUdpSocket::readyRead,
642 }
643 
644 // Process a RTCP packet received on m_socket
646 {
647  while (m_socket->hasPendingDatagrams())
648  {
649 #if 0
650  LOG(VB_RECORD, LOG_INFO, LOC_CRH +
651  QString("Processing RTCP packet(pendingDatagramSize:%1)")
652  .arg(m_socket->pendingDatagramSize()));
653 #endif
654  QHostAddress sender;
655  quint16 senderPort = 0;
656 
657  QByteArray buf = QByteArray(m_socket->pendingDatagramSize(), Qt::Uninitialized);
658  m_socket->readDatagram(buf.data(), buf.size(), &sender, &senderPort);
659 
660  SatIPRTCPPacket pkt = SatIPRTCPPacket(buf);
661  if (!pkt.IsValid())
662  {
663  LOG(VB_GENERAL, LOG_ERR, LOC_CRH + "Invalid RTCP packet received");
664  continue;
665  }
666 
667  QStringList data = pkt.Data().split(";");
668  bool found = false;
669  int i = 0;
670 
671 #if 0
672  LOG(VB_RECORD, LOG_DEBUG, LOC_CRH + QString(">2 %1 ").arg(__func__) + data.join('^'));
673 #endif
674  while (!found && i < data.length())
675  {
676  const QString& item = data.at(i);
677 
678  if (item.startsWith("tuner="))
679  {
680  found = true;
681  QStringList tuner = item.split(",");
682 
683  if (tuner.length() > 3)
684  {
685  int level = tuner.at(1).toInt(); // [0, 255]
686  bool lock = tuner.at(2).toInt() != 0; // [0 , 1]
687  int quality = tuner.at(3).toInt(); // [0, 15]
688 
689  LOG(VB_RECORD, LOG_DEBUG, LOC_CRH +
690  QString("Tuner lock:%1 level:%2 quality:%3").arg(lock).arg(level).arg(quality));
691 
692  m_streamHandler->SetSigmonValues(lock, level);
693  }
694  }
695  i++;
696  }
697  }
698 }
699 
700 // ===========================================================================
701 
711 {
712  QVariant ss = socket->socketOption(QAbstractSocket::ReceiveBufferSizeSocketOption);
713  return ss.toUInt()/2;
714 }
715 
725 uint SatIPStreamHandler::SetUDPReceiveBufferSize(QUdpSocket *socket, uint rcvbuffersize)
726 {
728  if (rcvbuffersize > oldsize)
729  {
730  socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, rcvbuffersize);
731  }
733 }
DTVMultiplex::m_frequency
uint64_t m_frequency
Definition: dtvmultiplex.h:94
DTVMultiplex
Definition: dtvmultiplex.h:24
SatIPRTSP::Play
bool Play(const QString &pids_str)
Definition: satiprtsp.cpp:258
SatIPControlReadHelper::m_streamHandler
SatIPStreamHandler * m_streamHandler
Definition: satipstreamhandler.h:139
DTVTunerType::kTunerTypeDVBC
static const int kTunerTypeDVBC
Definition: dtvconfparserhelpers.h:95
DTVMultiplex::m_rolloff
DTVRollOff m_rolloff
Definition: dtvmultiplex.h:107
StreamHandler::RemoveAllPIDFilters
bool RemoveAllPIDFilters(void)
Definition: streamhandler.cpp:240
RTPTSDataPacket
RTP Transport Stream Data Packet.
Definition: rtptsdatapacket.h:16
StreamHandler::SetRunning
void SetRunning(bool running, bool using_buffering, bool using_section_reader)
Definition: streamhandler.cpp:173
StreamHandler::WriteMPTS
void WriteMPTS(const unsigned char *buffer, uint len)
Write out a copy of the raw MPTS.
Definition: streamhandler.cpp:355
SatIP::ro
static QString ro(DTVRollOff ro)
Definition: satiputils.cpp:439
SatIPStreamHandler::m_dport
ushort m_dport
Definition: satipstreamhandler.h:80
StreamHandler
Definition: streamhandler.h:58
SatIPStreamHandler::m_sigmonLock
QMutex m_sigmonLock
Definition: satipstreamhandler.h:94
RTPTSDataPacket::GetTSDataSize
unsigned int GetTSDataSize(void) const
Definition: rtptsdatapacket.h:29
SatIPStreamHandler::m_tuningurl
QUrl m_tuningurl
Definition: satipstreamhandler.h:67
SatIPDataReadHelper::ReadPending
void ReadPending(void)
Definition: satipstreamhandler.cpp:541
DTVTunerType::kTunerTypeDVBS1
static const int kTunerTypeDVBS1
Definition: dtvconfparserhelpers.h:93
SatIPStreamHandler::m_signalStrength
int m_signalStrength
Definition: satipstreamhandler.h:96
SatIP::bw
static QString bw(DTVBandwidth bw)
Definition: satiputils.cpp:235
SatIPStreamHandler::m_dsocket
QUdpSocket * m_dsocket
Definition: satipstreamhandler.h:78
MThread::setObjectName
void setObjectName(const QString &name)
Definition: mthread.cpp:238
SatIPStreamHandler::m_rtsp
SatIPRTSP * m_rtsp
Definition: satipstreamhandler.h:84
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MThread::RunProlog
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Definition: mthread.cpp:196
SatIP::tmode
static QString tmode(DTVTransmitMode tmode)
Definition: satiputils.cpp:332
DTVMultiplex::m_bandwidth
DTVBandwidth m_bandwidth
Definition: dtvmultiplex.h:97
SatIPStreamHandler::m_oldtuningurl
QUrl m_oldtuningurl
Definition: satipstreamhandler.h:68
RTPDataPacket::kPayLoadTypeTS
@ kPayLoadTypeTS
Definition: rtpdatapacket.h:88
satipchannel.h
SatIPStreamHandler::s_handlersRefCnt
static QMap< QString, uint > s_handlersRefCnt
Definition: satipstreamhandler.h:55
SatIP::findDeviceIP
static QString findDeviceIP(const QString &deviceuuid)
Definition: satiputils.cpp:152
SatIPStreamHandler::HasLock
bool HasLock()
Definition: satipstreamhandler.cpp:484
satiputils.h
SatIPStreamHandler::SetUDPReceiveBufferSize
static uint SetUDPReceiveBufferSize(QUdpSocket *socket, uint rcvbuffersize)
Set receive buffer size of UDP socket.
Definition: satipstreamhandler.cpp:725
StreamHandler::m_listenerLock
QRecursiveMutex m_listenerLock
Definition: streamhandler.h:153
SatIPControlReadHelper
Definition: satipstreamhandler.h:127
StreamHandler::m_pidInfo
PIDInfoMap m_pidInfo
Definition: streamhandler.h:139
SatIPDataReadHelper::m_sequenceNumber
uint m_sequenceNumber
Definition: satipstreamhandler.h:120
mythlogging.h
StreamHandler::m_pidLock
QRecursiveMutex m_pidLock
Definition: streamhandler.h:136
SatIPStreamHandler::SetSigmonValues
void SetSigmonValues(bool lock, int level)
Definition: satipstreamhandler.cpp:496
SatIPStreamHandler::Return
static void Return(SatIPStreamHandler *&ref, int inputid)
Definition: satipstreamhandler.cpp:63
DTVMultiplex::m_guardInterval
DTVGuardInterval m_guardInterval
Definition: dtvmultiplex.h:102
SatIPControlReadHelper::ReadPending
void ReadPending(void)
Definition: satipstreamhandler.cpp:645
SatIPStreamHandler::Open
bool Open(void)
Definition: satipstreamhandler.cpp:439
SatIP::toTunerType
static int toTunerType(const QString &deviceid)
Definition: satiputils.cpp:201
StreamHandler::UpdateFiltersFromStreamData
bool UpdateFiltersFromStreamData(void)
Definition: streamhandler.cpp:290
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
SatIPStreamHandler::m_tunerType
DTVTunerType m_tunerType
Definition: satipstreamhandler.h:63
SatIPStreamHandler::GetSignalStrength
int GetSignalStrength()
Definition: satipstreamhandler.cpp:490
MThread::RunEpilog
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
Definition: mthread.cpp:209
SatIPStreamHandler::SatIPDataReadHelper
friend class SatIPDataReadHelper
Definition: satipstreamhandler.h:28
SatIPControlReadHelper::SatIPControlReadHelper
SatIPControlReadHelper(SatIPStreamHandler *handler)
Definition: satipstreamhandler.cpp:632
SatIP::freq
static QString freq(uint64_t freq)
Definition: satiputils.cpp:268
DTVMultiplex::m_modSys
DTVModulationSystem m_modSys
Definition: dtvmultiplex.h:106
SatIP::gi
static QString gi(DTVGuardInterval gi)
Definition: satiputils.cpp:361
DTVMultiplex::m_fec
DTVCodeRate m_fec
Definition: dtvmultiplex.h:105
RTPTSDataPacket::GetTSData
const unsigned char * GetTSData(void) const
Definition: rtptsdatapacket.h:24
SatIPStreamHandler::SatIPStreamHandler
SatIPStreamHandler(const QString &device, int inputid)
Definition: satipstreamhandler.cpp:108
SatIPStreamHandler::m_hasLock
bool m_hasLock
Definition: satipstreamhandler.h:95
LOC_CRH
#define LOC_CRH
Definition: satipstreamhandler.cpp:630
SatIPRTSP::Teardown
bool Teardown()
Definition: satiprtsp.cpp:276
uint
unsigned int uint
Definition: compat.h:79
SatIP::pol
static QString pol(DTVPolarity pol)
Definition: satiputils.cpp:460
LOC
#define LOC
Definition: satipstreamhandler.cpp:25
SatIPStreamHandler::Close
void Close(void)
Definition: satipstreamhandler.cpp:477
RTPDataPacket::GetSequenceNumber
uint GetSequenceNumber(void) const
Definition: rtpdatapacket.h:97
DTVTunerType::kTunerTypeDVBS2
static const int kTunerTypeDVBS2
Definition: dtvconfparserhelpers.h:94
DTVMultiplex::m_symbolRate
uint64_t m_symbolRate
Definition: dtvmultiplex.h:95
SatIPStreamHandler::m_satipsrc
int m_satipsrc
Definition: satipstreamhandler.h:60
SatIPControlReadHelper::m_socket
QUdpSocket * m_socket
Definition: satipstreamhandler.h:140
SatIPStreamHandler::m_baseurl
QUrl m_baseurl
Definition: satipstreamhandler.h:66
SatIPDataReadHelper::m_count
uint m_count
Definition: satipstreamhandler.h:121
SatIPRTCPPacket::IsValid
bool IsValid() const
Definition: satiprtcppacket.h:19
SatIPDataReadHelper::SatIPDataReadHelper
SatIPDataReadHelper(SatIPStreamHandler *handler)
Definition: satipstreamhandler.cpp:516
LOC_DRH
#define LOC_DRH
Definition: satipstreamhandler.cpp:514
SatIPRTCPPacket
Definition: satiprtcppacket.h:14
SatIPDataReadHelper::m_socket
QUdpSocket * m_socket
Definition: satipstreamhandler.h:118
SatIPStreamHandler::UpdateFilters
bool UpdateFilters() override
Definition: satipstreamhandler.cpp:234
cardutil.h
SatIPStreamHandler::m_cport
ushort m_cport
Definition: satipstreamhandler.h:81
StreamHandler::m_runningDesired
volatile bool m_runningDesired
Definition: streamhandler.h:121
SatIPStreamHandler::s_handlersLock
static QMutex s_handlersLock
Definition: satipstreamhandler.h:56
SatIPDataReadHelper::~SatIPDataReadHelper
~SatIPDataReadHelper() override
Definition: satipstreamhandler.cpp:536
SatIPStreamHandler::run
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: satipstreamhandler.cpp:279
StreamHandler::m_streamDataList
StreamDataList m_streamDataList
Definition: streamhandler.h:155
RTPDataPacket::GetPayloadType
uint GetPayloadType(void) const
Definition: rtpdatapacket.h:92
SatIPRTSP
-*- Mode: c++ -*-
Definition: satiprtsp.h:25
SatIPStreamHandler::m_dataReadHelper
SatIPDataReadHelper * m_dataReadHelper
Definition: satipstreamhandler.h:85
rtptsdatapacket.h
satipstreamhandler.h
SatIPStreamHandler::Get
static SatIPStreamHandler * Get(const QString &devname, int inputid)
Definition: satipstreamhandler.cpp:32
SatIPStreamHandler::m_setupinvoked
bool m_setupinvoked
Definition: satipstreamhandler.h:69
SatIP::fec
static QString fec(DTVCodeRate fec)
Definition: satiputils.cpp:394
StreamHandler::m_bError
volatile bool m_bError
Definition: streamhandler.h:126
DTVMultiplex::m_modulation
DTVModulation m_modulation
Definition: dtvmultiplex.h:100
RTPDataPacket
RTP Data Packet.
Definition: rtpdatapacket.h:32
SatIPStreamHandler::GetUDPReceiveBufferSize
static uint GetUDPReceiveBufferSize(QUdpSocket *socket)
Get receive buffer size of UDP socket.
Definition: satipstreamhandler.cpp:710
DTVMultiplex::m_polarity
DTVPolarity m_polarity
Definition: dtvmultiplex.h:104
SatIPStreamHandler::m_tunelock
QRecursiveMutex m_tunelock
Definition: satipstreamhandler.h:73
SatIPDataReadHelper::m_valid
bool m_valid
Definition: satipstreamhandler.h:122
SatIPRTSP::Setup
bool Setup(const QUrl &url, ushort clientPort1, ushort clientPort2)
Definition: satiprtsp.cpp:184
DTVTunerType::kTunerTypeDVBT
static const int kTunerTypeDVBT
Definition: dtvconfparserhelpers.h:96
UDPPacket::GetDataReference
QByteArray & GetDataReference(void)
Definition: udppacket.h:36
SatIP::msys
static QString msys(DTVModulationSystem msys)
Definition: satiputils.cpp:273
satiprtcppacket.h
SatIPStreamHandler::m_csocket
QUdpSocket * m_csocket
Definition: satipstreamhandler.h:79
SatIPRTCPPacket::Data
QString Data() const
Definition: satiprtcppacket.h:20
DTVTunerType::kTunerTypeDVBT2
static const int kTunerTypeDVBT2
Definition: dtvconfparserhelpers.h:97
SatIPStreamHandler::Tune
bool Tune(const DTVMultiplex &tuning)
Definition: satipstreamhandler.cpp:345
SatIPStreamHandler::s_handlers
static QMap< QString, SatIPStreamHandler * > s_handlers
Definition: satipstreamhandler.h:54
SatIP::mtype
static QString mtype(DTVModulation mtype)
Definition: satiputils.cpp:299
dtvsignalmonitor.h
SatIPStreamHandler::m_device
QString m_device
Definition: satipstreamhandler.h:64
DTVMultiplex::m_transMode
DTVTransmitMode m_transMode
Definition: dtvmultiplex.h:101
SatIPStreamHandler::m_inputId
int m_inputId
Definition: satipstreamhandler.h:59
SatIPStreamHandler
Definition: satipstreamhandler.h:26
RTPDataPacket::IsValid
bool IsValid(void) const override
IsValid() must return true before any data access methods are called, other than GetDataReference() a...
Definition: rtpdatapacket.h:42
SatIPDataReadHelper::m_streamHandler
SatIPStreamHandler * m_streamHandler
Definition: satipstreamhandler.h:117
SatIPStreamHandler::m_oldpids
QStringList m_oldpids
Definition: satipstreamhandler.h:75
SatIPStreamHandler::m_frontend
uint m_frontend
Definition: satipstreamhandler.h:65
SatIPStreamHandler::m_controlReadHelper
SatIPControlReadHelper * m_controlReadHelper
Definition: satipstreamhandler.h:86