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  int m_freqOffsets[3] {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 
223  {
225  operator++();
226  return tmp;
227  }
228 
230  {
232  operator--();
233  return tmp;
234  }
235 
237  { for (int i = 0; i < incr; i++) ++(*this); return *this; }
239  { for (int i = 0; i < incr; i++) --(*this); return *this; }
240 
241 
242  const TransportScanItem& operator*() const { return *m_it; }
243  TransportScanItem& operator*() { return *m_it; }
244 
245  list<TransportScanItem>::iterator iter() { return m_it; }
246  list<TransportScanItem>::const_iterator iter() const { return m_it; }
247  uint offset() const { return (uint) m_offset; }
249  {
250  list<TransportScanItem>::iterator tmp = m_it;
251  return {++tmp};
252  }
253 
254  private:
255  list<TransportScanItem>::iterator m_it;
256  int m_offset {0};
257 
258  friend bool operator==(const transport_scan_items_it_t&A,
259  const transport_scan_items_it_t&B);
260  friend bool operator!=(const transport_scan_items_it_t&A,
261  const transport_scan_items_it_t&B);
262 
263  friend bool operator==(const transport_scan_items_it_t&A,
264  const list<TransportScanItem>::iterator&B);
265 };
266 
268  const transport_scan_items_it_t& B)
269 {
270  list<TransportScanItem>::const_iterator A_it = A.m_it;
271  list<TransportScanItem>::const_iterator B_it = B.m_it;
272 
273  return (A_it == B_it) && (A.m_offset == B.m_offset);
274 }
275 
277  const transport_scan_items_it_t &B)
278 {
279  return (A.m_it != B.m_it) || (A.m_offset != B.m_offset);
280 }
281 
283  const list<TransportScanItem>::iterator& B)
284 {
285  list<TransportScanItem>::const_iterator A_it = A.m_it;
286  list<TransportScanItem>::const_iterator B_it = B;
287 
288  return (A_it == B_it) && (0 == A.offset());
289 }
290 
291 using transport_scan_items_t = list<TransportScanItem>;
292 
293 #endif // FREQUENCY_TABLE_H
DTVHierarchy m_hierarchy
DTVCodeRate m_coderateLp
FrequencyTable(QString _name_format, int _name_offset, uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, DTVModulation::Types _modulation)
list< TransportScanItem >::iterator m_it
DTVInversion m_inversion
uint64_t m_frequencyEnd
The ending centre frequency.
Class used for doing a list of frequencies / transports.
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)
QString toString(MarkTypes type)
DTVGuardInterval m_guardInterval
DTVModulation m_modulation
freq_table_list_t get_matching_freq_tables(const QString &format, const QString &modulation, const QString &country)
transport_scan_items_it_t & operator+=(int incr)
IPTVTuningData m_iptvTuning
IPTV Tuning info.
transport_scan_items_it_t & operator--()
bool teardown_frequency_tables(void)
TransportScanItem & operator*()
QString m_iptvChannel
IPTV base channel.
static guint32 * tmp
Definition: goom_core.c:35
transport_scan_items_it_t operator++(int)
int m_nameOffset
Offset to add to the pretty name.
int get_closest_freqid(const QString &format, QString modulation, const QString &country, long long centerfreq)
QString m_nameFormat
pretty name format
transport_scan_items_it_t & operator++()
DTVCodeRate m_fecInner
bool operator==(const transport_scan_items_it_t &A, const transport_scan_items_it_t &B)
#define MTV_PUBLIC
Definition: mythtvexp.h:15
vector< const FrequencyTable * > freq_table_list_t
uint64_t m_frequencyStart
The staring centre frequency.
DTVChannelInfoList m_expectedChannels
DTVCodeRate m_coderateHp
list< TransportScanItem > transport_scan_items_t
unsigned int uint
Definition: compat.h:140
QMap< QString, const FrequencyTable * > freq_table_map_t
uint m_frequencyStep
The step in frequency.
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)
DTVBandwidth m_bandwidth
MTV_PUBLIC long long get_center_frequency(const QString &format, const QString &modulation, const QString &country, int freqid)
bool operator!=(const transport_scan_items_it_t &A, const transport_scan_items_it_t &B)
vector< DTVChannelInfo > DTVChannelInfoList
Definition: dtvconfparser.h:61
transport_scan_items_it_t operator--(int)
QString m_friendlyName
Name to display in scanner dialog.
transport_scan_items_it_t & operator-=(int incr)
DTVModulation m_constellation
const TransportScanItem & operator*() const
DTVTransmitMode m_transMode
transport_scan_items_it_t nextTransport() const
uint offset_cnt() const
list< TransportScanItem >::iterator iter()
list< TransportScanItem >::const_iterator iter() const
DTVMultiplex m_tuning
Tuning info.
transport_scan_items_it_t(const list< TransportScanItem >::iterator it)
virtual ~FrequencyTable()