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