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 uint ChannelScanSM::kDVBTableTimeout = 30 * 1000;
73 const uint ChannelScanSM::kATSCTableTimeout = 10 * 1000;
75 const uint ChannelScanSM::kMPEGTableTimeout = 15 * 1000;
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, uint signal_timeout,
147  uint 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 = 10000;
476  // Delay processing the SDT until we've seen BATs and SDTos
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))
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 
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 
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)))
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)))
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  if (m_dvbt2Tried)
1069  else
1071  }
1072 
1073  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1074  QString("Adding %1 offset:%2 ss:%3")
1075  .arg(item.m_tuning.toString()).arg(m_current.offset())
1076  .arg(item.m_signalStrength));
1077 
1078  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
1079  QString("%1(%2) m_inputName: %3 ").arg(__FUNCTION__).arg(__LINE__).arg(m_inputName) +
1080  QString("tunerType:%1 %2 ").arg(m_scanDTVTunerType).arg(m_scanDTVTunerType.toString()) +
1081  QString("m_modSys:%1 %2 ").arg(item.m_tuning.m_modSys).arg(item.m_tuning.m_modSys.toString()) +
1082  QString("m_dvbt2Tried:%1").arg(m_dvbt2Tried));
1083 
1085  m_currentInfo = nullptr;
1086  }
1087  else
1088  {
1089  delete m_currentInfo;
1090  m_currentInfo = nullptr;
1091  }
1092 
1094  if (HasTimedOut())
1095  {
1096  msg_tr = (cchan_cnt) ?
1097  QObject::tr("%1 possible channels").arg(cchan_cnt) :
1098  QObject::tr("no channels");
1099  msg_tr = QString("%1, %2").arg(chan_tr).arg(msg_tr);
1100  msg = (cchan_cnt) ?
1101  QString("%1 possible channels").arg(cchan_cnt) :
1102  QString("no channels");
1103  msg = QString("%1, %2").arg(chan_tr).arg(msg);
1104  }
1105  else if ((m_current != m_scanTransports.end()) &&
1106  m_timer.hasExpired((*m_current).m_timeoutTune) &&
1107  sm && !sm->HasSignalLock())
1108  {
1109  msg_tr = QObject::tr("%1, no signal").arg(chan_tr);
1110  msg = QString("%1, no signal").arg(chan);
1111  }
1112  else
1113  {
1114  msg_tr = QObject::tr("%1 -- Found %2 probable channels")
1115  .arg(cchan_tr).arg(cchan_cnt);
1116 
1117  msg = QString("%1 -- Found %2 probable channels")
1118  .arg(cchan).arg(cchan_cnt);
1119  }
1120 
1122  LOG(VB_CHANSCAN, LOG_INFO, LOC + msg);
1123 
1124  m_currentEncryptionStatus.clear();
1126 
1127  m_setOtherTables = false;
1128  m_otherTableTime = 0;
1129 
1130  if (m_scanning)
1131  {
1134  m_waitingForTables = false;
1136  m_dvbt2Tried = true;
1137  }
1138  else
1139  {
1142  }
1143 
1144  return true;
1145  }
1146 
1147  return false;
1148 }
1149 
1150 #define PCM_INFO_INIT(SISTD) \
1151  ChannelInsertInfo &info = pnum_to_dbchan[pnum]; \
1152  info.m_dbMplexId = mplexid; info.m_sourceId = m_sourceID; \
1153  info.m_serviceId = pnum; info.m_freqId = freqidStr; \
1154  info.m_siStandard = SISTD;
1155 
1156 static void update_info(ChannelInsertInfo &info,
1157  const VirtualChannelTable *vct, uint i)
1158 {
1159  if (vct->ModulationMode(i) == 0x01 /* NTSC Modulation */ ||
1160  vct->ServiceType(i) == 0x01 /* Analog TV */)
1161  {
1162  info.m_siStandard = "ntsc";
1163  info.m_format = "ntsc";
1164  }
1165 
1166  info.m_callSign = vct->ShortChannelName(i);
1167 
1168  info.m_serviceName = vct->GetExtendedChannelName(i);
1169  if (info.m_serviceName.isEmpty())
1170  info.m_serviceName = vct->ShortChannelName(i);
1171 
1172  info.m_chanNum.clear();
1173 
1174  info.m_serviceId = vct->ProgramNumber(i);
1175  info.m_atscMajorChannel = vct->MajorChannel(i);
1176  info.m_atscMinorChannel = vct->MinorChannel(i);
1177 
1178  info.m_useOnAirGuide = !vct->IsHidden(i) || !vct->IsHiddenInGuide(i);
1179 
1180  info.m_hidden = vct->IsHidden(i);
1181  info.m_hiddenInGuide = vct->IsHiddenInGuide(i);
1182 
1183  info.m_vctTsId = vct->TransportStreamID();
1184  info.m_vctChanTsId = vct->ChannelTransportStreamID(i);
1185  info.m_isEncrypted |= vct->IsAccessControlled(i);
1186  info.m_isDataService = vct->ServiceType(i) == 0x04;
1187  info.m_isAudioService = vct->ServiceType(i) == 0x03;
1188 
1189  info.m_inVct = true;
1190 }
1191 
1192 static void update_info(ChannelInsertInfo &info,
1193  const ServiceDescriptionTable *sdt, uint i,
1194  const QMap<uint64_t, QString> &defAuthorities)
1195 {
1196  // HACK beg -- special exception for these networks
1197  // this enables useonairguide by default for all matching channels
1198  // (dbver == "1067")
1199  bool force_guide_present = (
1200  // Telenor (NO)
1202 #if 0 // #9592#comment:23 - meanwhile my provider changed his signaling
1203  // Kabelplus (AT) formerly Kabelsignal, registered to NDS, see #9592
1204  (sdt->OriginalNetworkID() == 222) ||
1205 #endif
1206  // ERT (GR) from the private temporary allocation, see #9592:comment:17
1207  (sdt->OriginalNetworkID() == 65330) ||
1208  // Digitenne (NL) see #13427
1210  );
1211  // HACK end -- special exception for these networks
1212 
1213  // Figure out best service name and callsign...
1214  ServiceDescriptor *desc = sdt->GetServiceDescriptor(i);
1215  QString callsign;
1216  QString service_name;
1217  if (desc)
1218  {
1219  callsign = desc->ServiceShortName();
1220  if (callsign.trimmed().isEmpty())
1221  {
1222  callsign = QString("%1-%2-%3")
1223  .arg(ChannelUtil::GetUnknownCallsign()).arg(sdt->TSID())
1224  .arg(sdt->ServiceID(i));
1225  }
1226 
1227  service_name = desc->ServiceName();
1228  if (service_name.trimmed().isEmpty())
1229  service_name.clear();
1230 
1231  info.m_serviceType = desc->ServiceType();
1232  info.m_isDataService =
1233  (desc && !desc->IsDTV() && !desc->IsDigitalAudio());
1234  info.m_isAudioService = (desc && desc->IsDigitalAudio());
1235  delete desc;
1236  }
1237  else
1238  {
1239  LOG(VB_CHANSCAN, LOG_INFO, "ChannelScanSM: " +
1240  QString("No ServiceDescriptor for onid %1 tid %2 sid %3")
1241  .arg(sdt->OriginalNetworkID()).arg(sdt->TSID()).arg(sdt->ServiceID(i)));
1242  }
1243 
1244  if (info.m_callSign.isEmpty())
1245  info.m_callSign = callsign;
1246  if (info.m_serviceName.isEmpty())
1247  info.m_serviceName = service_name;
1248 
1249  info.m_useOnAirGuide =
1250  sdt->HasEITPresentFollowing(i) ||
1251  sdt->HasEITSchedule(i) ||
1252  force_guide_present;
1253 
1254  info.m_hidden = false;
1255  info.m_hiddenInGuide = false;
1256  info.m_serviceId = sdt->ServiceID(i);
1257  info.m_sdtTsId = sdt->TSID();
1258  info.m_origNetId = sdt->OriginalNetworkID();
1259  info.m_inSdt = true;
1260 
1261  desc_list_t parsed =
1263  sdt->ServiceDescriptorsLength(i));
1264  // Look for default authority
1265  const unsigned char *def_auth =
1267  if (def_auth)
1268  {
1269  DefaultAuthorityDescriptor authority(def_auth);
1270  if (authority.IsValid())
1271  {
1272 #if 0
1273  LOG(VB_CHANSCAN, LOG_DEBUG,
1274  QString("ChannelScanSM: Found default authority '%1' in SDT for service onid %2 tid %3 sid %4")
1275  .arg(authority.DefaultAuthority())
1276  .arg(info.m_origNetId).arg(info.m_sdtTsId).arg(info.m_serviceId));
1277 #endif
1278  info.m_defaultAuthority = authority.DefaultAuthority();
1279  return;
1280  }
1281  }
1282 
1283  // If no authority in the SDT then use the one found in the BAT or the SDTo
1284  uint64_t index = (uint64_t)info.m_origNetId << 32 |
1285  info.m_sdtTsId << 16 | info.m_serviceId;
1286  if (defAuthorities.contains(index))
1287  info.m_defaultAuthority = defAuthorities[index];
1288 
1289  // Is this service relocated from somewhere else?
1291  if (srdesc)
1292  {
1293  info.m_oldOrigNetId = srdesc->OldOriginalNetworkID();
1294  info.m_oldTsId = srdesc->OldTransportID();
1295  info.m_oldServiceId = srdesc->OldServiceID();
1296 
1297  LOG(VB_CHANSCAN, LOG_DEBUG, "ChannelScanSM: " +
1298  QString("Service '%1' onid:%2 tid:%3 sid:%4 ")
1299  .arg(info.m_serviceName)
1300  .arg(info.m_origNetId)
1301  .arg(info.m_sdtTsId)
1302  .arg(info.m_serviceId) +
1303  QString(" relocated from onid:%1 tid:%2 sid:%3")
1304  .arg(info.m_oldOrigNetId)
1305  .arg(info.m_oldTsId)
1306  .arg(info.m_oldServiceId));
1307 
1308  delete srdesc;
1309  }
1310 
1311 }
1312 
1314  QString &cur_chan, QString &cur_chan_tr) const
1315 {
1316  if (m_current.iter() == m_scanTransports.end())
1317  {
1318  cur_chan.clear();
1319  cur_chan_tr.clear();
1320  return 0;
1321  }
1322 
1323  uint max_chan_cnt = 0;
1324 
1325  QMap<uint,ChannelInsertInfo> list = GetChannelList(m_current, m_currentInfo);
1326  {
1327  for (const auto & info : qAsConst(list))
1328  {
1329  max_chan_cnt +=
1330  (info.m_inPat || info.m_inPmt ||
1331  info.m_inSdt || info.m_inVct) ? 1 : 0;
1332  }
1333  }
1334 
1335  QString offset_str_tr = m_current.offset() ?
1336  QObject::tr(" offset %2").arg(m_current.offset()) : "";
1337  cur_chan_tr = QString("%1%2")
1338  .arg((*m_current).m_friendlyName).arg(offset_str_tr);
1339 
1340  QString offset_str = m_current.offset() ?
1341  QString(" offset %2").arg(m_current.offset()) : "";
1342  cur_chan = QString("%1%2")
1343  .arg((*m_current).m_friendlyName).arg(offset_str);
1344 
1345  return max_chan_cnt;
1346 }
1347 
1348 QMap<uint,ChannelInsertInfo>
1350  ScannedChannelInfo *scan_info) const
1351 {
1352  QMap<uint,ChannelInsertInfo> pnum_to_dbchan;
1353 
1354  uint mplexid = (*trans_info).m_mplexid;
1355  int freqid = (*trans_info).m_friendlyNum;
1356  QString freqidStr = (freqid) ? QString::number(freqid) : QString("");
1357  QString iptv_channel = (*trans_info).m_iptvChannel;
1358 
1359  // channels.conf
1360  const DTVChannelInfoList &echan = (*trans_info).m_expectedChannels;
1361  for (const auto & chan : echan)
1362  {
1363  uint pnum = chan.m_serviceid;
1364  PCM_INFO_INIT("mpeg");
1365  info.m_serviceName = chan.m_name;
1366  info.m_inChannelsConf = true;
1367  }
1368 
1369  // PATs
1370  for (const auto& pat_list : qAsConst(scan_info->m_pats))
1371  {
1372  for (const auto *pat : pat_list)
1373  {
1374  bool could_be_opencable = false;
1375  for (uint i = 0; i < pat->ProgramCount(); ++i)
1376  {
1377  if ((pat->ProgramNumber(i) == 0) &&
1378  (pat->ProgramPID(i) == SCTE_PSIP_PID))
1379  {
1380  could_be_opencable = true;
1381  }
1382  }
1383 
1384  for (uint i = 0; i < pat->ProgramCount(); ++i)
1385  {
1386  uint pnum = pat->ProgramNumber(i);
1387  if (pnum)
1388  {
1389  PCM_INFO_INIT("mpeg");
1390  info.m_patTsId = pat->TransportStreamID();
1391  info.m_couldBeOpencable = could_be_opencable;
1392  info.m_inPat = true;
1393  }
1394  }
1395  }
1396  }
1397 
1398  // PMTs
1399  for (const auto *pmt : scan_info->m_pmts)
1400  {
1401  uint pnum = pmt->ProgramNumber();
1402  PCM_INFO_INIT("mpeg");
1403  for (uint i = 0; i < pmt->StreamCount(); ++i)
1404  {
1405  info.m_couldBeOpencable |=
1406  (StreamID::OpenCableVideo == pmt->StreamType(i));
1407  }
1408 
1410  pmt->ProgramInfo(), pmt->ProgramInfoLength(),
1412 
1413  for (auto & desc : descs)
1414  {
1415  RegistrationDescriptor reg(desc);
1416  if (!reg.IsValid())
1417  continue;
1418  if (reg.FormatIdentifierString() == "CUEI" ||
1419  reg.FormatIdentifierString() == "SCTE")
1420  info.m_couldBeOpencable = true;
1421  }
1422 
1423  info.m_isEncrypted |= pmt->IsEncrypted(GetDTVChannel()->GetSIStandard());
1424  info.m_inPmt = true;
1425  }
1426 
1427  // Cable VCTs
1428  for (const auto *cvct : scan_info->m_cvcts)
1429  {
1430  for (uint i = 0; i < cvct->ChannelCount(); ++i)
1431  {
1432  uint pnum = cvct->ProgramNumber(i);
1433  PCM_INFO_INIT("atsc");
1434  update_info(info, cvct, i);
1435 
1436  // One-part channel number, as defined in the ATSC Standard:
1437  // Program and System Information Protocol for Terrestrial Broadcast and Cable
1438  // Doc. A65/2013 7 August 2013 page 35
1439  if ((info.m_atscMajorChannel & 0x3F0) == 0x3F0)
1440  {
1441  info.m_chanNum = QString::number(((info.m_atscMajorChannel & 0x00F) << 10) + info.m_atscMinorChannel);
1442  }
1443  }
1444  }
1445 
1446  // Terrestrial VCTs
1447  for (const auto *tvct : scan_info->m_tvcts)
1448  {
1449  for (uint i = 0; i < tvct->ChannelCount(); ++i)
1450  {
1451  uint pnum = tvct->ProgramNumber(i);
1452  PCM_INFO_INIT("atsc");
1453  update_info(info, tvct, i);
1454  }
1455  }
1456 
1457  // SDTs
1458  QString siStandard = (scan_info->m_mgt == nullptr) ? "dvb" : "atsc";
1459  for (const auto& sdt_list : qAsConst(scan_info->m_sdts))
1460  {
1461  for (const auto *sdt_it : sdt_list)
1462  {
1463  for (uint i = 0; i < sdt_it->ServiceCount(); ++i)
1464  {
1465  uint pnum = sdt_it->ServiceID(i);
1466  PCM_INFO_INIT(siStandard);
1467  update_info(info, sdt_it, i, m_defAuthorities);
1468  }
1469  }
1470  }
1471 
1472  // NIT
1473  QMap<qlonglong, uint> ukChanNums;
1474  QMap<qlonglong, uint> scnChanNums;
1475  QMap<uint,ChannelInsertInfo>::iterator dbchan_it;
1476  for (dbchan_it = pnum_to_dbchan.begin();
1477  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1478  {
1479  ChannelInsertInfo &info = *dbchan_it;
1480 
1481  // NIT
1482  for (const auto *item : scan_info->m_nits)
1483  {
1484  for (uint i = 0; i < item->TransportStreamCount(); ++i)
1485  {
1486  const NetworkInformationTable *nit = item;
1487  if ((nit->TSID(i) == info.m_sdtTsId) &&
1488  (nit->OriginalNetworkID(i) == info.m_origNetId))
1489  {
1490  info.m_netId = nit->NetworkID();
1491  info.m_inNit = true;
1492  }
1493  else
1494  {
1495  continue;
1496  }
1497 
1498  // Descriptors in the transport stream loop of this transport in the NIT
1499  const desc_list_t &list =
1501  nit->TransportDescriptorsLength(i));
1502 
1503  // Presence of T2 delivery system descriptor indicates DVB-T2 delivery system
1504  // DVB BlueBook A038 (Feb 2019) page 104, paragraph 6.4.6.3
1505  {
1506  const unsigned char *desc =
1509 
1510  if (desc)
1511  {
1512  T2DeliverySystemDescriptor t2tdsd(desc);
1513  if (t2tdsd.IsValid())
1514  {
1515  (*trans_info).m_tuning.m_modSys = DTVModulationSystem::kModulationSystem_DVBT2;
1516  }
1517  }
1518  }
1519 
1520  // Logical channel numbers
1521  {
1522  const unsigned char *desc =
1525 
1526  if (desc)
1527  {
1528  DVBLogicalChannelDescriptor uklist(desc);
1529  if (!uklist.IsValid())
1530  continue;
1531  for (uint j = 0; j < uklist.ChannelCount(); ++j)
1532  {
1533  ukChanNums[((qlonglong)info.m_origNetId<<32) |
1534  uklist.ServiceID(j)] =
1535  uklist.ChannelNumber(j);
1536  }
1537  }
1538  }
1539 
1540  // HD Simulcast logical channel numbers
1541  {
1542  const unsigned char *desc =
1545 
1546  if (desc)
1547  {
1548  DVBSimulcastChannelDescriptor scnlist(desc);
1549  if (!scnlist.IsValid())
1550  continue;
1551  for (uint j = 0; j < scnlist.ChannelCount(); ++j)
1552  {
1553  scnChanNums[((qlonglong)info.m_origNetId<<32) |
1554  scnlist.ServiceID(j)] =
1555  scnlist.ChannelNumber(j);
1556  }
1557  }
1558  }
1559  }
1560  }
1561  }
1562 
1563  // BAT
1564 
1565  // Channel numbers for Freesat and Sky on Astra 28.2E
1566  //
1567  // Get the Logical Channel Number (LCN) information from the BAT.
1568  // The first filter is on the bouquet ID.
1569  // Then collect all LCN for the selected region and
1570  // for the common (undefined) region with id 0xFFFF.
1571  // The LCN of the selected region has priority; if
1572  // a service is not defined there then the value of the LCN
1573  // table of the common region is used.
1574  // This works because the BAT of each transport contains
1575  // the LCN of all transports and services for all bouquets.
1576  //
1577  // For reference, this website has the Freesat and Sky channel numbers
1578  // for each bouquet and region:
1579  // https://www.satellite-calculations.com/DVB/28.2E/28E_FreeSat_ChannelNumber.php
1580  // https://www.satellite-calculations.com/DVB/28.2E/28E_Sky_ChannelNumber.php
1581  //
1582 
1583  // Lookup table from LCN to service ID
1584  QMap<uint,qlonglong> lcn_sid;
1585 
1586  for (const auto *bat : scan_info->m_bats)
1587  {
1588  // Only the bouquet selected by user
1589  if (bat->BouquetID() != m_bouquetId)
1590  continue;
1591 
1592  for (uint t = 0; t < bat->TransportStreamCount(); ++t)
1593  {
1594  uint netid = bat->OriginalNetworkID(t);
1595 
1596  // No network check to allow scanning on all Sky satellites
1597 #if 0
1598  if (!(netid == OriginalNetworkID::SES2 ||
1599  netid == OriginalNetworkID::BBC ||
1600  netid == OriginalNetworkID::SKYNZ ))
1601  continue;
1602 #endif
1603  desc_list_t parsed =
1604  MPEGDescriptor::Parse(bat->TransportDescriptors(t),
1605  bat->TransportDescriptorsLength(t));
1606 
1607  uint priv_dsid = 0;
1608  for (const auto *item : parsed)
1609  {
1610  if (item[0] == DescriptorID::private_data_specifier)
1611  {
1613  if (pd.IsValid())
1614  priv_dsid = pd.PrivateDataSpecifier();
1615  }
1616 
1617  // Freesat logical channels
1618  if (priv_dsid == PrivateDataSpecifierID::FSAT &&
1620  {
1621  FreesatLCNDescriptor ld(item);
1622  if (ld.IsValid())
1623  {
1624  for (uint i = 0; i<ld.ServiceCount(); i++)
1625  {
1626  uint service_id = ld.ServiceID(i);
1627  for (uint j=0; j<ld.LCNCount(i); j++)
1628  {
1629  uint region_id = ld.RegionID(i,j);
1630  uint lcn = ld.LogicalChannelNumber(i,j);
1631  if (region_id == m_regionId)
1632  {
1633  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1634  }
1635  else if (region_id == kRegionUndefined)
1636  {
1637  if (lcn_sid.value(lcn,0) == 0)
1638  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1639  }
1640  }
1641  }
1642  }
1643  }
1644 
1645  // Sky logical channels
1646  if (priv_dsid == PrivateDataSpecifierID::BSB1 &&
1648  {
1649  SkyLCNDescriptor ld(item);
1650  if (ld.IsValid())
1651  {
1652  uint region_id = ld.RegionID();
1653  for (uint i = 0; i<ld.ServiceCount(); i++)
1654  {
1655  uint service_id = ld.ServiceID(i);
1656  uint lcn = ld.LogicalChannelNumber(i);
1657  if (region_id == m_regionId)
1658  {
1659  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1660  }
1661  else if (region_id == kRegionUndefined)
1662  {
1663  if (lcn_sid.value(lcn,0) == 0)
1664  lcn_sid[lcn] = ((qlonglong)netid<<32) | service_id;
1665  }
1666 #if 0
1667  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1668  QString("LCN bid:%1 tid:%2 rid:%3 sid:%4 lcn:%5")
1669  .arg(bat->BouquetID()).arg(bat->TSID(t)).arg(region_id).arg(service_id).arg(lcn));
1670 #endif
1671  }
1672  }
1673  }
1674  }
1675  }
1676  }
1677 
1678  // Create the reverse table from service id to LCN.
1679  // If the service has more than one logical
1680  // channel number the lowest number is used.
1681  QMap<qlonglong, uint> sid_lcn;
1682  QMap<uint, qlonglong>::const_iterator r = lcn_sid.constEnd();
1683  while (r != lcn_sid.constBegin())
1684  {
1685  --r;
1686  qlonglong sid = r.value();
1687  uint lcn = r.key();
1688  sid_lcn[sid] = lcn;
1689  }
1690 
1691  // ------------------------------------------------------------------------
1692 
1693  // Get IPTV channel numbers
1694  for (dbchan_it = pnum_to_dbchan.begin();
1695  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1696  {
1697  ChannelInsertInfo &info = *dbchan_it;
1698 
1699  if (!info.m_chanNum.isEmpty())
1700  continue;
1701 
1702  if (!iptv_channel.isEmpty())
1703  {
1704  info.m_chanNum = iptv_channel;
1705  if (info.m_serviceId)
1706  info.m_chanNum += "-" + QString::number(info.m_serviceId);
1707  }
1708  }
1709 
1710  // Get DVB Logical Channel Numbers
1711  for (dbchan_it = pnum_to_dbchan.begin();
1712  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1713  {
1714  ChannelInsertInfo &info = *dbchan_it;
1715 
1716  if (!info.m_chanNum.isEmpty())
1717  continue;
1718 
1719  // DVB HD Simulcast channel numbers
1720  //
1721  // The HD simulcast channel number table gives the correct channel number
1722  // when HD and SD versions of the same channel are simultaneously broadcast
1723  // and the receiver is capable of receiving the HD signal.
1724  // The latter is assumed correct for a MythTV system.
1725  //
1726  if (info.m_chanNum.isEmpty())
1727  {
1728  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1729  QMap<qlonglong, uint>::const_iterator it = scnChanNums.constFind(key);
1730 
1731  if (it != scnChanNums.constEnd())
1732  {
1733  info.m_chanNum = QString::number(*it);
1734  }
1735  }
1736 
1737  // DVB Logical Channel Numbers (a.k.a. UK channel numbers)
1738  if (info.m_chanNum.isEmpty())
1739  {
1740  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1741  QMap<qlonglong, uint>::const_iterator it = ukChanNums.constFind(key);
1742 
1743  if (it != ukChanNums.constEnd())
1744  {
1745  info.m_chanNum = QString::number(*it);
1746  }
1747  }
1748 
1749  // Freesat and Sky channel numbers
1750  if (info.m_chanNum.isEmpty())
1751  {
1752  qlonglong key = ((qlonglong)info.m_origNetId<<32) | info.m_serviceId;
1753  QMap<qlonglong, uint>::const_iterator it = sid_lcn.constFind(key);
1754 
1755  if (it != sid_lcn.constEnd())
1756  {
1757  info.m_chanNum = QString::number(*it);
1758  }
1759  }
1760 
1761  LOG(VB_CHANSCAN, LOG_INFO, LOC +
1762  QString("GetChannelList: service %1 (0x%2) chan_num '%3' callsign '%4'")
1763  .arg(info.m_serviceId).arg(info.m_serviceId,4,16,QChar('0'))
1764  .arg(info.m_chanNum).arg(info.m_callSign));
1765  }
1766 
1767  // Get QAM/SCTE/MPEG channel numbers
1768  for (dbchan_it = pnum_to_dbchan.begin();
1769  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1770  {
1771  ChannelInsertInfo &info = *dbchan_it;
1772 
1773  if (!info.m_chanNum.isEmpty())
1774  continue;
1775 
1776  if ((info.m_siStandard == "mpeg") ||
1777  (info.m_siStandard == "scte") ||
1778  (info.m_siStandard == "opencable"))
1779  {
1780  if (info.m_freqId.isEmpty())
1781  {
1782  info.m_chanNum = QString("%1-%2")
1783  .arg(info.m_sourceId)
1784  .arg(info.m_serviceId);
1785  }
1786  else
1787  {
1788  info.m_chanNum = QString("%1-%2")
1789  .arg(info.m_freqId)
1790  .arg(info.m_serviceId);
1791  }
1792  }
1793  }
1794 
1795  // Check for decryption success
1796  for (dbchan_it = pnum_to_dbchan.begin();
1797  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1798  {
1799  uint pnum = dbchan_it.key();
1800  ChannelInsertInfo &info = *dbchan_it;
1801  info.m_decryptionStatus = scan_info->m_programEncryptionStatus[pnum];
1802  }
1803 
1804  return pnum_to_dbchan;
1805 }
1806 
1808 {
1809  ScanDTVTransportList list;
1810 
1811  uint cardid = m_channel->GetInputID();
1812 
1814  tuner_type = GuessDTVTunerType(tuner_type);
1815 
1816  for (const auto & it : qAsConst(m_channelList))
1817  {
1818  QMap<uint,ChannelInsertInfo> pnum_to_dbchan =
1819  GetChannelList(it.first, it.second);
1820 
1821  ScanDTVTransport item((*it.first).m_tuning, tuner_type, cardid);
1822  item.m_iptvTuning = (*(it.first)).m_iptvTuning;
1823  item.m_signalStrength = (*(it.first)).m_signalStrength;
1824  item.m_networkID = (*(it.first)).m_networkID;
1825  item.m_transportID = (*(it.first)).m_transportID;
1826 
1827  QMap<uint,ChannelInsertInfo>::iterator dbchan_it;
1828  for (dbchan_it = pnum_to_dbchan.begin();
1829  dbchan_it != pnum_to_dbchan.end(); ++dbchan_it)
1830  {
1831  item.m_channels.push_back(*dbchan_it);
1832  }
1833 
1834  if (!item.m_channels.empty())
1835  {
1836  if (addFullTS)
1837  {
1838  /* If addFullTS, then add a 'MPTS' channel
1839  which can be used to record the entire MPTS from
1840  the transport. */
1841  dbchan_it = pnum_to_dbchan.begin();
1842  ChannelInsertInfo info = *dbchan_it;
1843 
1844  // Use transport stream ID as (fake) service ID
1845  // to use in callsign and as channel number
1846  info.m_serviceId = info.m_sdtTsId ? info.m_sdtTsId : info.m_patTsId;
1847 
1848  if (tuner_type == DTVTunerType::kTunerTypeASI)
1849  {
1850  info.m_callSign = QString("MPTS_%1")
1851  .arg(CardUtil::GetDisplayName(cardid));
1852  }
1853  else if (info.m_siStandard == "mpeg" ||
1854  info.m_siStandard == "scte" ||
1855  info.m_siStandard == "opencable")
1856  {
1857  info.m_callSign = QString("MPTS_%1").arg(info.m_freqId);
1858  }
1859  else if (info.m_atscMajorChannel > 0)
1860  {
1861  if (info.m_atscMajorChannel < 0x3F0)
1862  {
1863  info.m_callSign = QString("MPTS_%1").arg(info.m_atscMajorChannel);
1864  }
1865  else
1866  {
1867  info.m_callSign = QString("MPTS_%1").arg(info.m_freqId);
1868  }
1869  }
1870  else if (info.m_serviceId > 0)
1871  {
1872  info.m_callSign = QString("MPTS_%1").arg(info.m_serviceId);
1873  }
1874  else if (!info.m_chanNum.isEmpty())
1875  {
1876  info.m_callSign = QString("MPTS_%1").arg(info.m_chanNum);
1877  }
1878  else
1879  {
1880  info.m_callSign = "MPTS_UNKNOWN";
1881  }
1882 
1883  info.m_serviceName = info.m_callSign;
1884  info.m_atscMinorChannel = 0;
1885  info.m_format = "MPTS";
1886  info.m_useOnAirGuide = false;
1887  info.m_isEncrypted = false;
1888  item.m_channels.push_back(info);
1889  }
1890 
1891  list.push_back(item);
1892  }
1893  }
1894 
1895  return list;
1896 }
1897 
1899 {
1900  return dynamic_cast<DTVSignalMonitor*>(m_signalMonitor);
1901 }
1902 
1904 {
1905 #ifdef USING_DVB
1906  return dynamic_cast<DVBSignalMonitor*>(m_signalMonitor);
1907 #else
1908  return nullptr;
1909 #endif
1910 }
1911 
1913 {
1914  return dynamic_cast<DTVChannel*>(m_channel);
1915 }
1916 
1918 {
1919  return dynamic_cast<const DTVChannel*>(m_channel);
1920 }
1921 
1923 {
1924 #ifdef USING_HDHOMERUN
1925  return dynamic_cast<HDHRChannel*>(m_channel);
1926 #else
1927  return nullptr;
1928 #endif
1929 }
1930 
1932 {
1933 #ifdef USING_DVB
1934  return dynamic_cast<DVBChannel*>(m_channel);
1935 #else
1936  return nullptr;
1937 #endif
1938 }
1939 
1941 {
1942 #ifdef USING_DVB
1943  return dynamic_cast<const DVBChannel*>(m_channel);
1944 #else
1945  return nullptr;
1946 #endif
1947 }
1948 
1950 {
1951 #ifdef USING_V4L2
1952  return dynamic_cast<V4LChannel*>(m_channel);
1953 #else
1954  return nullptr;
1955 #endif
1956 }
1957 
1962 {
1963  while (m_scannerThread)
1964  {
1965  m_threadExit = true;
1966  if (m_scannerThread->wait(1000))
1967  {
1968  delete m_scannerThread;
1969  m_scannerThread = nullptr;
1970  }
1971  }
1972  m_threadExit = false;
1973  m_scannerThread = new MThread("Scanner", this);
1975 }
1976 
1981 {
1982  LOG(VB_CHANSCAN, LOG_INFO, LOC + "run -- begin");
1983 
1984  while (!m_threadExit)
1985  {
1986  if (m_scanning)
1987  HandleActiveScan();
1988 
1989  usleep(10 * 1000);
1990  }
1991 
1992  LOG(VB_CHANSCAN, LOG_INFO, LOC + "run -- end");
1993 }
1994 
1995 // See if we have timed out
1997 {
1999  m_timer.hasExpired(kDecryptionTimeout))
2000  {
2002  return true;
2003  }
2004 
2005  if (!m_waitingForTables)
2006  return true;
2007 
2008 #ifdef USING_DVB
2009  // If the rotor is still moving, reset the timer and keep waiting
2011  if (sigmon)
2012  {
2013  const DiSEqCDevRotor *rotor = GetDVBChannel()->GetRotor();
2014  if (rotor)
2015  {
2016  bool was_moving = false;
2017  bool is_moving = false;
2018  sigmon->GetRotorStatus(was_moving, is_moving);
2019  if (was_moving && !is_moving)
2020  {
2021  m_timer.restart();
2022  return false;
2023  }
2024  }
2025  }
2026 #endif // USING_DVB
2027 
2028  // have the tables have timed out?
2029  if (m_timer.hasExpired(m_channelTimeout))
2030  {
2031  // the channelTimeout alone is only valid if we have seen no tables..
2032  const ScanStreamData *sd = nullptr;
2033  if (GetDTVSignalMonitor())
2035 
2036  if (!sd)
2037  return true;
2038 
2039  if (sd->HasCachedAnyNIT() || sd->HasCachedAnySDTs())
2040  return m_timer.hasExpired(kDVBTableTimeout);
2041  if (sd->HasCachedMGT() || sd->HasCachedAnyVCTs())
2042  return m_timer.hasExpired(kATSCTableTimeout);
2043  if (sd->HasCachedAnyPAT() || sd->HasCachedAnyPMTs())
2044  return m_timer.hasExpired(kMPEGTableTimeout);
2045 
2046  return true;
2047  }
2048 
2049  // ok the tables haven't timed out, but have we hit the signal timeout?
2051  if (m_timer.hasExpired((*m_current).m_timeoutTune) &&
2052  sm && !sm->HasSignalLock())
2053  {
2054  const ScanStreamData *sd = nullptr;
2055  if (GetDTVSignalMonitor())
2057 
2058  if (!sd)
2059  return true;
2060 
2061  // Just is case we temporarily lose the signal after we've seen
2062  // tables...
2063  if (!sd->HasCachedAnyPAT() && !sd->HasCachedAnyPMTs() &&
2064  !sd->HasCachedMGT() && !sd->HasCachedAnyVCTs() &&
2065  !sd->HasCachedAnyNIT() && !sd->HasCachedAnySDTs())
2066  {
2067  return true;
2068  }
2069  }
2070 
2071  return false;
2072 }
2073 
2078 {
2079  QMutexLocker locker(&m_lock);
2080 
2081  bool do_post_insertion = m_waitingForTables;
2082 
2083  if (!HasTimedOut())
2084  return;
2085 
2086  if (0 == m_nextIt.offset() && m_nextIt == m_scanTransports.begin())
2087  {
2088  m_channelList.clear();
2089  m_channelsFound = 0;
2090  m_dvbt2Tried = true;
2091  }
2092 
2094  {
2095  // If we failed to get a lock with DVB-T try DVB-T2.
2096  m_dvbt2Tried = true;
2098  return;
2099  }
2100 
2101  if (0 == m_nextIt.offset() && m_nextIt != m_scanTransports.begin())
2102  {
2103  // Add channel to scanned list and potentially check decryption
2104  if (do_post_insertion && !UpdateChannelInfo(false))
2105  return;
2106 
2107  // Stop signal monitor for previous transport
2108  locker.unlock();
2109  m_signalMonitor->Stop();
2110  locker.relock();
2111  }
2112 
2113  m_current = m_nextIt; // Increment current
2114  m_dvbt2Tried = false;
2115 
2116  if (m_current != m_scanTransports.end())
2117  {
2119 
2120  // Increment nextIt
2121  m_nextIt = m_current;
2122  ++m_nextIt;
2123  }
2124  else if (!m_extendTransports.isEmpty())
2125  {
2126  --m_current;
2127  QMap<uint32_t,DTVMultiplex>::iterator it = m_extendTransports.begin();
2128  while (it != m_extendTransports.end())
2129  {
2130  if (!m_tsScanned.contains(it.key()))
2131  {
2132  QString name = QString("TransportID %1").arg(it.key() & 0xffff);
2133  TransportScanItem item(m_sourceID, name, *it, m_signalTimeout);
2134  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Adding " + name + ' ' + item.m_tuning.toString());
2135  m_scanTransports.push_back(item);
2136  m_tsScanned.insert(it.key());
2137  }
2138  ++it;
2139  }
2140  m_extendTransports.clear();
2141  m_nextIt = m_current;
2142  ++m_nextIt;
2143  }
2144  else
2145  {
2147  m_scanning = false;
2149  }
2150 }
2151 
2153 {
2154  const TransportScanItem &item = *transport;
2155 
2156 #ifdef USING_DVB
2158  if (monitor)
2159  {
2160  // always wait for rotor to finish
2162  monitor->SetRotorTarget(1.0F);
2163  }
2164 #endif // USING_DVB
2165 
2167  if (!channel)
2168  return false;
2169 
2170  if (item.m_mplexid > 0 && transport.offset() == 0)
2171  return channel->TuneMultiplex(item.m_mplexid, m_inputName);
2172 
2173  if (item.m_tuning.m_sistandard == "MPEG")
2174  return channel->Tune(item.m_iptvTuning, true);
2175 
2176  const uint64_t freq = item.freq_offset(transport.offset());
2177  DTVMultiplex tuning = item.m_tuning;
2178  tuning.m_frequency = freq;
2179 
2181  {
2183  }
2185  {
2186  if (m_dvbt2Tried)
2188  else
2190  }
2191 
2192  return channel->Tune(tuning);
2193 }
2194 
2196 {
2197  QString offset_str = (transport.offset()) ?
2198  QObject::tr(" offset %2").arg(transport.offset()) : "";
2199  QString cur_chan = QString("%1%2")
2200  .arg((*m_current).m_friendlyName).arg(offset_str);
2201  QString tune_msg_str =
2202  QObject::tr("ScanTransport Tuning to %1 mplexid(%2)")
2203  .arg(cur_chan).arg((*m_current).m_mplexid);
2204 
2205  const TransportScanItem &item = *transport;
2206 
2207  if (transport.offset() &&
2208  (item.freq_offset(transport.offset()) == item.freq_offset(0)))
2209  {
2210  m_waitingForTables = false;
2211  return; // nothing to do
2212  }
2213 
2214  if (m_channelsFound)
2215  {
2216  QString progress = QObject::tr("Found %n", "", m_channelsFound);
2218  }
2219 
2221  LOG(VB_CHANSCAN, LOG_INFO, LOC + tune_msg_str);
2222 
2223  if (!Tune(transport))
2224  { // If we did not tune successfully, bail with message
2226  LOG(VB_CHANSCAN, LOG_ERR, LOC +
2227  QString("Failed to tune %1 mplexid(%2) at offset %3")
2228  .arg(item.m_friendlyName).arg(item.m_mplexid)
2229  .arg(transport.offset()));
2230  return;
2231  }
2232 
2233  // If we have a DTV Signal Monitor, perform table scanner reset
2234  if (GetDTVSignalMonitor() && GetDTVSignalMonitor()->GetScanStreamData())
2235  {
2237  GetDTVSignalMonitor()->SetChannel(-1,-1);
2238  GetDTVSignalMonitor()->SetDVBService(0, 0, -1);
2239  }
2240 
2241  // Start signal monitor for this channel
2242  if (m_signalMonitor)
2244 
2245  m_timer.start();
2246  m_waitingForTables = (item.m_tuning.m_sistandard != "analog");
2247 }
2248 
2254 {
2255  LOG(VB_CHANSCAN, LOG_INFO, LOC + "StopScanner");
2256 
2257  while (m_scannerThread)
2258  {
2259  m_threadExit = true;
2260  if (m_scannerThread->wait(1000))
2261  {
2262  delete m_scannerThread;
2263  m_scannerThread = nullptr;
2264  }
2265  }
2266 
2267  if (m_signalMonitor)
2268  m_signalMonitor->Stop();
2269 }
2270 
2276  int SourceID,
2277  const QString &std,
2278  const QString &modulation,
2279  const QString &country,
2280  const QString &table_start,
2281  const QString &table_end)
2282 {
2283  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
2284  QString("%1:%2 ").arg(__FUNCTION__).arg(__LINE__) +
2285  QString("SourceID:%1 ").arg(SourceID) +
2286  QString("std:%1 ").arg(std) +
2287  QString("modulation:%1 ").arg(modulation) +
2288  QString("country:%1 ").arg(country) +
2289  QString("table_start:%1 ").arg(table_start) +
2290  QString("table_end:%1 ").arg(table_end));
2291 
2292  QString name("");
2293  if (m_scanning)
2294  return false;
2295 
2296  m_scanTransports.clear();
2297  m_nextIt = m_scanTransports.end();
2298 
2299  freq_table_list_t tables =
2300  get_matching_freq_tables(std, modulation, country);
2301 
2302  if (tables.empty())
2303  {
2304  QString msg = QString("No freq table for (%1, %2, %3) found")
2305  .arg(std).arg(modulation).arg(country);
2307  }
2308  LOG(VB_CHANSCAN, LOG_INFO, LOC +
2309  QString("Looked up freq table (%1, %2, %3) w/%4 entries")
2310  .arg(std).arg(modulation).arg(country).arg(tables.size()));
2311 
2312  QString start = table_start;
2313  const QString& end = table_end;
2314  // NOLINTNEXTLINE(modernize-loop-convert)
2315  for (auto it = tables.begin(); it != tables.end(); ++it)
2316  {
2317  const FrequencyTable &ft = **it;
2318  int name_num = ft.m_nameOffset;
2319  QString strNameFormat = ft.m_nameFormat;
2320  uint freq = ft.m_frequencyStart;
2321  while (freq <= ft.m_frequencyEnd)
2322  {
2323  name = strNameFormat;
2324  if (strNameFormat.indexOf("%") >= 0)
2325  name = strNameFormat.arg(name_num);
2326 
2327  if (start.isEmpty() || name == start)
2328  {
2329  start.clear();
2330 
2331  TransportScanItem item(SourceID, std, name, name_num,
2332  freq, ft, m_signalTimeout);
2333  m_scanTransports.push_back(item);
2334 
2335  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanTransports " +
2336  item.toString());
2337  }
2338 
2339  ++name_num;
2340  freq += ft.m_frequencyStep;
2341 
2342  if (!end.isEmpty() && name == end)
2343  break;
2344  }
2345  if (!end.isEmpty() && name == end)
2346  break;
2347  }
2348 
2349  while (!tables.empty())
2350  {
2351  delete tables.back();
2352  tables.pop_back();
2353  }
2354 
2355  m_extendScanList = true;
2356  m_timer.start();
2357  m_waitingForTables = false;
2358 
2359  m_nextIt = m_scanTransports.begin();
2360  m_transportsScanned = 0;
2361  m_scanning = true;
2362 
2363  return true;
2364 }
2365 
2367  const QString &std,
2368  const QString &cardtype,
2369  const DTVChannelList &channels)
2370 {
2371  m_scanTransports.clear();
2372  m_nextIt = m_scanTransports.end();
2373 
2374  DTVTunerType tunertype;
2375  tunertype.Parse(cardtype);
2376 
2377  auto it = channels.cbegin();
2378  for (uint i = 0; it != channels.cend(); ++it, ++i)
2379  {
2380  DTVTransport tmp = *it;
2381  tmp.m_sistandard = std;
2382  TransportScanItem item(sourceid, QString::number(i),
2383  tunertype, tmp, m_signalTimeout);
2384 
2385  m_scanTransports.push_back(item);
2386 
2387  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanForChannels " + item.toString());
2388  }
2389 
2390  if (m_scanTransports.empty())
2391  {
2392  LOG(VB_GENERAL, LOG_ERR, LOC + "ScanForChannels() no transports");
2393  return false;
2394  }
2395 
2396  m_timer.start();
2397  m_waitingForTables = false;
2398 
2399  m_nextIt = m_scanTransports.begin();
2400  m_transportsScanned = 0;
2401  m_scanning = true;
2402 
2403  return true;
2404 }
2405 
2407  const fbox_chan_map_t &iptv_channels)
2408 {
2409  m_scanTransports.clear();
2410  m_nextIt = m_scanTransports.end();
2411 
2412  fbox_chan_map_t::const_iterator Ichan = iptv_channels.begin();
2413  for (uint idx = 0; Ichan != iptv_channels.end(); ++Ichan, ++idx)
2414  {
2415  TransportScanItem item(sourceid, QString::number(idx),
2416  Ichan.value().m_tuning, Ichan.key(),
2417  m_signalTimeout);
2418 
2419  m_scanTransports.push_back(item);
2420 
2421  LOG(VB_CHANSCAN, LOG_INFO, LOC + "ScanIPTVChannels " + item.toString());
2422  }
2423 
2424  if (m_scanTransports.empty())
2425  {
2426  LOG(VB_GENERAL, LOG_ERR, LOC + "ScanIPTVChannels() no transports");
2427  return false;
2428  }
2429 
2430  m_timer.start();
2431  m_waitingForTables = false;
2432 
2433  m_nextIt = m_scanTransports.begin();
2434  m_transportsScanned = 0;
2435  m_scanning = true;
2436 
2437  return true;
2438 }
2439 
2440 
2446  int sourceid, const QMap<QString,QString> &startChan)
2447 {
2448  if (startChan.find("std") == startChan.end() ||
2449  startChan.find("type") == startChan.end())
2450  {
2451  return false;
2452  }
2453 
2454  QString std = *startChan.find("std");
2455  QString si_std = (std.toLower() != "atsc") ? "dvb" : "atsc";
2456  bool ok = false;
2457 
2458  if (m_scanning)
2459  return false;
2460 
2461  m_scanTransports.clear();
2462  m_nextIt = m_scanTransports.end();
2463 
2464  DTVMultiplex tuning;
2465 
2467  ok = type.Parse(startChan["type"]);
2468 
2469  if (ok)
2470  {
2471  ok = tuning.ParseTuningParams(
2472  type,
2473  startChan["frequency"], startChan["inversion"],
2474  startChan["symbolrate"], startChan["fec"],
2475  startChan["polarity"],
2476  startChan["coderate_hp"], startChan["coderate_lp"],
2477  startChan["constellation"], startChan["trans_mode"],
2478  startChan["guard_interval"], startChan["hierarchy"],
2479  startChan["modulation"], startChan["bandwidth"],
2480  startChan["mod_sys"], startChan["rolloff"]);
2481  }
2482 
2483  if (ok)
2484  {
2485  tuning.m_sistandard = si_std;
2486  TransportScanItem item(
2487  sourceid, QObject::tr("Frequency %1").arg(startChan["frequency"]),
2488  tuning, m_signalTimeout);
2489  m_scanTransports.push_back(item);
2490  }
2491 
2492  if (!ok)
2493  return false;
2494 
2495  m_extendScanList = true;
2496 
2497  m_timer.start();
2498  m_waitingForTables = false;
2499 
2500  m_nextIt = m_scanTransports.begin();
2501  m_transportsScanned = 0;
2502  m_scanning = true;
2503 
2504  return true;
2505 }
2506 
2508 {
2510  query.prepare(
2511  "SELECT sourceid, sistandard, transportid, frequency, modulation, mod_sys "
2512  "FROM dtv_multiplex "
2513  "WHERE mplexid = :MPLEXID");
2514  query.bindValue(":MPLEXID", mplexid);
2515  if (!query.exec())
2516  {
2517  MythDB::DBError("ChannelScanSM::AddToList()", query);
2518  return false;
2519  }
2520 
2521  if (!query.next())
2522  {
2523  LOG(VB_GENERAL, LOG_ERR, LOC + "AddToList() " +
2524  QString("Failed to locate mplexid(%1) in DB").arg(mplexid));
2525  return false;
2526  }
2527 
2528  uint sourceid = query.value(0).toUInt();
2529  QString sistandard = query.value(1).toString();
2530  uint tsid = query.value(2).toUInt();
2531  uint frequency = query.value(3).toUInt();
2532  QString modulation = query.value(4).toString();
2533  QString mod_sys = query.value(5).toString();
2534  DTVModulationSystem delsys;
2535  delsys.Parse(mod_sys);
2537  QString fn = (tsid) ? QString("Transport ID %1").arg(tsid) :
2538  QString("Multiplex #%1").arg(mplexid);
2539 
2540  if (modulation == "8vsb")
2541  {
2542  QString chan = QString("%1 Hz").arg(frequency);
2543  int findFrequency = (query.value(3).toInt() / 1000) - 1750;
2544  for (const auto & list : gChanLists[0].list)
2545  {
2546  if ((list.freq <= findFrequency + 200) &&
2547  (list.freq >= findFrequency - 200))
2548  {
2549  chan = QString("%1").arg(list.name);
2550  }
2551  }
2552  fn = QObject::tr("ATSC Channel %1").arg(chan);
2554  }
2555 
2556  tt = GuessDTVTunerType(tt);
2557 
2558  TransportScanItem item(sourceid, sistandard, fn, mplexid, m_signalTimeout);
2559 
2560  LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
2561  QString("tunertype:%1 %2 sourceid:%3 sistandard:%4 fn:'%5' mplexid:%6")
2562  .arg(tt).arg(tt.toString()).arg(sourceid).arg(sistandard).arg(fn).arg(mplexid));
2563 
2564  if (item.m_tuning.FillFromDB(tt, mplexid))
2565  {
2566  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Adding " + fn);
2567  m_scanTransports.push_back(item);
2568  return true;
2569  }
2570 
2571  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Not adding incomplete transport " + fn);
2572  return false;
2573 }
2574 
2575 bool ChannelScanSM::ScanTransport(uint mplexid, bool follow_nit)
2576 {
2577  m_scanTransports.clear();
2578  m_nextIt = m_scanTransports.end();
2579 
2580  AddToList(mplexid);
2581 
2582  m_timer.start();
2583  m_waitingForTables = false;
2584 
2585  m_extendScanList = follow_nit;
2586  m_transportsScanned = 0;
2587  if (!m_scanTransports.empty())
2588  {
2589  m_nextIt = m_scanTransports.begin();
2590  m_scanning = true;
2591  return true;
2592  }
2593 
2594  return false;
2595 }
2596 
2597 bool ChannelScanSM::ScanCurrentTransport(const QString &sistandard)
2598 {
2599  m_scanTransports.clear();
2600  m_nextIt = m_scanTransports.end();
2601 
2602  m_signalTimeout = 30000;
2603  QString name;
2604  TransportScanItem item(m_sourceID, sistandard, name, 0, m_signalTimeout);
2605  m_scanTransports.push_back(item);
2606 
2607  m_timer.start();
2608  m_waitingForTables = false;
2609  m_extendScanList = false;
2610  m_transportsScanned = 0;
2611  m_nextIt = m_scanTransports.begin();
2612  m_scanning = true;
2613  return true;
2614 }
2615 
2620  const DTVChannelInfoList &channels,
2621  uint mpeg_program_num,
2622  QString &service_name,
2623  QString &callsign,
2624  QString &common_status_info)
2625 {
2626  if (channels.empty())
2627  return true;
2628 
2629  bool found = false;
2630  for (const auto & channel : channels)
2631  {
2632  LOG(VB_GENERAL, LOG_DEBUG, LOC +
2633  QString("comparing %1 %2 against %3 %4")
2634  .arg(channel.m_serviceid).arg(channel.m_name)
2635  .arg(mpeg_program_num).arg(common_status_info));
2636 
2637  if (channel.m_serviceid == mpeg_program_num)
2638  {
2639  found = true;
2640  if (!channel.m_name.isEmpty())
2641  {
2642  service_name = channel.m_name;
2643  callsign = channel.m_name;
2644  }
2645  }
2646  }
2647 
2648  if (found)
2649  {
2650  common_status_info += QString(" %1 %2")
2651  .arg(QObject::tr("as")).arg(service_name);
2652  }
2653  else
2654  {
2656  QObject::tr("Skipping %1, not in imported channel map")
2657  .arg(common_status_info));
2658  }
2659 
2660  return found;
2661 }
ServiceRelocatedDescriptor
Definition: dvbdescriptors.h:1414
NetworkInformationTable::TransportDescriptorsLength
uint TransportDescriptorsLength(uint i) const
trans_desc_length 12 4.4+p
Definition: dvbtables.h:85
ChannelInsertInfo::m_isEncrypted
bool m_isEncrypted
Definition: channelinfo.h: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
Tuning info.
Definition: frequencytables.h:182
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:204
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:126
ChannelScanSM::m_otherTableTime
uint m_otherTableTime
Definition: channelscan_sm.h:214
ProgramAssociationTable::ProgramPID
uint ProgramPID(uint i) const
Definition: mpegtables.h:635
VirtualChannelTable
This table contains information about the channels transmitted on this multiplex.
Definition: atsctables.h:190
kEncUnknown
@ kEncUnknown
Definition: mpegstreamdata.h:56
DTVMultiplex
Definition: dtvmultiplex.h:25
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:252
DVBStreamData::GetCachedBATs
bat_vec_t GetCachedBATs(bool current=true) const
Definition: dvbstreamdata.cpp:845
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:288
DVBStreamData::GetCachedSDTs
sdt_vec_t GetCachedSDTs(bool current=true) const
Definition: dvbstreamdata.cpp:912
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
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:343
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:766
NetworkInformationTable::TSID
uint TSID(uint i) const
transport_stream_id 16 0.0+p
Definition: dvbtables.h:79
FrequencyTable
Definition: frequencytables.h:39
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:1138
ChannelScanSM::HandleSDTo
void HandleSDTo(uint tsid, const ServiceDescriptionTable *sdt) override
Definition: channelscan_sm.cpp:573
DiSEqCDevRotor
Rotor class.
Definition: diseqc.h:303
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:693
mythdb.h
ChannelScanSM::m_scannerThread
MThread * m_scannerThread
Scanner thread, runs ChannelScanSM::run()
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:2592
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
StreamID::OpenCableVideo
@ OpenCableVideo
Always MPEG-2??
Definition: mpegtables.h:120
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
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
pretty name format
Definition: frequencytables.h:95
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:148
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:682
channelscan_sm.h
progress
bool progress
Definition: mythtv/programs/mythcommflag/main.cpp:73
ChannelScanSM::m_scanning
bool m_scanning
Definition: channelscan_sm.h:233
frequencies.h
ScanMonitor::ScanPercentComplete
void ScanPercentComplete(int pct)
Definition: scanmonitor.cpp:103
DVBSignalMonitor
Definition: dvbsignalmonitor.h:18
SignalMonitor::kDTVSigMon_WaitForMGT
static const uint64_t kDTVSigMon_WaitForMGT
Definition: signalmonitor.h:182
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
DVBSignalMonitor::SetRotorTarget
void SetRotorTarget(float target) override
Sets rotor target pos from 0.0 to 1.0.
Definition: dvbsignalmonitor.cpp:136
arg
arg(title).arg(filename).arg(doDelete))
mythdbcon.h
ServiceDescriptionTable::ServiceID
uint ServiceID(uint i) const
service_id 16 0.0+p
Definition: dvbtables.h:150
ServiceDescriptor::IsDTV
bool IsDTV(void) const
Definition: dvbdescriptors.h:2046
ChannelScanSM::GetHDHRChannel
HDHRChannel * GetHDHRChannel(void)
Definition: channelscan_sm.cpp:1922
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:717
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:718
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:2784
ScanDTVTransport::m_networkID
uint m_networkID
Definition: dtvmultiplex.h:139
OriginalNetworkID::TELENOR
@ TELENOR
Definition: mpegdescriptors.h:294
TransportScanItem::m_iptvTuning
IPTVTuningData m_iptvTuning
IPTV Tuning info.
Definition: frequencytables.h:183
DVBLogicalChannelDescriptor
DVB Logical Channel Descriptor.
Definition: dvbdescriptors.h:2534
ChannelScanSM::m_dvbt2Tried
bool m_dvbt2Tried
Definition: channelscan_sm.h:249
ChannelScanSM::m_channelTimeout
uint m_channelTimeout
Definition: channelscan_sm.h:212
TransportScanItem::m_signalStrength
int m_signalStrength
Definition: frequencytables.h:188
ChannelScanSM::Tune
bool Tune(transport_scan_items_it_t transport)
Definition: channelscan_sm.cpp:2152
ChannelScanSM::run
void run(void) override
This runs the event loop for ChannelScanSM until 'threadExit' is true.
Definition: channelscan_sm.cpp:1980
RegistrationDescriptor
Definition: mpegdescriptors.h:428
DTVSignalMonitor::GetDVBStreamData
DVBStreamData * GetDVBStreamData()
Returns the DVB stream data if it exists.
Definition: dtvsignalmonitor.cpp:539
CableDeliverySystemDescriptor::FrequencyHz
unsigned long long FrequencyHz(void) const
Definition: dvbdescriptors.h:731
ProgramAssociationTable::ProgramCount
uint ProgramCount(void) const
Definition: mpegtables.h:625
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:92
ChannelScanSM::kDVBTableTimeout
static const uint kDVBTableTimeout
SDT's should be sent every 2 seconds and NIT's every 10 seconds, so lets wait at least 30 seconds,...
Definition: channelscan_sm.h:201
DVBChannel::SetPMT
void SetPMT(const ProgramMapTable *pmt)
Tells the Conditional Access Module which streams we wish to decode.
Definition: dvbchannel.cpp:706
VirtualChannelTable::ProgramNumber
uint ProgramNumber(uint i) const
Definition: atsctables.h:266
ScanStreamData
Definition: scanstreamdata.h:14
ProgramMapTable::IsEncrypted
bool IsEncrypted(const QString &sistandard) const
Returns true iff PMT contains CA descriptor for a vid/aud stream.
Definition: mpegtables.cpp:551
VirtualChannelTable::IsHiddenInGuide
bool IsHiddenInGuide(uint i) const
Definition: atsctables.h:287
PCM_INFO_INIT
#define PCM_INFO_INIT(SISTD)
Definition: channelscan_sm.cpp:1150
VirtualChannelTable::toString
QString toString(void) const override
Definition: atsctables.cpp:200
ChannelUtil::CreateChannel
static bool CreateChannel(uint db_mplexid, uint db_sourceid, uint new_channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, ChannelVisibleType visible, const QString &freqid, const QString &icon=QString(), QString format="Default", const QString &xmltvid=QString(), const QString &default_authority=QString(), uint service_type=0)
Definition: channelutil.cpp:1482
ChannelUtil::GetUnknownCallsign
static QString GetUnknownCallsign(void)
Definition: channelutil.cpp:1305
ChannelScanSM::m_sourceID
int m_sourceID
Definition: channelscan_sm.h:210
ChannelScanSM::m_signalTimeout
uint m_signalTimeout
Definition: channelscan_sm.h:211
sdt_map_t
QMap< uint, sdt_vec_t > sdt_map_t
Definition: dvbstreamdata.h:19
BouquetAssociationTable::TSID
uint TSID(uint i) const
Definition: dvbtables.h:231
ATSCStreamData::HasCachedAllTVCTs
bool HasCachedAllTVCTs(bool current=true) const
Definition: atscstreamdata.cpp: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:441
PSIPTable::Section
uint Section(void) const
Definition: mpegtables.h:537
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:905
ChannelScanSM::StopScanner
void StopScanner(void)
Stops the ChannelScanSM event loop and the signal monitor, blocking until both exit.
Definition: channelscan_sm.cpp:2253
ChannelScanSM::ChannelScanSM
ChannelScanSM(ScanMonitor *_scan_monitor, const QString &_cardtype, ChannelBase *_channel, int _sourceID, uint signal_timeout, uint channel_timeout, QString _inputname, bool test_decryption)
Definition: channelscan_sm.cpp:144
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:142
HDHRChannel
Definition: hdhrchannel.h:21
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
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:2275
MPEGStreamData::ReturnCachedPATTables
virtual void ReturnCachedPATTables(pat_vec_t &pats) const
Definition: mpegstreamdata.cpp:1475
ChannelInsertInfo
Definition: channelinfo.h:134
DTVTunerType
Definition: dtvconfparserhelpers.h:77
VirtualChannelTable::ChannelTransportStreamID
uint ChannelTransportStreamID(uint i) const
Definition: atsctables.h:261
MPEGDescriptor::FindExtension
static const unsigned char * FindExtension(const desc_list_t &parsed, uint desc_tag)
Definition: mpegdescriptors.cpp:86
ChannelScanSM::GetV4LChannel
V4LChannel * GetV4LChannel(void)
Definition: channelscan_sm.cpp:1949
DescriptorID::terrestrial_delivery_system
@ terrestrial_delivery_system
Definition: mpegdescriptors.h:99
FrequencyTable::m_frequencyStep
uint m_frequencyStep
The step in frequency.
Definition: frequencytables.h:99
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
Protect UpdateChannelInfo.
Definition: channelscan_sm.h:263
MPEGDescriptor::IsValid
bool IsValid(void) const
Definition: mpegdescriptors.h:340
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:1961
DVBStreamData::HasCachedAllSDT
bool HasCachedAllSDT(uint tsid, bool current=true) const
Definition: dvbstreamdata.cpp:709
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:792
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:2077
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:32
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:125
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:250
ChannelScanSM::m_otherTableTimeout
uint m_otherTableTimeout
Definition: channelscan_sm.h:213
DVBLogicalChannelDescriptor::ChannelCount
uint ChannelCount(void) const
Definition: dvbdescriptors.h:2542
AnalogSignalHandler
Definition: channelscan_sm.h:71
ServiceDescriptionTable::OriginalNetworkID
uint OriginalNetworkID() const
original_network_id 16 8.0
Definition: dvbtables.h:141
ChannelUtil::FindChannel
static uint FindChannel(uint sourceid, const QString &freqid)
Definition: channelutil.cpp:1383
ChannelScanSM::m_extendTransports
QMap< uint32_t, DTVMultiplex > m_extendTransports
Definition: channelscan_sm.h:241
DTVTunerType::kTunerTypeUnknown
static const int kTunerTypeUnknown
Definition: dtvconfparserhelpers.h:103
hardwareprofile.i18n.t
t
Definition: i18n.py:36
MPEGDescriptor
Definition: mpegdescriptors.h:301
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:627
ChannelScanSM::m_channelsFound
uint m_channelsFound
Definition: channelscan_sm.h:253
MPEGDescriptor::ParseOnlyInclude
static desc_list_t ParseOnlyInclude(const unsigned char *data, uint len, int excluded_descid)
Definition: mpegdescriptors.cpp:57
ServiceDescriptionTable
This table tells the decoder on which PIDs to find A/V data.
Definition: dvbtables.h:111
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
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:1090
SkyLCNDescriptor
Sky Logical Channel Number descriptor.
Definition: dvbdescriptors.h:2750
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:2562
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
DTVSignalMonitor::GetScanStreamData
ScanStreamData * GetScanStreamData()
Returns the scan stream data if it exists.
Definition: dtvsignalmonitor.cpp:544
ChannelUtil::CreateChanID
static int CreateChanID(uint sourceid, const QString &chan_num)
Creates a unique channel ID for database use.
Definition: channelutil.cpp:1446
DTVMultiplex::m_modSys
DTVModulationSystem m_modSys
Definition: dtvmultiplex.h:106
MPEGDescriptor::DescriptorTagExtension
uint DescriptorTagExtension(void) const
Definition: mpegdescriptors.h:345
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:687
transport_scan_items_it_t
Definition: frequencytables.h:194
ChannelScanSM
Scanning class for cards that support a SignalMonitor class.
Definition: channelscan_sm.h:90
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:1313
uint
unsigned int uint
Definition: compat.h:141
ChannelScanSM::kATSCTableTimeout
static const uint kATSCTableTimeout
No logic here, lets just wait at least 10 seconds.
Definition: channelscan_sm.h:202
kEncDecrypted
@ kEncDecrypted
Definition: mpegstreamdata.h: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:605
TransportScanItem::m_friendlyName
QString m_friendlyName
Name to display in scanner dialog.
Definition: frequencytables.h:172
DTVSignalMonitor::GetTransportID
uint GetTransportID(void) const
Definition: dtvsignalmonitor.h:38
ChannelScanSM::GetDVBSignalMonitor
DVBSignalMonitor * GetDVBSignalMonitor(void)
Definition: channelscan_sm.cpp:1903
ChannelScanSM::loc
static QString loc(const ChannelScanSM *siscan)
Definition: channelscan_sm.cpp:80
PSIPTable::LastSection
uint LastSection(void) const
Definition: mpegtables.h:540
PrivateDescriptorID::freesat_lcn_table
@ freesat_lcn_table
Definition: mpegdescriptors.h:232
ScanMonitor::ScanAppendTextToLog
void ScanAppendTextToLog(const QString &status)
Definition: scanmonitor.cpp:109
SCTE_PSIP_PID
@ SCTE_PSIP_PID
Definition: mpegtables.h:227
ServiceDescriptor::ServiceType
uint ServiceType(void) const
Definition: dvbdescriptors.h:2022
SignalMonitor
Signal monitoring base class.
Definition: signalmonitor.h:32
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:1870
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
The ending centre frequency.
Definition: frequencytables.h:98
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:2406
ServiceListDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2096
ChannelScanSM::GetDTVSignalMonitor
DTVSignalMonitor * GetDTVSignalMonitor(void)
Definition: channelscan_sm.cpp:1898
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:717
MasterGuideTable
This table tells the decoder on which PIDs to find other tables, and their sizes and each table's cur...
Definition: atsctables.h:75
TransportScanItem::m_mplexid
uint m_mplexid
DB Mplexid.
Definition: frequencytables.h:170
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::AddToList
bool AddToList(uint mplexid)
Definition: channelscan_sm.cpp:2507
MPEGStreamData::ReturnCachedPMTTables
virtual void ReturnCachedPMTTables(pmt_vec_t &pmts) const
Definition: mpegstreamdata.cpp:1505
ChannelScanSM::GetDVBChannel
DVBChannel * GetDVBChannel(void)
Definition: channelscan_sm.cpp:1931
BouquetAssociationTable::TransportStreamCount
uint TransportStreamCount(void) const
Definition: dvbtables.h:226
BouquetAssociationTable
Tells what channels can be found on each transponder for one bouquet (a bunch of channels from one pr...
Definition: dvbtables.h:190
ServiceDescriptionTable::HasEITPresentFollowing
bool HasEITPresentFollowing(uint i) const
Definition: dvbtables.h:155
MasterGuideTable::toString
QString toString(void) const override
Definition: atsctables.cpp:69
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:296
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:643
cardutil.h
DVBLogicalChannelDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2544
ChannelScanSM::m_defAuthorities
QMap< uint64_t, QString > m_defAuthorities
Definition: channelscan_sm.h:248
kRegionUndefined
static const uint kRegionUndefined
Definition: channelscan_sm.cpp: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::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
ServiceDescriptor
Definition: dvbdescriptors.h:2013
DTVSignalMonitor::SetStreamData
virtual void SetStreamData(MPEGStreamData *data)
Sets the MPEG stream data for DTVSignalMonitor to use, and connects the table signals to the monitor.
Definition: dtvsignalmonitor.cpp: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:2597
ChannelInsertInfo::m_inSdt
bool m_inSdt
Definition: channelinfo.h:246
TransportScanItem::m_networkID
uint m_networkID
Definition: frequencytables.h:189
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:845
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:19
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:796
ChannelScanSM::HandleAllGood
void HandleAllGood(void)
Definition: channelscan_sm.cpp:253
FrequencyTable::m_nameOffset
int m_nameOffset
Offset to add to the pretty name.
Definition: frequencytables.h:96
DTVTransport
Definition: dtvconfparser.h:63
DTVTunerType::kTunerTypeASI
static const int kTunerTypeASI
Definition: dtvconfparserhelpers.h:100
atsctables.h
Overall structure.
ScannedChannelInfo::m_nits
nit_vec_t m_nits
Definition: channelscan_sm.cpp: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:295
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
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:2889
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:1156
TransportScanItem::m_transportID
uint m_transportID
Definition: frequencytables.h:190
DTVModulationSystem::kModulationSystem_DVBT2
@ kModulationSystem_DVBT2
Definition: dtvconfparserhelpers.h:670
DTVTunerType::kTunerTypeDVBT
static const int kTunerTypeDVBT
Definition: dtvconfparserhelpers.h:96
DVBStreamData::HasCachedAnyNIT
bool HasCachedAnyNIT(bool current=true) const
Definition: dvbstreamdata.cpp:616
ChannelScanSM::kMPEGTableTimeout
static const uint kMPEGTableTimeout
No logic here, lets just wait at least 15 seconds.
Definition: channelscan_sm.h:203
ATSCStreamData::HasCachedAnyVCTs
bool HasCachedAnyVCTs(bool current=true) const
Definition: atscstreamdata.h:82
MThread::wait
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:305
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:2445
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:1349
ScanMonitor::ScanUpdateStatusText
void ScanUpdateStatusText(const QString &status)
Definition: scanmonitor.cpp:114
hdhrchannel.h
ChannelScanSM::GetDTVChannel
DTVChannel * GetDTVChannel(void)
Definition: channelscan_sm.cpp:1912
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:2575
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:31
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:2081
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:931
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
The staring centre frequency.
Definition: frequencytables.h:97
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:2619
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:657
ChannelScanSM::m_currentEncryptionStatusChecked
QMap< uint, bool > m_currentEncryptionStatusChecked
Definition: channelscan_sm.h:247
ServiceDescriptor::IsDigitalAudio
bool IsDigitalAudio(void) const
Definition: dvbdescriptors.h:2048
ChannelInsertInfo::m_siStandard
QString m_siStandard
Definition: channelinfo.h:240
ScanMonitor
Definition: scanmonitor.h:47
transport_scan_items_it_t::nextTransport
transport_scan_items_it_t nextTransport() const
Definition: frequencytables.h:253
ServiceDescriptionTable::TSID
uint TSID() const
transport_stream_id 16 3.0 0x0000
Definition: dvbtables.h:138
VirtualChannelTable::MinorChannel
uint MinorChannel(uint i) const
Definition: atsctables.h:249
ChannelScanSM::UpdateScanPercentCompleted
void UpdateScanPercentCompleted(void)
Updates Transport Scan progress bar.
Definition: channelscan_sm.h:266
SignalMonitor::kDTVSigMon_WaitForVCT
static const uint64_t kDTVSigMon_WaitForVCT
Definition: signalmonitor.h:183
DescriptorID::private_data_specifier
@ private_data_specifier
Definition: mpegdescriptors.h:104
ChannelScanSM::HasTimedOut
bool HasTimedOut(void)
Definition: channelscan_sm.cpp:1996
ChannelScanSM::ScanForChannels
bool ScanForChannels(uint sourceid, const QString &std, const QString &cardtype, const DTVChannelList &channels)
Definition: channelscan_sm.cpp:2366
ChannelScanSM::m_regionId
uint m_regionId
Definition: channelscan_sm.h:223
DVBSimulcastChannelDescriptor::ServiceID
uint ServiceID(uint i) const
Definition: dvbdescriptors.h:2572
ScanDTVTransport
Definition: dtvmultiplex.h:116
ScanDTVTransport::m_channels
ChannelInsertInfoList m_channels
Definition: dtvmultiplex.h:138
FreesatLCNDescriptor::ServiceCount
uint ServiceCount(void) const
Definition: dvbdescriptors.h:2623
DefaultAuthorityDescriptor::DefaultAuthority
QString DefaultAuthority(void) const
Definition: dvbdescriptors.h: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:714
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:883
NetworkInformationTable
This table tells the decoder on which PIDs to find other tables.
Definition: dvbtables.h:31
VirtualChannelTable::GetExtendedChannelName
QString GetExtendedChannelName(uint idx) const
Definition: atsctables.cpp:506
ScanMonitor::ScanUpdateStatusTitleText
void ScanUpdateStatusTitleText(const QString &status)
Definition: scanmonitor.cpp:123