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