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 <vector>
9 using namespace std;
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;
23 
24 typedef QMap<QString, const FrequencyTable*> freq_table_map_t;
25 typedef vector<const FrequencyTable*> freq_table_list_t;
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  FrequencyTable(const QString& _name_format,
42  int _name_offset,
43  uint64_t _frequencyStart,
44  uint64_t _frequencyEnd,
45  uint _frequencyStep,
46  DTVModulation::Types _modulation)
47  : m_nameFormat(_name_format), m_nameOffset(_name_offset),
48  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
49  m_frequencyStep(_frequencyStep), m_modulation(_modulation) {}
50 
51  FrequencyTable(uint64_t _frequencyStart,
52  uint64_t _frequencyEnd,
53  uint _frequencyStep,
54  const QString& _name_format,
55  int _name_offset,
56  DTVInversion::Types _inversion,
57  DTVBandwidth::Types _bandwidth,
58  DTVCodeRate::Types _coderate_hp,
59  DTVCodeRate::Types _coderate_lp,
60  DTVModulation::Types _constellation,
61  DTVTransmitMode::Types _trans_mode,
62  DTVGuardInterval::Types _guard_interval,
63  DTVHierarchy::Types _hierarchy,
64  DTVModulation::Types _modulation,
65  int _offset1,
66  int _offset2)
67  : m_nameFormat(_name_format), m_nameOffset(_name_offset),
68  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
69  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
70  m_offset1(_offset1), m_offset2(_offset2),
71  m_inversion(_inversion), m_bandwidth(_bandwidth),
72  m_coderateHp(_coderate_hp), m_coderateLp(_coderate_lp),
73  m_constellation(_constellation), m_transMode(_trans_mode),
74  m_guardInterval(_guard_interval), m_hierarchy(_hierarchy) {}
75 
76  FrequencyTable(uint64_t _frequencyStart,
77  uint64_t _frequencyEnd,
78  uint _frequencyStep,
79  const QString& _name_format,
80  int _name_offset,
81  DTVCodeRate::Types _fec_inner,
82  DTVModulation::Types _modulation,
83  uint _symbol_rate,
84  int _offset1,
85  int _offset2)
86  : m_nameFormat(_name_format), m_nameOffset(_name_offset),
87  m_frequencyStart(_frequencyStart), m_frequencyEnd(_frequencyEnd),
88  m_frequencyStep(_frequencyStep), m_modulation(_modulation),
89  m_offset1(_offset1), m_offset2(_offset2),
90  m_symbolRate(_symbol_rate), m_fecInner(_fec_inner) { ; }
91 
92  virtual ~FrequencyTable() { ; }
93 
94  // Common Stuff
95  QString m_nameFormat;
97  uint64_t m_frequencyStart;
98  uint64_t m_frequencyEnd;
101  int m_offset1 {0};
102  int m_offset2 {0};
103 
104  // DVB OFDM stuff
113 
114  // DVB-C/DVB-S stuff
115  uint m_symbolRate {0};
117 };
118 
125 {
126  public:
128  TransportScanItem(uint _sourceid,
129  const QString &_si_std,
130  const QString &_name,
131  uint _mplexid,
132  uint _timeoutTune);
133 
134  TransportScanItem(uint _sourceid,
135  const QString &_name,
136  DTVMultiplex &_tuning,
137  uint _timeoutTune);
138 
139  TransportScanItem(uint _sourceid,
140  const QString &_name,
141  DTVTunerType _tuner_type,
142  const DTVTransport &_tuning,
143  uint _timeoutTune);
144 
145  TransportScanItem(uint _sourceid,
146  const QString &_si_std,
147  const QString &strFmt, /* fmt for info shown to user */
148  uint freqNum,
149  uint frequency, /* center frequency to use */
150  const FrequencyTable&, /* freq table to get info from */
151  uint _timeoutTune);
152 
153  TransportScanItem(uint _sourceid,
154  const QString &_name,
155  const IPTVTuningData &_tuning,
156  const QString &_channel,
157  uint _timeoutTune);
158 
159  uint offset_cnt() const
160  { return (m_freqOffsets[2]) ? 3 : ((m_freqOffsets[1]) ? 2 : 1); }
161 
162  uint64_t freq_offset(uint i) const;
163 
164  QString toString() const;
165 
166  private:
167  uint GetMultiplexIdFromDB(void) const;
168 
169  public:
170  uint m_mplexid {(uint)-1};
171 
172  QString m_friendlyName;
173  uint m_friendlyNum {0};
174  int m_sourceID {0};
175  bool m_useTimer {false};
178  bool m_scanning {false};
179  int m_freqOffsets[3];
180  unsigned m_timeoutTune {1000};
181 
184  QString m_iptvChannel;
185 
187 };
188 
190 {
191  public:
192  transport_scan_items_it_t() = default;
193  transport_scan_items_it_t(const list<TransportScanItem>::iterator it)
194  : m_it(it) {}
195 
197  {
198  m_offset++;
199  if ((uint)m_offset >= (*m_it).offset_cnt())
200  {
201  ++m_it;
202  m_offset = 0;
203  }
204  return *this;
205  }
207  {
208  m_offset--;
209  if (m_offset < 0)
210  {
211  --m_it;
212  m_offset = (*m_it).offset_cnt() - 1;
213  }
214  return *this;
215  }
216 
218  {
220  operator++();
221  return tmp;
222  }
223 
225  {
227  operator--();
228  return tmp;
229  }
230 
232  { for (int i = 0; i < incr; i++) ++(*this); return *this; }
234  { for (int i = 0; i < incr; i++) --(*this); return *this; }
235 
236 
237  const TransportScanItem& operator*() const { return *m_it; }
238  TransportScanItem& operator*() { return *m_it; }
239 
240  list<TransportScanItem>::iterator iter() { return m_it; }
241  list<TransportScanItem>::const_iterator iter() const { return m_it; }
242  uint offset() const { return (uint) m_offset; }
244  {
245  list<TransportScanItem>::iterator tmp = m_it;
246  return transport_scan_items_it_t(++tmp);
247  }
248 
249  private:
250  list<TransportScanItem>::iterator m_it;
251  int m_offset {0};
252 
253  friend bool operator==(const transport_scan_items_it_t&,
255  friend bool operator!=(const transport_scan_items_it_t&,
257 
258  friend bool operator==(const transport_scan_items_it_t&,
259  const list<TransportScanItem>::iterator&);
260 };
261 
263  const transport_scan_items_it_t& B)
264 {
265  list<TransportScanItem>::const_iterator A_it = A.m_it;
266  list<TransportScanItem>::const_iterator B_it = B.m_it;
267 
268  return (A_it == B_it) && (A.m_offset == B.m_offset);
269 }
270 
272  const transport_scan_items_it_t &B)
273 {
274  return (A.m_it != B.m_it) || (A.m_offset != B.m_offset);
275 }
276 
278  const list<TransportScanItem>::iterator& B)
279 {
280  list<TransportScanItem>::const_iterator A_it = A.m_it;
281  list<TransportScanItem>::const_iterator B_it = B;
282 
283  return (A_it == B_it) && (0 == A.offset());
284 }
285 
286 typedef list<TransportScanItem> transport_scan_items_t;
287 
288 #endif // FREQUENCY_TABLE_H
DTVHierarchy m_hierarchy
DTVCodeRate m_coderateLp
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.
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)
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, const 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)
transport_scan_items_it_t & operator+=(int incr)
IPTVTuningData m_iptvTuning
IPTV Tuning info.
vector< const FrequencyTable * > freq_table_list_t
transport_scan_items_it_t & operator--()
bool teardown_frequency_tables(void)
unsigned int uint
Definition: compat.h:140
QMap< QString, const FrequencyTable * > freq_table_map_t
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
uint64_t m_frequencyStart
The staring centre frequency.
DTVChannelInfoList m_expectedChannels
DTVCodeRate m_coderateHp
uint m_frequencyStep
The step in frequency.
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)
transport_scan_items_it_t operator--(int)
QString m_friendlyName
Name to display in scanner dialog.
transport_scan_items_it_t & operator-=(int incr)
list< TransportScanItem > transport_scan_items_t
vector< DTVChannelInfo > DTVChannelInfoList
Definition: dtvconfparser.h:60
DTVModulation m_constellation
const TransportScanItem & operator*() const
DTVTransmitMode m_transMode
transport_scan_items_it_t nextTransport() const
uint offset_cnt() const
FrequencyTable(uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, const QString &_name_format, int _name_offset, DTVCodeRate::Types _fec_inner, DTVModulation::Types _modulation, uint _symbol_rate, int _offset1, int _offset2)
list< TransportScanItem >::iterator iter()
FrequencyTable(const QString &_name_format, int _name_offset, uint64_t _frequencyStart, uint64_t _frequencyEnd, uint _frequencyStep, DTVModulation::Types _modulation)
list< TransportScanItem >::const_iterator iter() const
DTVMultiplex m_tuning
Tuning info.
transport_scan_items_it_t(const list< TransportScanItem >::iterator it)
virtual ~FrequencyTable()