MythTV  master
dtvconfparserhelpers.cpp
Go to the documentation of this file.
1 
2 #include <QMutex>
3 #include <QMap>
4 
5 #include "mythlogging.h"
6 #include "dtvconfparserhelpers.h"
7 
8 bool DTVParamHelper::ParseParam(const QString &symbol, int &value,
9  const DTVParamHelperStruct *table)
10 {
11  const DTVParamHelperStruct *p = table;
12 
13  while (!p->symbol.isEmpty())
14  {
15  if (p->symbol == symbol) //.left(p->symbol.length()))
16  {
17  //symbol = symbol.mid(p->symbol.length());
18  value = p->value;
19  return true;
20  }
21  p++;
22  }
23 
24  return false;
25 }
26 
27 QString DTVParamHelper::toString(const char *strings[], int index,
28  uint strings_size)
29 {
30  if ((index < 0) || ((uint)index >= strings_size))
31  {
32  LOG(VB_GENERAL, LOG_ERR,
33  "DTVParamHelper::toString() index out of bounds");
34 
35  return QString();
36  }
37 
38  return strings[index];
39 }
40 
41 //
42 // === Tuner Type ===
43 //
44 
45 const int DTVTunerType::kTunerTypeDVBS1 = 0x0000;
46 const int DTVTunerType::kTunerTypeDVBS2 = 0x0020;
47 const int DTVTunerType::kTunerTypeDVBC = 0x0001;
48 const int DTVTunerType::kTunerTypeDVBT = 0x0002;
49 const int DTVTunerType::kTunerTypeDVBT2 = 0x0022;
50 const int DTVTunerType::kTunerTypeATSC = 0x0003;
51 const int DTVTunerType::kTunerTypeASI = 0x1000;
52 const int DTVTunerType::kTunerTypeOCUR = 0x2000;
53 const int DTVTunerType::kTunerTypeIPTV = 0x4000;
54 const int DTVTunerType::kTunerTypeUnknown = 0x80000000;
55 
57 static QMap<int,QString> dtv_tt_canonical_str;
59 {
60  QMutexLocker locker(&dtv_tt_canonical_str_lock);
70 }
71 
72 QString DTVTunerType::toString(int _value)
73 {
74  QMutexLocker locker(&dtv_tt_canonical_str_lock);
75  QMap<int,QString>::const_iterator it = dtv_tt_canonical_str.find(_value);
76  if (it != dtv_tt_canonical_str.end())
77  return *it;
79 }
80 
82 {
83  { "QPSK", kTunerTypeDVBS1 },
84  { "QAM", kTunerTypeDVBC },
85  { "OFDM", kTunerTypeDVBT },
86  { "DVB_T2", kTunerTypeDVBT2 },
87  { "ATSC", kTunerTypeATSC },
88  { "DVB_S2", kTunerTypeDVBS2 },
89  { "ASI", kTunerTypeASI },
90  { "OCUR", kTunerTypeOCUR },
91  { "UNKNOWN", kTunerTypeUnknown },
92  { nullptr, kTunerTypeUnknown },
93 };
94 
95 //
96 // === Inversion ===
97 //
98 
100 {
101  { "INVERSION_AUTO", kInversionAuto },
102  { "INVERSION_OFF", kInversionOff },
103  { "INVERSION_ON", kInversionOn },
104  { nullptr, kInversionAuto },
105 };
106 
108 {
109  { "999", kInversionAuto },
110  { "0", kInversionOff },
111  { "1", kInversionOn },
112  { nullptr, kInversionAuto },
113 };
114 
116 {
117  { "a", kInversionAuto },
118  { "0", kInversionOff },
119  { "1", kInversionOn },
120  { nullptr, kInversionAuto },
121 };
122 
124 {
125  "0",
126  "1",
127  "a"
128 };
129 
130 //
131 // === Bandwidth ===
132 //
133 // Database update needed for the 10MHz and 1.712MHz because
134 // dtvmultiplex:bandwidth is now only one character.
135 //
136 
138 {
139  { "BANDWIDTH_AUTO", kBandwidthAuto },
140  { "BANDWIDTH_8_MHZ", kBandwidth8MHz },
141  { "BANDWIDTH_7_MHZ", kBandwidth7MHz },
142  { "BANDWIDTH_6_MHZ", kBandwidth6MHz },
143  { "BANDWIDTH_5_MHZ", kBandwidth5MHz },
144  { "BANDWIDTH_10_MHZ", kBandwidth10MHz },
145  { "BANDWIDTH_1_712_MHZ", kBandwidth1712kHz },
146  { nullptr, kBandwidthAuto },
147 };
148 
150 {
151  { "999", kBandwidthAuto },
152  { "8", kBandwidth8MHz },
153  { "7", kBandwidth7MHz },
154  { "6", kBandwidth6MHz },
155  { "5", kBandwidth5MHz },
156  { "10", kBandwidth10MHz },
157  { "1712", kBandwidth1712kHz },
158  { nullptr, kBandwidthAuto },
159 };
160 
162 {
163  { "a", kBandwidthAuto },
164  { "8", kBandwidth8MHz },
165  { "7", kBandwidth7MHz },
166  { "6", kBandwidth6MHz },
167  { "5", kBandwidth5MHz },
168  { "10", kBandwidth10MHz },
169  { "1712", kBandwidth1712kHz },
170  { nullptr, kBandwidthAuto },
171 };
172 
174 {
175  "8",
176  "7",
177  "6",
178  "a",
179  "5",
180  "10",
181  "1712",
182 };
183 
184 //
185 // === Forward Error Correction / Code Rate ===
186 //
187 
189 {
190  { "FEC_AUTO", kFECAuto },
191  { "FEC_1_2", kFEC_1_2 },
192  { "FEC_2_3", kFEC_2_3 },
193  { "FEC_3_4", kFEC_3_4 },
194  { "FEC_4_5", kFEC_4_5 },
195  { "FEC_5_6", kFEC_5_6 },
196  { "FEC_6_7", kFEC_6_7 },
197  { "FEC_7_8", kFEC_7_8 },
198  { "FEC_8_9", kFEC_8_9 },
199  { "FEC_NONE", kFECNone },
200  { "FEC_3_5", kFEC_3_5 },
201  { "FEC_9_10", kFEC_9_10 },
202  { nullptr, kFECAuto },
203 };
204 
206 {
207  { "999", kFECAuto },
208  { "12", kFEC_1_2 },
209  { "23", kFEC_2_3 },
210  { "34", kFEC_3_4 },
211  { "45", kFEC_4_5 },
212  { "56", kFEC_5_6 },
213  { "67", kFEC_6_7 },
214  { "78", kFEC_7_8 },
215  { "89", kFEC_8_9 },
216  { "0", kFECNone },
217  { "35", kFEC_3_5 },
218  { "910", kFEC_9_10 },
219  { nullptr, kFECAuto }
220 };
221 
223 {
224  { "auto", kFECAuto },
225  { "1/2", kFEC_1_2 },
226  { "2/3", kFEC_2_3 },
227  { "3/4", kFEC_3_4 },
228  { "4/5", kFEC_4_5 },
229  { "5/6", kFEC_5_6 },
230  { "6/7", kFEC_6_7 },
231  { "7/8", kFEC_7_8 },
232  { "8/9", kFEC_8_9 },
233  { "none", kFECNone },
234  { "3/5", kFEC_3_5 },
235  { "9/10", kFEC_9_10 },
236  { nullptr, kFECAuto }
237 };
238 
240 {
241  "none",
242  "1/2",
243  "2/3",
244  "3/4",
245  "4/5",
246  "5/6",
247  "6/7",
248  "7/8",
249  "8/9",
250  "auto",
251  "3/5",
252  "9/10",
253 };
254 
255 //
256 // === Modulation ===
257 //
258 
260 {
261  { "QAM_AUTO", kModulationQAMAuto },
262  { "QAM_16", kModulationQAM16 },
263  { "QAM_32", kModulationQAM32 },
264  { "QAM_64", kModulationQAM64 },
265  { "QAM_128", kModulationQAM128 },
266  { "QAM_256", kModulationQAM256 },
267  { "QPSK", kModulationQPSK },
268  { "8VSB", kModulation8VSB },
269  { "16VSB", kModulation16VSB },
270  { "8PSK", kModulation8PSK },
271  { "16APSK", kModulation16APSK },
272  { "32APSK", kModulation32APSK },
273  { "DQPSK", kModulationDQPSK },
274  { "16PSK", kModulationInvalid },
275  { "2VSB", kModulationInvalid },
276  { "4VSB", kModulationInvalid },
277  { "BPSK", kModulationInvalid },
278  { "analog", kModulationAnalog },
279  { nullptr, kModulationQAMAuto },
280 };
281 
283 {
284  { "999", kModulationQAMAuto },
285  { "16", kModulationQAM16 },
286  { "32", kModulationQAM32 },
287  { "64", kModulationQAM64 },
288  { "128", kModulationQAM128 },
289  { "256", kModulationQAM256 },
290  { "2", kModulationQPSK },
291  { "5", kModulation8PSK },
292  { "6", kModulation16APSK },
293  { "7", kModulation32APSK },
294  { "10", kModulation8VSB },
295  { "11", kModulation16VSB },
296  { nullptr, kModulationQAMAuto },
297 };
298 
300 {
301  { "auto", kModulationQAMAuto },
302  { "qam_16", kModulationQAM16 },
303  { "qam_32", kModulationQAM32 },
304  { "qam_64", kModulationQAM64 },
305  { "qam_128", kModulationQAM128 },
306  { "qam_256", kModulationQAM256 },
307  { "qpsk", kModulationQPSK },
308  { "8vsb", kModulation8VSB },
309  { "16vsb", kModulation16VSB },
310  { "8psk", kModulation8PSK },
311  { "16apsk", kModulation16APSK },
312  { "32apsk", kModulation32APSK },
313  { "dqpsk", kModulationDQPSK },
314  // alternates
315  { "a", kModulationQAMAuto },
316  { "qam_auto", kModulationQAMAuto },
317  { "qam-16", kModulationQAM16 },
318  { "qam-32", kModulationQAM32 },
319  { "qam-64", kModulationQAM64 },
320  { "qam-128", kModulationQAM128 },
321  { "qam-256", kModulationQAM256 },
322  // qpsk, no alternative
323  { "8-vsb", kModulation8VSB },
324  { "16-vsb", kModulation16VSB },
325  // bpsk, no alternative
326  { "16-apsk", kModulation16APSK },
327  { "32-apsk", kModulation32APSK },
328  { "8-psk", kModulation8PSK },
329  // removed modulations and alternatives
330  { "bpsk", kModulationInvalid },
331  { "2vsb", kModulationInvalid },
332  { "2-vsb", kModulationInvalid },
333  { "4vsb", kModulationInvalid },
334  { "4-vsb", kModulationInvalid },
335  { "16psk", kModulationInvalid },
336  { "16-psk", kModulationInvalid },
337  { nullptr, kModulationQAMAuto },
338 };
339 
341 {
342  "qpsk",
343  "qam_16",
344  "qam_32",
345  "qam_64",
346  "qam_128",
347  "qam_256",
348  "auto",
349  "8vsb",
350  "16vsb",
351  "8psk",
352  "16apsk",
353  "32apsk",
354  "dqpsk"
355 };
356 
357 //
358 // === Transmission Mode ===
359 //
360 // Database update needed for the 16k and 32k modes because
361 // dtvmultiplex:transmission_mode is now only one character.
362 //
364 {
365  { "TRANSMISSION_MODE_1K", kTransmissionMode1K },
366  { "TRANSMISSION_MODE_2K", kTransmissionMode2K },
367  { "TRANSMISSION_MODE_4K", kTransmissionMode4K },
368  { "TRANSMISSION_MODE_8K", kTransmissionMode8K },
369  { "TRANSMISSION_MODE_16K", kTransmissionMode16K },
370  { "TRANSMISSION_MODE_32K", kTransmissionMode32K },
371  { "TRANSMISSION_MODE_AUTO", kTransmissionModeAuto },
372  { nullptr, kTransmissionModeAuto },
373 };
374 
376 {
377  { "999", kTransmissionModeAuto },
378  { "1", kTransmissionMode1K },
379  { "2", kTransmissionMode2K },
380  { "4", kTransmissionMode4K },
381  { "8", kTransmissionMode8K },
382  { "16", kTransmissionMode16K },
383  { "32", kTransmissionMode32K },
384  { nullptr, kTransmissionModeAuto },
385 };
386 
388 {
389  { "a", kTransmissionModeAuto },
390  { "1", kTransmissionMode1K },
391  { "2", kTransmissionMode2K },
392  { "4", kTransmissionMode4K },
393  { "8", kTransmissionMode8K },
394  { "16", kTransmissionMode16K },
395  { "32", kTransmissionMode32K },
396  { nullptr, kTransmissionModeAuto },
397 };
398 
400 {
401  "2",
402  "8",
403  "a",
404  "4",
405  "1",
406  "16",
407  "32"
408 };
409 
410 //
411 // === Guard Interval ===
412 //
413 
415 {
416  { "GUARD_INTERVAL_1_32", kGuardInterval_1_32 },
417  { "GUARD_INTERVAL_1_16", kGuardInterval_1_16 },
418  { "GUARD_INTERVAL_1_8", kGuardInterval_1_8 },
419  { "GUARD_INTERVAL_1_4", kGuardInterval_1_4 },
420  { "GUARD_INTERVAL_AUTO", kGuardIntervalAuto },
421  { "GUARD_INTERVAL_1_128", kGuardInterval_1_128 },
422  { "GUARD_INTERVAL_19_128", kGuardInterval_19_128 },
423  { "GUARD_INTERVAL_19_256", kGuardInterval_19_256 },
424  { nullptr, kGuardIntervalAuto },
425 };
426 
428 {
429  { "999", kGuardIntervalAuto },
430  { "32", kGuardInterval_1_32 },
431  { "16", kGuardInterval_1_16 },
432  { "8", kGuardInterval_1_8 },
433  { "4", kGuardInterval_1_4 },
434  { "128", kGuardInterval_1_128 },
435  { "19128", kGuardInterval_19_128 },
436  { "19256", kGuardInterval_19_256 },
437  { nullptr, kGuardIntervalAuto },
438 };
439 
441 {
442  { "auto", kGuardIntervalAuto },
443  { "1/32", kGuardInterval_1_32 },
444  { "1/16", kGuardInterval_1_16 },
445  { "1/8", kGuardInterval_1_8 },
446  { "1/4", kGuardInterval_1_4 },
447  { "1/128", kGuardInterval_1_128 },
448  { "19/128", kGuardInterval_19_128 },
449  { "19/256", kGuardInterval_19_256 },
450  { nullptr, kGuardIntervalAuto },
451 };
452 
454 {
455  "1/32",
456  "1/16",
457  "1/8",
458  "1/4",
459  "auto",
460  "1/128",
461  "19/128",
462  "19/256",
463 };
464 
465 //
466 // === Hierarchy ===
467 //
468 
470 {
471  { "HIERARCHY_NONE", kHierarchyNone },
472  { "HIERARCHY_1", kHierarchy1 },
473  { "HIERARCHY_2", kHierarchy2 },
474  { "HIERARCHY_4", kHierarchy4 },
475  { "HIERARCHY_AUTO", kHierarchyAuto },
476  { nullptr, kHierarchyAuto },
477 };
478 
480 {
481  { "999", kHierarchyAuto },
482  { "0", kHierarchyNone },
483  { "1", kHierarchy1 },
484  { "2", kHierarchy2 },
485  { "4", kHierarchy4 },
486  { nullptr, kHierarchyAuto },
487 };
488 
490 {
491  { "n", kHierarchyNone },
492  { "1", kHierarchy1 },
493  { "2", kHierarchy2 },
494  { "4", kHierarchy4 },
495  { "a", kHierarchyAuto },
496  { nullptr, kHierarchyAuto },
497 };
498 
500 {
501  "n",
502  "1",
503  "2",
504  "4",
505  "a"
506 };
507 
508 //
509 // === Polarity ===
510 //
511 
513 {
514  { "v", kPolarityVertical },
515  { "h", kPolarityHorizontal },
516  { "r", kPolarityRight },
517  { "l", kPolarityLeft },
518  { nullptr, kPolarityVertical },
519 };
520 
522 {
523  "v",
524  "h",
525  "r",
526  "l"
527 };
528 
529 //
530 // === Modulation System ===
531 //
532 
534 {
535  { "SYS_UNDEFINED", kModulationSystem_UNDEFINED },
536  { "SYS_DVBC_ANNEX_A", kModulationSystem_DVBC_ANNEX_A },
537  { "SYS_DVBC_ANNEX_B", kModulationSystem_DVBC_ANNEX_B },
538  { "SYS_DVBT", kModulationSystem_DVBT },
539  { "SYS_DVBT2", kModulationSystem_DVBT2 },
540  { "SYS_DSS", kModulationSystem_DSS },
541  { "SYS_DVBS", kModulationSystem_DVBS },
542  { "SYS_DVBS2", kModulationSystem_DVBS2 },
543  { "SYS_DVBH", kModulationSystem_DVBH },
544  { "SYS_ISDBT", kModulationSystem_ISDBT },
545  { "SYS_ISDBS", kModulationSystem_ISDBS },
546  { "SYS_ISDBC", kModulationSystem_ISDBC },
547  { "SYS_ATSC", kModulationSystem_ATSC },
548  { "SYS_ATSCMH", kModulationSystem_ATSCMH },
549  { "SYS_DTMB", kModulationSystem_DTMB },
550  { "SYS_CMMB", kModulationSystem_CMMB },
551  { "SYS_DAB", kModulationSystem_DAB },
552  { "SYS_TURBO", kModulationSystem_TURBO },
553  { "SYS_DVBC_ANNEX_C", kModulationSystem_DVBC_ANNEX_C },
554  { nullptr, kModulationSystem_UNDEFINED },
555 };
556 
558 {
559  { "0", kModulationSystem_DVBS },
560  { "1", kModulationSystem_DVBS2 },
561  { nullptr, kModulationSystem_UNDEFINED },
562 };
563 
565 {
566  { "UNDEFINED", kModulationSystem_UNDEFINED },
567  { "DVB-C/A", kModulationSystem_DVBC_ANNEX_A },
568  { "DVB-C/B", kModulationSystem_DVBC_ANNEX_B },
569  { "DVB-T", kModulationSystem_DVBT },
570  { "DSS", kModulationSystem_DSS },
571  { "DVB-S", kModulationSystem_DVBS },
572  { "DVB-S2", kModulationSystem_DVBS2 },
573  { "DVBH", kModulationSystem_DVBH },
574  { "ISDBT", kModulationSystem_ISDBT },
575  { "ISDBS", kModulationSystem_ISDBS },
576  { "ISDBC", kModulationSystem_ISDBC },
577  { "ATSC", kModulationSystem_ATSC },
578  { "ATSCMH", kModulationSystem_ATSCMH },
579  { "DTMB", kModulationSystem_DTMB },
580  { "CMMB", kModulationSystem_CMMB },
581  { "DAB", kModulationSystem_DAB },
582  { "DVB-T2", kModulationSystem_DVBT2 },
583  { "TURBO", kModulationSystem_TURBO },
584  { "DVB-C/C", kModulationSystem_DVBC_ANNEX_C },
585  { nullptr, kModulationSystem_UNDEFINED },
586 };
587 
589 {
590  "UNDEFINED",
591  "DVB-C/A",
592  "DVB-C/B",
593  "DVB-T",
594  "DSS",
595  "DVB-S",
596  "DVB-S2",
597  "DVBH",
598  "ISDBT",
599  "ISDBS",
600  "ISDBC",
601  "ATSC",
602  "ATSCMH",
603  "DTMB",
604  "CMMB",
605  "DAB",
606  "DVB-T2",
607  "TURBO",
608  "DVB-C/C",
609 };
610 
611 //
612 // === Rolloff ===
613 //
614 
616 {
617  { "ROLLOFF_35", kRollOff_35 },
618  { "ROLLOFF_20", kRollOff_20 },
619  { "ROLLOFF_25", kRollOff_25 },
620  { "ROLLOFF_AUTO", kRollOff_Auto },
621  { nullptr, kRollOff_35 },
622 };
623 
625 {
626  { "35", kRollOff_35 },
627  { "20", kRollOff_20 },
628  { "25", kRollOff_25 },
629  { "0", kRollOff_Auto },
630  { nullptr, kRollOff_35 },
631 };
632 
634 {
635  { "0.35", kRollOff_35 },
636  { "0.20", kRollOff_20 },
637  { "0.25", kRollOff_25 },
638  { "auto", kRollOff_Auto },
639  { nullptr, kRollOff_35 },
640 };
641 
643 {
644  "0.35",
645  "0.20",
646  "0.25",
647  "auto",
648 };
static const DTVParamHelperStruct kConfTable[]
static QMap< int, QString > dtv_tt_canonical_str
static const DTVParamHelperStruct kConfTable[]
static const int kTunerTypeDVBT
static const uint kDBStrCnt
static const char * s_dbStr[kDBStrCnt]
static const DTVParamHelperStruct kParseTable[]
static const DTVParamHelperStruct kConfTable[]
static const int kTunerTypeATSC
static const uint kDBStrCnt
static const int kTunerTypeUnknown
static const char * s_dbStr[kDBStrCnt]
static const uint kDBStrCnt
static const int kTunerTypeOCUR
static const uint kDBStrCnt
static QString toString(const char *strings[], int index, uint strings_size)
static const DTVParamHelperStruct kVdrTable[]
static const DTVParamHelperStruct kParseTable[]
static QMutex dtv_tt_canonical_str_lock
static const DTVParamHelperStruct kVdrTable[]
static const int kTunerTypeDVBS1
static const DTVParamHelperStruct kVdrTable[]
static const DTVParamHelperStruct kVdrTable[]
static const DTVParamHelperStruct kVdrTable[]
static const DTVParamHelperStruct kParseTable[]
static const DTVParamHelperStruct kConfTable[]
static const DTVParamHelperStruct kConfTable[]
static const uint kDBStrCnt
static const DTVParamHelperStruct kVdrTable[]
static const int kTunerTypeDVBS2
static const int kTunerTypeDVBT2
static const int kTunerTypeDVBC
static const DTVParamHelperStruct kParseTable[]
static const char * s_dbStr[kDBStrCnt]
static const DTVParamHelperStruct kVdrTable[]
static const DTVParamHelperStruct kParseTable[]
static const uint kDBStrCnt
static const DTVParamHelperStruct kParseTable[]
static const char * s_dbStr[kDBStrCnt]
static const DTVParamHelperStruct kConfTable[]
static const DTVParamHelperStruct kParseTable[]
static const uint kDBStrCnt
unsigned int uint
Definition: compat.h:140
static const DTVParamHelperStruct kParseTable[]
static const uint kDBStrCnt
static const char * s_dbStr[kDBStrCnt]
static const DTVParamHelperStruct kParseTable[]
static const DTVParamHelperStruct kVdrTable[]
static const char * s_dbStr[kDBStrCnt]
static bool ParseParam(const QString &symbol, int &value, const DTVParamHelperStruct *table)
static const int kTunerTypeIPTV
static const int kTunerTypeASI
static const DTVParamHelperStruct kParseTable[]
static const DTVParamHelperStruct kConfTable[]
static const DTVParamHelperStruct kVdrTable[]
static const char * s_dbStr[kDBStrCnt]
static const uint kDBStrCnt
static const DTVParamHelperStruct kConfTable[]
static const char * s_dbStr[kDBStrCnt]
static void initStr(void)
static const DTVParamHelperStruct kConfTable[]
static const DTVParamHelperStruct kParseTable[]
static const char * s_dbStr[kDBStrCnt]
static const char * s_dbStr[kDBStrCnt]
QString toString() const
static const uint kDBStrCnt
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23