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