MythTV  master
channelscan_sm.cpp
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  *
4  * Original Project
5  * MythTV http://www.mythtv.org
6  *
7  * Copyright (c) 2004, 2005 John Pullan <john@pullan.org>
8  * Copyright (c) 2005 - 2007 Daniel Kristjansson
9  *
10  * Description:
11  * Collection of classes to provide channel scanning functionallity
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
27  *
28  */
29 
30 // C includes
31 #include <unistd.h>
32 
33 // C++ includes
34 #include <algorithm>
35 #include <utility>
36 
37 // Qt includes
38 #include <QMutexLocker>
39 #include <QObject>
40 
41 // MythTV includes - General
42 #include "channelscan_sm.h"
43 #include "frequencies.h"
44 #include "scanwizardconfig.h"
45 #include "mythdbcon.h"
46 #include "channelutil.h"
47 #include "cardutil.h"
48 #include "sourceutil.h"
49 #include "mthread.h"
50 #include "mythdb.h"
51 #include "mythlogging.h"
52 
53 // MythTV includes - DTV
54 #include "dtvsignalmonitor.h"
55 #include "scanstreamdata.h"
56 
57 // MythTV includes - ATSC
58 #include "atsctables.h"
59 
60 // MythTV includes - DVB
61 #include "dvbsignalmonitor.h"
62 #include "dvbtables.h"
63 
64 #include "dvbchannel.h"
65 #include "hdhrchannel.h"
66 #include "v4lchannel.h"
67 
71 const std::chrono::milliseconds ChannelScanSM::kDVBTableTimeout = 30s;
73 const std::chrono::milliseconds ChannelScanSM::kATSCTableTimeout = 10s;
75 const std::chrono::milliseconds ChannelScanSM::kMPEGTableTimeout = 15s;
76 
77 // Freesat and Sky
78 static const uint kRegionUndefined = 0xFFFF; // Not regional
79 
80 QString ChannelScanSM::loc(const ChannelScanSM *siscan)
81 {
82  if (siscan && siscan->m_channel)
83  return QString("ChannelScanSM[%1]").arg(siscan->m_channel->GetInputID());
84  return "ChannelScanSM(u)";
85 }
86 
87 #define LOC (ChannelScanSM::loc(this) + ": ")
88 
89 #define kDecryptionTimeout 4250
90 
91 static const QString kATSCChannelFormat = "%1_%2";
92 
94 {
95  public:
96  ScannedChannelInfo() = default;
97 
98  bool IsEmpty() const
99  {
100  return m_pats.empty() && m_pmts.empty() &&
101  m_programEncryptionStatus.isEmpty() &&
102  !m_mgt && m_cvcts.empty() &&
103  m_tvcts.empty() && m_nits.empty() &&
104  m_sdts.empty() && m_bats.empty();
105  }
106 
107  // MPEG
110  QMap<uint,uint> m_programEncryptionStatus; // pnum->enc_status
111 
112  // ATSC
113  const MasterGuideTable *m_mgt {nullptr};
116 
117  // DVB
121 };
122 
147  const QString &cardtype, ChannelBase *channel,
148  int sourceID, std::chrono::milliseconds signal_timeout,
149  std::chrono::milliseconds channel_timeout, QString inputname,
150  bool test_decryption)
151  : // Set in constructor
152  m_scanMonitor(scan_monitor),
153  m_channel(channel),
154  m_signalMonitor(SignalMonitor::Init(cardtype, m_channel->GetInputID(),
155  channel, true)),
156  m_sourceID(sourceID),
157  m_signalTimeout(signal_timeout),
158  m_channelTimeout(channel_timeout),
159  m_inputName(std::move(inputname)),
160  m_testDecryption(test_decryption),
161  // Misc
162  m_analogSignalHandler(new AnalogSignalHandler(this))
163 {
164  m_current = m_scanTransports.end();
165 
166  // Create a stream data for digital signal monitors
167  DTVSignalMonitor* dtvSigMon = GetDTVSignalMonitor();
168  if (dtvSigMon)
169  {
170  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Connecting up DTVSignalMonitor");
171  auto *data = new ScanStreamData();
172 
173  MSqlQuery query(MSqlQuery::InitCon());
174  query.prepare(
175  "SELECT dvb_nit_id, bouquet_id, region_id, lcnoffset "
176  "FROM videosource "
177  "WHERE videosource.sourceid = :SOURCEID");
178  query.bindValue(":SOURCEID", m_sourceID);
179  if (!query.exec() || !query.isActive())
180  {
181  MythDB::DBError("ChannelScanSM", query);
182  }
183  else if (query.next())
184  {
185  int nitid = query.value(0).toInt();
186  data->SetRealNetworkID(nitid);
187  LOG(VB_CHANSCAN, LOG_INFO, LOC +
188  QString("Setting NIT-ID to %1").arg(nitid));
189 
190  m_bouquetId = query.value(1).toUInt();
191  m_regionId = query.value(2).toUInt();
192  m_lcnOffset = query.value(3).toUInt();
193  m_nitId = nitid > 0 ? nitid : 0;
194  }
195 
196  LOG(VB_CHANSCAN, LOG_INFO, LOC +
197  QString("Freesat/Sky bouquet_id:%1 region_id:%2")
198  .arg(m_bouquetId).arg(m_regionId));
199 
200  dtvSigMon->SetStreamData(data);
205 
206 #ifdef USING_DVB
207  auto *dvbchannel = dynamic_cast<DVBChannel*>(m_channel);
208  if (dvbchannel && dvbchannel->GetRotor())
210 #endif
211 
212  data->AddMPEGListener(this);
213  data->AddATSCMainListener(this);
214  data->AddDVBMainListener(this);
215  data->AddDVBOtherListener(this);
216  }
217 }
218 
220 {
221  StopScanner();
222  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ChannelScanSM Stopped");
223 
224  ScanStreamData *sd = nullptr;
225  if (GetDTVSignalMonitor())
226  {
228  }
229 
230  if (m_signalMonitor)
231  {
233  delete m_signalMonitor;
234  m_signalMonitor = nullptr;
235  }
236 
237  delete sd;
238 
240  {
241  delete m_analogSignalHandler;
242  m_analogSignalHandler = nullptr;
243  }
244 
246 }
247 
248 void ChannelScanSM::SetAnalog(bool is_analog)
249 {
251 
252  if (is_analog)
254 }
255 
257 {
258  QMutexLocker locker(&m_lock);
259 
260  QString cur_chan = (*m_current).m_friendlyName;
261 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
262  QStringList list = cur_chan.split(" ", QString::SkipEmptyParts);
263 #else
264  QStringList list = cur_chan.split(" ", Qt::SkipEmptyParts);
265 #endif
266  QString freqid = (list.size() >= 2) ? list[1] : cur_chan;
267 
268  QString msg = QObject::tr("Updated Channel %1").arg(cur_chan);
269 
270  if (!ChannelUtil::FindChannel(m_sourceID, freqid))
271  {
272  int chanid = ChannelUtil::CreateChanID(m_sourceID, freqid);
273 
274  QString callsign = QString("%1-%2")
275  .arg(ChannelUtil::GetUnknownCallsign()).arg(chanid);
276 
277  bool ok = ChannelUtil::CreateChannel(
278  0 /* mplexid */,
279  m_sourceID,
280  chanid,
281  callsign,
282  "" /* service name */,
283  freqid /* channum */,
284  0 /* service id */,
285  0 /* ATSC major channel */,
286  0 /* ATSC minor channel */,
287  false /* use on air guide */,
288  kChannelVisible /* visible */,
289  freqid);
290 
291  msg = (ok) ?
292  QObject::tr("Added Channel %1").arg(cur_chan) :
293  QObject::tr("Failed to add channel %1").arg(cur_chan);
294  }
295  else
296  {
297  // nothing to do here, XMLTV has better info
298  }
299 
301 
302  // tell UI we are done with these channels
303  if (m_scanning)
304  {
306  m_waitingForTables = false;
308  m_dvbt2Tried = true;
309  }
310 }
311 
323 bool ChannelScanSM::ScanExistingTransports(uint sourceid, bool follow_nit)
324 {
325  if (m_scanning)
326  return false;
327 
328  m_scanTransports.clear();
329  m_nextIt = m_scanTransports.end();
330 
331  std::vector<uint> multiplexes = SourceUtil::GetMplexIDs(sourceid);
332 
333  if (multiplexes.empty())
334  {
335  LOG(VB_CHANSCAN, LOG_ERR, LOC + "Unable to find any transports for " +
336  QString("sourceid %1").arg(sourceid));
337 
338  return false;
339  }
340 
341  LOG(VB_CHANSCAN, LOG_INFO, LOC +
342  QString("Found %1 transports for ").arg(multiplexes.size()) +
343  QString("sourceid %1").arg(sourceid));
344 
345  for (uint multiplex : multiplexes)
346  AddToList(multiplex);
347 
348  m_extendScanList = follow_nit;
349  m_waitingForTables = false;
351  if (!m_scanTransports.empty())
352  {
353  m_nextIt = m_scanTransports.begin();
354  m_scanning = true;
355  }
356  else
357  {
358  LOG(VB_CHANSCAN, LOG_ERR, LOC +
359  "Unable to find add any transports for " +
360  QString("sourceid %1").arg(sourceid));
361 
362  return false;
363  }
364 
365  return m_scanning;
366 }
367 
368 void ChannelScanSM::LogLines(const QString& string)
369 {
370  if (VERBOSE_LEVEL_CHECK(VB_CHANSCAN, LOG_DEBUG))
371  {
372  QStringList lines = string.split('\n');
373  for (const QString& line : qAsConst(lines))
374  LOG(VB_CHANSCAN, LOG_DEBUG, line);
375  }
376 }
377 
379 {
380  QMutexLocker locker(&m_lock);
381 
382  LOG(VB_CHANSCAN, LOG_INFO, LOC +
383  QString("Got a Program Association Table for %1")
384  .arg((*m_current).m_friendlyName));
385  LogLines(pat->toString());
386 
387  // Add pmts to list, so we can do MPEG scan properly.
389  for (uint i = 0; i < pat->ProgramCount(); ++i)
390  {
391  sd->AddListeningPID(pat->ProgramPID(i));
392  }
393 }
394 
396 {
397  QMutexLocker locker(&m_lock);
398 
399  LOG(VB_CHANSCAN, LOG_INFO, LOC +
400  QString("Got a Conditional Access Table for %1")
401  .arg((*m_current).m_friendlyName));
402  LogLines(cat->toString());
403 }
404 
405 void ChannelScanSM::HandlePMT(uint /*program_num*/, const ProgramMapTable *pmt)
406 {
407  QMutexLocker locker(&m_lock);
408 
409  LOG(VB_CHANSCAN, LOG_INFO, LOC + QString("Got a Program Map Table for %1 program %2 (0x%3)")
410  .arg((*m_current).m_friendlyName).arg(pmt->ProgramNumber())
411  .arg(pmt->ProgramNumber(),4,16,QChar('0')));
412  LogLines(pmt->toString());
413 
415  pmt->IsEncrypted(GetDTVChannel()->GetSIStandard()))
417 
418  UpdateChannelInfo(true);
419 }
420 
422 {
423  QMutexLocker locker(&m_lock);
424 
425  LOG(VB_CHANSCAN, LOG_INFO, LOC +
426  QString("Got a Virtual Channel Table for %1")
427  .arg((*m_current).m_friendlyName));
428  LogLines(vct->toString());
429 
430  for (uint i = 0; !m_currentTestingDecryption && i < vct->ChannelCount(); ++i)
431  {
432  if (vct->IsAccessControlled(i))
433  {
435  }
436  }
437 
438  UpdateChannelInfo(true);
439 }
440 
442 {
443  QMutexLocker locker(&m_lock);
444 
445  LOG(VB_CHANSCAN, LOG_INFO, LOC + QString("Got the Master Guide for %1")
446  .arg((*m_current).m_friendlyName));
447  LogLines(mgt->toString());
448 
449  UpdateChannelInfo(true);
450 }
451 
460 {
461  QMutexLocker locker(&m_lock);
462 
463  LOG(VB_CHANSCAN, LOG_INFO, LOC +
464  QString("Got a Service Description Table for %1 section %2/%3")
465  .arg((*m_current).m_friendlyName)
466  .arg(sdt->Section()).arg(sdt->LastSection()));
467  LogLines(sdt->toString());
468 
469  // If this is Astra 28.2 add start listening for Freesat BAT and SDTo
470  if (!m_setOtherTables && (
473  {
475  SetFreesatAdditionalSI(true);
476  m_setOtherTables = true;
477  // The whole BAT & SDTo group comes round in 10s
478  m_otherTableTimeout = 10s;
479  // Delay processing the SDT until we've seen BATs and SDTos
480  m_otherTableTime = std::chrono::milliseconds(m_timer.elapsed()) + m_otherTableTimeout;
481 
482  LOG(VB_CHANSCAN, LOG_INFO, LOC +
483  QString("SDT has OriginalNetworkID %1, look for "
484  "additional Freesat SI").arg(sdt->OriginalNetworkID()));
485  }
486 
487  if (!m_timer.hasExpired(m_otherTableTime.count()))
488  {
489  // Set the version for the SDT so we see it again.
491  SetVersionSDT(sdt->TSID(), -1, 0);
492  }
493 
494  uint id = sdt->OriginalNetworkID() << 16 | sdt->TSID();
495  m_tsScanned.insert(id);
496 
497  for (uint i = 0; !m_currentTestingDecryption && i < sdt->ServiceCount(); ++i)
498  {
499  if (sdt->IsEncrypted(i))
500  {
502  }
503  }
504 
505  UpdateChannelInfo(true);
506 }
507 
509 {
510  QMutexLocker locker(&m_lock);
511 
512  LOG(VB_CHANSCAN, LOG_INFO, LOC +
513  QString("Got a Network Information Table id %1 for %2 section %3/%4")
514  .arg(nit->NetworkID()).arg((*m_current).m_friendlyName)
515  .arg(nit->Section()).arg(nit->LastSection()));
516  LogLines(nit->toString());
517 
518  UpdateChannelInfo(true);
519 }
520 
522 {
523  QMutexLocker locker(&m_lock);
524 
525  LOG(VB_CHANSCAN, LOG_INFO, LOC +
526  QString("Got a Bouquet Association Table id %1 for %2 section %3/%4")
527  .arg(bat->BouquetID()).arg((*m_current).m_friendlyName)
528  .arg(bat->Section()).arg(bat->LastSection()));
529  LogLines(bat->toString());
530 
531  m_otherTableTime = std::chrono::milliseconds(m_timer.elapsed()) + m_otherTableTimeout;
532 
533  for (uint i = 0; i < bat->TransportStreamCount(); ++i)
534  {
535  uint tsid = bat->TSID(i);
536  uint netid = bat->OriginalNetworkID(i);
537  desc_list_t parsed =
540  // Look for default authority
541  const unsigned char *def_auth =
543  const unsigned char *serv_list =
545 
546  if (def_auth && serv_list)
547  {
548  DefaultAuthorityDescriptor authority(def_auth);
549  ServiceListDescriptor services(serv_list);
550  if (!authority.IsValid() || !services.IsValid())
551  continue;
552 #if 0
553  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
554  QString("Found default authority '%1' in BAT for services in nid %2 tid %3")
555  .arg(authority.DefaultAuthority())
556  .arg(netid).arg(tsid));
557 #endif
558  for (uint j = 0; j < services.ServiceCount(); ++j)
559  {
560  // If the default authority is given in the SDT this
561  // overrides any definition in the BAT (or in the NIT)
562  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
563  QString("Found default authority '%1' in BAT for service nid %2 tid %3 sid %4")
564  .arg(authority.DefaultAuthority())
565  .arg(netid).arg(tsid).arg(services.ServiceID(j)));
566  uint64_t index = ((uint64_t)netid << 32) | (tsid << 16) |
567  services.ServiceID(j);
568  if (! m_defAuthorities.contains(index))
569  m_defAuthorities[index] = authority.DefaultAuthority();
570  }
571  }
572  }
573  UpdateChannelInfo(true);
574 }
575 
577 {
578  QMutexLocker locker(&m_lock);
579 
580  LOG(VB_CHANSCAN, LOG_INFO, LOC +
581  QString("Got a Service Description Table (other) for Transport ID %1 section %2/%3")
582  .arg(tsid).arg(sdt->Section()).arg(sdt->LastSection()));
583  LogLines(sdt->toString());
584 
585  m_otherTableTime = std::chrono::milliseconds(m_timer.elapsed()) + m_otherTableTimeout;
586 
587  uint netid = sdt->OriginalNetworkID();
588 
589  for (uint i = 0; i < sdt->ServiceCount(); ++i)
590  {
591  uint serviceId = sdt->ServiceID(i);
592  desc_list_t parsed =
594  sdt->ServiceDescriptorsLength(i));
595  // Look for default authority
596  const unsigned char *def_auth =
598  if (def_auth)
599  {
600  DefaultAuthorityDescriptor authority(def_auth);
601  if (!authority.IsValid())
602  continue;
603 #if 0
604  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
605  QString("Found default authority '%1' in SDTo for service nid %2 tid %3 sid %4")
606  .arg(authority.DefaultAuthority())
607  .arg(netid).arg(tsid).arg(serviceId));
608 #endif
609  m_defAuthorities[((uint64_t)netid << 32) | (tsid << 16) | serviceId] =
610  authority.DefaultAuthority();
611  }
612  }
613 }
614 
615 void ChannelScanSM::HandleEncryptionStatus(uint pnum, bool encrypted)
616 {
617  QMutexLocker locker(&m_lock);
618 
620 
623 
624  UpdateChannelInfo(true);
625 }
626 
628 {
629  if (!m_currentInfo || m_currentInfo->m_pmts.empty())
630  {
631  LOG(VB_GENERAL, LOG_ERR, LOC + "Can't monitor decryption -- no pmts");
633  return false;
634  }
635 
636  do
637  {
638  uint pnum = 0;
639  QMap<uint, uint>::const_iterator it = m_currentEncryptionStatus.cbegin();
640 #if 0
641  LOG(VB_GENERAL, LOG_DEBUG, LOC + QString("%1/%2 checked")
642  .arg(currentEncryptionStatusChecked.size())
643  .arg(currentEncryptionStatus.size()));
644 #endif
645  while (it != m_currentEncryptionStatus.cend())
646  {
647  if (!m_currentEncryptionStatusChecked[it.key()])
648  {
649  pnum = it.key();
650  break;
651  }
652  ++it;
653  }
654 
655  if (!pnum)
656  break;
657 
659 
660  if (!m_testDecryption)
661  {
663  continue;
664  }
665 
666  const ProgramMapTable *pmt = nullptr;
667  for (uint i = 0; !pmt && (i < m_currentInfo->m_pmts.size()); ++i)
668  {
669  pmt = (m_currentInfo->m_pmts[i]->ProgramNumber() == pnum) ?
670  m_currentInfo->m_pmts[i] : nullptr;
671  }
672 
673  if (pmt)
674  {
675  QString cur_chan;
676  QString cur_chan_tr;
677  GetCurrentTransportInfo(cur_chan, cur_chan_tr);
678 
679  QString msg_tr =
680  QObject::tr("Program %1 Testing Decryption")
681  .arg(pnum);
682  QString msg =
683  QString("%1 -- Testing decryption of program %2")
684  .arg(cur_chan).arg(pnum);
685 
687  LOG(VB_CHANSCAN, LOG_INFO, LOC + msg);
688 
689 #ifdef USING_DVB
690  if (GetDVBChannel())
691  GetDVBChannel()->SetPMT(pmt);
692 #endif // USING_DVB
693 
696 
698  m_timer.start();
699  return true;
700  }
701 
702  LOG(VB_GENERAL, LOG_INFO, LOC +
703  QString("Can't monitor decryption of program %1 -- no pmt")
704  .arg(pnum));
705 
706  } while (true);
707 
709  return false;
710 }
711 
713 {
716 
717  const DTVChannel *chan = GetDTVChannel();
718 
719  if (!chan)
720  return type;
721 
722  std::vector<DTVTunerType> tts = chan->GetTunerTypes();
723 
724  for (auto & tt : tts)
725  {
726  if (tt == type)
727  return type;
728  }
729 
730  if (!tts.empty())
731  return tts[0];
732 
733  return type;
734 }
735 
737 {
738  LOG(VB_CHANSCAN, LOG_DEBUG, LOC + QString("%1 NIT nid:%2 fr:%3 section:%4/%5 ts count:%6 ")
739  .arg(__func__).arg(nit->NetworkID()).arg(nit_frequency).arg(nit->Section()).arg(nit->LastSection())
740  .arg(nit->TransportStreamCount()));
741 
742  for (uint i = 0; i < nit->TransportStreamCount(); ++i)
743  {
744  uint32_t tsid = nit->TSID(i);
745  uint32_t netid = nit->OriginalNetworkID(i);
746  uint32_t id = netid << 16 | tsid;
747 
748  if (m_tsScanned.contains(id) || m_extendTransports.contains(id))
749  continue;
750 
751  const desc_list_t& list =
754 
755  for (const auto * const item : list)
756  {
757  uint64_t frequency = 0;
758  const MPEGDescriptor desc(item);
759  uint tag = desc.DescriptorTag();
760 // QString tagString = desc.DescriptorTagString();
761 
763  switch (tag)
764  {
766  {
768  if (cd.IsValid())
769  frequency = cd.FrequencyHz();
771  break;
772  }
774  {
775  switch (desc.DescriptorTagExtension())
776  {
778  {
780  continue; // T2 descriptor not yet used
781  }
782  default:
783  continue; // Next descriptor
784  }
785  }
787  {
788  const SatelliteDeliverySystemDescriptor cd(desc);
789  if (cd.IsValid())
790  frequency = cd.FrequencykHz();
792  break;
793  }
795  {
797  continue; // S2 descriptor not yet used
798  }
800  {
801  const CableDeliverySystemDescriptor cd(desc);
802  if (cd.IsValid())
803  frequency = cd.FrequencyHz();
805  break;
806  }
807  default:
808  continue; // Next descriptor
809  }
810 
811  // Have now a delivery system descriptor
812  tt = GuessDTVTunerType(tt);
813  DTVMultiplex tuning;
814  if (tuning.FillFromDeliverySystemDesc(tt, desc))
815  {
816  LOG(VB_CHANSCAN, LOG_DEBUG, QString("NIT onid:%1 add ts(%2):%3 %4")
817  .arg(netid).arg(i).arg(tsid).arg(tuning.toString()));
818  m_extendTransports[id] = tuning;
819  }
820  else
821  {
822  LOG(VB_CHANSCAN, LOG_DEBUG, QString("NIT onid:%1 cannot add ts(%2):%3 fr:%4")
823  .arg(netid).arg(i).arg(tsid).arg(frequency));
824  }
825 
826  // Next TS in loop
827  break;
828  }
829  }
830 }
831 
832 bool ChannelScanSM::UpdateChannelInfo(bool wait_until_complete)
833 {
834  QMutexLocker locker(&m_mutex);
835 
836  if (m_current == m_scanTransports.end())
837  return true;
838 
839  if (wait_until_complete && !m_waitingForTables)
840  return true;
841 
842  if (wait_until_complete && m_currentTestingDecryption)
843  return false;
844 
846  if (!dtv_sm)
847  return false;
848 
849  const ScanStreamData *sd = dtv_sm->GetScanStreamData();
850 
851  if (!m_currentInfo)
853 
854  bool transport_tune_complete = true;
855 
856  // MPEG
857 
858  // Grab PAT tables
859  pat_vec_t pattmp = sd->GetCachedPATs();
860  QMap<uint,bool> tsid_checked;
861  for (auto & pat : pattmp)
862  {
863  uint tsid = pat->TransportStreamID();
864  if (tsid_checked[tsid])
865  continue;
866  tsid_checked[tsid] = true;
867  if (m_currentInfo->m_pats.contains(tsid))
868  continue;
869 
870  if (!wait_until_complete || sd->HasCachedAllPAT(tsid))
871  {
872  m_currentInfo->m_pats[tsid] = sd->GetCachedPATs(tsid);
873  if (!m_currentInfo->m_pmts.empty())
874  {
876  m_currentInfo->m_pmts.clear();
877  }
878  }
879  else
880  transport_tune_complete = false;
881  }
882  transport_tune_complete &= !pattmp.empty();
883  sd->ReturnCachedPATTables(pattmp);
884 
885  // Grab PMT tables
886  if ((!wait_until_complete || sd->HasCachedAllPMTs()) &&
887  m_currentInfo->m_pmts.empty())
889 
890  // ATSC
891  if (!m_currentInfo->m_mgt && sd->HasCachedMGT())
893 
894  if ((!wait_until_complete || sd->HasCachedAllCVCTs()) &&
895  m_currentInfo->m_cvcts.empty())
896  {
898  }
899 
900  if ((!wait_until_complete || sd->HasCachedAllTVCTs()) &&
901  m_currentInfo->m_tvcts.empty())
902  {
904  }
905 
906  // DVB
907  if ((!wait_until_complete || sd->HasCachedAllNIT()) &&
908  (m_currentInfo->m_nits.empty() ||
909  m_timer.hasExpired(m_otherTableTime.count())))
910  {
912  }
913 
914  sdt_vec_t sdttmp = sd->GetCachedSDTs();
915  tsid_checked.clear();
916  for (auto & sdt : sdttmp)
917  {
918  uint tsid = sdt->TSID();
919  if (tsid_checked[tsid])
920  continue;
921  tsid_checked[tsid] = true;
922  if (m_currentInfo->m_sdts.contains(tsid))
923  continue;
924 
925  if (!wait_until_complete || sd->HasCachedAllSDT(tsid))
926  m_currentInfo->m_sdts[tsid] = sd->GetCachedSDTSections(tsid);
927  }
928  sd->ReturnCachedSDTTables(sdttmp);
929 
930  if ((!wait_until_complete || sd->HasCachedAllBATs()) &&
931  (m_currentInfo->m_bats.empty() ||
932  m_timer.hasExpired(m_otherTableTime.count())))
933  {
935  }
936 
937  // Check if transport tuning is complete
938  if (transport_tune_complete)
939  {
940  transport_tune_complete &= !m_currentInfo->m_pmts.empty();
941 
942  if (!(sd->HasCachedMGT() || sd->HasCachedAnyNIT()))
943  {
944  transport_tune_complete = false;
945  }
946 
947  if (sd->HasCachedMGT() || sd->HasCachedAnyVCTs())
948  {
949  transport_tune_complete &= sd->HasCachedMGT();
950  transport_tune_complete &=
951  (!m_currentInfo->m_tvcts.empty() || !m_currentInfo->m_cvcts.empty());
952  }
953  else if (sd->HasCachedAnyNIT() || sd->HasCachedAnySDTs())
954  {
955  transport_tune_complete &= !m_currentInfo->m_nits.empty();
956  transport_tune_complete &= !m_currentInfo->m_sdts.empty();
957  }
958  if (sd->HasCachedAnyBATs())
959  {
960  transport_tune_complete &= !m_currentInfo->m_bats.empty();
961  }
962  if (transport_tune_complete)
963  {
964  uint tsid = dtv_sm->GetTransportID();
965  LOG(VB_CHANSCAN, LOG_INFO, LOC +
966  QString("\nTable status after transport tune complete:") +
967  QString("\nsd->HasCachedAnyNIT(): %1").arg(sd->HasCachedAnyNIT()) +
968  QString("\nsd->HasCachedAnySDTs(): %1").arg(sd->HasCachedAnySDTs()) +
969  QString("\nsd->HasCachedAnyBATs(): %1").arg(sd->HasCachedAnyBATs()) +
970  QString("\nsd->HasCachedAllPMTs(): %1").arg(sd->HasCachedAllPMTs()) +
971  QString("\nsd->HasCachedAllNIT(): %1").arg(sd->HasCachedAllNIT()) +
972  QString("\nsd->HasCachedAllSDT(%1): %2").arg(tsid,5).arg(sd->HasCachedAllSDT(tsid)) +
973  QString("\nsd->HasCachedAllBATs(): %1").arg(sd->HasCachedAllBATs()) +
974  QString("\nsd->HasCachedMGT(): %1").arg(sd->HasCachedMGT()) +
975  QString("\nsd->HasCachedAnyVCTs(): %1").arg(sd->HasCachedAnyVCTs()) +
976  QString("\nsd->HasCachedAllCVCTs(): %1").arg(sd->HasCachedAllCVCTs()) +
977  QString("\nsd->HasCachedAllTVCTs(): %1").arg(sd->HasCachedAllTVCTs()) +
978  QString("\ncurrentInfo->m_pmts.empty(): %1").arg(m_currentInfo->m_pmts.empty()) +
979  QString("\ncurrentInfo->m_nits.empty(): %1").arg(m_currentInfo->m_nits.empty()) +
980  QString("\ncurrentInfo->m_sdts.empty(): %1").arg(m_currentInfo->m_sdts.empty()) +
981  QString("\ncurrentInfo->m_bats.empty(): %1").arg(m_currentInfo->m_bats.empty()) +
982  QString("\ncurrentInfo->m_cvtcs.empty(): %1").arg(m_currentInfo->m_cvcts.empty()) +
983  QString("\ncurrentInfo->m_tvtcs.empty(): %1").arg(m_currentInfo->m_tvcts.empty()));
984  }
985  }
986  if (!wait_until_complete)
987  transport_tune_complete = true;
988  if (transport_tune_complete)
989  {
990  LOG(VB_CHANSCAN, LOG_INFO, LOC +
991  QString("transport_tune_complete: wait_until_complete %1").arg(wait_until_complete));
992  }
993 
994  if (transport_tune_complete && !m_currentEncryptionStatus.empty())
996  {
997  //GetDTVSignalMonitor()->GetStreamData()->StopTestingDecryption();
998 
1000  return false;
1001 
1002  QMap<uint, uint>::const_iterator it = m_currentEncryptionStatus.cbegin();
1003  for (; it != m_currentEncryptionStatus.cend(); ++it)
1004  {
1005  m_currentInfo->m_programEncryptionStatus[it.key()] = *it;
1006 
1007  if (m_testDecryption)
1008  {
1009  QString msg_tr1 = QObject::tr("Program %1").arg(it.key());
1010  QString msg_tr2 = QObject::tr("Unknown decryption status");
1011  if (kEncEncrypted == *it)
1012  msg_tr2 = QObject::tr("Encrypted");
1013  else if (kEncDecrypted == *it)
1014  msg_tr2 = QObject::tr("Decrypted");
1015  QString msg_tr =QString("%1 %2").arg(msg_tr1, msg_tr2);
1017  }
1018 
1019  QString msg = QString("Program %1").arg(it.key());
1020  if (kEncEncrypted == *it)
1021  msg = msg + " -- Encrypted";
1022  else if (kEncDecrypted == *it)
1023  msg = msg + " -- Decrypted";
1024  else if (kEncUnknown == *it)
1025  msg = msg + " -- Unknown decryption status";
1026 
1027  LOG(VB_CHANSCAN, LOG_INFO, LOC + msg);
1028  }
1029  }
1030 
1031  // Append transports from the NIT to the scan list
1032  if (transport_tune_complete && m_extendScanList &&
1033  !m_currentInfo->m_nits.empty())
1034  {
1035  // Update transport with delivery system descriptors from the NIT
1036  auto it = m_currentInfo->m_nits.begin();
1037  while (it != m_currentInfo->m_nits.end())
1038  {
1039  UpdateScanTransports((*m_current).m_tuning.m_frequency, *it);
1040  ++it;
1041  }
1042  }
1043 
1044  // Start scanning next transport if we are done with this one..
1045  if (transport_tune_complete)
1046  {
1047  QString cchan;
1048  QString cchan_tr;
1049  uint cchan_cnt = GetCurrentTransportInfo(cchan, cchan_tr);
1050  m_channelsFound += cchan_cnt;
1051  QString chan_tr = QObject::tr("%1 -- Timed out").arg(cchan_tr);
1052  QString chan = QString( "%1 -- Timed out").arg(cchan);
1053  QString msg_tr = "";
1054  QString msg = "";
1055 
1056  if (!m_currentInfo->IsEmpty())
1057  {
1058  TransportScanItem &item = *m_current;
1061  item.m_networkID = dtv_sm->GetNetworkID();
1062  item.m_transportID = dtv_sm->GetTransportID();
1063 
1065  {
1067  {
1069  }
1070  }
1072  {
1074  }
1076  {
1077  if (m_dvbt2Tried)
1079  else
1081  }
1082 
1083  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1084  QString("Adding %1 offset:%2 ss:%3")
1085  .arg(item.m_tuning.toString()).arg(m_current.offset())
1086  .arg(item.m_signalStrength));
1087 
1088  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
1089  QString("%1(%2) m_inputName: %3 ").arg(__FUNCTION__).arg(__LINE__).arg(m_inputName) +
1090  QString("tunerType:%1 %2 ").arg(m_scanDTVTunerType).arg(m_scanDTVTunerType.toString()) +
1091  QString("m_modSys:%1 %2 ").arg(item.m_tuning.m_modSys).arg(item.m_tuning.m_modSys.toString()) +
1092  QString("m_dvbt2Tried:%1").arg(m_dvbt2Tried));
1093 
1095  m_currentInfo = nullptr;
1096  }
1097  else
1098  {
1099  delete m_currentInfo;
1100  m_currentInfo = nullptr;
1101  }
1102 
1104  if (HasTimedOut())
1105  {
1106  msg_tr = (cchan_cnt) ?
1107  QObject::tr("%1 possible channels").arg(cchan_cnt) :
1108  QObject::tr("no channels");
1109  msg_tr = QString("%1, %2").arg(chan_tr, msg_tr);
1110  msg = (cchan_cnt) ?
1111  QString("%1 possible channels").arg(cchan_cnt) :
1112  QString("no channels");
1113  msg = QString("%1, %2").arg(chan_tr, msg);
1114  }
1115  else if ((m_current != m_scanTransports.end()) &&
1116  m_timer.hasExpired((*m_current).m_timeoutTune.count()) &&
1117  sm && !sm->HasSignalLock())
1118  {
1119  msg_tr = QObject::tr("%1, no signal").arg(chan_tr);
1120  msg = QString("%1, no signal").arg(chan);
1121  }
1122  else
1123  {
1124  msg_tr = QObject::tr("%1 -- Found %2 probable channels")
1125  .arg(cchan_tr).arg(cchan_cnt);
1126 
1127  msg = QString("%1 -- Found %2 probable channels")
1128  .arg(cchan).arg(cchan_cnt);
1129  }
1130 
1132  LOG(VB_CHANSCAN, LOG_INFO, LOC + msg);
1133 
1134  m_currentEncryptionStatus.clear();
1136 
1137  m_setOtherTables = false;
1138  m_otherTableTime = 0ms;
1139 
1140  if (m_scanning)
1141  {
1144  m_waitingForTables = false;
1146  m_dvbt2Tried = true;
1147  }
1148  else
1149  {
1152  }
1153 
1154  return true;
1155  }
1156 
1157  return false;
1158 }
1159 
1160 #define PCM_INFO_INIT(SISTD) \
1161  ChannelInsertInfo &info = pnum_to_dbchan[pnum]; \
1162  info.m_dbMplexId = mplexid; info.m_sourceId = m_sourceID; \
1163  info.m_serviceId = pnum; info.m_freqId = freqidStr; \
1164  info.m_siStandard = SISTD;
1165 
1166 static void update_info(ChannelInsertInfo &info,
1167  const VirtualChannelTable *vct, uint i)
1168 {
1169  if (vct->ModulationMode(i) == 0x01 /* NTSC Modulation */ ||
1170  vct->ServiceType(i) == 0x01 /* Analog TV */)
1171  {
1172  info.m_siStandard = "ntsc";
1173  info.m_format = "ntsc";
1174  }
1175 
1176  info.m_callSign = vct->ShortChannelName(i);
1177 
1178  info.m_serviceName = vct->GetExtendedChannelName(i);
1179  if (info.m_serviceName.isEmpty())
1180  info.m_serviceName = vct->ShortChannelName(i);
1181 
1182  info.m_chanNum.clear();
1183 
1184  info.m_serviceId = vct->ProgramNumber(i);
1185  info.m_atscMajorChannel = vct->MajorChannel(i);
1186  info.m_atscMinorChannel = vct->MinorChannel(i);
1187 
1188  info.m_useOnAirGuide = !vct->IsHidden(i) || !vct->IsHiddenInGuide(i);
1189 
1190  info.m_hidden = vct->IsHidden(i);
1191  info.m_hiddenInGuide = vct->IsHiddenInGuide(i);
1192 
1193  info.m_vctTsId = vct->TransportStreamID();
1194  info.m_vctChanTsId = vct->ChannelTransportStreamID(i);
1195  info.m_isEncrypted |= vct->IsAccessControlled(i);
1196  info.m_isDataService = vct->ServiceType(i) == 0x04;
1197  info.m_isAudioService = vct->ServiceType(i) == 0x03;
1198 
1199  info.m_inVct = true;
1200 }
1201 
1202 static void update_info(ChannelInsertInfo &info,
1203  const ServiceDescriptionTable *sdt, uint i,
1204  const QMap<uint64_t, QString> &defAuthorities)
1205 {
1206  // HACK begin -- special exception for these networks
1207  // this enables useonairguide by default for all matching channels
1208  // (dbver == "1067")
1209  bool force_guide_present = (
1210  // Telenor (NO)
1212 #if 0 // #9592#comment:23 - meanwhile my provider changed his signaling
1213  // Kabelplus (AT) formerly Kabelsignal, registered to NDS, see #9592
1214  (sdt->OriginalNetworkID() == 222) ||
1215 #endif
1216  // ERT (GR) from the private temporary allocation, see #9592:comment:17
1217  (sdt->OriginalNetworkID() == 65330) ||
1218  // Digitenne (NL) see #13427
1220  );
1221  // HACK end -- special exception for these networks
1222 
1223  // Figure out best service name and callsign...
1224  ServiceDescriptor *desc = sdt->GetServiceDescriptor(i);
1225  QString callsign;
1226  QString service_name;
1227  if (desc)
1228  {
1229  callsign = desc->ServiceShortName();
1230  if (callsign.trimmed().isEmpty())
1231  {
1232  callsign = QString("%1-%2-%3")
1233  .arg(ChannelUtil::GetUnknownCallsign()).arg(sdt->TSID())
1234  .arg(sdt->ServiceID(i));
1235  }
1236 
1237  service_name = desc->ServiceName();
1238  if (service_name.trimmed().isEmpty())
1239  service_name.clear();
1240 
1241  info.m_serviceType = desc->ServiceType();
1242  info.m_isDataService =
1243  (desc && !desc->IsDTV() && !desc->IsDigitalAudio());
1244  info.m_isAudioService = (desc && desc->IsDigitalAudio());
1245  delete desc;
1246  }
1247  else
1248  {
1249  LOG(VB_CHANSCAN, LOG_INFO, "ChannelScanSM: " +
1250  QString("No ServiceDescriptor for onid %1 tid %2 sid %3")
1251  .arg(sdt->OriginalNetworkID()).arg(sdt->TSID()).arg(sdt->ServiceID(i)));
1252  }
1253 
1254  if (info.m_callSign.isEmpty())
1255  info.m_callSign = callsign;
1256  if (info.m_serviceName.isEmpty())
1257  info.m_serviceName = service_name;
1258 
1259  info.m_useOnAirGuide =
1260  sdt->HasEITPresentFollowing(i) ||
1261  sdt->HasEITSchedule(i) ||
1262  force_guide_present;
1263 
1264  info.m_hidden = false;
1265  info.m_hiddenInGuide = false;
1266  info.m_serviceId = sdt->ServiceID(i);
1267  info.m_sdtTsId = sdt->TSID();
1268  info.m_origNetId = sdt->OriginalNetworkID();
1269  info.m_inSdt = true;
1270 
1271  desc_list_t parsed =
1273  sdt->ServiceDescriptorsLength(i));
1274  // Look for default authority
1275  const unsigned char *def_auth =
1277  if (def_auth)
1278  {
1279  DefaultAuthorityDescriptor authority(def_auth);
1280  if (authority.IsValid())
1281  {
1282 #if 0
1283  LOG(VB_CHANSCAN, LOG_DEBUG,
1284  QString("ChannelScanSM: Found default authority '%1' in SDT for service onid %2 tid %3 sid %4")
1285  .arg(authority.DefaultAuthority())
1286  .arg(info.m_origNetId).arg(info.m_sdtTsId).arg(info.m_serviceId));
1287 #endif
1288  info.m_defaultAuthority = authority.DefaultAuthority();
1289  return;
1290  }
1291  }
1292 
1293  // If no authority in the SDT then use the one found in the BAT or the SDTo
1294  uint64_t index = (uint64_t)info.m_origNetId << 32 |
1295  info.m_sdtTsId << 16 | info.m_serviceId;
1296  if (defAuthorities.contains(index))
1297  info.m_defaultAuthority = defAuthorities[index];
1298 
1299  // Is this service relocated from somewhere else?
1301  if (srdesc)
1302  {
1303  info.m_oldOrigNetId = srdesc->OldOriginalNetworkID();
1304  info.m_oldTsId = srdesc->OldTransportID();
1305  info.m_oldServiceId = srdesc->OldServiceID();
1306 
1307  LOG(VB_CHANSCAN, LOG_DEBUG, "ChannelScanSM: " +
1308  QString("Service '%1' onid:%2 tid:%3 sid:%4 ")
1309  .arg(info.m_serviceName)
1310  .arg(info.m_origNetId)
1311  .arg(info.m_sdtTsId)
1312  .arg(info.m_serviceId) +
1313  QString(" relocated from onid:%1 tid:%2 sid:%3")
1314  .arg(info.m_oldOrigNetId)
1315  .arg(info.m_oldTsId)
1316  .arg(info.m_oldServiceId));
1317 
1318  delete srdesc;
1319  }
1320 
1321 }
1322 
1324  QString &cur_chan, QString &cur_chan_tr) const
1325 {
1326  if (m_current.iter() == m_scanTransports.end())
1327  {
1328  cur_chan.clear();
1329  cur_chan_tr.clear();
1330  return 0;
1331  }
1332 
1333  uint max_chan_cnt = 0;
1334 
1335  QMap<uint,ChannelInsertInfo> list = GetChannelList(m_current, m_currentInfo);
1336  {
1337  for (const auto & info : qAsConst(list))
1338  {
1339  max_chan_cnt +=
1340  (info.m_inPat || info.m_inPmt ||
1341  info.m_inSdt || info.m_inVct) ? 1 : 0;
1342  }
1343  }
1344 
1345  QString offset_str_tr = m_current.offset() ?
1346  QObject::tr(" offset %2").arg(m_current.offset()) : "";
1347  cur_chan_tr = QString("%1%2")
1348  .arg((*m_current).m_friendlyName, offset_str_tr);
1349 
1350  QString offset_str = m_current.offset() ?
1351  QString(" offset %2").arg(m_current.offset()) : "";
1352  cur_chan = QString("%1%2")
1353  .arg((*m_current).m_friendlyName, offset_str);
1354 
1355  return max_chan_cnt;
1356 }
1357 
1358 QMap<uint,ChannelInsertInfo>
1360  ScannedChannelInfo *scan_info) const
1361 {
1362  QMap<uint,ChannelInsertInfo> pnum_to_dbchan;
1363 
1364  uint mplexid = (*trans_info).m_mplexid;
1365  int freqid = (*trans_info).m_friendlyNum;
1366  QString freqidStr = (freqid) ? QString::number(freqid) : QString("");
1367  QString iptv_channel = (*trans_info).m_iptvChannel;
1368 
1369  // channels.conf
1370  const DTVChannelInfoList &echan = (*trans_info).m_expectedChannels;
1371  for (const auto & chan : echan)
1372  {
1373  uint pnum = chan.m_serviceid;
1374  PCM_INFO_INIT("mpeg");
1375  info.m_serviceName = chan.m_name;
1376  info.m_inChannelsConf = true;
1377  }
1378 
1379  // PATs
1380  for (const auto& pat_list : qAsConst(scan_info->m_pats))
1381  {
1382  for (const auto *pat : pat_list)
1383  {
1384  bool could_be_opencable = false;
1385  for (uint i = 0; i < pat->ProgramCount(); ++i)
1386  {
1387  if ((pat->ProgramNumber(i) == 0) &&
1388  (pat->ProgramPID(i) == PID::SCTE_PSIP_PID))
1389  {
1390  could_be_opencable = true;
1391  }
1392  }
1393 
1394  for (uint i = 0; i < pat->ProgramCount(); ++i)
1395  {
1396  uint pnum = pat->ProgramNumber(i);
1397  if (pnum)
1398  {
1399  PCM_INFO_INIT("mpeg");
1400  info.m_patTsId = pat->TransportStreamID();
1401  info.m_couldBeOpencable = could_be_opencable;
1402  info.m_inPat = true;
1403  }
1404  }
1405  }
1406  }
1407 
1408  // PMTs
1409  for (const auto *pmt : scan_info->m_pmts)
1410  {
1411  uint pnum = pmt->ProgramNumber();
1412  PCM_INFO_INIT("mpeg");
1413  for (uint i = 0; i < pmt->StreamCount(); ++i)
1414  {
1415  info.m_couldBeOpencable |=
1416  (StreamID::OpenCableVideo == pmt->StreamType(i));
1417  }
1418 
1420  pmt->ProgramInfo(), pmt->ProgramInfoLength(),
1422 
1423  for (auto & desc : descs)
1424  {
1425  RegistrationDescriptor reg(desc);
1426  if (!reg.IsValid())
1427  continue;
1428  if (reg.FormatIdentifierString() == "CUEI" ||
1429  reg.FormatIdentifierString() == "SCTE")
1430  info.m_couldBeOpencable = true;
1431  }
1432 
1433  info.m_isEncrypted |= pmt->IsEncrypted(GetDTVChannel()->GetSIStandard());
1434  info.m_inPmt = true;
1435  }
1436 
1437  // Cable VCTs
1438  for (const auto *cvct : scan_info->m_cvcts)
1439  {
1440  for (uint i = 0; i < cvct->ChannelCount(); ++i)
1441  {
1442  uint pnum = cvct->ProgramNumber(i);
1443  PCM_INFO_INIT("atsc");
1444  update_info(info, cvct, i);
1445 
1446  // One-part channel number, as defined in the ATSC Standard:
1447  // Program and System Information Protocol for Terrestrial Broadcast and Cable
1448  // Doc. A65/2013 7 August 2013 page 35
1449  if ((info.m_atscMajorChannel & 0x3F0) == 0x3F0)
1450  {
1451  info.m_chanNum = QString::number(((info.m_atscMajorChannel & 0x00F) << 10) + info.m_atscMinorChannel);
1452  }
1453  else
1454  {
1455  info.m_chanNum = kATSCChannelFormat.arg(info.m_atscMajorChannel).arg(info.m_atscMinorChannel);
1456  }
1457  }
1458  }
1459 
1460  // Terrestrial VCTs
1461  for (const auto *tvct : scan_info->m_tvcts)
1462  {
1463  for (uint i = 0; i < tvct->ChannelCount(); ++i)
1464  {
1465  uint pnum = tvct->ProgramNumber(i);
1466  PCM_INFO_INIT("atsc");
1467  update_info(info, tvct, i);
1468  info.m_chanNum = kATSCChannelFormat.arg(info.m_atscMajorChannel).arg(info.m_atscMinorChannel);
1469  }
1470  }
1471 
1472  // SDTs
1473  QString siStandard = (scan_info->m_mgt == nullptr) ? "dvb" : "atsc";
1474  for (const auto& sdt_list : qAsConst(scan_info->m_sdts))
1475  {
1476  for (const auto *sdt_it : sdt_list)
1477  {
1478  for (uint i = 0; i < sdt_it->ServiceCount(); ++i)
1479  {
1480  uint pnum = sdt_it->ServiceID(i);
1481  PCM_INFO_INIT(siStandard);
1482  update_info(info, sdt_it, i, m_defAuthorities);
1483  }
1484  }
1485  }
1486 
1487  // NIT
1488  QMap<qlonglong, uint> ukChanNums;
1489  QMap<qlonglong, uint> scnChanNums;
1490  QMap<uint,ChannelInsertInfo>::iterator dbchan_it;
1491  for (dbchan_it = pnum_to_dbchan.begin();
1492  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1493  {
1494  ChannelInsertInfo &info = *dbchan_it;
1495 
1496  // NIT
1497  for (const auto *item : scan_info->m_nits)
1498  {
1499  for (uint i = 0; i < item->TransportStreamCount(); ++i)
1500  {
1501  const NetworkInformationTable *nit = item;
1502  if ((nit->TSID(i) == info.m_sdtTsId) &&
1503  (nit->OriginalNetworkID(i) == info.m_origNetId))
1504  {
1505  info.m_netId = nit->NetworkID();
1506  info.m_inNit = true;
1507  }
1508  else
1509  {
1510  continue;
1511  }
1512 
1513  // Descriptors in the transport stream loop of this transport in the NIT
1514  const desc_list_t &list =
1516  nit->TransportDescriptorsLength(i));
1517 
1518  // Presence of T2 delivery system descriptor indicates DVB-T2 delivery system
1519  // DVB BlueBook A038 (Feb 2019) page 104, paragraph 6.4.6.3
1520  {
1521  const unsigned char *desc =
1524 
1525  if (desc)
1526  {
1527  T2DeliverySystemDescriptor t2tdsd(desc);
1528  if (t2tdsd.IsValid())
1529  {
1530  (*trans_info).m_tuning.m_modSys = DTVModulationSystem::kModulationSystem_DVBT2;
1531  }
1532  }
1533  }
1534 
1535  // Logical channel numbers
1536  {
1537  const unsigned char *desc =
1540 
1541  if (desc)
1542  {
1543  DVBLogicalChannelDescriptor uklist(desc);
1544  if (!uklist.IsValid())
1545  continue;
1546  for (uint j = 0; j < uklist.ChannelCount(); ++j)
1547  {
1548  ukChanNums[((qlonglong)info.m_origNetId<<32) |
1549  uklist.ServiceID(j)] =
1550  uklist.ChannelNumber(j);
1551  }
1552  }
1553  }
1554 
1555  // HD Simulcast logical channel numbers
1556  {
1557  const unsigned char *desc =
1560 
1561  if (desc)
1562  {
1563  DVBSimulcastChannelDescriptor scnlist(desc);
1564  if (!scnlist.IsValid())
1565  continue;
1566  for (uint j = 0; j < scnlist.ChannelCount(); ++j)
1567  {
1568  scnChanNums[((qlonglong)info.m_origNetId<<32) |
1569  scnlist.ServiceID(j)] =
1570  scnlist.ChannelNumber(j);
1571  }
1572  }
1573  }
1574  }
1575  }
1576  }
1577 
1578  // BAT
1579 
1580  // Channel numbers for Freesat and Sky on Astra 28.2E
1581  //
1582  // Get the Logical Channel Number (LCN) information from the BAT.
1583  // The first filter is on the bouquet ID.
1584  // Then collect all LCN for the selected region and
1585  // for the common (undefined) region with id 0xFFFF.
1586  // The LCN of the selected region has priority; if
1587  // a service is not defined there then the value of the LCN
1588  // table of the common region is used.
1589  // This works because the BAT of each transport contains
1590  // the LCN of all transports and services for all bouquets.
1591  //
1592  // For reference, this website has the Freesat and Sky channel numbers
1593  // for each bouquet and region:
1594  // https://www.satellite-calculations.com/DVB/28.2E/28E_FreeSat_ChannelNumber.php
1595  // https://www.satellite-calculations.com/DVB/28.2E/28E_Sky_ChannelNumber.php
1596  //
1597 
1598  // Lookup table from LCN to service ID
1599  QMap<uint,qlonglong> lcn_sid;
1600 
1601  for (const auto *bat : scan_info->m_bats)
1602  {
1603  // Only the bouquet selected by user
1604  if (bat->BouquetID() != m_bouquetId)
1605  continue;
1606 
1607  for (uint t = 0; t < bat->TransportStreamCount(); ++t)
1608  {
1609  uint netid = bat->OriginalNetworkID(t);
1610 
1611  // No network check to allow scanning on all Sky satellites
1612 #if 0
1613  if (!(netid == OriginalNetworkID::SES2 ||
1614  netid == OriginalNetworkID::BBC ||
1615  netid == OriginalNetworkID::SKYNZ ))
1616  continue;
1617 #endif
1618  desc_list_t parsed =
1619  MPEGDescriptor::Parse(bat->TransportDescriptors(t),
1620  bat->TransportDescriptorsLength(t));
1621 
1622  uint priv_dsid = 0;
1623  for (const auto *item : parsed)
1624  {
1625  if (item[0] == DescriptorID::private_data_specifier)
1626  {
1628  if (pd.IsValid())
1629  priv_dsid = pd.PrivateDataSpecifier();
1630  }
1631 
1632  // Freesat logical channels
1633  if (priv_dsid == PrivateDataSpecifierID::FSAT &&
1635  {
1636  FreesatLCNDescriptor ld(item);
1637  if (ld.IsValid())
1638  {
1639  for (uint i = 0; i<ld.ServiceCount(); i++)
1640  {
1641  uint service_id = ld.ServiceID(i);
1642  for (uint j=0; j<ld.LCNCount(i); j++)
1643  {
1644  uint region_id = ld.RegionID(i,j);
1645  uint lcn = ld.LogicalChannelNumber(i,j);
1646  if (region_id == m_regionId)
1647  {
1648  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1649  }
1650  else if (region_id == kRegionUndefined)
1651  {
1652  if (lcn_sid.value(lcn,0) == 0)
1653  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1654  }
1655  }
1656  }
1657  }
1658  }
1659 
1660  // Sky logical channels
1661  if (priv_dsid == PrivateDataSpecifierID::BSB1 &&
1663  {
1664  SkyLCNDescriptor ld(item);
1665  if (ld.IsValid())
1666  {
1667  uint region_id = ld.RegionID();
1668  for (uint i = 0; i<ld.ServiceCount(); i++)
1669  {
1670  uint service_id = ld.ServiceID(i);
1671  uint lcn = ld.LogicalChannelNumber(i);
1672  if (region_id == m_regionId)
1673  {
1674  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1675  }
1676  else if (region_id == kRegionUndefined)
1677  {
1678  if (lcn_sid.value(lcn,0) == 0)
1679  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1680  }
1681 #if 0
1682  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1683  QString("LCN bid:%1 tid:%2 rid:%3 sid:%4 lcn:%5")
1684  .arg(bat->BouquetID()).arg(bat->TSID(t)).arg(region_id).arg(service_id).arg(lcn));
1685 #endif
1686  }
1687  }
1688  }
1689  }
1690  }
1691  }
1692 
1693  // Create the reverse table from service id to LCN.
1694  // If the service has more than one logical
1695  // channel number the lowest number is used.
1696  QMap<qlonglong, uint> sid_lcn;
1697  QMap<uint, qlonglong>::const_iterator r = lcn_sid.constEnd();
1698  while (r != lcn_sid.constBegin())
1699  {
1700  --r;
1701  qlonglong sid = r.value();
1702  uint lcn = r.key();
1703  sid_lcn[sid] = lcn;
1704  }
1705 
1706  // ------------------------------------------------------------------------
1707 
1708  // Get DVB Logical Channel Numbers
1709  for (dbchan_it = pnum_to_dbchan.begin();
1710  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1711  {
1712  ChannelInsertInfo &info = *dbchan_it;
1713 
1714  if (!info.m_chanNum.isEmpty())
1715  continue;
1716 
1717  // DVB HD Simulcast channel numbers
1718  //
1719  // The HD simulcast channel number table gives the correct channel number
1720  // when HD and SD versions of the same channel are simultaneously broadcast
1721  // and the receiver is capable of receiving the HD signal.
1722  // The latter is assumed correct for a MythTV system.
1723  //
1724  if (info.m_chanNum.isEmpty())
1725  {
1726  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1727  QMap<qlonglong, uint>::const_iterator it = scnChanNums.constFind(key);
1728 
1729  if (it != scnChanNums.constEnd())
1730  {
1731  info.m_chanNum = QString::number(*it + m_lcnOffset);
1732  }
1733  }
1734 
1735  // DVB Logical Channel Numbers (a.k.a. UK channel numbers)
1736  if (info.m_chanNum.isEmpty())
1737  {
1738  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1739  QMap<qlonglong, uint>::const_iterator it = ukChanNums.constFind(key);
1740 
1741  if (it != ukChanNums.constEnd())
1742  {
1743  info.m_chanNum = QString::number(*it + m_lcnOffset);
1744  }
1745  }
1746 
1747  // Freesat and Sky channel numbers
1748  if (info.m_chanNum.isEmpty())
1749  {
1750  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1751  QMap<qlonglong, uint>::const_iterator it = sid_lcn.constFind(key);
1752 
1753  if (it != sid_lcn.constEnd())
1754  {
1755  info.m_chanNum = QString::number(*it + m_lcnOffset);
1756  }
1757  }
1758 
1759  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1760  QString("GetChannelList: service %1 (0x%2) chan_num '%3' callsign '%4'")
1761  .arg(info.m_serviceId).arg(info.m_serviceId,4,16,QChar('0'))
1762  .arg(info.m_chanNum, info.m_callSign));
1763  }
1764 
1765  // Get QAM/SCTE/MPEG channel numbers
1766  for (dbchan_it = pnum_to_dbchan.begin();
1767  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1768  {
1769  ChannelInsertInfo &info = *dbchan_it;
1770 
1771  if (!info.m_chanNum.isEmpty())
1772  continue;
1773 
1774  if ((info.m_siStandard == "mpeg") ||
1775  (info.m_siStandard == "scte") ||
1776  (info.m_siStandard == "opencable"))
1777  {
1778  if (info.m_freqId.isEmpty())
1779  {
1780  info.m_chanNum = QString("%1-%2")
1781  .arg(info.m_sourceId)
1782  .arg(info.m_serviceId);
1783  }
1784  else
1785  {
1786  info.m_chanNum = QString("%1-%2")
1787  .arg(info.m_freqId)
1788  .arg(info.m_serviceId);
1789  }
1790  }
1791  }
1792 
1793  // Get IPTV channel numbers
1794  for (dbchan_it = pnum_to_dbchan.begin();
1795  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1796  {
1797  ChannelInsertInfo &info = *dbchan_it;
1798 
1799  if (!info.m_chanNum.isEmpty())
1800  continue;
1801 
1802  if (!iptv_channel.isEmpty())
1803  {
1804  info.m_chanNum = iptv_channel;
1805  if (info.m_serviceId)
1806  info.m_chanNum += "-" + QString::number(info.m_serviceId);
1807  }
1808  }
1809 
1810  // Check for decryption success
1811  for (dbchan_it = pnum_to_dbchan.begin();
1812  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1813  {
1814  uint pnum = dbchan_it.key();
1815  ChannelInsertInfo &info = *dbchan_it;
1816  info.m_decryptionStatus = scan_info->m_programEncryptionStatus[pnum];
1817  }
1818 
1819  return pnum_to_dbchan;
1820 }
1821 
1823 {
1824  ScanDTVTransportList list;
1825 
1826  uint cardid = m_channel->GetInputID();
1827 
1829  tuner_type = GuessDTVTunerType(tuner_type);
1830 
1831  for (const auto & it : qAsConst(m_channelList))
1832  {
1833  QMap<uint,ChannelInsertInfo> pnum_to_dbchan =
1834  GetChannelList(it.first, it.second);
1835 
1836  ScanDTVTransport item((*it.first).m_tuning, tuner_type, cardid);
1837  item.m_iptvTuning = (*(it.first)).m_iptvTuning;
1838  item.m_signalStrength = (*(it.first)).m_signalStrength;
1839  item.m_networkID = (*(it.first)).m_networkID;
1840  item.m_transportID = (*(it.first)).m_transportID;
1841 
1842  QMap<uint,ChannelInsertInfo>::iterator dbchan_it;
1843  for (dbchan_it = pnum_to_dbchan.begin();
1844  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1845  {
1846  item.m_channels.push_back(*dbchan_it);
1847  }
1848 
1849  if (!item.m_channels.empty())
1850  {
1851  if (addFullTS)
1852  {
1853  /* If addFullTS, then add a 'MPTS' channel
1854  which can be used to record the entire MPTS from
1855  the transport. */
1856  dbchan_it = pnum_to_dbchan.begin();
1857  ChannelInsertInfo info = *dbchan_it;
1858 
1859  // Use transport stream ID as (fake) service ID
1860  // to use in callsign and as channel number
1861  info.m_serviceId = info.m_sdtTsId ? info.m_sdtTsId : info.m_patTsId;
1862 
1863  if (tuner_type == DTVTunerType::kTunerTypeASI)
1864  {
1865  info.m_callSign = QString("MPTS_%1")
1866  .arg(CardUtil::GetDisplayName(cardid));
1867  }
1868  else if (info.m_siStandard == "mpeg" ||
1869  info.m_siStandard == "scte" ||
1870  info.m_siStandard == "opencable")
1871  {
1872  info.m_callSign = QString("MPTS_%1").arg(info.m_freqId);
1873  }
1874  else if (info.m_atscMajorChannel > 0)
1875  {
1876  if (info.m_atscMajorChannel < 0x3F0)
1877  {
1878  info.m_callSign = QString("MPTS_%1").arg(info.m_atscMajorChannel);
1879  }
1880  else
1881  {
1882  info.m_callSign = QString("MPTS_%1").arg(info.m_freqId);
1883  }
1884  }
1885  else if (info.m_serviceId > 0)
1886  {
1887  info.m_callSign = QString("MPTS_%1").arg(info.m_serviceId);
1888  }
1889  else if (!info.m_chanNum.isEmpty())
1890  {
1891  info.m_callSign = QString("MPTS_%1").arg(info.m_chanNum);
1892  }
1893  else
1894  {
1895  info.m_callSign = "MPTS_UNKNOWN";
1896  }
1897 
1898  info.m_serviceName = info.m_callSign;
1899  info.m_atscMinorChannel = 0;
1900  info.m_format = "MPTS";
1901  info.m_useOnAirGuide = false;
1902  info.m_isEncrypted = false;
1903  item.m_channels.push_back(info);
1904  }
1905 
1906  list.push_back(item);
1907  }
1908  }
1909 
1910  return list;
1911 }
1912 
1914 {
1915  return dynamic_cast<DTVSignalMonitor*>(m_signalMonitor);
1916 }
1917 
1919 {
1920 #ifdef USING_DVB
1921  return dynamic_cast<DVBSignalMonitor*>(m_signalMonitor);
1922 #else
1923  return nullptr;
1924 #endif
1925 }
1926 
1928 {
1929  return dynamic_cast<DTVChannel*>(m_channel);
1930 }
1931 
1933 {
1934  return dynamic_cast<const DTVChannel*>(m_channel);
1935 }
1936 
1938 {
1939 #ifdef USING_HDHOMERUN
1940  return dynamic_cast<HDHRChannel*>(m_channel);
1941 #else
1942  return nullptr;
1943 #endif
1944 }
1945 
1947 {
1948 #ifdef USING_DVB
1949  return dynamic_cast<DVBChannel*>(m_channel);
1950 #else
1951  return nullptr;
1952 #endif
1953 }
1954 
1956 {
1957 #ifdef USING_DVB
1958  return dynamic_cast<const DVBChannel*>(m_channel);
1959 #else
1960  return nullptr;
1961 #endif
1962 }
1963 
1965 {
1966 #ifdef USING_V4L2
1967  return dynamic_cast<V4LChannel*>(m_channel);
1968 #else
1969  return nullptr;
1970 #endif
1971 }
1972 
1977 {
1978  while (m_scannerThread)
1979  {
1980  m_threadExit = true;
1981  if (m_scannerThread->wait(1s))
1982  {
1983  delete m_scannerThread;
1984  m_scannerThread = nullptr;
1985  }
1986  }
1987  m_threadExit = false;
1988  m_scannerThread = new MThread("Scanner", this);
1990 }
1991 
1996 {
1997  LOG(VB_CHANSCAN, LOG_INFO, LOC + "run -- begin");
1998 
1999  while (!m_threadExit)
2000  {
2001  if (m_scanning)
2002  HandleActiveScan();
2003 
2004  usleep(10 * 1000);
2005  }
2006 
2007  LOG(VB_CHANSCAN, LOG_INFO, LOC + "run -- end");
2008 }
2009 
2010 // See if we have timed out
2012 {
2014  m_timer.hasExpired(kDecryptionTimeout))
2015  {
2017  return true;
2018  }
2019 
2020  if (!m_waitingForTables)
2021  return true;
2022 
2023 #ifdef USING_DVB
2024  // If the rotor is still moving, reset the timer and keep waiting
2026  if (sigmon)
2027  {
2028  const DiSEqCDevRotor *rotor = GetDVBChannel()->GetRotor();
2029  if (rotor)
2030  {
2031  bool was_moving = false;
2032  bool is_moving = false;
2033  sigmon->GetRotorStatus(was_moving, is_moving);
2034  if (was_moving && !is_moving)
2035  {
2036  m_timer.restart();
2037  return false;
2038  }
2039  }
2040  }
2041 #endif // USING_DVB
2042 
2043  // have the tables have timed out?
2044  if (m_timer.hasExpired(m_channelTimeout.count()))
2045  {
2046  // the channelTimeout alone is only valid if we have seen no tables..
2047  const ScanStreamData *sd = nullptr;
2048  if (GetDTVSignalMonitor())
2050 
2051  if (!sd)
2052  return true;
2053 
2054  if (sd->HasCachedAnyNIT() || sd->HasCachedAnySDTs())
2055  return m_timer.hasExpired(kDVBTableTimeout.count());
2056  if (sd->HasCachedMGT() || sd->HasCachedAnyVCTs())
2057  return m_timer.hasExpired(kATSCTableTimeout.count());
2058  if (sd->HasCachedAnyPAT() || sd->HasCachedAnyPMTs())
2059  return m_timer.hasExpired(kMPEGTableTimeout.count());
2060 
2061  return true;
2062  }
2063 
2064  // ok the tables haven't timed out, but have we hit the signal timeout?
2066  if (m_timer.hasExpired((*m_current).m_timeoutTune.count()) &&
2067  sm && !sm->HasSignalLock())
2068  {
2069  const ScanStreamData *sd = nullptr;
2070  if (GetDTVSignalMonitor())
2072 
2073  if (!sd)
2074  return true;
2075 
2076  // Just is case we temporarily lose the signal after we've seen
2077  // tables...
2078  if (!sd->HasCachedAnyPAT() && !sd->HasCachedAnyPMTs() &&
2079  !sd->HasCachedMGT() && !sd->HasCachedAnyVCTs() &&
2080  !sd->HasCachedAnyNIT() && !sd->HasCachedAnySDTs())
2081  {
2082  return true;
2083  }
2084  }
2085 
2086  return false;
2087 }
2088 
2093 {
2094  QMutexLocker locker(&m_lock);
2095 
2096  bool do_post_insertion = m_waitingForTables;
2097 
2098  if (!HasTimedOut())
2099  return;
2100 
2101  if (0 == m_nextIt.offset() && m_nextIt == m_scanTransports.begin())
2102  {
2103  m_channelList.clear();
2104  m_channelsFound = 0;
2105  m_dvbt2Tried = true;
2106  }
2107 
2109  {
2110  // If we failed to get a lock with DVB-T try DVB-T2.
2111  m_dvbt2Tried = true;
2113  return;
2114  }
2115 
2116  if (0 == m_nextIt.offset() && m_nextIt != m_scanTransports.begin())
2117  {
2118  // Add channel to scanned list and potentially check decryption
2119  if (do_post_insertion && !UpdateChannelInfo(false))
2120  return;
2121 
2122  // Stop signal monitor for previous transport
2123  locker.unlock();
2124  m_signalMonitor->Stop();
2125  locker.relock();
2126  }
2127 
2128  m_current = m_nextIt; // Increment current
2129  m_dvbt2Tried = false;
2130 
2131  if (m_current != m_scanTransports.end())
2132  {
2134 
2135  // Increment nextIt
2136  m_nextIt = m_current;
2137  ++m_nextIt;
2138  }
2139  else if (!m_extendTransports.isEmpty())
2140  {
2141  --m_current;
2142  QMap<uint32_t,DTVMultiplex>::iterator it = m_extendTransports.begin();
2143  while (it != m_extendTransports.end())
2144  {
2145  if (!m_tsScanned.contains(it.key()))
2146  {
2147  QString name = QString("TransportID %1").arg(it.key() & 0xffff);
2148  TransportScanItem item(m_sourceID, name, *it, m_signalTimeout);
2149  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Adding " + name + ' ' + item.m_tuning.toString());
2150  m_scanTransports.push_back(item);
2151  m_tsScanned.insert(it.key());
2152  }
2153  ++it;
2154  }
2155  m_extendTransports.clear();
2156  m_nextIt = m_current;
2157  ++m_nextIt;
2158  }
2159  else
2160  {
2162  m_scanning = false;
2164  }
2165 }
2166 
2168 {
2169  const TransportScanItem &item = *transport;
2170 
2171 #ifdef USING_DVB
2173  if (monitor)
2174  {
2175  // always wait for rotor to finish
2177  monitor->SetRotorTarget(1.0F);
2178  }
2179 #endif // USING_DVB
2180 
2181  DTVChannel *channel = GetDTVChannel();
2182  if (!channel)
2183  return false;
2184 
2185  if (item.m_mplexid > 0 && transport.offset() == 0)
2186  return channel->TuneMultiplex(item.m_mplexid, m_inputName);
2187 
2188  if (item.m_tuning.m_sistandard == "MPEG")
2189  {
2190  IPTVTuningData tuning = item.m_iptvTuning;
2191  if (tuning.GetProtocol() == IPTVTuningData::inValid)
2192  tuning.GuessProtocol();
2193  return channel->Tune(tuning, true);
2194  }
2195 
2196  const uint64_t freq = item.freq_offset(transport.offset());
2197  DTVMultiplex tuning = item.m_tuning;
2198  tuning.m_frequency = freq;
2199 
2201  {
2203  }
2205  {
2206  if (m_dvbt2Tried)
2208  else
2210  }
2211 
2212  return channel->Tune(tuning);
2213 }
2214 
2216 {
2217  QString offset_str = (transport.offset()) ?
2218  QObject::tr(" offset %2").arg(transport.offset()) : "";
2219  QString cur_chan = QString("%1%2")
2220  .arg((*m_current).m_friendlyName, offset_str);
2221  QString tune_msg_str =
2222  QObject::tr("ScanTransport Tuning to %1 mplexid(%2)")
2223  .arg(cur_chan).arg((*m_current).m_mplexid);
2224 
2225  const TransportScanItem &item = *transport;
2226 
2227  if (transport.offset() &&
2228  (item.freq_offset(transport.offset()) == item.freq_offset(0)))
2229  {
2230  m_waitingForTables = false;
2231  return; // nothing to do
2232  }
2233 
2234  if (m_channelsFound)
2235  {
2236  QString progress = QObject::tr("Found %n", "", m_channelsFound);
2238  }
2239 
2241  LOG(VB_CHANSCAN, LOG_INFO, LOC + tune_msg_str);
2242 
2243  if (!Tune(transport))
2244  { // If we did not tune successfully, bail with message
2246  LOG(VB_CHANSCAN, LOG_ERR, LOC +
2247  QString("Failed to tune %1 mplexid(%2) at offset %3")
2248  .arg(item.m_friendlyName).arg(item.m_mplexid)
2249  .arg(transport.offset()));
2250  return;
2251  }
2252 
2253  // If we have a DTV Signal Monitor, perform table scanner reset
2254  if (GetDTVSignalMonitor() && GetDTVSignalMonitor()->GetScanStreamData())
2255  {
2257  GetDTVSignalMonitor()->SetChannel(-1,-1);
2258  GetDTVSignalMonitor()->SetDVBService(0, 0, -1);
2259  }
2260 
2261  // Start signal monitor for this channel
2262  if (m_signalMonitor)
2264 
2265  m_timer.start();
2266  m_waitingForTables = (item.m_tuning.m_sistandard != "analog");
2267 }
2268 
2274 {
2275  LOG(VB_CHANSCAN, LOG_INFO, LOC + "StopScanner");
2276 
2277  while (m_scannerThread)
2278  {
2279  m_threadExit = true;
2280  if (m_scannerThread->wait(1s))
2281  {
2282  delete m_scannerThread;
2283  m_scannerThread = nullptr;
2284  }
2285  }
2286 
2287  if (m_signalMonitor)
2288  m_signalMonitor->Stop();
2289 }
2290 
2296  int SourceID,
2297  const QString &std,
2298  const QString &modulation,
2299  const QString &country,
2300  const QString &table_start,
2301  const QString &table_end)
2302 {
2303  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
2304  QString("%1:%2 ").arg(__FUNCTION__).arg(__LINE__) +
2305  QString("SourceID:%1 ").arg(SourceID) +
2306  QString("std:%1 ").arg(std) +
2307  QString("modulation:%1 ").arg(modulation) +
2308  QString("country:%1 ").arg(country) +
2309  QString("table_start:%1 ").arg(table_start) +
2310  QString("table_end:%1 ").arg(table_end));
2311 
2312  QString name("");
2313  if (m_scanning)
2314  return false;
2315 
2316  m_scanTransports.clear();
2317  m_nextIt = m_scanTransports.end();
2318 
2319  freq_table_list_t tables =
2320  get_matching_freq_tables(std, modulation, country);
2321 
2322  if (tables.empty())
2323  {
2324  QString msg = QString("No freq table for (%1, %2, %3) found")
2325  .arg(std, modulation, country);
2327  }
2328  LOG(VB_CHANSCAN, LOG_INFO, LOC +
2329  QString("Looked up freq table (%1, %2, %3) w/%4 entries")
2330  .arg(std, modulation, country, QString::number(tables.size())));
2331 
2332  QString start = table_start;
2333  const QString& end = table_end;
2334  // NOLINTNEXTLINE(modernize-loop-convert)
2335  for (auto it = tables.begin(); it != tables.end(); ++it)
2336  {
2337  const FrequencyTable &ft = **it;
2338  int name_num = ft.m_nameOffset;
2339  QString strNameFormat = ft.m_nameFormat;
2340  uint freq = ft.m_frequencyStart;
2341  while (freq <= ft.m_frequencyEnd)
2342  {
2343  name = strNameFormat;
2344  if (strNameFormat.indexOf("%") >= 0)
2345  name = strNameFormat.arg(name_num);
2346 
2347  if (start.isEmpty() || name == start)
2348  {
2349  start.clear();
2350 
2351  TransportScanItem item(SourceID, std, name, name_num,
2352  freq, ft, m_signalTimeout);
2353  m_scanTransports.push_back(item);
2354 
2355  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanTransports " +
2356  item.toString());
2357  }
2358 
2359  ++name_num;
2360  freq += ft.m_frequencyStep;
2361 
2362  if (!end.isEmpty() && name == end)
2363  break;
2364  }
2365  if (!end.isEmpty() && name == end)
2366  break;
2367  }
2368 
2369  while (!tables.empty())
2370  {
2371  delete tables.back();
2372  tables.pop_back();
2373  }
2374 
2375  m_extendScanList = true;
2376  m_timer.start();
2377  m_waitingForTables = false;
2378 
2379  m_nextIt = m_scanTransports.begin();
2380  m_transportsScanned = 0;
2381  m_scanning = true;
2382 
2383  return true;
2384 }
2385 
2387  const QString &std,
2388  const QString &cardtype,
2389  const DTVChannelList &channels)
2390 {
2391  m_scanTransports.clear();
2392  m_nextIt = m_scanTransports.end();
2393 
2394  DTVTunerType tunertype;
2395  tunertype.Parse(cardtype);
2396 
2397  auto it = channels.cbegin();
2398  for (uint i = 0; it != channels.cend(); ++it, ++i)
2399  {
2400  DTVTransport tmp = *it;
2401  tmp.m_sistandard = std;
2402  TransportScanItem item(sourceid, QString::number(i),
2403  tunertype, tmp, m_signalTimeout);
2404 
2405  m_scanTransports.push_back(item);
2406 
2407  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanForChannels " + item.toString());
2408  }
2409 
2410  if (m_scanTransports.empty())
2411  {
2412  LOG(VB_GENERAL, LOG_ERR, LOC + "ScanForChannels() no transports");
2413  return false;
2414  }
2415 
2416  m_timer.start();
2417  m_waitingForTables = false;
2418 
2419  m_nextIt = m_scanTransports.begin();
2420  m_transportsScanned = 0;
2421  m_scanning = true;
2422 
2423  return true;
2424 }
2425 
2427  const fbox_chan_map_t &iptv_channels)
2428 {
2429  m_scanTransports.clear();
2430  m_nextIt = m_scanTransports.end();
2431 
2432  fbox_chan_map_t::const_iterator Ichan = iptv_channels.begin();
2433  for (uint idx = 0; Ichan != iptv_channels.end(); ++Ichan, ++idx)
2434  {
2435  TransportScanItem item(sourceid, QString::number(idx),
2436  Ichan.value().m_tuning, Ichan.key(),
2437  m_signalTimeout);
2438 
2439  m_scanTransports.push_back(item);
2440 
2441  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanIPTVChannels " + item.toString());
2442  }
2443 
2444  if (m_scanTransports.empty())
2445  {
2446  LOG(VB_GENERAL, LOG_ERR, LOC + "ScanIPTVChannels() no transports");
2447  return false;
2448  }
2449 
2450  m_timer.start();
2451  m_waitingForTables = false;
2452 
2453  m_nextIt = m_scanTransports.begin();
2454  m_transportsScanned = 0;
2455  m_scanning = true;
2456 
2457  return true;
2458 }
2459 
2460 
2466  int sourceid, const QMap<QString,QString> &startChan)
2467 {
2468  if (startChan.find("std") == startChan.end() ||
2469  startChan.find("type") == startChan.end())
2470  {
2471  return false;
2472  }
2473 
2474  QString std = *startChan.find("std");
2475  QString si_std = (std.toLower() != "atsc") ? "dvb" : "atsc";
2476  bool ok = false;
2477 
2478  if (m_scanning)
2479  return false;
2480 
2481  m_scanTransports.clear();
2482  m_nextIt = m_scanTransports.end();
2483 
2484  DTVMultiplex tuning;
2485 
2487  ok = type.Parse(startChan["type"]);
2488 
2489  if (ok)
2490  {
2491  ok = tuning.ParseTuningParams(
2492  type,
2493  startChan["frequency"], startChan["inversion"],
2494  startChan["symbolrate"], startChan["fec"],
2495  startChan["polarity"],
2496  startChan["coderate_hp"], startChan["coderate_lp"],
2497  startChan["constellation"], startChan["trans_mode"],
2498  startChan["guard_interval"], startChan["hierarchy"],
2499  startChan["modulation"], startChan["bandwidth"],
2500  startChan["mod_sys"], startChan["rolloff"]);
2501  }
2502 
2503  if (ok)
2504  {
2505  tuning.m_sistandard = si_std;
2506  TransportScanItem item(
2507  sourceid, QObject::tr("Frequency %1").arg(startChan["frequency"]),
2508  tuning, m_signalTimeout);
2509  m_scanTransports.push_back(item);
2510  }
2511 
2512  if (!ok)
2513  return false;
2514 
2515  m_extendScanList = true;
2516 
2517  m_timer.start();
2518  m_waitingForTables = false;
2519 
2520  m_nextIt = m_scanTransports.begin();
2521  m_transportsScanned = 0;
2522  m_scanning = true;
2523 
2524  return true;
2525 }
2526 
2528 {
2529  MSqlQuery query(MSqlQuery::InitCon());
2530  query.prepare(
2531  "SELECT sourceid, sistandard, transportid, frequency, modulation, mod_sys "
2532  "FROM dtv_multiplex "
2533  "WHERE mplexid = :MPLEXID");
2534  query.bindValue(":MPLEXID", mplexid);
2535  if (!query.exec())
2536  {
2537  MythDB::DBError("ChannelScanSM::AddToList()", query);
2538  return false;
2539  }
2540 
2541  if (!query.next())
2542  {
2543  LOG(VB_GENERAL, LOG_ERR, LOC + "AddToList() " +
2544  QString("Failed to locate mplexid(%1) in DB").arg(mplexid));
2545  return false;
2546  }
2547 
2548  uint sourceid = query.value(0).toUInt();
2549  QString sistandard = query.value(1).toString();
2550  uint tsid = query.value(2).toUInt();
2551  uint frequency = query.value(3).toUInt();
2552  QString modulation = query.value(4).toString();
2553  QString mod_sys = query.value(5).toString();
2554  DTVModulationSystem delsys;
2555  delsys.Parse(mod_sys);
2557  QString fn = (tsid) ? QString("Transport ID %1").arg(tsid) :
2558  QString("Multiplex #%1").arg(mplexid);
2559 
2560  if (modulation == "8vsb")
2561  {
2562  QString chan = QString("%1 Hz").arg(frequency);
2563  int findFrequency = (query.value(3).toInt() / 1000) - 1750;
2564  for (const auto & list : gChanLists[0].list)
2565  {
2566  if ((list.freq <= findFrequency + 200) &&
2567  (list.freq >= findFrequency - 200))
2568  {
2569  chan = QString("%1").arg(list.name);
2570  }
2571  }
2572  fn = QObject::tr("ATSC Channel %1").arg(chan);
2574  }
2575 
2576  tt = GuessDTVTunerType(tt);
2577 
2578  TransportScanItem item(sourceid, sistandard, fn, mplexid, m_signalTimeout);
2579 
2580  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
2581  QString("tunertype:%1 %2 sourceid:%3 sistandard:%4 fn:'%5' mplexid:%6")
2582  .arg(tt).arg(tt.toString()).arg(sourceid).arg(sistandard, fn).arg(mplexid));
2583 
2584  if (item.m_tuning.FillFromDB(tt, mplexid))
2585  {
2586  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Adding " + fn);
2587  m_scanTransports.push_back(item);
2588  return true;
2589  }
2590 
2591  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Not adding incomplete transport " + fn);
2592  return false;
2593 }
2594 
2595 bool ChannelScanSM::ScanTransport(uint mplexid, bool follow_nit)
2596 {
2597  m_scanTransports.clear();
2598  m_nextIt = m_scanTransports.end();
2599 
2600  AddToList(mplexid);
2601 
2602  m_timer.start();
2603  m_waitingForTables = false;
2604 
2605  m_extendScanList = follow_nit;
2606  m_transportsScanned = 0;
2607  if (!m_scanTransports.empty())
2608  {
2609  m_nextIt = m_scanTransports.begin();
2610  m_scanning = true;
2611  return true;
2612  }
2613 
2614  return false;
2615 }
2616 
2617 bool ChannelScanSM::ScanCurrentTransport(const QString &sistandard)
2618 {
2619  m_scanTransports.clear();
2620  m_nextIt = m_scanTransports.end();
2621 
2622  m_signalTimeout = 30s;
2623  QString name;
2624  TransportScanItem item(m_sourceID, sistandard, name, 0, m_signalTimeout);
2625  m_scanTransports.push_back(item);
2626 
2627  m_timer.start();
2628  m_waitingForTables = false;
2629  m_extendScanList = false;
2630  m_transportsScanned = 0;
2631  m_nextIt = m_scanTransports.begin();
2632  m_scanning = true;
2633  return true;
2634 }
2635 
2640  const DTVChannelInfoList &channels,
2641  uint mpeg_program_num,
2642  QString &service_name,
2643  QString &callsign,
2644  QString &common_status_info)
2645 {
2646  if (channels.empty())
2647  return true;
2648 
2649  bool found = false;
2650  for (const auto & channel : channels)
2651  {
2652  LOG(VB_GENERAL, LOG_DEBUG, LOC +
2653  QString("comparing %1 %2 against %3 %4")
2654  .arg(channel.m_serviceid).arg(channel.m_name)
2655  .arg(mpeg_program_num).arg(common_status_info));
2656 
2657  if (channel.m_serviceid == mpeg_program_num)
2658  {
2659  found = true;
2660  if (!channel.m_name.isEmpty())
2661  {
2662  service_name = channel.m_name;
2663  callsign = channel.m_name;
2664  }
2665  }
2666  }
2667 
2668  if (found)
2669  {
2670  common_status_info += QString(" %1 %2")
2671  .arg(QObject::tr("as"), service_name);
2672  }
2673  else
2674  {
2676  QObject::tr("Skipping %1, not in imported channel map")
2677  .arg(common_status_info));
2678  }
2679 
2680  return found;
2681 }
ServiceRelocatedDescriptor
Definition: dvbdescriptors.h:1440
NetworkInformationTable::TransportDescriptorsLength
uint TransportDescriptorsLength(uint i) const
trans_desc_length 12 4.4+p
Definition: dvbtables.h:85
ChannelInsertInfo::m_isEncrypted
bool m_isEncrypted
Definition: channelinfo.h:247
DTVMultiplex::m_frequency
uint64_t m_frequency
Definition: dtvmultiplex.h:94
DTVChannel::GetTunerTypes
virtual std::vector< DTVTunerType > GetTunerTypes(void) const
Returns a vector of supported tuning types.
Definition: dtvchannel.cpp:78
ScannedChannelInfo::m_mgt
const MasterGuideTable * m_mgt
Definition: channelscan_sm.cpp:113
TransportScanItem::m_tuning
DTVMultiplex m_tuning
Definition: frequencytables.h:184
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:212
pat_vec_t
std::vector< const ProgramAssociationTable * > pat_vec_t
Definition: mpegstreamdata.h:30
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:802
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:124
ProgramAssociationTable::ProgramPID
uint ProgramPID(uint i) const
Definition: mpegtables.h:646
VirtualChannelTable
This table contains information about the channels transmitted on this multiplex.
Definition: atsctables.h:192
kEncUnknown
@ kEncUnknown
Definition: mpegstreamdata.h:56
DTVMultiplex
Definition: dtvmultiplex.h:24
DTVSignalMonitor::AddFlags
void AddFlags(uint64_t _flags) override
Definition: dtvsignalmonitor.cpp:140
MPEGStreamData::GetCachedPATs
pat_vec_t GetCachedPATs(uint tsid) const
Definition: mpegstreamdata.cpp:1345
transport_scan_items_it_t::offset
uint offset() const
Definition: frequencytables.h:254
DVBStreamData::GetCachedBATs
bat_vec_t GetCachedBATs(bool current=true) const
Definition: dvbstreamdata.cpp:843
kEncEncrypted
@ kEncEncrypted
Definition: mpegstreamdata.h:58
DescriptorID::service_list
@ service_list
Definition: mpegdescriptors.h:73
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:286
DVBStreamData::GetCachedSDTs
sdt_vec_t GetCachedSDTs(bool current=true) const
Definition: dvbstreamdata.cpp:910
ChannelInsertInfo::m_oldOrigNetId
uint m_oldOrigNetId
Definition: channelinfo.h:255
ChannelScanSM::HandleSDT
void HandleSDT(uint tsid, const ServiceDescriptionTable *sdt) override
Definition: channelscan_sm.cpp:459
VirtualChannelTable::IsAccessControlled
bool IsAccessControlled(uint i) const
Definition: atsctables.h:279
CardUtil::GetDisplayName
static QString GetDisplayName(uint inputid)
Definition: cardutil.cpp:1724
ChannelInsertInfo::m_useOnAirGuide
bool m_useOnAirGuide
Definition: channelinfo.h:223
MPEGDescriptor::DescriptorTag
uint DescriptorTag(void) const
Definition: mpegdescriptors.h:345
DTVTunerType::kTunerTypeDVBC
static const int kTunerTypeDVBC
Definition: dtvconfparserhelpers.h:95
ChannelInsertInfo::m_hiddenInGuide
bool m_hiddenInGuide
Definition: channelinfo.h:225
ScannedChannelInfo::m_sdts
sdt_map_t m_sdts
Definition: channelscan_sm.cpp:119
DVBStreamData::HasCachedAnySDTs
bool HasCachedAnySDTs(bool current=true) const
Definition: dvbstreamdata.cpp:764
NetworkInformationTable::TSID
uint TSID(uint i) const
transport_stream_id 16 0.0+p
Definition: dvbtables.h:79
FrequencyTable
Definition: frequencytables.h:38
ChannelInsertInfo::m_chanNum
QString m_chanNum
Definition: channelinfo.h:218
DTVSignalMonitor::SetDVBService
void SetDVBService(uint network_id, uint transport_id, int service_id)
Definition: dtvsignalmonitor.cpp:229
DVBChannel::GetRotor
const DiSEqCDevRotor * GetRotor(void) const
Returns rotor object if it exists, nullptr otherwise.
Definition: dvbchannel.cpp:1157
ChannelScanSM::HandleSDTo
void HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt) override
Definition: channelscan_sm.cpp:576
DiSEqCDevRotor
Rotor class.
Definition: diseqc.h:302
ChannelInsertInfo::m_atscMajorChannel
uint m_atscMajorChannel
Definition: channelinfo.h:221
ChannelScanSM::m_tsScanned
QSet< uint32_t > m_tsScanned
Definition: channelscan_sm.h:241
DVBStreamData::HasCachedAllBATs
bool HasCachedAllBATs(bool current=true) const
Definition: dvbstreamdata.cpp:691
mythdb.h
ChannelScanSM::m_scannerThread
MThread * m_scannerThread
Definition: channelscan_sm.h:261
cvct_vec_t
std::vector< const CableVirtualChannelTable * > cvct_vec_t
Definition: atscstreamdata.h:16
ChannelInsertInfo::m_inNit
bool m_inNit
Definition: channelinfo.h:245
freq_table_list_t
std::vector< const FrequencyTable * > freq_table_list_t
Definition: frequencytables.h:25
FreesatLCNDescriptor
Freesat Logical Channel Number descriptor.
Definition: dvbdescriptors.h:2624
ScanStreamData::Reset
void Reset(void) override
Definition: scanstreamdata.cpp:58
LOC
#define LOC
Definition: channelscan_sm.cpp:87
DescriptorID::s2_satellite_delivery_system
@ s2_satellite_delivery_system
Definition: mpegdescriptors.h:132
ChannelScanSM::m_lock
QMutex m_lock
The big lock.
Definition: channelscan_sm.h:231
ScanDTVTransport::m_transportID
uint m_transportID
Definition: dtvmultiplex.h:140
NetworkInformationTable::NetworkID
uint NetworkID(void) const
network_id 16 3.0 0x0000
Definition: dvbtables.h:59
ChannelInsertInfo::m_freqId
QString m_freqId
Definition: channelinfo.h:227
ATSCStreamData::HasCachedAllCVCTs
bool HasCachedAllCVCTs(bool current=true) const
Definition: atscstreamdata.cpp:722
ScannedChannelInfo::m_pmts
pmt_vec_t m_pmts
Definition: channelscan_sm.cpp:109
DTVSignalMonitor::GetScanStreamData
ScanStreamData * GetScanStreamData()
Returns the scan stream data if it exists.
Definition: dtvsignalmonitor.cpp:544
ChannelScanSM::kMPEGTableTimeout
static const std::chrono::milliseconds kMPEGTableTimeout
No logic here, lets just wait at least 15 seconds.
Definition: channelscan_sm.h:203
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:303
ChannelInsertInfo::m_isDataService
bool m_isDataService
Definition: channelinfo.h:248
DTVTunerType::kTunerTypeDVBS1
static const int kTunerTypeDVBS1
Definition: dtvconfparserhelpers.h:93
ChannelInsertInfo::m_origNetId
uint m_origNetId
Definition: channelinfo.h:238
DescriptorID::extension
@ extension
Definition: mpegdescriptors.h:138
ATSCStreamData::HasCachedMGT
bool HasCachedMGT(bool current=true) const
Definition: atscstreamdata.cpp:626
BouquetAssociationTable::BouquetID
uint BouquetID() const
Definition: dvbtables.h:205
NetworkInformationTable::TransportDescriptors
const unsigned char * TransportDescriptors(uint i) const
for(j=0;j<N;j++) x 6.0+p { descriptor() }
Definition: dvbtables.h:89
ChannelScanSM::m_current
transport_scan_items_it_t m_current
Definition: channelscan_sm.h:244
DTVMultiplex::FillFromDeliverySystemDesc
bool FillFromDeliverySystemDesc(DTVTunerType type, const MPEGDescriptor &desc)
Definition: dtvmultiplex.cpp:465
BouquetAssociationTable::TransportDescriptors
const unsigned char * TransportDescriptors(uint i) const
for(j=0;j<N;j++) x 6.0+p { descriptor() }
Definition: dvbtables.h:241
pat_map_t
QMap< uint, pat_vec_t > pat_map_t
Definition: mpegstreamdata.h:31
ATSCStreamData::GetCachedCVCTs
cvct_vec_t GetCachedCVCTs(bool current=true) const
Definition: atscstreamdata.cpp:840
FrequencyTable::m_nameFormat
QString m_nameFormat
Definition: frequencytables.h:98
tvct_vec_t
std::vector< const TerrestrialVirtualChannelTable * > tvct_vec_t
Definition: atscstreamdata.h:15
hardwareprofile.devicelist.cat
def cat(file_name)
Definition: devicelist.py:95
freq
static const std::array< const uint32_t, 4 > freq
Definition: element.cpp:45
SourceUtil::GetMplexIDs
static std::vector< uint > GetMplexIDs(uint sourceid)
Definition: sourceutil.cpp:145
PrivateDescriptorID::dvb_simulcast_channel_descriptor
@ dvb_simulcast_channel_descriptor
Definition: mpegdescriptors.h:207
BouquetAssociationTable::TransportDescriptorsLength
uint TransportDescriptorsLength(uint i) const
Definition: dvbtables.h:237
ProgramMapTable
A PMT table maps a program described in the ProgramAssociationTable to various PID's which describe t...
Definition: mpegtables.h:692
channelscan_sm.h
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:71
ChannelScanSM::m_scanning
bool m_scanning
Definition: channelscan_sm.h:234
frequencies.h
kATSCChannelFormat
static const QString kATSCChannelFormat
Definition: channelscan_sm.cpp:91
ScanMonitor::ScanPercentComplete
void ScanPercentComplete(int pct)
Definition: scanmonitor.cpp:103
DVBSignalMonitor
Definition: dvbsignalmonitor.h:17
SignalMonitor::kDTVSigMon_WaitForMGT
static const uint64_t kDTVSigMon_WaitForMGT
Definition: signalmonitor.h:185
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:201
DVBSignalMonitor::SetRotorTarget
void SetRotorTarget(float target) override
Sets rotor target pos from 0.0 to 1.0.
Definition: dvbsignalmonitor.cpp:137
mythdbcon.h
ServiceDescriptionTable::ServiceID
uint ServiceID(uint i) const
service_id 16 0.0+p
Definition: dvbtables.h:150
ServiceDescriptor::IsDTV
bool IsDTV(void) const
Definition: dvbdescriptors.h:2077
ChannelScanSM::GetHDHRChannel
HDHRChannel * GetHDHRChannel(void)
Definition: channelscan_sm.cpp:1937
ChannelScanSM::m_currentTestingDecryption
bool m_currentTestingDecryption
Definition: channelscan_sm.h:246
ChannelInsertInfo::m_defaultAuthority
QString m_defaultAuthority
Definition: channelinfo.h:231
CableDeliverySystemDescriptor
Definition: dvbdescriptors.h:739
scanwizardconfig.h
DTVSignalMonitor::GetStreamData
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
Definition: dtvsignalmonitor.h:59
SignalMonitor::GetSignalStrength
int GetSignalStrength(void)
Definition: signalmonitor.h:75
ScannedChannelInfo::m_bats
bat_vec_t m_bats
Definition: channelscan_sm.cpp:120
VirtualChannelTable::ShortChannelName
QString ShortChannelName(uint i) const
Definition: atsctables.h:228
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
ChannelScanSM::m_scanTransports
transport_scan_items_t m_scanTransports
Definition: channelscan_sm.h:243
ChannelScanSM::SetAnalog
void SetAnalog(bool is_analog)
Definition: channelscan_sm.cpp:248
ChannelInsertInfo::m_hidden
bool m_hidden
Definition: channelinfo.h:224
ProgramMapTable::ProgramNumber
uint ProgramNumber(void) const
Definition: mpegtables.h:729
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
ChannelScanSM::m_nitId
uint m_nitId
Definition: channelscan_sm.h:224
SourceID
Definition: videosource.cpp:2874
ScanDTVTransport::m_networkID
uint m_networkID
Definition: dtvmultiplex.h:139
OriginalNetworkID::TELENOR
@ TELENOR
Definition: mpegdescriptors.h:294
ChannelScanSM::m_otherTableTimeout
std::chrono::milliseconds m_otherTableTimeout
Definition: channelscan_sm.h:213
TransportScanItem::m_iptvTuning
IPTVTuningData m_iptvTuning
Definition: frequencytables.h:185
DVBLogicalChannelDescriptor
DVB Logical Channel Descriptor.
Definition: dvbdescriptors.h:2566
ChannelScanSM::m_dvbt2Tried
bool m_dvbt2Tried
Definition: channelscan_sm.h:250
TransportScanItem::m_signalStrength
int m_signalStrength
Definition: frequencytables.h:192
ChannelScanSM::Tune
bool Tune(transport_scan_items_it_t transport)
Definition: channelscan_sm.cpp:2167
ChannelScanSM::run
void run(void) override
This runs the event loop for ChannelScanSM until 'threadExit' is true.
Definition: channelscan_sm.cpp:1995
RegistrationDescriptor
Definition: mpegdescriptors.h:429
CableDeliverySystemDescriptor::FrequencyHz
unsigned long long FrequencyHz(void) const
Definition: dvbdescriptors.h:754
ChannelScanSM::m_signalTimeout
std::chrono::milliseconds m_signalTimeout
Definition: channelscan_sm.h:211
ProgramAssociationTable::ProgramCount
uint ProgramCount(void) const
Definition: mpegtables.h:636
ChannelInsertInfo::m_isAudioService
bool m_isAudioService
Definition: channelinfo.h:249
bat_vec_t
std::vector< const BouquetAssociationTable * > bat_vec_t
Definition: dvbstreamdata.h:23
DTVChannel::Tune
virtual bool Tune(const DTVMultiplex &tuning)=0
This performs the actual frequency tuning and in some cases input switching.
ScannedChannelInfo
Definition: channelscan_sm.cpp:93
DVBChannel::SetPMT
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
Definition: dvbchannel.cpp:725
VirtualChannelTable::ProgramNumber
uint ProgramNumber(uint i) const
Definition: atsctables.h:269
ScanStreamData
Definition: scanstreamdata.h:10
ProgramMapTable::IsEncrypted
bool IsEncrypted(const QString &sistandard) const
Returns true iff PMT contains CA descriptor for a vid/aud stream.
Definition: mpegtables.cpp:551
VirtualChannelTable::IsHiddenInGuide
bool IsHiddenInGuide(uint i) const
Definition: atsctables.h:290
PCM_INFO_INIT
#define PCM_INFO_INIT(SISTD)
Definition: channelscan_sm.cpp:1160
VirtualChannelTable::toString
QString toString(void) const override
Definition: atsctables.cpp:200
ChannelUtil::CreateChannel
static bool CreateChannel(uint db_mplexid, uint db_sourceid, uint new_channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, ChannelVisibleType visible, const QString &freqid, const QString &icon=QString(), QString format="Default", const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0)
Definition: channelutil.cpp:1480
ChannelUtil::GetUnknownCallsign
static QString GetUnknownCallsign(void)
Definition: channelutil.cpp:1303
PID::SCTE_PSIP_PID
@ SCTE_PSIP_PID
Definition: mpegtables.h:237
ChannelScanSM::m_sourceID
int m_sourceID
Definition: channelscan_sm.h:210
sdt_map_t
QMap< uint, sdt_vec_t > sdt_map_t
Definition: dvbstreamdata.h:19
BouquetAssociationTable::TSID
uint TSID(uint i) const
Definition: dvbtables.h:231
ATSCStreamData::HasCachedAllTVCTs
bool HasCachedAllTVCTs(bool current=true) const
Definition: atscstreamdata.cpp:691
ChannelScanSM::m_bouquetId
uint m_bouquetId
Definition: channelscan_sm.h:222
ScannedChannelInfo::ScannedChannelInfo
ScannedChannelInfo()=default
ChannelScanSM::m_scanMonitor
ScanMonitor * m_scanMonitor
Definition: channelscan_sm.h:207
DVBSimulcastChannelDescriptor::ChannelNumber
uint ChannelNumber(uint i) const
Definition: dvbdescriptors.h:2608
RegistrationDescriptor::FormatIdentifierString
QString FormatIdentifierString(void) const
Definition: mpegdescriptors.h:443
PSIPTable::Section
uint Section(void) const
Definition: mpegtables.h:548
FreesatLCNDescriptor::LCNCount
uint LCNCount(int i) const
Definition: dvbdescriptors.h:2665
DTVMultiplex::FillFromDB
virtual bool FillFromDB(DTVTunerType type, uint mplexid)
Definition: dtvmultiplex.cpp:417
dvbchannel.h
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
TerrestrialDeliverySystemDescriptor
Definition: dvbdescriptors.h:927
ChannelScanSM::StopScanner
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
Definition: channelscan_sm.cpp:2273
DescriptorID::cable_delivery_system
@ cable_delivery_system
Definition: mpegdescriptors.h:76
DVBSignalMonitor::GetRotorStatus
void GetRotorStatus(bool &was_moving, bool &is_moving) override
Definition: dvbsignalmonitor.cpp:143
ChannelScanSM::m_otherTableTime
std::chrono::milliseconds m_otherTableTime
Definition: channelscan_sm.h:214
HDHRChannel
Definition: hdhrchannel.h:20
VirtualChannelTable::IsHidden
bool IsHidden(uint i) const
Definition: atsctables.h:284
DescriptorID::t2_delivery_system
@ t2_delivery_system
Definition: mpegdescriptors.h:144
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
ChannelScanSM::m_extendScanList
bool m_extendScanList
Definition: channelscan_sm.h:218
OriginalNetworkID::BBC
@ BBC
Definition: mpegdescriptors.h:293
PrivateDataSpecifierID::BSB1
@ BSB1
Definition: mpegdescriptors.h:270
DTVModulationSystem::kModulationSystem_UNDEFINED
@ kModulationSystem_UNDEFINED
Definition: dtvconfparserhelpers.h:656
ChannelInsertInfo::m_atscMinorChannel
uint m_atscMinorChannel
Definition: channelinfo.h:222
ChannelScanSM::ScanTransports
bool ScanTransports(int SourceID, const QString &std, const QString &mod, const QString &country, const QString &table_start=QString(), const QString &table_end=QString())
Generates a list of frequencies to scan and adds it to the scanTransport list, and then sets the scan...
Definition: channelscan_sm.cpp:2295
MPEGStreamData::ReturnCachedPATTables
virtual void ReturnCachedPATTables(pat_vec_t &pats) const
Definition: mpegstreamdata.cpp:1475
ChannelInsertInfo
Definition: channelinfo.h:133
DTVTunerType
Definition: dtvconfparserhelpers.h:76
VirtualChannelTable::ChannelTransportStreamID
uint ChannelTransportStreamID(uint i) const
Definition: atsctables.h:264
MPEGDescriptor::FindExtension
static const unsigned char * FindExtension(const desc_list_t &parsed, uint desc_tag)
Definition: mpegdescriptors.cpp:86
ChannelScanSM::GetV4LChannel
V4LChannel * GetV4LChannel(void)
Definition: channelscan_sm.cpp:1964
DescriptorID::terrestrial_delivery_system
@ terrestrial_delivery_system
Definition: mpegdescriptors.h:99
FrequencyTable::m_frequencyStep
uint m_frequencyStep
Definition: frequencytables.h:102
MPEGStreamData::HasCachedAllPMTs
bool HasCachedAllPMTs(void) const
Definition: mpegstreamdata.cpp:1303
pmt_vec_t
std::vector< const ProgramMapTable * > pmt_vec_t
Definition: channelscan_sm.h:63
ChannelScanSM::m_mutex
QMutex m_mutex
Definition: channelscan_sm.h:264
MPEGDescriptor::IsValid
bool IsValid(void) const
Definition: mpegdescriptors.h:342
ChannelScanSM::kDVBTableTimeout
static const std::chrono::milliseconds kDVBTableTimeout
SDT's should be sent every 2 seconds and NIT's every 10 seconds, so lets wait at least 30 seconds,...
Definition: channelscan_sm.h:201
VirtualChannelTable::MajorChannel
uint MajorChannel(uint i) const
Definition: atsctables.h:247
ChannelScanSM::m_setOtherTables
bool m_setOtherTables
Definition: channelscan_sm.h:215
OriginalNetworkID::SES2
@ SES2
Definition: mpegdescriptors.h:292
ChannelScanSM::StartScanner
void StartScanner(void)
Starts the ChannelScanSM event loop.
Definition: channelscan_sm.cpp:1976
DVBStreamData::HasCachedAllSDT
bool HasCachedAllSDT(uint tsid, bool current=true) const
Definition: dvbstreamdata.cpp:707
DTVMultiplex::m_iptvTuning
IPTVTuningData m_iptvTuning
Definition: dtvmultiplex.h:112
sourceutil.h
ServiceDescriptor::ServiceName
QString ServiceName(void) const
Definition: dvbdescriptors.h:2067
DTVChannelList
std::vector< DTVTransport > DTVChannelList
Definition: dtvconfparser.h:68
ServiceDescriptionTable::ServiceCount
uint ServiceCount() const
Number of services.
Definition: dvbtables.h:145
DVBStreamData::GetCachedNIT
nit_const_ptr_t GetCachedNIT(uint section_num, bool current=true) const
Definition: dvbstreamdata.cpp:790
ChannelScanSM::m_timer
QElapsedTimer m_timer
Definition: channelscan_sm.h:237
ChannelScanSM::HandleActiveScan
void HandleActiveScan(void)
Handles the TRANSPORT_LIST ChannelScanSM mode.
Definition: channelscan_sm.cpp:2092
ChannelScanSM::HandleNIT
void HandleNIT(const NetworkInformationTable *nit) override
Definition: channelscan_sm.cpp:508
dvbsignalmonitor.h
ServiceDescriptionTable::GetServiceDescriptor
ServiceDescriptor * GetServiceDescriptor(uint i) const
Definition: dvbtables.cpp:164
mythlogging.h
SignalMonitor::kDVBSigMon_WaitForPos
static const uint64_t kDVBSigMon_WaitForPos
Wait for rotor to complete turning the antenna.
Definition: signalmonitor.h:202
IPTVTuningData::inValid
@ inValid
Definition: iptvtuningdata.h:43
ChannelBase
Abstract class providing a generic interface to tuning hardware.
Definition: channelbase.h:31
MPEGStreamData::HasCachedAnyPAT
bool HasCachedAnyPAT(uint tsid) const
Definition: mpegstreamdata.cpp:1220
sdt_vec_t
std::vector< const ServiceDescriptionTable * > sdt_vec_t
Definition: dvbstreamdata.h:17
MPEGDescriptor::Parse
static desc_list_t Parse(const unsigned char *data, uint len)
Definition: mpegdescriptors.cpp:15
TransportScanItem
Class used for doing a list of frequencies / transports.
Definition: frequencytables.h:127
ServiceDescriptionTable::toString
QString toString(void) const override
Definition: dvbtables.cpp:127
ChannelScanSM::m_analogSignalHandler
AnalogSignalHandler * m_analogSignalHandler
Definition: channelscan_sm.h:258
ProgramMapTable::toString
QString toString(void) const override
Definition: mpegtables.cpp:879
transport_scan_items_it_t::iter
std::list< TransportScanItem >::iterator iter()
Definition: frequencytables.h:252
DVBLogicalChannelDescriptor::ChannelCount
uint ChannelCount(void) const
Definition: dvbdescriptors.h:2575
AnalogSignalHandler
Definition: channelscan_sm.h:70
ServiceDescriptionTable::OriginalNetworkID
uint OriginalNetworkID() const
original_network_id 16 8.0
Definition: dvbtables.h:141
ChannelUtil::FindChannel
static uint FindChannel(uint sourceid, const QString &freqid)
Definition: channelutil.cpp:1381
ChannelScanSM::m_extendTransports
QMap< uint32_t, DTVMultiplex > m_extendTransports
Definition: channelscan_sm.h:242
DTVTunerType::kTunerTypeUnknown
static const int kTunerTypeUnknown
Definition: dtvconfparserhelpers.h:103
hardwareprofile.i18n.t
t
Definition: i18n.py:36
MPEGDescriptor
Definition: mpegdescriptors.h:302
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
scanstreamdata.h
DTVChannelInfoList
std::vector< DTVChannelInfo > DTVChannelInfoList
Definition: dtvconfparser.h:58
PrivateDataSpecifierID::FSAT
@ FSAT
Definition: mpegdescriptors.h:279
v4lchannel.h
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:200
ScannedChannelInfo::m_tvcts
tvct_vec_t m_tvcts
Definition: channelscan_sm.cpp:115
SignalMonitor::kDTVSigMon_WaitForNIT
static const uint64_t kDTVSigMon_WaitForNIT
Definition: signalmonitor.h:187
DescriptorID::default_authority
@ default_authority
Definition: mpegdescriptors.h:126
ChannelScanSM::HandlePAT
void HandlePAT(const ProgramAssociationTable *pat) override
Definition: channelscan_sm.cpp:378
ChannelScanSM::HandleEncryptionStatus
void HandleEncryptionStatus(uint pnum, bool encrypted) override
Definition: channelscan_sm.cpp:615
teardown_frequency_tables
bool teardown_frequency_tables(void)
Definition: frequencytables.cpp:214
SignalMonitor::kDTVSigMon_WaitForSDT
static const uint64_t kDTVSigMon_WaitForSDT
Definition: signalmonitor.h:188
DVBLogicalChannelDescriptor::ChannelNumber
uint ChannelNumber(uint i) const
Definition: dvbdescriptors.h:2580
desc_list_t
std::vector< const unsigned char * > desc_list_t
Definition: mpegdescriptors.h:18
BouquetAssociationTable::OriginalNetworkID
uint OriginalNetworkID(uint i) const
Definition: dvbtables.h:233
DVBStreamData::HasCachedAllNIT
bool HasCachedAllNIT(bool current=true) const
Definition: dvbstreamdata.cpp:625
ChannelScanSM::m_channelsFound
uint m_channelsFound
Definition: channelscan_sm.h:254
DTVSignalMonitor::GetDVBStreamData
DVBStreamData * GetDVBStreamData()
Returns the DVB stream data if it exists.
Definition: dtvsignalmonitor.cpp:539
MPEGDescriptor::ParseOnlyInclude
static desc_list_t ParseOnlyInclude(const unsigned char *data, uint len, int excluded_descid)
Definition: mpegdescriptors.cpp:57
ServiceDescriptionTable
This table tells the decoder on which PIDs to find A/V data.
Definition: dvbtables.h:110
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
ScannedChannelInfo::m_cvcts
cvct_vec_t m_cvcts
Definition: channelscan_sm.cpp:114
ChannelScanSM::ChannelScanSM
ChannelScanSM(ScanMonitor *scan_monitor, const QString &cardtype, ChannelBase *channel, int sourceID, std::chrono::milliseconds signal_timeout, std::chrono::milliseconds channel_timeout, QString inputname, bool test_decryption)
Definition: channelscan_sm.cpp:146
MPEGStreamData::GetCachedPMTs
pmt_vec_t GetCachedPMTs(void) const
Definition: mpegstreamdata.cpp:1430
ScannedChannelInfo::IsEmpty
bool IsEmpty() const
Definition: channelscan_sm.cpp:98
T2DeliverySystemDescriptor
Definition: dvbdescriptors.h:1112
SkyLCNDescriptor
Sky Logical Channel Number descriptor.
Definition: dvbdescriptors.h:2782
ProgramAssociationTable::toString
QString toString(void) const override
Definition: mpegtables.cpp:814
IPTVTuningData
Definition: iptvtuningdata.h:19
ChannelScanSM::HandleBAT
void HandleBAT(const BouquetAssociationTable *bat) override
Definition: channelscan_sm.cpp:521
dvbtables.h
PrivateDataSpecifierDescriptor::PrivateDataSpecifier
uint32_t PrivateDataSpecifier(void) const
Definition: dvbdescriptors.h:1912
DVBSimulcastChannelDescriptor
DVB HD Simulcast Logical Channel Descriptor.
Definition: dvbdescriptors.h:2594
ChannelScanSM::UpdateChannelInfo
bool UpdateChannelInfo(bool wait_until_complete)
Definition: channelscan_sm.cpp:832
kDecryptionTimeout
#define kDecryptionTimeout
Definition: channelscan_sm.cpp:89
FreesatLCNDescriptor::ServiceID
uint ServiceID(int i) const
Definition: dvbdescriptors.h:2659
ChannelUtil::CreateChanID
static int CreateChanID(uint sourceid, const QString &chan_num)
Creates a unique channel ID for database use.
Definition: channelutil.cpp:1444
DTVMultiplex::m_modSys
DTVModulationSystem m_modSys
Definition: dtvmultiplex.h:106
MPEGDescriptor::DescriptorTagExtension
uint DescriptorTagExtension(void) const
Definition: mpegdescriptors.h:347
ChannelScanSM::UpdateScanTransports
void UpdateScanTransports(uint frequency, const NetworkInformationTable *nit)
Definition: channelscan_sm.cpp:736
ChannelScanSM::m_nextIt
transport_scan_items_it_t m_nextIt
Definition: channelscan_sm.h:245
MPEGStreamData::ResetDecryptionMonitoringState
void ResetDecryptionMonitoringState(void)
Definition: mpegstreamdata.cpp:1835
ChannelScanSM::m_waitingForTables
bool m_waitingForTables
Definition: channelscan_sm.h:236
DTVMultiplex::toString
QString toString() const
Definition: dtvmultiplex.cpp:34
DVBStreamData::HasCachedAnyBATs
bool HasCachedAnyBATs(bool current=true) const
Definition: dvbstreamdata.cpp:685
transport_scan_items_it_t
Definition: frequencytables.h:195
ChannelScanSM
Scanning class for cards that support a SignalMonitor class.
Definition: channelscan_sm.h:85
PrivateDescriptorID::dvb_logical_channel_descriptor
@ dvb_logical_channel_descriptor
Definition: mpegdescriptors.h:206
ChannelInsertInfo::m_vctTsId
uint m_vctTsId
Definition: channelinfo.h:235
NetworkInformationTable::OriginalNetworkID
uint OriginalNetworkID(uint i) const
original_network_id 16 2.0+p
Definition: dvbtables.h:81
ChannelScanSM::GetCurrentTransportInfo
uint GetCurrentTransportInfo(QString &chan, QString &chan_tr) const
Definition: channelscan_sm.cpp:1323
uint
unsigned int uint
Definition: compat.h:140
kEncDecrypted
@ kEncDecrypted
Definition: mpegstreamdata.h:57
ScanDTVTransportList
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
ChannelScanSM::m_scanDTVTunerType
DTVTunerType m_scanDTVTunerType
Definition: channelscan_sm.h:228
ChannelScanSM::HandlePMT
void HandlePMT(uint program_num, const ProgramMapTable *pmt) override
Definition: channelscan_sm.cpp:405
DTVSignalMonitor::GetNetworkID
uint GetNetworkID(void) const
Definition: dtvsignalmonitor.h:39
ProgramAssociationTable
The Program Association Table lists all the programs in a stream, and is always found on PID 0.
Definition: mpegtables.h:615
TransportScanItem::m_friendlyName
QString m_friendlyName
Definition: frequencytables.h:175
DTVSignalMonitor::GetTransportID
uint GetTransportID(void) const
Definition: dtvsignalmonitor.h:38
ChannelScanSM::GetDVBSignalMonitor
DVBSignalMonitor * GetDVBSignalMonitor(void)
Definition: channelscan_sm.cpp:1918
ChannelScanSM::loc
static QString loc(const ChannelScanSM *siscan)
Definition: channelscan_sm.cpp:80
PSIPTable::LastSection
uint LastSection(void) const
Definition: mpegtables.h:551
PrivateDescriptorID::freesat_lcn_table
@ freesat_lcn_table
Definition: mpegdescriptors.h:232
ScanMonitor::ScanAppendTextToLog
void ScanAppendTextToLog(const QString &status)
Definition: scanmonitor.cpp:109
ServiceDescriptor::ServiceType
uint ServiceType(void) const
Definition: dvbdescriptors.h:2053
SignalMonitor
Signal monitoring base class.
Definition: signalmonitor.h:34
SatelliteDeliverySystemDescriptor::FrequencykHz
unsigned long long FrequencykHz(void) const
Definition: dvbdescriptors.h:834
ATSCStreamData::GetCachedTVCTs
tvct_vec_t GetCachedTVCTs(bool current=true) const
Definition: atscstreamdata.cpp:821
NetworkInformationTable::toString
QString toString(void) const override
Definition: dvbtables.cpp:30
ScanDTVTransport::m_signalStrength
int m_signalStrength
Definition: dtvmultiplex.h:141
ChannelScanSM::m_transportsScanned
int m_transportsScanned
Definition: channelscan_sm.h:240
ChannelInsertInfo::m_callSign
QString m_callSign
Definition: channelinfo.h:216
ChannelScanSM::HandleMGT
void HandleMGT(const MasterGuideTable *mgt) override
Definition: channelscan_sm.cpp:441
ChannelInsertInfo::m_format
QString m_format
Definition: channelinfo.h:229
get_matching_freq_tables
freq_table_list_t get_matching_freq_tables(const QString &format, const QString &modulation, const QString &country)
Definition: frequencytables.cpp:246
PrivateDescriptorID::sky_lcn_table
@ sky_lcn_table
Definition: mpegdescriptors.h:229
PrivateDataSpecifierDescriptor
Definition: dvbdescriptors.h:1900
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
Definition: frequencytables.h:101
ServiceListDescriptor::ServiceCount
uint ServiceCount(void) const
Definition: dvbdescriptors.h:2125
channelutil.h
SkyLCNDescriptor::ServiceID
uint ServiceID(int i) const
Definition: dvbdescriptors.h:2811
ChannelScanSM::m_threadExit
volatile bool m_threadExit
Definition: channelscan_sm.h:235
DTVTunerType::kTunerTypeDVBS2
static const int kTunerTypeDVBS2
Definition: dtvconfparserhelpers.h:94
ChannelInsertInfo::m_decryptionStatus
int m_decryptionStatus
Definition: channelinfo.h:252
ChannelScanSM::ScanIPTVChannels
bool ScanIPTVChannels(uint sourceid, const fbox_chan_map_t &iptv_channels)
Definition: channelscan_sm.cpp:2426
ServiceListDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2127
ChannelScanSM::GetDTVSignalMonitor
DTVSignalMonitor * GetDTVSignalMonitor(void)
Definition: channelscan_sm.cpp:1913
ServiceDescriptionTable::IsEncrypted
bool IsEncrypted(uint i) const
free_CA_mode 1 3.3+p
Definition: dvbtables.h:160
DTVModulationSystem::toString
QString toString() const
Definition: dtvconfparserhelpers.h:719
MasterGuideTable
This table tells the decoder on which PIDs to find other tables, and their sizes and each table's cur...
Definition: atsctables.h:77
TransportScanItem::m_mplexid
uint m_mplexid
Definition: frequencytables.h:173
gChanLists
const CHANLISTS_vec gChanLists
Definition: frequencies.cpp:2215
FreesatLCNDescriptor::RegionID
uint RegionID(int i, int j) const
Definition: dvbdescriptors.h:2671
ChannelScanSM::GuessDTVTunerType
DTVTunerType GuessDTVTunerType(DTVTunerType type) const
Definition: channelscan_sm.cpp:712
TransportScanItem::freq_offset
uint64_t freq_offset(uint i) const
Definition: frequencytables.cpp:157
ChannelInsertInfo::m_serviceName
QString m_serviceName
Definition: channelinfo.h:217
DVBChannel
Provides interface to the tuning hardware when using DVB drivers.
Definition: dvbchannel.h:30
ChannelScanSM::m_channelTimeout
std::chrono::milliseconds m_channelTimeout
Definition: channelscan_sm.h:212
ChannelScanSM::AddToList
bool AddToList(uint mplexid)
Definition: channelscan_sm.cpp:2527
MPEGStreamData::ReturnCachedPMTTables
virtual void ReturnCachedPMTTables(pmt_vec_t &pmts) const
Definition: mpegstreamdata.cpp:1505
ChannelScanSM::GetDVBChannel
DVBChannel * GetDVBChannel(void)
Definition: channelscan_sm.cpp:1946
BouquetAssociationTable::TransportStreamCount
uint TransportStreamCount(void) const
Definition: dvbtables.h:226
BouquetAssociationTable
Tells what channels can be found on each transponder for one bouquet (a bunch of channels from one pr...
Definition: dvbtables.h:189
ServiceDescriptionTable::HasEITPresentFollowing
bool HasEITPresentFollowing(uint i) const
Definition: dvbtables.h:155
MasterGuideTable::toString
QString toString(void) const override
Definition: atsctables.cpp:69
DTVSignalMonitor::SetChannel
void SetChannel(int major, int minor)
Definition: dtvsignalmonitor.cpp:196
VERBOSE_LEVEL_CHECK
#define VERBOSE_LEVEL_CHECK(_MASK_, _LEVEL_)
Definition: mythlogging.h:14
ChannelScanSM::m_currentInfo
ScannedChannelInfo * m_currentInfo
Definition: channelscan_sm.h:255
SkyLCNDescriptor::LogicalChannelNumber
uint LogicalChannelNumber(int i) const
Definition: dvbdescriptors.h:2820
DTVChannel::TuneMultiplex
virtual bool TuneMultiplex(uint mplexid, const QString &inputname)
To be used by the channel scanner and possibly the EIT scanner.
Definition: dtvchannel.cpp:394
ChannelScanSM::HandleVCT
void HandleVCT(uint tsid, const VirtualChannelTable *vct) override
Definition: channelscan_sm.cpp:421
kChannelVisible
@ kChannelVisible
Definition: channelinfo.h:23
nit_vec_t
std::vector< const NetworkInformationTable * > nit_vec_t
Definition: dvbstreamdata.h:12
SignalMonitor::AddListener
void AddListener(SignalMonitorListener *listener)
Definition: signalmonitor.cpp:387
ChannelInsertInfo::m_sdtTsId
uint m_sdtTsId
Definition: channelinfo.h:237
OriginalNetworkID::NOZEMA
@ NOZEMA
Definition: mpegdescriptors.h:298
ChannelInsertInfo::m_netId
uint m_netId
Definition: channelinfo.h:239
DescriptorID::registration
@ registration
Definition: mpegdescriptors.h:29
ServiceDescriptor::ServiceShortName
QString ServiceShortName(void) const
Definition: dvbdescriptors.h:2072
DTVModulationSystem
Definition: dtvconfparserhelpers.h:644
cardutil.h
DVBLogicalChannelDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2577
ChannelScanSM::m_defAuthorities
QMap< uint64_t, QString > m_defAuthorities
Definition: channelscan_sm.h:249
kRegionUndefined
static const uint kRegionUndefined
Definition: channelscan_sm.cpp:78
BouquetAssociationTable::toString
QString toString(void) const override
Definition: dvbtables.cpp:215
SignalMonitor::RemoveListener
void RemoveListener(SignalMonitorListener *listener)
Definition: signalmonitor.cpp:398
VirtualChannelTable::ServiceType
uint ServiceType(uint i) const
Definition: atsctables.h:296
ScanMonitor::ScanComplete
void ScanComplete(void)
Definition: scanmonitor.cpp:98
ChannelScanSM::kATSCTableTimeout
static const std::chrono::milliseconds kATSCTableTimeout
No logic here, lets just wait at least 10 seconds.
Definition: channelscan_sm.h:202
ChannelScanSM::m_signalMonitor
SignalMonitor * m_signalMonitor
Definition: channelscan_sm.h:209
ChannelScanSM::m_channelList
ChannelList m_channelList
Found Channel Info.
Definition: channelscan_sm.h:253
ScannedChannelInfo::m_pats
pat_map_t m_pats
Definition: channelscan_sm.cpp:108
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:878
std
Definition: mythchrono.h:23
ServiceDescriptor
Definition: dvbdescriptors.h:2043
IPTVTuningData::GuessProtocol
void GuessProtocol(void)
Definition: iptvtuningdata.h:206
DTVSignalMonitor::SetStreamData
virtual void SetStreamData(MPEGStreamData *data)
Sets the MPEG stream data for DTVSignalMonitor to use, and connects the table signals to the monitor.
Definition: dtvsignalmonitor.cpp:258
ChannelScanSM::m_channel
ChannelBase * m_channel
Definition: channelscan_sm.h:208
TerrestrialDeliverySystemDescriptor::FrequencyHz
uint64_t FrequencyHz(void) const
Definition: dvbdescriptors.h:943
ChannelInsertInfo::m_serviceId
uint m_serviceId
Definition: channelinfo.h:219
DVBSimulcastChannelDescriptor::ChannelCount
uint ChannelCount(void) const
Definition: dvbdescriptors.h:2603
ChannelScanSM::ScanCurrentTransport
bool ScanCurrentTransport(const QString &sistandard)
Definition: channelscan_sm.cpp:2617
ChannelInsertInfo::m_inSdt
bool m_inSdt
Definition: channelinfo.h:246
TransportScanItem::m_networkID
uint m_networkID
Definition: frequencytables.h:190
ServiceDescriptionTable::GetServiceRelocatedDescriptor
ServiceRelocatedDescriptor * GetServiceRelocatedDescriptor(uint i) const
Definition: dvbtables.cpp:179
ConditionalAccessTable
The CAT is used to transmit additional ConditionalAccessDescriptor instances, in addition to the ones...
Definition: mpegtables.h:855
DTVTunerType::Parse
bool Parse(const QString &_value)
Definition: dtvconfparserhelpers.h:131
ServiceDescriptionTable::ServiceDescriptorsLength
uint ServiceDescriptorsLength(uint i) const
desc_loop_length 12 3.4+p
Definition: dvbtables.h:162
DTVMultiplex::m_sistandard
QString m_sistandard
Definition: dtvmultiplex.h:111
MThread
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:48
ChannelInsertInfo::m_sourceId
uint m_sourceId
Definition: channelinfo.h:214
mthread.h
DTVMultiplex::ParseTuningParams
bool ParseTuningParams(DTVTunerType type, const QString &frequency, const QString &inversion, const QString &symbolrate, const QString &fec, const QString &polarity, const QString &hp_code_rate, const QString &lp_code_rate, const QString &ofdm_modulation, const QString &trans_mode, const QString &guard_interval, const QString &hierarchy, const QString &modulation, const QString &bandwidth, const QString &mod_sys, const QString &rolloff)
Definition: dtvmultiplex.cpp:356
DTVSignalMonitor
This class is intended to detect the presence of needed tables.
Definition: dtvsignalmonitor.h:14
ChannelBase::GetInputID
virtual int GetInputID(void) const
Definition: channelbase.h:67
SkyLCNDescriptor::ServiceCount
uint ServiceCount(void) const
Definition: dvbdescriptors.h:2808
MPEGStreamData::HasCachedAnyPMTs
bool HasCachedAnyPMTs(void) const
Definition: mpegstreamdata.cpp:1326
ScannedChannelInfo::m_programEncryptionStatus
QMap< uint, uint > m_programEncryptionStatus
Definition: channelscan_sm.cpp:110
SignalMonitor::Start
virtual void Start()
Start signal monitoring thread.
Definition: signalmonitor.cpp:290
ChannelScanSM::TestNextProgramEncryption
bool TestNextProgramEncryption(void)
Definition: channelscan_sm.cpp:627
SatelliteDeliverySystemDescriptor
Definition: dvbdescriptors.h:818
ChannelScanSM::HandleAllGood
void HandleAllGood(void)
Definition: channelscan_sm.cpp:256
FrequencyTable::m_nameOffset
int m_nameOffset
Definition: frequencytables.h:99
DTVTransport
Definition: dtvconfparser.h:60
DTVTunerType::kTunerTypeASI
static const int kTunerTypeASI
Definition: dtvconfparserhelpers.h:100
atsctables.h
ScannedChannelInfo::m_nits
nit_vec_t m_nits
Definition: channelscan_sm.cpp:118
MPEGStreamData::HasCachedAllPAT
bool HasCachedAllPAT(uint tsid) const
Definition: mpegstreamdata.cpp:1201
CardUtil::ConvertToTunerType
static DTVTunerType ConvertToTunerType(DTVModulationSystem delsys)
Definition: cardutil.cpp:756
DTVTunerType::kTunerTypeATSC
static const int kTunerTypeATSC
Definition: dtvconfparserhelpers.h:98
MPEGStreamData::AddListeningPID
virtual void AddListeningPID(uint pid, PIDPriority priority=kPIDPriorityNormal)
Definition: mpegstreamdata.h:119
ChannelScanSM::LogLines
static void LogLines(const QString &string)
Definition: channelscan_sm.cpp:368
OriginalNetworkID::SKYNZ
@ SKYNZ
Definition: mpegdescriptors.h:296
StreamID::OpenCableVideo
@ OpenCableVideo
Always MPEG-2??
Definition: mpegtables.h:120
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:33
ServiceDescriptionTable::HasEITSchedule
bool HasEITSchedule(uint i) const
Definition: dvbtables.h:153
ChannelInsertInfo::m_serviceType
uint m_serviceType
Definition: channelinfo.h:220
ChannelScanSM::HandleCAT
void HandleCAT(const ConditionalAccessTable *cat) override
Definition: channelscan_sm.cpp:395
DefaultAuthorityDescriptor
Definition: dvbdescriptors.h:2921
SignalMonitor::HasSignalLock
bool HasSignalLock(void) const
Returns true iff scriptStatus.IsGood() and signalLock.IsGood() return true.
Definition: signalmonitor.h:79
update_info
static void update_info(ChannelInsertInfo &info, const VirtualChannelTable *vct, uint i)
Definition: channelscan_sm.cpp:1166
TransportScanItem::m_transportID
uint m_transportID
Definition: frequencytables.h:191
DTVModulationSystem::kModulationSystem_DVBT2
@ kModulationSystem_DVBT2
Definition: dtvconfparserhelpers.h:672
DTVTunerType::kTunerTypeDVBT
static const int kTunerTypeDVBT
Definition: dtvconfparserhelpers.h:96
DVBStreamData::HasCachedAnyNIT
bool HasCachedAnyNIT(bool current=true) const
Definition: dvbstreamdata.cpp:614
ATSCStreamData::HasCachedAnyVCTs
bool HasCachedAnyVCTs(bool current=true) const
Definition: atscstreamdata.h:82
SkyLCNDescriptor::RegionID
uint RegionID(void) const
Definition: dvbdescriptors.h:2802
ChannelScanSM::ScanTransportsStartingOn
bool ScanTransportsStartingOn(int sourceid, const QMap< QString, QString > &startChan)
Generates a list of frequencies to scan and adds it to the scanTransport list, and then sets the scan...
Definition: channelscan_sm.cpp:2465
NetworkInformationTable::TransportStreamCount
uint TransportStreamCount(void) const
Definition: dvbtables.h:75
SignalMonitor::Stop
virtual void Stop()
Stop signal monitoring thread.
Definition: signalmonitor.cpp:306
VirtualChannelTable::ModulationMode
uint ModulationMode(uint i) const
Definition: atsctables.h:257
ChannelScanSM::m_lcnOffset
uint m_lcnOffset
Definition: channelscan_sm.h:225
ChannelScanSM::m_inputName
QString m_inputName
Definition: channelscan_sm.h:216
MPEGDescriptor::Find
static const unsigned char * Find(const desc_list_t &parsed, uint desc_tag)
Definition: mpegdescriptors.cpp:78
ChannelScanSM::GetChannelList
chan_info_map_t GetChannelList(transport_scan_items_it_t trans_info, ScannedChannelInfo *scan_info) const
Definition: channelscan_sm.cpp:1359
ScanMonitor::ScanUpdateStatusText
void ScanUpdateStatusText(const QString &status)
Definition: scanmonitor.cpp:114
hdhrchannel.h
ChannelScanSM::GetDTVChannel
DTVChannel * GetDTVChannel(void)
Definition: channelscan_sm.cpp:1927
DTVTunerType::kTunerTypeDVBT2
static const int kTunerTypeDVBT2
Definition: dtvconfparserhelpers.h:97
ChannelInsertInfo::m_vctChanTsId
uint m_vctChanTsId
Definition: channelinfo.h:236
ChannelScanSM::ScanTransport
bool ScanTransport(uint mplexid, bool follow_nit)
Definition: channelscan_sm.cpp:2595
ChannelScanSM::m_testDecryption
bool m_testDecryption
Definition: channelscan_sm.h:217
VirtualChannelTable::ChannelCount
uint ChannelCount() const
Definition: atsctables.h:224
V4LChannel
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
Definition: v4lchannel.h:30
ChannelScanSM::ScanExistingTransports
bool ScanExistingTransports(uint sourceid, bool follow_nit)
If we are not already scanning a frequency table, this creates a new frequency table from database an...
Definition: channelscan_sm.cpp:323
IPTVTuningData::GetProtocol
IPTVProtocol GetProtocol(void) const
Definition: iptvtuningdata.h:224
DescriptorID::satellite_delivery_system
@ satellite_delivery_system
Definition: mpegdescriptors.h:75
VirtualChannelTable::TransportStreamID
uint TransportStreamID() const
Definition: atsctables.h:221
ChannelInsertInfo::m_patTsId
uint m_patTsId
Definition: channelinfo.h:234
ServiceListDescriptor
Definition: dvbdescriptors.h:2111
fbox_chan_map_t
QMap< QString, IPTVChannelInfo > fbox_chan_map_t
Definition: iptvchannelfetcher.h:62
ChannelScanSM::~ChannelScanSM
~ChannelScanSM() override
Definition: channelscan_sm.cpp:219
DVBStreamData::ReturnCachedSDTTables
void ReturnCachedSDTTables(sdt_vec_t &sdts) const
Definition: dvbstreamdata.cpp:929
TransportScanItem::toString
QString toString() const
Definition: frequencytables.cpp:164
ChannelInsertInfo::m_oldTsId
uint m_oldTsId
Definition: channelinfo.h:256
ChannelInsertInfo::m_oldServiceId
uint m_oldServiceId
Definition: channelinfo.h:257
dtvsignalmonitor.h
MPEGStreamData::TestDecryption
void TestDecryption(const ProgramMapTable *pmt)
Definition: mpegstreamdata.cpp:1807
ChannelInsertInfo::m_inVct
bool m_inVct
Definition: channelinfo.h:244
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
Definition: frequencytables.h:100
ChannelScanSM::m_currentEncryptionStatus
QMap< uint, uint > m_currentEncryptionStatus
Definition: channelscan_sm.h:247
FreesatLCNDescriptor::LogicalChannelNumber
uint LogicalChannelNumber(int i, int j) const
Definition: dvbdescriptors.h:2668
ChannelScanSM::CheckImportedList
bool CheckImportedList(const DTVChannelInfoList &channels, uint mpeg_program_num, QString &service_name, QString &callsign, QString &common_status_info)
If we are scanning a dvb-utils import verify channel is in list.
Definition: channelscan_sm.cpp:2639
ServiceDescriptionTable::ServiceDescriptors
const unsigned char * ServiceDescriptors(uint i) const
for (j=0;j<N;j++) x 5.0+p { descriptor() }
Definition: dvbtables.h:166
ATSCStreamData::GetCachedMGT
const MasterGuideTable * GetCachedMGT(bool current=true) const
Definition: atscstreamdata.cpp:773
ChannelListItem
QPair< transport_scan_items_it_t, ScannedChannelInfo * > ChannelListItem
Definition: channelscan_sm.h:66
DTVModulationSystem::kModulationSystem_DVBT
@ kModulationSystem_DVBT
Definition: dtvconfparserhelpers.h:659
ChannelScanSM::m_currentEncryptionStatusChecked
QMap< uint, bool > m_currentEncryptionStatusChecked
Definition: channelscan_sm.h:248
ServiceDescriptor::IsDigitalAudio
bool IsDigitalAudio(void) const
Definition: dvbdescriptors.h:2079
ChannelInsertInfo::m_siStandard
QString m_siStandard
Definition: channelinfo.h:240
ScanMonitor
Definition: scanmonitor.h:44
transport_scan_items_it_t::nextTransport
transport_scan_items_it_t nextTransport() const
Definition: frequencytables.h:255
ServiceDescriptionTable::TSID
uint TSID() const
transport_stream_id 16 3.0 0x0000
Definition: dvbtables.h:138
VirtualChannelTable::MinorChannel
uint MinorChannel(uint i) const
Definition: atsctables.h:252
ChannelScanSM::UpdateScanPercentCompleted
void UpdateScanPercentCompleted(void)
Definition: channelscan_sm.h:267
SignalMonitor::kDTVSigMon_WaitForVCT
static const uint64_t kDTVSigMon_WaitForVCT
Definition: signalmonitor.h:186
DescriptorID::private_data_specifier
@ private_data_specifier
Definition: mpegdescriptors.h:104
ChannelScanSM::HasTimedOut
bool HasTimedOut(void)
Definition: channelscan_sm.cpp:2011
ChannelScanSM::ScanForChannels
bool ScanForChannels(uint sourceid, const QString &std, const QString &cardtype, const DTVChannelList &channels)
Definition: channelscan_sm.cpp:2386
ChannelScanSM::m_regionId
uint m_regionId
Definition: channelscan_sm.h:223
DVBSimulcastChannelDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2605
ScanDTVTransport
Definition: dtvmultiplex.h:115
ScanDTVTransport::m_channels
ChannelInsertInfoList m_channels
Definition: dtvmultiplex.h:138
DTVModulationSystem::kModulationSystem_DVBC_ANNEX_A
@ kModulationSystem_DVBC_ANNEX_A
Definition: dtvconfparserhelpers.h:657
FreesatLCNDescriptor::ServiceCount
uint ServiceCount(void) const
Definition: dvbdescriptors.h:2656
DefaultAuthorityDescriptor::DefaultAuthority
QString DefaultAuthority(void) const
Definition: dvbdescriptors.h:2930
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:827
DTVModulationSystem::Parse
bool Parse(const QString &_value)
Definition: dtvconfparserhelpers.h:716
ChannelScanSM::GetSignalMonitor
SignalMonitor * GetSignalMonitor(void)
Definition: channelscan_sm.h:128
DVBStreamData::GetCachedSDTSections
sdt_vec_t GetCachedSDTSections(uint tsid, bool current=true) const
Definition: dvbstreamdata.cpp:881
NetworkInformationTable
This table tells the decoder on which PIDs to find other tables.
Definition: dvbtables.h:30
VirtualChannelTable::GetExtendedChannelName
QString GetExtendedChannelName(uint idx) const
Definition: atsctables.cpp:506
ScanMonitor::ScanUpdateStatusTitleText
void ScanUpdateStatusTitleText(const QString &status)
Definition: scanmonitor.cpp:123