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 "scanwizardconfig.h"
33 #include "channelscanner_gui.h"
34 #include "scanwizard.h"
35 
36 #include "channelimporter.h"
37 #include "mythlogging.h"
38 #include "scaninfo.h"
39 #include "sourceutil.h"
40 #include "videosource.h"
41 #include <utility>
42 
43 #define LOC QString("SWiz: ")
44 
45 ScanWizard::ScanWizard(uint default_sourceid,
46  uint default_cardid,
47  const QString& default_inputname) :
48  m_scannerPane(new ChannelScannerGUI())
49 {
50  SetupConfig(default_sourceid, default_cardid, default_inputname);
51  auto *scanButton = new ButtonStandardSetting(tr("Scan"));
52  connect(scanButton, SIGNAL(clicked()), SLOT(Scan()));
53  addChild(scanButton);
54 }
55 
57 {
58  QMap<QString,QString> start_chan;
60 
61  uint cardid = GetCardID();
62  QString inputname = GetInputName();
63  uint sourceid = GetSourceID();
64  int scantype = GetScanType();
65  bool do_scan = true;
66 
67  LOG(VB_CHANSCAN, LOG_INFO, LOC + "Scan(): " +
68  QString("type(%1) cardid(%2) inputname(%3)")
69  .arg(scantype).arg(cardid).arg(inputname));
70 
71  if (scantype == ScanTypeSetting::DVBUtilsImport)
72  {
74  GetFilename());
75  }
76  else if (scantype == ScanTypeSetting::NITAddScan_DVBT)
77  {
78  start_chan = GetStartChan();
79  parse_type = DTVTunerType::kTunerTypeDVBT;
80  }
81  else if (scantype == ScanTypeSetting::NITAddScan_DVBT2)
82  {
83  start_chan = GetStartChan();
84  parse_type = DTVTunerType::kTunerTypeDVBT2;
85  }
86  else if (scantype == ScanTypeSetting::NITAddScan_DVBS)
87  {
88  start_chan = GetStartChan();
89  parse_type = DTVTunerType::kTunerTypeDVBS1;
90  }
91  else if (scantype == ScanTypeSetting::NITAddScan_DVBS2)
92  {
93  start_chan = GetStartChan();
94  parse_type = DTVTunerType::kTunerTypeDVBS2;
95  }
96  else if (scantype == ScanTypeSetting::NITAddScan_DVBC)
97  {
98  start_chan = GetStartChan();
99  parse_type = DTVTunerType::kTunerTypeDVBC;
100  }
101  else if (scantype == ScanTypeSetting::IPTVImport)
102  {
103  do_scan = false;
104  m_scannerPane->ImportM3U(cardid, inputname, sourceid, false);
105  }
106  else if (scantype == ScanTypeSetting::VBoxImport)
107  {
108  do_scan = false;
109  m_scannerPane->ImportVBox(cardid, inputname, sourceid,
110  DoFreeToAirOnly(),
112  }
113  else if (scantype == ScanTypeSetting::ExternRecImport)
114  {
115  do_scan = false;
116  m_scannerPane->ImportExternRecorder(cardid, inputname, sourceid);
117  }
118  else if (scantype == ScanTypeSetting::IPTVImportMPTS)
119  {
120  m_scannerPane->ImportM3U(cardid, inputname, sourceid, true);
121  }
122  else if ((scantype == ScanTypeSetting::FullScan_ATSC) ||
123  (scantype == ScanTypeSetting::FullTransportScan) ||
124  (scantype == ScanTypeSetting::TransportScan) ||
126  (scantype == ScanTypeSetting::FullScan_DVBC) ||
127  (scantype == ScanTypeSetting::FullScan_DVBT) ||
128  (scantype == ScanTypeSetting::FullScan_DVBT2) ||
129  (scantype == ScanTypeSetting::FullScan_Analog))
130  {
131  ;
132  }
133  else if (scantype == ScanTypeSetting::ExistingScanImport)
134  {
135  do_scan = false;
136  uint scanid = GetScanID();
137  ScanDTVTransportList transports = LoadScan(scanid);
138  ChannelImporter ci(true, true, true, true, false,
139  DoFreeToAirOnly(),
144  ci.Process(transports, sourceid);
145  }
146  else
147  {
148  do_scan = false;
149  LOG(VB_CHANSCAN, LOG_ERR, LOC + "SetPage(): " +
150  QString("type(%1) src(%2) cardid(%3) not handled")
151  .arg(scantype).arg(sourceid).arg(cardid));
152 
153  ShowOkPopup(tr("Programmer Error, see console"));
154  }
155 
156  // Just verify what we get from the UI...
157  DTVMultiplex tuning;
158  if ((parse_type != DTVTunerType::kTunerTypeUnknown) &&
159  !tuning.ParseTuningParams(
160  parse_type,
161  start_chan["frequency"], start_chan["inversion"],
162  start_chan["symbolrate"], start_chan["fec"],
163  start_chan["polarity"],
164  start_chan["coderate_hp"], start_chan["coderate_lp"],
165  start_chan["constellation"], start_chan["trans_mode"],
166  start_chan["guard_interval"], start_chan["hierarchy"],
167  start_chan["modulation"], start_chan["bandwidth"],
168  start_chan["mod_sys"], start_chan["rolloff"]))
169  {
170  ShowOkPopup(tr("Error parsing parameters"));
171 
172  do_scan = false;
173  }
174 
175  if (do_scan)
176  {
177  QString table_start;
178  QString table_end;
179  GetFrequencyTableRange(table_start, table_end);
180 
182  GetScanType(), GetCardID(),
188  DoAddFullTS(),
190 
191  // stuff needed for particular scans
192  GetMultiplex(), start_chan,
195  table_start, table_end);
196  }
197 }
198 
199 void ScanWizard::SetInput(const QString &cardid_inputname)
200 {
201  uint cardid = 0;
202  QString inputname;
203  if (!InputSelector::Parse(cardid_inputname, cardid, inputname))
204  return;
205 
206  // Work out what kind of card we've got
207  // We need to check against the last capture card so that we don't
208  // try and probe a card which is already open by scan()
209  if ((m_lastHWCardID != cardid) ||
211  {
212  m_lastHWCardID = cardid;
213  QString subtype = CardUtil::ProbeSubTypeName(cardid);
215  }
216 }
bool DoFullChannelSearch(void) const
QString GetFrequencyStandard(void) const
Definition: scanwizard.h:80
static const int kTunerTypeDVBT
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_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())
void SetupConfig(uint default_sourceid, uint default_cardid, const QString &default_inputname)
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
QString GetFilename(void) const
Definition: scanwizard.h:76
bool DoFreeToAirOnly(void) const
#define LOC
Definition: scanwizard.cpp:43
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:927
static const int kTunerTypeUnknown
static enum INPUT_TYPES toInputType(const QString &name)
Definition: cardutil.h:72
bool DoIgnoreSignalTimeout(void) const
Definition: scanwizard.h:87
bool DoCompleteChannelsOnly(void) const
uint GetSourceID(void) const
virtual bool ImportM3U(uint cardid, const QString &inputname, uint sourceid, bool is_mpts)
static const int kTunerTypeDVBS1
QString GetFrequencyTable(void) const
Definition: scanwizard.h:82
static const int kTunerTypeDVBS2
static const int kTunerTypeDVBT2
static const int kTunerTypeDVBC
static bool Parse(const QString &cardid_inputname, uint &cardid, QString &inputname)
virtual bool ImportExternRecorder(uint cardid, const QString &inputname, uint sourceid)
uint m_lastHWCardID
Definition: scanwizard.h:61
QString GetModulation(void) const
Definition: scanwizard.h:72
uint GetScanID(void) const
Definition: scanwizard.h:71
unsigned int uint
Definition: compat.h:140
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)
bool DoTestDecryption(void) const
virtual DTVConfParser::return_t ImportDVBUtils(uint sourceid, int cardtype, const QString &file)
uint GetMultiplex(void) const
Definition: scanwizard.h:77
virtual void addChild(StandardSetting *child)
ChannelScannerGUI * m_scannerPane
Definition: scanwizard.h:63
bool DoChannelNumbersOnly(void) const
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
int GetScanType(void) const
Definition: scanwizard.h:73
QString GetInputName(void) const
Definition: scanwizard.h:75
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
uint m_lastHWCardType
Definition: scanwizard.h:62
ScanDTVTransportList LoadScan(uint scanid)
Definition: scaninfo.cpp:73
ScanWizard(uint default_sourceid=0, uint default_cardid=0, const QString &default_inputname=QString())
Definition: scanwizard.cpp:45
virtual bool ImportVBox(uint cardid, const QString &inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType)
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:140
bool DoFollowNIT(void) const
Definition: scanwizard.h:89
bool GetFrequencyTableRange(QString &start, QString &end) const
Definition: scanwizard.h:78
bool DoAddFullTS(void) const
uint GetCardID(void) const
Definition: scanwizard.h:74
Scans the transport when there is no tuner (for ASI)
void SetInput(const QString &cardid_inputname)
Definition: scanwizard.cpp:199
ServiceRequirements GetServiceRequirements(void) const
static void do_scan(struct replex *rx)
Definition: replex.c:2259
QMap< QString, QString > GetStartChan(void) const
Definition: scanwizard.h:84
void Scan()
Definition: scanwizard.cpp:56