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 #include "sourceutil.h"
36 #include "cardutil.h"
37 #include "videosource.h"
38 #include "scaninfo.h"
39 #include "channelimporter.h"
40 #include "mythlogging.h"
41 
42 #define LOC QString("SWiz: ")
43 
44 ScanWizard::ScanWizard(uint default_sourceid,
45  uint default_cardid,
46  QString default_inputname) :
47  lastHWCardID(0),
48  lastHWCardType(CardUtil::ERROR_PROBE),
49  scannerPane(new ChannelScannerGUI())
50 {
51  SetupConfig(default_sourceid, default_cardid, default_inputname);
52  ButtonStandardSetting *scanButton = new ButtonStandardSetting(tr("Scan"));
53  connect(scanButton, SIGNAL(clicked()), SLOT(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  scannerPane->ImportM3U(cardid, inputname, sourceid, false);
106  }
107  else if (scantype == ScanTypeSetting::VBoxImport)
108  {
109  do_scan = false;
110  scannerPane->ImportVBox(cardid, inputname, sourceid,
111  DoFreeToAirOnly(),
113  }
114  else if (scantype == ScanTypeSetting::ExternRecImport)
115  {
116  do_scan = false;
117  scannerPane->ImportExternRecorder(cardid, inputname, sourceid);
118  }
119  else if (scantype == ScanTypeSetting::IPTVImportMPTS)
120  {
121  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(),
142  ci.Process(transports, sourceid);
143  }
144  else
145  {
146  do_scan = false;
147  LOG(VB_CHANSCAN, LOG_ERR, LOC + "SetPage(): " +
148  QString("type(%1) src(%2) cardid(%3) not handled")
149  .arg(scantype).arg(sourceid).arg(cardid));
150 
151  ShowOkPopup(tr("Programmer Error, see console"));
152  }
153 
154  // Just verify what we get from the UI...
155  DTVMultiplex tuning;
156  if ((parse_type != DTVTunerType::kTunerTypeUnknown) &&
157  !tuning.ParseTuningParams(
158  parse_type,
159  start_chan["frequency"], start_chan["inversion"],
160  start_chan["symbolrate"], start_chan["fec"],
161  start_chan["polarity"],
162  start_chan["coderate_hp"], start_chan["coderate_lp"],
163  start_chan["constellation"], start_chan["trans_mode"],
164  start_chan["guard_interval"], start_chan["hierarchy"],
165  start_chan["modulation"], start_chan["bandwidth"],
166  start_chan["mod_sys"], start_chan["rolloff"]))
167  {
168  ShowOkPopup(tr("Error parsing parameters"));
169 
170  do_scan = false;
171  }
172 
173  if (do_scan)
174  {
175  QString table_start, table_end;
176  GetFrequencyTableRange(table_start, table_end);
177 
178  scannerPane->Scan(
179  GetScanType(), GetCardID(),
184  // stuff needed for particular scans
185  GetMultiplex(), start_chan,
188  table_start, table_end);
189  }
190 }
191 
192 void ScanWizard::SetInput(const QString &cardids_inputname)
193 {
194  uint cardid;
195  QString inputname;
196  if (!InputSelector::Parse(cardids_inputname, cardid, inputname))
197  return;
198 
199  // Work out what kind of card we've got
200  // We need to check against the last capture card so that we don't
201  // try and probe a card which is already open by scan()
202  if ((lastHWCardID != cardid) ||
204  {
205  lastHWCardID = cardid;
206  QString subtype = CardUtil::ProbeSubTypeName(cardid);
208  }
209 }
Collection of helper utilities for input DB use.
Definition: cardutil.h:39
QString GetFrequencyStandard(void) const
Definition: scanwizard.h:79
static const int kTunerTypeDVBT
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:75
bool DoFreeToAirOnly(void) const
#define LOC
Definition: scanwizard.cpp:42
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:726
static const int kTunerTypeUnknown
static enum INPUT_TYPES toInputType(const QString &name)
Definition: cardutil.h:71
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:132
bool DoIgnoreSignalTimeout(void) const
Definition: scanwizard.h:86
uint GetSourceID(void) const
unsigned int uint
Definition: compat.h:140
virtual bool ImportM3U(uint cardid, const QString &inputname, uint sourceid, bool is_mpts)
ScanWizard(uint default_sourceid=0, uint default_cardid=0, QString default_inputname=QString())
Definition: scanwizard.cpp:44
static bool Parse(const QString &cardids_inputname, uint &cardid, QString &inputname)
static const int kTunerTypeDVBS1
QString GetFrequencyTable(void) const
Definition: scanwizard.h:81
ChannelScannerGUI * scannerPane
Definition: scanwizard.h:62
static const int kTunerTypeDVBS2
static const int kTunerTypeDVBT2
static const int kTunerTypeDVBC
virtual bool ImportExternRecorder(uint cardid, const QString &inputname, uint sourceid)
uint lastHWCardID
Definition: scanwizard.h:60
QString GetModulation(void) const
Definition: scanwizard.h:71
uint GetScanID(void) const
Definition: scanwizard.h:70
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_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())
bool DoTestDecryption(void) const
virtual DTVConfParser::return_t ImportDVBUtils(uint sourceid, int cardtype, const QString &file)
uint GetMultiplex(void) const
Definition: scanwizard.h:76
virtual void addChild(StandardSetting *child)
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
int GetScanType(void) const
Definition: scanwizard.h:72
QString GetInputName(void) const
Definition: scanwizard.h:74
bool ParseTuningParams(DTVTunerType type, QString frequency, QString inversion, QString symbolrate, QString fec, QString polarity, QString hp_code_rate, QString lp_code_rate, QString constellation, QString trans_mode, QString guard_interval, QString hierarchy, QString modulation, QString bandwidth, QString mod_sys, QString rolloff)
uint lastHWCardType
Definition: scanwizard.h:61
ScanDTVTransportList LoadScan(uint scanid)
Definition: scaninfo.cpp:74
virtual bool ImportVBox(uint cardid, const QString &inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType)
bool DoFollowNIT(void) const
Definition: scanwizard.h:88
bool GetFrequencyTableRange(QString &start, QString &end) const
Definition: scanwizard.h:77
bool DoAddFullTS(void) const
uint GetCardID(void) const
Definition: scanwizard.h:73
Scans the transport when there is no tuner (for ASI)
void SetInput(const QString &cardid_inputname)
Definition: scanwizard.cpp:192
ServiceRequirements GetServiceRequirements(void) const
void SetupConfig(uint default_sourceid, uint default_cardid, QString default_inputname)
static void do_scan(struct replex *rx)
Definition: replex.c:2259
QMap< QString, QString > GetStartChan(void) const
Definition: scanwizard.h:83
void Scan()
Definition: scanwizard.cpp:57
void Process(const ScanDTVTransportList &, int sourceid=-1)