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  { return (m_freqOffsets[2]) ? 3 : ((m_freqOffsets[1]) ? 2 : 1); }
164 
165  uint64_t freq_offset(uint i) const;
166 
167  QString toString() const;
168 
169  private:
170  uint GetMultiplexIdFromDB(void) const;
171 
172  public:
173  uint m_mplexid {UINT_MAX}; // DB mplexid in dtv_multiplex
174 
175  QString m_friendlyName; // Name to display in scanner dialog
176  uint m_friendlyNum {0}; // Frequency number (freqid w/freq table)
177  int m_sourceID {0}; // DB sourceid in videosource
178  bool m_useTimer {false}; // Set if timer is used after lock for getting PAT
179 
180  bool m_scanning {false}; // Probably unnecessary
181  std::array<int,3> m_freqOffsets {0,0,0}; // Frequency offsets
182  std::chrono::milliseconds m_timeoutTune {1s};
183 
184  DTVMultiplex m_tuning; // Tuning info
185  IPTVTuningData m_iptvTuning; // IPTV Tuning info
186  QString m_iptvChannel; // IPTV base channel
187 
189 
193 };
194 
196 {
197  public:
198  transport_scan_items_it_t() = default;
199  transport_scan_items_it_t(const std::list<TransportScanItem>::iterator it)
200  : m_it(it) {}
201 
203  {
204  m_offset++;
205  if ((uint)m_offset >= (*m_it).offset_cnt())
206  {
207  ++m_it;
208  m_offset = 0;
209  }
210  return *this;
211  }
213  {
214  m_offset--;
215  if (m_offset < 0)
216  {
217  --m_it;
218  m_offset = (*m_it).offset_cnt() - 1;
219  }
220  return *this;
221  }
222 
223  // cert-dcl21-cpp says this function should be const.
224  // readability-const-return-type says it shouldn't.
225  // NOLINTNEXTLINE(readability-const-return-type)
227  {
229  operator++();
230  return tmp;
231  }
232 
233  // cert-dcl21-cpp says this function should be const.
234  // readability-const-return-type says it shouldn't.
235  // NOLINTNEXTLINE(readability-const-return-type)
237  {
239  operator--();
240  return tmp;
241  }
242 
244  { for (int i = 0; i < incr; i++) ++(*this); return *this; }
246  { for (int i = 0; i < incr; i++) --(*this); return *this; }
247 
248 
249  const TransportScanItem& operator*() const { return *m_it; }
251 
252  std::list<TransportScanItem>::iterator iter() { return m_it; }
253  std::list<TransportScanItem>::const_iterator iter() const { return m_it; }
254  uint offset() const { return (uint) m_offset; }
256  {
257  std::list<TransportScanItem>::iterator tmp = m_it;
258  return {++tmp};
259  }
260 
261  private:
262  std::list<TransportScanItem>::iterator m_it;
263  int m_offset {0};
264 
269 
271  std::list<TransportScanItem>::iterator B);
272 };
273 
276 {
277  return (A.m_it == B.m_it) && (A.m_offset == B.m_offset);
278 }
279 
282 {
283  return (A.m_it != B.m_it) || (A.m_offset != B.m_offset);
284 }
285 
287  const std::list<TransportScanItem>::iterator B)
288 {
289  return (A.m_it == B) && (0 == A.offset());
290 }
291 
292 using transport_scan_items_t = std::list<TransportScanItem>;
293 
294 #endif // FREQUENCY_TABLE_H
DTVInversion
Definition: dtvconfparserhelpers.h:162
TransportScanItem::m_tuning
DTVMultiplex m_tuning
Definition: frequencytables.h:184
transport_scan_items_it_t::operator*
const TransportScanItem & operator*() const
Definition: frequencytables.h:249
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:254
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:250
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:199
TransportScanItem::m_scanning
bool m_scanning
Definition: frequencytables.h:180
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:262
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:263
FrequencyTable::m_modulation
DTVModulation m_modulation
Definition: frequencytables.h:103
TransportScanItem::m_iptvChannel
QString m_iptvChannel
Definition: frequencytables.h:186
TransportScanItem::m_useTimer
bool m_useTimer
Definition: frequencytables.h:178
mythtvexp.h
FrequencyTable::m_nameFormat
QString m_nameFormat
Definition: frequencytables.h:98
DTVTransmitMode::Types
Types
Definition: dtvconfparserhelpers.h:433
FrequencyTable::~FrequencyTable
virtual ~FrequencyTable()
Definition: frequencytables.h:95
TransportScanItem::m_friendlyNum
uint m_friendlyNum
Definition: frequencytables.h:176
DTVHierarchy
Definition: dtvconfparserhelpers.h:546
TransportScanItem::m_sourceID
int m_sourceID
Definition: frequencytables.h:177
TransportScanItem::m_iptvTuning
IPTVTuningData m_iptvTuning
Definition: frequencytables.h:185
TransportScanItem::m_signalStrength
int m_signalStrength
Definition: frequencytables.h:192
transport_scan_items_it_t::operator++
const transport_scan_items_it_t operator++(int)
Definition: frequencytables.h:226
DTVGuardInterval
Definition: dtvconfparserhelpers.h:487
transport_scan_items_it_t::operator--
const transport_scan_items_it_t operator--(int)
Definition: frequencytables.h:236
operator==
bool operator==(const transport_scan_items_it_t A, const transport_scan_items_it_t B)
Definition: frequencytables.h:274
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
DTVCodeRate
Definition: dtvconfparserhelpers.h:280
DTVGuardInterval::Types
Types
Definition: dtvconfparserhelpers.h:496
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:212
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:245
TransportScanItem
Class used for doing a list of frequencies / transports.
Definition: frequencytables.h:127
transport_scan_items_it_t::iter
std::list< TransportScanItem >::iterator iter()
Definition: frequencytables.h:252
DTVInversion::Types
Types
Definition: dtvconfparserhelpers.h:171
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:280
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:215
DTVModulation::Types
Types
Definition: dtvconfparserhelpers.h:356
DTVCodeRate::Types
Types
Definition: dtvconfparserhelpers.h:289
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:202
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:148
FrequencyTable::m_symbolRate
uint m_symbolRate
Definition: frequencytables.h:118
DTVBandwidth::Types
Types
Definition: dtvconfparserhelpers.h:226
iptvtuningdata.h
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:247
transport_scan_items_it_t
Definition: frequencytables.h:195
transport_scan_items_it_t::operator==
friend bool operator==(transport_scan_items_it_t A, transport_scan_items_it_t B)
Definition: frequencytables.h:274
uint
unsigned int uint
Definition: compat.h:79
TransportScanItem::m_freqOffsets
std::array< int, 3 > m_freqOffsets
Definition: frequencytables.h:181
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:175
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:286
FrequencyTable::m_frequencyEnd
uint64_t m_frequencyEnd
Definition: frequencytables.h:101
TransportScanItem::m_expectedChannels
DTVChannelInfoList m_expectedChannels
Definition: frequencytables.h:188
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:173
TransportScanItem::freq_offset
uint64_t freq_offset(uint i) const
Definition: frequencytables.cpp:158
get_center_frequency
MTV_PUBLIC long long get_center_frequency(const QString &format, const QString &modulation, const QString &country, int freqid)
Definition: frequencytables.cpp:263
std
Definition: mythchrono.h:23
TransportScanItem::m_networkID
uint m_networkID
Definition: frequencytables.h:190
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:182
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:280
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:253
TransportScanItem::m_transportID
uint m_transportID
Definition: frequencytables.h:191
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:243
TransportScanItem::offset_cnt
uint offset_cnt() const
Definition: frequencytables.h:162
TransportScanItem::toString
QString toString() const
Definition: frequencytables.cpp:165
FrequencyTable::m_offset1
int m_offset1
Definition: frequencytables.h:104
dtvconfparserhelpers.h
FrequencyTable::m_frequencyStart
uint64_t m_frequencyStart
Definition: frequencytables.h:100
transport_scan_items_t
std::list< TransportScanItem > transport_scan_items_t
Definition: frequencytables.h:292
transport_scan_items_it_t::nextTransport
transport_scan_items_it_t nextTransport() const
Definition: frequencytables.h:255
DTVModulation
Definition: dtvconfparserhelpers.h:347
DTVHierarchy::Types
Types
Definition: dtvconfparserhelpers.h:555