MythTV  master
frequencytables.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef FREQUENCY_TABLE_H
4 #define FREQUENCY_TABLE_H
5 
6 // C++ includes
7 #include <list>
8 #include <utility>
9 #include <vector>
10 using namespace std;
11 
12 // Qt includes
13 #include <QString>
14 #include <QMap>
15 
16 // MythTV includes
17 #include "mythtvexp.h"
18 #include "dtvconfparser.h"
19 #include "dtvconfparserhelpers.h"
20 #include "iptvtuningdata.h"
21 
22 class FrequencyTable;
23 class TransportScanItem;
24 
25 using freq_table_map_t = QMap<QString, const FrequencyTable*>;
26 using freq_table_list_t = vector<const FrequencyTable*>;
27 
28 bool teardown_frequency_tables(void);
29 
31  const QString &format, const QString &modulation, const QString &country);
32 
34  const QString& format, const QString& modulation, const QString& country, int freqid);
35 
37  const QString& format, QString modulation, const QString& country, long long centerfreq);
38 
40 {
41  public:
42  FrequencyTable(QString _name_format,
43  int _name_offset,
44  uint64_t _frequencyStart,
45  uint64_t _frequencyEnd,
46  uint _frequencyStep,
47  DTVModulation::Types _modulation)
48  : m_nameFormat(std::move(_name_format)), m_nameOffset(_name_offset),
49  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
50  m_frequencyStep(_frequencyStep), m_modulation(_modulation) {}
51 
52  FrequencyTable(uint64_t _frequencyStart,
53  uint64_t _frequencyEnd,
54  uint _frequencyStep,
55  QString _name_format,
56  int _name_offset,
57  DTVInversion::Types _inversion,
58  DTVBandwidth::Types _bandwidth,
59  DTVCodeRate::Types _coderate_hp,
60  DTVCodeRate::Types _coderate_lp,
61  DTVModulation::Types _constellation,
62  DTVTransmitMode::Types _trans_mode,
63  DTVGuardInterval::Types _guard_interval,
64  DTVHierarchy::Types _hierarchy,
65  DTVModulation::Types _modulation,
66  int _offset1,
67  int _offset2)
68  : m_nameFormat(std::move(_name_format)), m_nameOffset(_name_offset),
69  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
70  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
71  m_offset1(_offset1), m_offset2(_offset2),
72  m_inversion(_inversion), m_bandwidth(_bandwidth),
73  m_coderateHp(_coderate_hp), m_coderateLp(_coderate_lp),
74  m_constellation(_constellation), m_transMode(_trans_mode),
75  m_guardInterval(_guard_interval), m_hierarchy(_hierarchy) {}
76 
77  FrequencyTable(uint64_t _frequencyStart,
78  uint64_t _frequencyEnd,
79  uint _frequencyStep,
80  QString _name_format,
81  int _name_offset,
82  DTVCodeRate::Types _fec_inner,
83  DTVModulation::Types _modulation,
84  uint _symbol_rate,
85  int _offset1,
86  int _offset2)
87  : m_nameFormat(std::move(_name_format)), m_nameOffset(_name_offset),
88  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
89  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
90  m_offset1(_offset1), m_offset2(_offset2),
91  m_symbolRate(_symbol_rate), m_fecInner(_fec_inner) { ; }
92 
93  virtual ~FrequencyTable() { ; }
94 
95  // Common Stuff
96  QString m_nameFormat;
98  uint64_t m_frequencyStart;
99  uint64_t m_frequencyEnd;
102  int m_offset1 {0};
103  int m_offset2 {0};
104 
105  // DVB OFDM stuff
114 
115  // DVB-C/DVB-S stuff
116  uint m_symbolRate {0};
118 };
119 
126 {
127  public:
129  TransportScanItem(uint _sourceid,
130  const QString &_si_std,
131  QString _name,
132  uint _mplexid,
133  uint _timeoutTune);
134 
135  TransportScanItem(uint _sourceid,
136  QString _name,
137  DTVMultiplex &_tuning,
138  uint _timeoutTune);
139 
140  TransportScanItem(uint _sourceid,
141  QString _name,
142  DTVTunerType _tuner_type,
143  const DTVTransport &_tuning,
144  uint _timeoutTune);
145 
146  TransportScanItem(uint _sourceid,
147  const QString &_si_std,
148  QString strFmt, /* fmt for info shown to user */
149  uint freqNum,
150  uint frequency, /* center frequency to use */
151  const FrequencyTable &ft, /* freq table to get info from */
152  uint _timeoutTune);
153 
154  TransportScanItem(uint _sourceid,
155  QString _name,
156  IPTVTuningData _tuning,
157  QString _channel,
158  uint _timeoutTune);
159 
160  uint offset_cnt() const
161  { return (m_freqOffsets[2]) ? 3 : ((m_freqOffsets[1]) ? 2 : 1); }
162 
163  uint64_t freq_offset(uint i) const;
164 
165  QString toString() const;
166 
167  private:
168  uint GetMultiplexIdFromDB(void) const;
169 
170  public:
171  uint m_mplexid {UINT_MAX};
172 
173  QString m_friendlyName;
174  uint m_friendlyNum {0};
175  int m_sourceID {0};
176  bool m_useTimer {false};
179  bool m_scanning {false};
180  std::array<int,3> m_freqOffsets {0,0,0};
181  unsigned m_timeoutTune {1000};
182 
185  QString m_iptvChannel;
186 
188 
189  int m_signalStrength {0};
190  uint m_networkID {0};
191  uint m_transportID {0};
192 };
193 
195 {
196  public:
197  transport_scan_items_it_t() = default;
198  transport_scan_items_it_t(const list<TransportScanItem>::iterator it)
199  : m_it(it) {}
200 
202  {
203  m_offset++;
204  if ((uint)m_offset >= (*m_it).offset_cnt())
205  {
206  ++m_it;
207  m_offset = 0;
208  }
209  return *this;
210  }
212  {
213  m_offset--;
214  if (m_offset < 0)
215  {
216  --m_it;
217  m_offset = (*m_it).offset_cnt() - 1;
218  }
219  return *this;
220  }
221 
222  // cert-dcl21-cpp says this function should be const.
223  // readability-const-return-type says it shouldn't.
224  // NOLINTNEXTLINE(readability-const-return-type)
226  {
228  operator++();
229  return tmp;
230  }
231 
232  // cert-dcl21-cpp says this function should be const.
233  // readability-const-return-type says it shouldn't.
234  // NOLINTNEXTLINE(readability-const-return-type)
236  {
238  operator--();
239  return tmp;
240  }
241 
243  { for (int i = 0; i < incr; i++) ++(*this); return *this; }
245  { for (int i = 0; i < incr; i++) --(*this); return *this; }
246 
247 
248  const TransportScanItem& operator*() const { return *m_it; }
249  TransportScanItem& operator*() { return *m_it; }
250 
251  list<TransportScanItem>::iterator iter() { return m_it; }
252  list<TransportScanItem>::const_iterator iter() const { return m_it; }
253  uint offset() const { return (uint) m_offset; }
255  {
256  list<TransportScanItem>::iterator tmp = m_it;
257  return {++tmp};
258  }
259 
260  private:
261  list<TransportScanItem>::iterator m_it;
262  int m_offset {0};
263 
264  friend bool operator==(const transport_scan_items_it_t&A,
265  const transport_scan_items_it_t&B);
266  friend bool operator!=(const transport_scan_items_it_t&A,
267  const transport_scan_items_it_t&B);
268 
269  friend bool operator==(const transport_scan_items_it_t&A,
270  const list<TransportScanItem>::iterator&B);
271 };
272 
274  const transport_scan_items_it_t& B)
275 {
276  return (A.m_it == B.m_it) && (A.m_offset == B.m_offset);
277 }
278 
280  const transport_scan_items_it_t &B)
281 {
282  return (A.m_it != B.m_it) || (A.m_offset != B.m_offset);
283 }
284 
286  const list<TransportScanItem>::iterator& B)
287 {
288  return (A.m_it == B) && (0 == A.offset());
289 }
290 
291 using transport_scan_items_t = list<TransportScanItem>;
292 
293 #endif // FREQUENCY_TABLE_H
DTVInversion
Definition: dtvconfparserhelpers.h:160
TransportScanItem::m_tuning
DTVMultiplex m_tuning
Tuning info.
Definition: frequencytables.h:183
transport_scan_items_it_t::operator*
const TransportScanItem & operator*() const
Definition: frequencytables.h:248
transport_scan_items_t
list< TransportScanItem > transport_scan_items_t
Definition: frequencytables.h:291
FrequencyTable::m_transMode
DTVTransmitMode m_transMode
Definition: frequencytables.h:111
DTVMultiplex
Definition: dtvmultiplex.h:24
transport_scan_items_it_t::offset
uint offset() const
Definition: frequencytables.h:253
DTVBandwidth
Definition: dtvconfparserhelpers.h:215
FrequencyTable::m_constellation
DTVModulation m_constellation
Definition: frequencytables.h:110
transport_scan_items_it_t::operator*
TransportScanItem & operator*()
Definition: frequencytables.h:249
FrequencyTable
Definition: frequencytables.h:39
transport_scan_items_it_t::m_offset
int m_offset
Definition: frequencytables.h:262
operator!=
bool operator!=(const transport_scan_items_it_t &A, const transport_scan_items_it_t &B)
Definition: frequencytables.h:279
FrequencyTable::m_modulation
DTVModulation m_modulation
Definition: frequencytables.h:101
TransportScanItem::m_iptvChannel
QString m_iptvChannel
IPTV base channel.
Definition: frequencytables.h:185
mythtvexp.h
FrequencyTable::m_nameFormat
QString m_nameFormat
pretty name format
Definition: frequencytables.h:96
DTVTransmitMode::Types
Types
Definition: dtvconfparserhelpers.h:431
FrequencyTable::~FrequencyTable
virtual ~FrequencyTable()
Definition: frequencytables.h:93
DTVHierarchy
Definition: dtvconfparserhelpers.h:544
TransportScanItem::m_iptvTuning
IPTVTuningData m_iptvTuning
IPTV Tuning info.
Definition: frequencytables.h:184
transport_scan_items_it_t::operator++
const transport_scan_items_it_t operator++(int)
Definition: frequencytables.h:225
DTVGuardInterval
Definition: dtvconfparserhelpers.h:485
transport_scan_items_it_t::operator--
const transport_scan_items_it_t operator--(int)
Definition: frequencytables.h:235
FrequencyTable::FrequencyTable
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, QString _name_format, int _name_offset, DTVInversion::Types _inversion, DTVBandwidth::Types _bandwidth, DTVCodeRate::Types _coderate_hp, DTVCodeRate::Types _coderate_lp, DTVModulation::Types _constellation, DTVTransmitMode::Types _trans_mode, DTVGuardInterval::Types _guard_interval, DTVHierarchy::Types _hierarchy, DTVModulation::Types _modulation, int _offset1, int _offset2)
Definition: frequencytables.h:52
tmp
static guint32 * tmp
Definition: goom_core.cpp:30
DTVCodeRate
Definition: dtvconfparserhelpers.h:278
DTVGuardInterval::Types
Types
Definition: dtvconfparserhelpers.h:494
DTVTunerType
Definition: dtvconfparserhelpers.h:76
FrequencyTable::m_inversion
DTVInversion m_inversion
Definition: frequencytables.h:106
FrequencyTable::m_frequencyStep
uint m_frequencyStep
The step in frequency.
Definition: frequencytables.h:100
FrequencyTable::FrequencyTable
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, QString _name_format, int _name_offset, DTVCodeRate::Types _fec_inner, DTVModulation::Types _modulation, uint _symbol_rate, int _offset1, int _offset2)
Definition: frequencytables.h:77
transport_scan_items_it_t::operator--
transport_scan_items_it_t & operator--()
Definition: frequencytables.h:211
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
FrequencyTable::m_coderateHp
DTVCodeRate m_coderateHp
Definition: frequencytables.h:108
transport_scan_items_it_t::operator-=
transport_scan_items_it_t & operator-=(int incr)
Definition: frequencytables.h:244
TransportScanItem
Class used for doing a list of frequencies / transports.
Definition: frequencytables.h:125
DTVInversion::Types
Types
Definition: dtvconfparserhelpers.h:169
DTVTransmitMode
Definition: dtvconfparserhelpers.h:422
teardown_frequency_tables
bool teardown_frequency_tables(void)
Definition: frequencytables.cpp:214
DTVModulation::Types
Types
Definition: dtvconfparserhelpers.h:354
operator==
bool operator==(const transport_scan_items_it_t &A, const transport_scan_items_it_t &B)
Definition: frequencytables.h:273
DTVCodeRate::Types
Types
Definition: dtvconfparserhelpers.h:287
IPTVTuningData
Definition: iptvtuningdata.h:16
transport_scan_items_it_t::operator++
transport_scan_items_it_t & operator++()
Definition: frequencytables.h:201
FrequencyTable::m_coderateLp
DTVCodeRate m_coderateLp
Definition: frequencytables.h:109
DTVBandwidth::Types
Types
Definition: dtvconfparserhelpers.h:224
iptvtuningdata.h
transport_scan_items_it_t
Definition: frequencytables.h:194
uint
unsigned int uint
Definition: compat.h:140
TransportScanItem::m_friendlyName
QString m_friendlyName
Name to display in scanner dialog.
Definition: frequencytables.h:173
FrequencyTable::m_hierarchy
DTVHierarchy m_hierarchy
Definition: frequencytables.h:113
freq_table_map_t
QMap< QString, const FrequencyTable * > freq_table_map_t
Definition: frequencytables.h:25
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
The ending centre frequency.
Definition: frequencytables.h:99
TransportScanItem::m_expectedChannels
DTVChannelInfoList m_expectedChannels
Definition: frequencytables.h:187
transport_scan_items_it_t::iter
list< TransportScanItem >::iterator iter()
Definition: frequencytables.h:251
FrequencyTable::m_fecInner
DTVCodeRate m_fecInner
Definition: frequencytables.h:117
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
get_closest_freqid
int get_closest_freqid(const QString &format, QString modulation, const QString &country, long long centerfreq)
Definition: frequencytables.cpp:285
DTVChannelInfoList
vector< DTVChannelInfo > DTVChannelInfoList
Definition: dtvconfparser.h:61
get_center_frequency
MTV_PUBLIC long long get_center_frequency(const QString &format, const QString &modulation, const QString &country, int freqid)
Definition: frequencytables.cpp:262
transport_scan_items_it_t::iter
list< TransportScanItem >::const_iterator iter() const
Definition: frequencytables.h:252
FrequencyTable::m_guardInterval
DTVGuardInterval m_guardInterval
Definition: frequencytables.h:112
FrequencyTable::m_nameOffset
int m_nameOffset
Offset to add to the pretty name.
Definition: frequencytables.h:97
transport_scan_items_it_t::transport_scan_items_it_t
transport_scan_items_it_t(const list< TransportScanItem >::iterator it)
Definition: frequencytables.h:198
DTVTransport
Definition: dtvconfparser.h:63
get_matching_freq_tables
freq_table_list_t get_matching_freq_tables(const QString &format, const QString &modulation, const QString &country)
Definition: frequencytables.cpp:246
FrequencyTable::m_bandwidth
DTVBandwidth m_bandwidth
Definition: frequencytables.h:107
FrequencyTable::FrequencyTable
FrequencyTable(QString _name_format, int _name_offset, uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, DTVModulation::Types _modulation)
Definition: frequencytables.h:42
dtvconfparser.h
transport_scan_items_it_t::operator+=
transport_scan_items_it_t & operator+=(int incr)
Definition: frequencytables.h:242
transport_scan_items_it_t::m_it
list< TransportScanItem >::iterator m_it
Definition: frequencytables.h:261
TransportScanItem::offset_cnt
uint offset_cnt() const
Definition: frequencytables.h:160
dtvconfparserhelpers.h
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
The staring centre frequency.
Definition: frequencytables.h:98
freq_table_list_t
vector< const FrequencyTable * > freq_table_list_t
Definition: frequencytables.h:26
transport_scan_items_it_t::nextTransport
transport_scan_items_it_t nextTransport() const
Definition: frequencytables.h:254
DTVModulation
Definition: dtvconfparserhelpers.h:345
DTVHierarchy::Types
Types
Definition: dtvconfparserhelpers.h:553