MythTV  master
scanwizard.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  * Author(s):
8  * John Pullan (john@pullan.org)
9  *
10  * Description:
11  * Collection of classes to provide dvb channel scanning
12  * functionallity
13  *
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
29  *
30  */
31 
32 #include <utility>
33 
35 
38 #include "channelscan/scaninfo.h"
40 #include "scanwizard.h"
41 #include "sourceutil.h"
42 #include "videosource.h"
43 
44 #define LOC QString("SWiz: ")
45 
46 ScanWizard::ScanWizard(uint default_sourceid,
47  uint default_cardid,
48  const QString& default_inputname) :
49  m_scannerPane(new ChannelScannerGUI())
50 {
51  SetupConfig(default_sourceid, default_cardid, default_inputname);
52  auto *scanButton = new ButtonStandardSetting(tr("Scan"));
53  connect(scanButton, &ButtonStandardSetting::clicked, this, &ScanWizard::Scan);
54  addChild(scanButton);
55 }
56 
58 {
59  QMap<QString,QString> start_chan;
61 
62  uint cardid = GetCardID();
63  QString inputname = GetInputName();
64  uint sourceid = GetSourceID();
65  int scantype = GetScanType();
66  bool do_scan = true;
67 
68  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Scan(): " +
69  QString("type(%1) cardid(%2) inputname(%3)")
70  .arg(scantype).arg(cardid).arg(inputname));
71 
72  if (scantype == ScanTypeSetting::DVBUtilsImport)
73  {
75  GetFilename());
76  }
77  else if (scantype == ScanTypeSetting::NITAddScan_DVBT)
78  {
79  start_chan = GetStartChan();
80  parse_type = DTVTunerType::kTunerTypeDVBT;
81  }
82  else if (scantype == ScanTypeSetting::NITAddScan_DVBT2)
83  {
84  start_chan = GetStartChan();
85  parse_type = DTVTunerType::kTunerTypeDVBT2;
86  }
87  else if (scantype == ScanTypeSetting::NITAddScan_DVBS)
88  {
89  start_chan = GetStartChan();
90  parse_type = DTVTunerType::kTunerTypeDVBS1;
91  }
92  else if (scantype == ScanTypeSetting::NITAddScan_DVBS2)
93  {
94  start_chan = GetStartChan();
95  parse_type = DTVTunerType::kTunerTypeDVBS2;
96  }
97  else if (scantype == ScanTypeSetting::NITAddScan_DVBC)
98  {
99  start_chan = GetStartChan();
100  parse_type = DTVTunerType::kTunerTypeDVBC;
101  }
102  else if (scantype == ScanTypeSetting::IPTVImport)
103  {
104  do_scan = false;
105  m_scannerPane->ImportM3U(cardid, inputname, sourceid, false);
106  }
107  else if (scantype == ScanTypeSetting::VBoxImport)
108  {
109  do_scan = false;
110  m_scannerPane->ImportVBox(cardid, inputname, sourceid,
111  DoFreeToAirOnly(),
113  }
114  else if (scantype == ScanTypeSetting::ExternRecImport)
115  {
116  do_scan = false;
117  m_scannerPane->ImportExternRecorder(cardid, inputname, sourceid);
118  }
119  else if (scantype == ScanTypeSetting::HDHRImport)
120  {
121  do_scan = false;
122  m_scannerPane->ImportHDHR(cardid, inputname, sourceid,
124  }
125  else if (scantype == ScanTypeSetting::IPTVImportMPTS)
126  {
127  m_scannerPane->ImportM3U(cardid, inputname, sourceid, true);
128  }
129  else if ((scantype == ScanTypeSetting::FullScan_ATSC) ||
130  (scantype == ScanTypeSetting::FullTransportScan) ||
131  (scantype == ScanTypeSetting::TransportScan) ||
133  (scantype == ScanTypeSetting::FullScan_DVBC) ||
134  (scantype == ScanTypeSetting::FullScan_DVBT) ||
135  (scantype == ScanTypeSetting::FullScan_DVBT2) ||
136  (scantype == ScanTypeSetting::FullScan_Analog))
137  {
138  ;
139  }
140  else if (scantype == ScanTypeSetting::ExistingScanImport)
141  {
142  do_scan = false;
143  uint scanid = GetScanID();
144  ScanDTVTransportList transports = LoadScan(scanid);
145  ChannelImporter ci(true, true, true, true, false,
146  DoFreeToAirOnly(),
152  ci.Process(transports, sourceid);
153  }
154  else
155  {
156  do_scan = false;
157  LOG(VB_CHANSCAN, LOG_ERR, LOC + "SetPage(): " +
158  QString("type(%1) src(%2) cardid(%3) not handled")
159  .arg(scantype).arg(sourceid).arg(cardid));
160 
161  ShowOkPopup(tr("Programmer Error, see console"));
162  }
163 
164  // Just verify what we get from the UI...
165  DTVMultiplex tuning;
166  if ((parse_type != DTVTunerType::kTunerTypeUnknown) &&
167  !tuning.ParseTuningParams(
168  parse_type,
169  start_chan["frequency"], start_chan["inversion"],
170  start_chan["symbolrate"], start_chan["fec"],
171  start_chan["polarity"],
172  start_chan["coderate_hp"], start_chan["coderate_lp"],
173  start_chan["constellation"], start_chan["trans_mode"],
174  start_chan["guard_interval"], start_chan["hierarchy"],
175  start_chan["modulation"], start_chan["bandwidth"],
176  start_chan["mod_sys"], start_chan["rolloff"]))
177  {
178  ShowOkPopup(tr("Error parsing parameters"));
179 
180  do_scan = false;
181  }
182 
183  if (do_scan)
184  {
185  QString table_start;
186  QString table_end;
187  GetFrequencyTableRange(table_start, table_end);
188 
190  GetScanType(), GetCardID(),
197  DoAddFullTS(),
199 
200  // stuff needed for particular scans
201  GetMultiplex(), start_chan,
204  table_start, table_end);
205  }
206 }
207 
208 void ScanWizard::SetInput(const QString &cardid_inputname)
209 {
210  uint cardid = 0;
211  QString inputname;
212  if (!InputSelector::Parse(cardid_inputname, cardid, inputname))
213  return;
214 
215  // Work out what kind of card we've got
216  // We need to check against the last capture card so that we don't
217  // try and probe a card which is already open by scan()
218  if ((m_lastHWCardID != cardid) ||
220  {
221  m_lastHWCardID = cardid;
222  QString subtype = CardUtil::ProbeSubTypeName(cardid);
224  }
225 }
ChannelScanner::ImportVBox
virtual bool ImportVBox(uint cardid, const QString &inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType)
Definition: channelscanner.cpp:358
DTVMultiplex
Definition: dtvmultiplex.h:24
ScanWizard::DoRemoveDuplicates
bool DoRemoveDuplicates(void) const
Definition: scanwizardconfig.cpp:124
DTVTunerType::kTunerTypeDVBC
static const int kTunerTypeDVBC
Definition: dtvconfparserhelpers.h:95
ScanTypeSetting::FullTransportScan
@ FullTransportScan
Definition: scanwizardconfig.h:90
ScanWizard::GetScanType
int GetScanType(void) const
Definition: scanwizard.h:73
ScanWizard::GetInputName
QString GetInputName(void) const
Definition: scanwizard.h:75
ScanTypeSetting::FullScan_DVBT
@ FullScan_DVBT
Definition: scanwizardconfig.h:80
CardUtil::toInputType
static enum INPUT_TYPES toInputType(const QString &name)
Definition: cardutil.h:78
channelimporter.h
ButtonStandardSetting
Definition: standardsettings.h:450
ScanTypeSetting::DVBUtilsImport
@ DVBUtilsImport
Definition: scanwizardconfig.h:100
DTVTunerType::kTunerTypeDVBS1
static const int kTunerTypeDVBS1
Definition: dtvconfparserhelpers.h:93
ScanTypeSetting::NITAddScan_DVBS
@ NITAddScan_DVBS
Definition: scanwizardconfig.h:86
ScanWizard::DoFollowNIT
bool DoFollowNIT(void) const
Definition: scanwizard.h:89
ScanWizard::m_scannerPane
ChannelScannerGUI * m_scannerPane
Definition: scanwizard.h:63
scanwizardconfig.h
ScanTypeSetting::FullScan_ATSC
@ FullScan_ATSC
Definition: scanwizardconfig.h:78
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
ScanWizard::m_lastHWCardType
uint m_lastHWCardType
Definition: scanwizard.h:62
ChannelScannerGUI
Definition: channelscanner_gui.h:47
ScanWizard::ScanWizard
ScanWizard(uint default_sourceid=0, uint default_cardid=0, const QString &default_inputname=QString())
Definition: scanwizard.cpp:46
ChannelImporter::Process
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
Definition: channelimporter.cpp:76
scanwizard.h
CardUtil::ProbeSubTypeName
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:981
ScanWizard::DoChannelNumbersOnly
bool DoChannelNumbersOnly(void) const
Definition: scanwizardconfig.cpp:109
ScanWizard::GetCardID
uint GetCardID(void) const
Definition: scanwizard.h:74
ButtonStandardSetting::clicked
void clicked()
ScanWizard::GetStartChan
QMap< QString, QString > GetStartChan(void) const
Definition: scanwizard.h:84
DTVTunerType
Definition: dtvconfparserhelpers.h:76
StandardSetting::addChild
virtual void addChild(StandardSetting *child)
Definition: standardsettings.cpp:71
sourceutil.h
ScanTypeSetting::NITAddScan_DVBT
@ NITAddScan_DVBT
Definition: scanwizardconfig.h:84
mythlogging.h
ScanTypeSetting::VBoxImport
@ VBoxImport
Definition: scanwizardconfig.h:104
ScanWizard::DoAddFullTS
bool DoAddFullTS(void) const
Definition: scanwizardconfig.cpp:129
DTVTunerType::kTunerTypeUnknown
static const int kTunerTypeUnknown
Definition: dtvconfparserhelpers.h:103
ChannelScanner::Scan
void Scan(int scantype, uint cardid, const QString &inputname, uint sourceid, bool do_ignore_signal_timeout, bool do_follow_nit, bool do_test_decryption, bool do_fta_only, bool do_lcn_only, bool do_complete_only, bool do_full_channel_search, bool do_remove_duplicates, bool do_add_full_ts, ServiceRequirements service_requirements, uint mplexid, const QMap< QString, QString > &startChan, const QString &freq_std, const QString &mod, const QString &tbl, const QString &tbl_start=QString(), const QString &tbl_end=QString())
Definition: channelscanner.cpp:109
ScanTypeSetting::FullScan_Analog
@ FullScan_Analog
Definition: scanwizardconfig.h:77
ScanTypeSetting::IPTVImportMPTS
@ IPTVImportMPTS
Definition: scanwizardconfig.h:98
ScanTypeSetting::ExistingScanImport
@ ExistingScanImport
Definition: scanwizardconfig.h:102
ChannelScanner::ImportHDHR
virtual bool ImportHDHR(uint cardid, const QString &inputname, uint sourceid, ServiceRequirements serviceType)
Definition: channelscanner.cpp:407
ScanWizard::GetServiceRequirements
ServiceRequirements GetServiceRequirements(void) const
Definition: scanwizardconfig.cpp:99
ScanTypeSetting::FullScan_DVBC
@ FullScan_DVBC
Definition: scanwizardconfig.h:79
ScanWizard::GetFrequencyTableRange
bool GetFrequencyTableRange(QString &start, QString &end) const
Definition: scanwizard.h:78
scaninfo.h
ScanTypeSetting::NITAddScan_DVBT2
@ NITAddScan_DVBT2
Definition: scanwizardconfig.h:85
ScanWizard::SetInput
void SetInput(const QString &cardid_inputname)
Definition: scanwizard.cpp:208
ScanTypeSetting::NITAddScan_DVBC
@ NITAddScan_DVBC
Definition: scanwizardconfig.h:88
ScanWizard::Scan
void Scan()
Definition: scanwizard.cpp:57
InputSelector::Parse
static bool Parse(const QString &cardid_inputname, uint &cardid, QString &inputname)
Definition: inputselectorsetting.cpp:129
uint
unsigned int uint
Definition: compat.h:81
ScanWizard::DoFullChannelSearch
bool DoFullChannelSearch(void) const
Definition: scanwizardconfig.cpp:119
ScanTypeSetting::CurrentTransportScan
@ CurrentTransportScan
Scans the transport when there is no tuner (for ASI)
Definition: scanwizardconfig.h:94
ScanTypeSetting::IPTVImport
@ IPTVImport
Definition: scanwizardconfig.h:96
ScanDTVTransportList
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
ScanWizard::DoFreeToAirOnly
bool DoFreeToAirOnly(void) const
Definition: scanwizardconfig.cpp:104
do_scan
static void do_scan(struct replex *rx)
Definition: replex.cpp:2287
ScanWizard::GetSourceID
uint GetSourceID(void) const
Definition: scanwizardconfig.cpp:94
DTVTunerType::kTunerTypeDVBS2
static const int kTunerTypeDVBS2
Definition: dtvconfparserhelpers.h:94
ScanTypeSetting::TransportScan
@ TransportScan
Definition: scanwizardconfig.h:92
ScanWizard::DoIgnoreSignalTimeout
bool DoIgnoreSignalTimeout(void) const
Definition: scanwizard.h:87
ChannelScanner::ImportDVBUtils
virtual DTVConfParser::return_t ImportDVBUtils(uint sourceid, int cardtype, const QString &file)
Definition: channelscanner.cpp:293
ScanTypeSetting::HDHRImport
@ HDHRImport
Definition: scanwizardconfig.h:108
ScanWizard::GetFilename
QString GetFilename(void) const
Definition: scanwizard.h:76
ScanWizard::DoCompleteChannelsOnly
bool DoCompleteChannelsOnly(void) const
Definition: scanwizardconfig.cpp:114
LOC
#define LOC
Definition: scanwizard.cpp:44
ScanWizard::GetFrequencyStandard
QString GetFrequencyStandard(void) const
Definition: scanwizard.h:80
ChannelImporter
Definition: channelimporter.h:71
ScanTypeSetting::ExternRecImport
@ ExternRecImport
Definition: scanwizardconfig.h:106
ScanWizard::SetupConfig
void SetupConfig(uint default_sourceid, uint default_cardid, const QString &default_inputname)
Definition: scanwizardconfig.cpp:43
LoadScan
ScanDTVTransportList LoadScan(uint scanid)
Definition: scaninfo.cpp:77
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:448
ScanWizard::m_lastHWCardID
uint m_lastHWCardID
Definition: scanwizard.h:61
channelscanner_gui.h
DTVTunerType::kTunerTypeDVBT
static const int kTunerTypeDVBT
Definition: dtvconfparserhelpers.h:96
ScanWizard::GetScanID
uint GetScanID(void) const
Definition: scanwizard.h:71
ScanWizard::GetFrequencyTable
QString GetFrequencyTable(void) const
Definition: scanwizard.h:82
DTVTunerType::kTunerTypeDVBT2
static const int kTunerTypeDVBT2
Definition: dtvconfparserhelpers.h:97
ScanWizard::DoTestDecryption
bool DoTestDecryption(void) const
Definition: scanwizardconfig.cpp:134
ShowOkPopup
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
Definition: mythdialogbox.cpp:562
ScanTypeSetting::NITAddScan_DVBS2
@ NITAddScan_DVBS2
Definition: scanwizardconfig.h:87
videosource.h
ScanTypeSetting::FullScan_DVBT2
@ FullScan_DVBT2
Definition: scanwizardconfig.h:81
ScanWizard::GetModulation
QString GetModulation(void) const
Definition: scanwizard.h:72
ChannelScanner::ImportM3U
virtual bool ImportM3U(uint cardid, const QString &inputname, uint sourceid, bool is_mpts)
Definition: channelscanner.cpp:334
ScanWizard::GetMultiplex
uint GetMultiplex(void) const
Definition: scanwizard.h:77
CardUtil::ERROR_OPEN
@ ERROR_OPEN
Definition: cardutil.h:51
ChannelScanner::ImportExternRecorder
virtual bool ImportExternRecorder(uint cardid, const QString &inputname, uint sourceid)
Definition: channelscanner.cpp:382