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
40#include "scanwizard.h"
41#include "sourceutil.h"
42#include "videosource.h"
43
44#define LOC QString("SWiz: ")
45
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();
81 }
82 else if (scantype == ScanTypeSetting::NITAddScan_DVBT2)
83 {
84 start_chan = GetStartChan();
86 }
87 else if (scantype == ScanTypeSetting::NITAddScan_DVBS)
88 {
89 start_chan = GetStartChan();
91 }
92 else if (scantype == ScanTypeSetting::NITAddScan_DVBS2)
93 {
94 start_chan = GetStartChan();
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,
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) ||
131 (scantype == ScanTypeSetting::TransportScan) ||
133 (scantype == ScanTypeSetting::FullScan_DVBC) ||
134 (scantype == ScanTypeSetting::FullScan_DVBT) ||
135 (scantype == ScanTypeSetting::FullScan_DVBT2) ||
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,
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
197 DoAddFullTS(),
199
200 // stuff needed for particular scans
201 GetMultiplex(), start_chan,
204 table_start, table_end);
205 }
206}
207
208void 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}
static INPUT_TYPES toInputType(const QString &name)
Definition: cardutil.h:78
static QString ProbeSubTypeName(uint inputid)
Definition: cardutil.cpp:983
void Process(const ScanDTVTransportList &_transports, int sourceid=-1)
virtual DTVConfParser::return_t ImportDVBUtils(uint sourceid, CardUtil::INPUT_TYPES cardtype, const QString &file)
virtual bool ImportHDHR(uint cardid, const QString &inputname, uint sourceid, ServiceRequirements serviceType)
virtual bool ImportM3U(uint cardid, const QString &inputname, uint sourceid, bool is_mpts)
virtual bool ImportVBox(uint cardid, const QString &inputname, uint sourceid, bool ftaOnly, ServiceRequirements serviceType)
virtual bool ImportExternRecorder(uint cardid, const QString &inputname, uint sourceid)
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())
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)
static const int kTunerTypeDVBS2
static const int kTunerTypeDVBT
static const int kTunerTypeUnknown
static const int kTunerTypeDVBC
static const int kTunerTypeDVBS1
static const int kTunerTypeDVBT2
static bool Parse(const QString &cardid_inputname, uint &cardid, QString &inputname)
@ CurrentTransportScan
Scans the transport when there is no tuner (for ASI)
QString GetModulation(void) const
Definition: scanwizard.h:72
bool DoIgnoreSignalTimeout(void) const
Definition: scanwizard.h:87
bool DoAddFullTS(void) const
void SetInput(const QString &cardid_inputname)
Definition: scanwizard.cpp:208
ServiceRequirements GetServiceRequirements(void) const
void SetupConfig(uint default_sourceid, uint default_cardid, const QString &default_inputname)
bool DoFollowNIT(void) const
Definition: scanwizard.h:89
bool DoFreeToAirOnly(void) const
bool DoFullChannelSearch(void) const
QMap< QString, QString > GetStartChan(void) const
Definition: scanwizard.h:84
bool DoTestDecryption(void) const
bool DoRemoveDuplicates(void) const
uint GetCardID(void) const
Definition: scanwizard.h:74
uint GetMultiplex(void) const
Definition: scanwizard.h:77
QString GetFilename(void) const
Definition: scanwizard.h:76
QString GetFrequencyStandard(void) const
Definition: scanwizard.h:80
ScanWizard(uint default_sourceid=0, uint default_cardid=0, const QString &default_inputname=QString())
Definition: scanwizard.cpp:46
bool DoCompleteChannelsOnly(void) const
ChannelScannerGUI * m_scannerPane
Definition: scanwizard.h:63
void Scan()
Definition: scanwizard.cpp:57
bool DoChannelNumbersOnly(void) const
bool GetFrequencyTableRange(QString &start, QString &end) const
Definition: scanwizard.h:78
QString GetFrequencyTable(void) const
Definition: scanwizard.h:82
uint GetSourceID(void) const
int GetScanType(void) const
Definition: scanwizard.h:73
CardUtil::INPUT_TYPES m_lastHWCardType
Definition: scanwizard.h:62
uint m_lastHWCardID
Definition: scanwizard.h:61
QString GetInputName(void) const
Definition: scanwizard.h:75
uint GetScanID(void) const
Definition: scanwizard.h:71
virtual void addChild(StandardSetting *child)
std::vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:143
unsigned int uint
Definition: freesurround.h:24
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
static void do_scan(struct replex *rx)
Definition: replex.cpp:2287
ScanDTVTransportList LoadScan(uint scanid)
Definition: scaninfo.cpp:77
#define LOC
Definition: scanwizard.cpp:44