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::IPTVImportMPTS)
120  {
121  m_scannerPane->ImportM3U(cardid, inputname, sourceid, true);
122  }
123  else if ((scantype == ScanTypeSetting::FullScan_ATSC) ||
124  (scantype == ScanTypeSetting::FullTransportScan) ||
125  (scantype == ScanTypeSetting::TransportScan) ||
127  (scantype == ScanTypeSetting::FullScan_DVBC) ||
128  (scantype == ScanTypeSetting::FullScan_DVBT) ||
129  (scantype == ScanTypeSetting::FullScan_DVBT2) ||
130  (scantype == ScanTypeSetting::FullScan_Analog))
131  {
132  ;
133  }
134  else if (scantype == ScanTypeSetting::ExistingScanImport)
135  {
136  do_scan = false;
137  uint scanid = GetScanID();
138  ScanDTVTransportList transports = LoadScan(scanid);
139  ChannelImporter ci(true, true, true, true, false,
140  DoFreeToAirOnly(),
146  ci.Process(transports, sourceid);
147  }
148  else
149  {
150  do_scan = false;
151  LOG(VB_CHANSCAN, LOG_ERR, LOC + "SetPage(): " +
152  QString("type(%1) src(%2) cardid(%3) not handled")
153  .arg(scantype).arg(sourceid).arg(cardid));
154 
155  ShowOkPopup(tr("Programmer Error, see console"));
156  }
157 
158  // Just verify what we get from the UI...
159  DTVMultiplex tuning;
160  if ((parse_type != DTVTunerType::kTunerTypeUnknown) &&
161  !tuning.ParseTuningParams(
162  parse_type,
163  start_chan["frequency"], start_chan["inversion"],
164  start_chan["symbolrate"], start_chan["fec"],
165  start_chan["polarity"],
166  start_chan["coderate_hp"], start_chan["coderate_lp"],
167  start_chan["constellation"], start_chan["trans_mode"],
168  start_chan["guard_interval"], start_chan["hierarchy"],
169  start_chan["modulation"], start_chan["bandwidth"],
170  start_chan["mod_sys"], start_chan["rolloff"]))
171  {
172  ShowOkPopup(tr("Error parsing parameters"));
173 
174  do_scan = false;
175  }
176 
177  if (do_scan)
178  {
179  QString table_start;
180  QString table_end;
181  GetFrequencyTableRange(table_start, table_end);
182 
184  GetScanType(), GetCardID(),
191  DoAddFullTS(),
193 
194  // stuff needed for particular scans
195  GetMultiplex(), start_chan,
198  table_start, table_end);
199  }
200 }
201 
202 void ScanWizard::SetInput(const QString &cardid_inputname)
203 {
204  uint cardid = 0;
205  QString inputname;
206  if (!InputSelector::Parse(cardid_inputname, cardid, inputname))
207  return;
208 
209  // Work out what kind of card we've got
210  // We need to check against the last capture card so that we don't
211  // try and probe a card which is already open by scan()
212  if ((m_lastHWCardID != cardid) ||
214  {
215  m_lastHWCardID = cardid;
216  QString subtype = CardUtil::ProbeSubTypeName(cardid);
218  }
219 }
ChannelScanner::ImportVBox
virtual bool ImportVBox(uint cardid, const QString &inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType)
Definition: channelscanner.cpp:357
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:73
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:54
scanwizard.h
CardUtil::ProbeSubTypeName
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:930
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
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:202
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:79
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:292
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:70
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:464
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:563
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:333
ScanWizard::GetMultiplex
uint GetMultiplex(void) const
Definition: scanwizard.h:77
CardUtil::ERROR_OPEN
@ ERROR_OPEN
Definition: cardutil.h:48
ChannelScanner::ImportExternRecorder
virtual bool ImportExternRecorder(uint cardid, const QString &inputname, uint sourceid)
Definition: channelscanner.cpp:380