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 
11 // Qt includes
12 #include <QString>
13 #include <QMap>
14 
15 // MythTV includes
16 #include "mythtvexp.h"
17 #include "dtvconfparser.h"
18 #include "dtvconfparserhelpers.h"
19 #include "iptvtuningdata.h"
20 
21 class FrequencyTable;
22 class TransportScanItem;
23 
24 using freq_table_map_t = QMap<QString, const FrequencyTable*>;
25 using freq_table_list_t = std::vector<const FrequencyTable*>;
26 
27 bool teardown_frequency_tables(void);
28 
30  const QString &format, const QString &modulation, const QString &country);
31 
33  const QString& format, const QString& modulation, const QString& country, int freqid);
34 
36  const QString& format, QString modulation, const QString& country, long long centerfreq);
37 
39 {
40  public:
41  // ATSC -- VSB, QAM
42  FrequencyTable(QString _name_format,
43  int _name_offset,
44  uint64_t _frequencyStart,
45  uint64_t _frequencyEnd,
46  uint64_t _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  // DVB-T/T2 -- OFDM
53  FrequencyTable(uint64_t _frequencyStart,
54  uint64_t _frequencyEnd,
55  uint64_t _frequencyStep,
56  QString _name_format,
57  int _name_offset,
58  DTVInversion::Types _inversion,
59  DTVBandwidth::Types _bandwidth,
60  DTVCodeRate::Types _coderate_hp,
61  DTVCodeRate::Types _coderate_lp,
62  DTVModulation::Types _constellation,
63  DTVTransmitMode::Types _trans_mode,
64  DTVGuardInterval::Types _guard_interval,
65  DTVHierarchy::Types _hierarchy,
66  DTVModulation::Types _modulation,
67  int _offset1,
68  int _offset2)
69  : m_nameFormat(std::move(_name_format)), m_nameOffset(_name_offset),
70  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
71  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
72  m_offset1(_offset1), m_offset2(_offset2),
73  m_inversion(_inversion), m_bandwidth(_bandwidth),
74  m_coderateHp(_coderate_hp), m_coderateLp(_coderate_lp),
75  m_constellation(_constellation), m_transMode(_trans_mode),
76  m_guardInterval(_guard_interval), m_hierarchy(_hierarchy) {}
77 
78  // DVB-C -- QAM
79  FrequencyTable(uint64_t _frequencyStart,
80  uint64_t _frequencyEnd,
81  uint64_t _frequencyStep,
82  QString _name_format,
83  int _name_offset,
84  DTVCodeRate::Types _fec_inner,
85  DTVModulation::Types _modulation,
86  uint _symbol_rate,
87  int _offset1,
88  int _offset2)
89  : m_nameFormat(std::move(_name_format)), m_nameOffset(_name_offset),
90  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
91  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
92  m_offset1(_offset1), m_offset2(_offset2),
93  m_symbolRate(_symbol_rate), m_fecInner(_fec_inner) { ; }
94 
95  virtual ~FrequencyTable() { ; }
96 
97  // Common
98  QString m_nameFormat; // Pretty name format
99  int m_nameOffset; // Offset to add to the pretty name
100  uint64_t m_frequencyStart; // Starting centre frequency
101  uint64_t m_frequencyEnd; // Ending centre frequency
102  uint64_t m_frequencyStep; // Frequency step
104  int m_offset1 {0}; // First offset from the centre frequency
105  int m_offset2 {0}; // Second offset from the centre frequency
106 
107  // DVB-T/T2 -- OFDM
116 
117  // DVB-C
120 };
121 
128 {
129  public:
131  TransportScanItem(uint _sourceid,
132  const QString &_si_std,
133  QString _name,
134  uint _mplexid,
135  std::chrono::milliseconds _timeoutTune);
136 
137  TransportScanItem(uint _sourceid,
138  QString _name,
139  const DTVMultiplex &_tuning,
140  std::chrono::milliseconds _timeoutTune);
141 
142  TransportScanItem(uint _sourceid,
143  QString _name,
144  DTVTunerType _tuner_type,
145  const DTVTransport &_tuning,
146  std::chrono::milliseconds _timeoutTune);
147 
148  TransportScanItem(uint _sourceid,
149  const QString &_si_std,
150  QString strFmt, /* fmt for info shown to user */
151  uint freqNum,
152  uint frequency, /* center frequency to use */
153  const FrequencyTable &ft, /* freq table to get info from */
154  std::chrono::milliseconds _timeoutTune);
155 
156  TransportScanItem(uint _sourceid,
157  QString _name,
158  IPTVTuningData _tuning,
159  QString _channel,
160  std::chrono::milliseconds _timeoutTune);
161 
162  uint offset_cnt() const
163  {
164  if (m_freqOffsets[2])
165  return 3;
166  if (m_freqOffsets[1])
167  return 2;
168  return 1;
169  }
170 
171  uint64_t freq_offset(uint i) const;
172 
173  QString toString() const;
174 
175  private:
176  uint GetMultiplexIdFromDB(void) const;
177 
178  public:
179  uint m_mplexid {UINT_MAX}; // DB mplexid in dtv_multiplex
180 
181  QString m_friendlyName; // Name to display in scanner dialog
182  uint m_friendlyNum {0}; // Frequency number (freqid w/freq table)
183  int m_sourceID {0}; // DB sourceid in videosource
184  bool m_useTimer {false}; // Set if timer is used after lock for getting PAT
185 
186  bool m_scanning {false}; // Probably unnecessary
187  std::array<int,3> m_freqOffsets {0,0,0}; // Frequency offsets
188  std::chrono::milliseconds m_timeoutTune {1s};
189 
190  DTVMultiplex m_tuning; // Tuning info
191  IPTVTuningData m_iptvTuning; // IPTV Tuning info
192  QString m_iptvChannel; // IPTV base channel
193 
195 
199 };
200 
202 {
203  public:
204  transport_scan_items_it_t() = default;
205  transport_scan_items_it_t(const std::list<TransportScanItem>::iterator it)
206  : m_it(it) {}
207 
209  {
210  m_offset++;
211  if ((uint)m_offset >= (*m_it).offset_cnt())
212  {
213  ++m_it;
214  m_offset = 0;
215  }
216  return *this;
217  }
219  {
220  m_offset--;
221  if (m_offset < 0)
222  {
223  --m_it;
224  m_offset = (*m_it).offset_cnt() - 1;
225  }
226  return *this;
227  }
228 
229  // cert-dcl21-cpp says this function should be const.
230  // readability-const-return-type says it shouldn't.
231  // NOLINTNEXTLINE(readability-const-return-type)
233  {
235  operator++();
236  return tmp;
237  }
238 
239  // cert-dcl21-cpp says this function should be const.
240  // readability-const-return-type says it shouldn't.
241  // NOLINTNEXTLINE(readability-const-return-type)
243  {
245  operator--();
246  return tmp;
247  }
248 
250  { for (int i = 0; i < incr; i++) ++(*this); return *this; }
252  { for (int i = 0; i < incr; i++) --(*this); return *this; }
253 
254 
255  const TransportScanItem& operator*() const { return *m_it; }
257 
258  std::list<TransportScanItem>::iterator iter() { return m_it; }
259  std::list<TransportScanItem>::const_iterator iter() const { return m_it; }
260  uint offset() const { return (uint) m_offset; }
262  {
263  std::list<TransportScanItem>::iterator tmp = m_it;
264  return {++tmp};
265  }
266 
267  private:
268  std::list<TransportScanItem>::iterator m_it;
269  int m_offset {0};
270 
275 
277  std::list<TransportScanItem>::iterator B);
278 };
279 
282 {
283  return (A.m_it == B.m_it) && (A.m_offset == B.m_offset);
284 }
285 
288 {
289  return (A.m_it != B.m_it) || (A.m_offset != B.m_offset);
290 }
291 
293  const std::list<TransportScanItem>::iterator B)
294 {
295  return (A.m_it == B) && (0 == A.offset());
296 }
297 
298 using transport_scan_items_t = std::list<TransportScanItem>;
299 
300 #endif // FREQUENCY_TABLE_H
DTVInversion
Definition: dtvconfparserhelpers.h:162
TransportScanItem::m_tuning
DTVMultiplex m_tuning
Definition: frequencytables.h:190
transport_scan_items_it_t::operator*
const TransportScanItem & operator*() const
Definition: frequencytables.h:255
FrequencyTable::m_transMode
DTVTransmitMode m_transMode
Definition: frequencytables.h:113
DTVMultiplex
Definition: dtvmultiplex.h:24
TransportScanItem::TransportScanItem
TransportScanItem()
Definition: frequencytables.cpp:19
transport_scan_items_it_t::offset
uint offset() const
Definition: frequencytables.h:260
DTVBandwidth
Definition: dtvconfparserhelpers.h:217
FrequencyTable::m_constellation
DTVModulation m_constellation
Definition: frequencytables.h:112
transport_scan_items_it_t::operator*
TransportScanItem & operator*()
Definition: frequencytables.h:256
FrequencyTable
Definition: frequencytables.h:38
transport_scan_items_it_t::transport_scan_items_it_t
transport_scan_items_it_t(const std::list< TransportScanItem >::iterator it)
Definition: frequencytables.h:205
TransportScanItem::m_scanning
bool m_scanning
Definition: frequencytables.h:186
FrequencyTable::FrequencyTable
FrequencyTable(QString _name_format, int _name_offset, uint64_t _frequencyStart, uint64_t _frequencyEnd, uint64_t _frequencyStep, DTVModulation::Types _modulation)
Definition: frequencytables.h:42
transport_scan_items_it_t::m_it
std::list< TransportScanItem >::iterator m_it
Definition: frequencytables.h:268
freq_table_list_t
std::vector< const FrequencyTable * > freq_table_list_t
Definition: frequencytables.h:25
transport_scan_items_it_t::m_offset
int m_offset
Definition: frequencytables.h:269
FrequencyTable::m_modulation
DTVModulation m_modulation
Definition: frequencytables.h:103
TransportScanItem::m_iptvChannel
QString m_iptvChannel
Definition: frequencytables.h:192
TransportScanItem::m_useTimer
bool m_useTimer
Definition: frequencytables.h:184
mythtvexp.h
FrequencyTable::m_nameFormat
QString m_nameFormat
Definition: frequencytables.h:98
FrequencyTable::~FrequencyTable
virtual ~FrequencyTable()
Definition: frequencytables.h:95
TransportScanItem::m_friendlyNum
uint m_friendlyNum
Definition: frequencytables.h:182
DTVHierarchy
Definition: dtvconfparserhelpers.h:546
DTVGuardInterval::Types
Types
Definition: dtvconfparserhelpers.h:496
TransportScanItem::m_sourceID
int m_sourceID
Definition: frequencytables.h:183
TransportScanItem::m_iptvTuning
IPTVTuningData m_iptvTuning
Definition: frequencytables.h:191
TransportScanItem::m_signalStrength
int m_signalStrength
Definition: frequencytables.h:198
transport_scan_items_it_t::operator++
const transport_scan_items_it_t operator++(int)
Definition: frequencytables.h:232
DTVGuardInterval
Definition: dtvconfparserhelpers.h:487
transport_scan_items_it_t::operator--
const transport_scan_items_it_t operator--(int)
Definition: frequencytables.h:242
DTVHierarchy::Types
Types
Definition: dtvconfparserhelpers.h:555
operator==
bool operator==(const transport_scan_items_it_t A, const transport_scan_items_it_t B)
Definition: frequencytables.h:280
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
DTVBandwidth::Types
Types
Definition: dtvconfparserhelpers.h:226
DTVCodeRate
Definition: dtvconfparserhelpers.h:280
DTVTunerType
Definition: dtvconfparserhelpers.h:76
FrequencyTable::m_inversion
DTVInversion m_inversion
Definition: frequencytables.h:108
transport_scan_items_it_t::operator--
transport_scan_items_it_t & operator--()
Definition: frequencytables.h:218
FrequencyTable::m_coderateHp
DTVCodeRate m_coderateHp
Definition: frequencytables.h:110
transport_scan_items_it_t::operator-=
transport_scan_items_it_t & operator-=(int incr)
Definition: frequencytables.h:251
TransportScanItem
Class used for doing a list of frequencies / transports.
Definition: frequencytables.h:127
DTVCodeRate::Types
Types
Definition: dtvconfparserhelpers.h:289
transport_scan_items_it_t::iter
std::list< TransportScanItem >::iterator iter()
Definition: frequencytables.h:258
FrequencyTable::m_offset2
int m_offset2
Definition: frequencytables.h:105
operator!=
bool operator!=(const transport_scan_items_it_t A, const transport_scan_items_it_t B)
Definition: frequencytables.h:286
DTVChannelInfoList
std::vector< DTVChannelInfo > DTVChannelInfoList
Definition: dtvconfparser.h:58
DTVTransmitMode
Definition: dtvconfparserhelpers.h:424
teardown_frequency_tables
bool teardown_frequency_tables(void)
Definition: frequencytables.cpp:214
IPTVTuningData
Definition: iptvtuningdata.h:21
FrequencyTable::m_frequencyStep
uint64_t m_frequencyStep
Definition: frequencytables.h:102
transport_scan_items_it_t::operator++
transport_scan_items_it_t & operator++()
Definition: frequencytables.h:208
FrequencyTable::m_coderateLp
DTVCodeRate m_coderateLp
Definition: frequencytables.h:111
TransportScanItem::GetMultiplexIdFromDB
uint GetMultiplexIdFromDB(void) const
Fetches mplexid if it exists, based on the frequency and sourceid.
Definition: frequencytables.cpp:147
FrequencyTable::m_symbolRate
uint m_symbolRate
Definition: frequencytables.h:118
iptvtuningdata.h
DTVInversion::Types
Types
Definition: dtvconfparserhelpers.h:171
get_matching_freq_tables
MTV_PUBLIC freq_table_list_t get_matching_freq_tables(const QString &format, const QString &modulation, const QString &country)
Definition: frequencytables.cpp:246
transport_scan_items_it_t
Definition: frequencytables.h:201
transport_scan_items_it_t::operator==
friend bool operator==(transport_scan_items_it_t A, transport_scan_items_it_t B)
Definition: frequencytables.h:280
uint
unsigned int uint
Definition: compat.h:81
TransportScanItem::m_freqOffsets
std::array< int, 3 > m_freqOffsets
Definition: frequencytables.h:187
transport_scan_items_it_t::transport_scan_items_it_t
transport_scan_items_it_t()=default
TransportScanItem::m_friendlyName
QString m_friendlyName
Definition: frequencytables.h:181
FrequencyTable::m_hierarchy
DTVHierarchy m_hierarchy
Definition: frequencytables.h:115
freq_table_map_t
QMap< QString, const FrequencyTable * > freq_table_map_t
Definition: frequencytables.h:24
get_closest_freqid
MTV_PUBLIC int get_closest_freqid(const QString &format, QString modulation, const QString &country, long long centerfreq)
Definition: frequencytables.cpp:285
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
Definition: frequencytables.h:101
TransportScanItem::m_expectedChannels
DTVChannelInfoList m_expectedChannels
Definition: frequencytables.h:194
FrequencyTable::m_fecInner
DTVCodeRate m_fecInner
Definition: frequencytables.h:119
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
TransportScanItem::m_mplexid
uint m_mplexid
Definition: frequencytables.h:179
TransportScanItem::freq_offset
uint64_t freq_offset(uint i) const
Definition: frequencytables.cpp:157
DTVTransmitMode::Types
Types
Definition: dtvconfparserhelpers.h:433
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
TransportScanItem::m_networkID
uint m_networkID
Definition: frequencytables.h:196
FrequencyTable::m_guardInterval
DTVGuardInterval m_guardInterval
Definition: frequencytables.h:114
TransportScanItem::m_timeoutTune
std::chrono::milliseconds m_timeoutTune
Timeout to tune to a frequency.
Definition: frequencytables.h:188
FrequencyTable::m_nameOffset
int m_nameOffset
Definition: frequencytables.h:99
DTVTransport
Definition: dtvconfparser.h:60
FrequencyTable::FrequencyTable
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint64_t _frequencyStep, QString _name_format, int _name_offset, DTVCodeRate::Types _fec_inner, DTVModulation::Types _modulation, uint _symbol_rate, int _offset1, int _offset2)
Definition: frequencytables.h:79
transport_scan_items_it_t::operator!=
friend bool operator!=(transport_scan_items_it_t A, transport_scan_items_it_t B)
Definition: frequencytables.h:286
FrequencyTable::FrequencyTable
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint64_t _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:53
transport_scan_items_it_t::iter
std::list< TransportScanItem >::const_iterator iter() const
Definition: frequencytables.h:259
TransportScanItem::m_transportID
uint m_transportID
Definition: frequencytables.h:197
FrequencyTable::m_bandwidth
DTVBandwidth m_bandwidth
Definition: frequencytables.h:109
dtvconfparser.h
transport_scan_items_it_t::operator+=
transport_scan_items_it_t & operator+=(int incr)
Definition: frequencytables.h:249
TransportScanItem::offset_cnt
uint offset_cnt() const
Definition: frequencytables.h:162
TransportScanItem::toString
QString toString() const
Definition: frequencytables.cpp:164
FrequencyTable::m_offset1
int m_offset1
Definition: frequencytables.h:104
dtvconfparserhelpers.h
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
Definition: frequencytables.h:100
DTVModulation::Types
Types
Definition: dtvconfparserhelpers.h:356
transport_scan_items_t
std::list< TransportScanItem > transport_scan_items_t
Definition: frequencytables.h:298
transport_scan_items_it_t::nextTransport
transport_scan_items_it_t nextTransport() const
Definition: frequencytables.h:261
DTVModulation
Definition: dtvconfparserhelpers.h:347