Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbtuneparamscommon.cpp @ c1a51f56

History | View | Annotate | Download (1.96 KB)

1
#include "config.h"
2
#include "tuneparams.h"
3

    
4
#include "dvbtuneparamscommon.h"
5
#include "tune.h"
6

    
7
#include <map>
8
#include <iostream>
9
#include <stdlib.h>
10

    
11
// transTable is an auxillary mapping from
12
// string keywords (eg FEC_1_2) to numbers
13
// FEC_1_2. Used in parsing. See translate() and
14
// DVBTTuneParams::createFromTZAP() 
15

    
16
typedef std::map<std::string, int> StringIntMap;
17

    
18
static StringIntMap transTable;
19
static bool transTableSetup = false;
20

    
21
int translateTuneParam(const std::string &t) 
22
{
23
  if (!transTableSetup) {
24
    transTable["INVERSION_AUTO"] = INVERSION_AUTO;
25
    transTable["INVERSION_OFF"] = INVERSION_OFF;
26
    transTable["INVERSION_ON"] = INVERSION_ON;
27
    transTable["FEC_NONE"] = FEC_NONE;
28
    transTable["FEC_1_2"] = FEC_1_2;
29
    transTable["FEC_2_3"] = FEC_2_3;
30
    transTable["FEC_3_4"] = FEC_3_4;
31
    transTable["FEC_5_6"] = FEC_5_6;
32
    transTable["FEC_AUTO"] = FEC_AUTO;
33
    transTable["QAM_16"] = QAM_16;
34
    transTable["QAM_32"] = QAM_32;
35
    transTable["QAM_64"] = QAM_64;
36
    transTable["QAM_AUTO"] = QAM_AUTO;
37
    transTable["GUARD_INTERVAL_1_4"] = GUARD_INTERVAL_1_4;
38
    transTable["GUARD_INTERVAL_1_8"] = GUARD_INTERVAL_1_8;
39
    transTable["GUARD_INTERVAL_1_16"] = GUARD_INTERVAL_1_16;
40
    transTable["GUARD_INTERVAL_1_32"] = GUARD_INTERVAL_1_32;
41
    transTable["GUARD_INTERVAL_AUTO"] = GUARD_INTERVAL_AUTO;
42
    transTable["HIERARCHY_NONE"] = HIERARCHY_NONE;
43
    transTable["HIERARCHY_AUTO"] = HIERARCHY_AUTO;
44
    transTable["BANDWIDTH_7_MHZ"] = BANDWIDTH_7_MHZ;
45
    transTable["BANDWIDTH_8_MHZ"] = BANDWIDTH_8_MHZ;
46
    transTable["TRANSMISSION_MODE_2K"] = TRANSMISSION_MODE_2K;
47
    transTable["TRANSMISSION_MODE_8K"] = TRANSMISSION_MODE_8K;
48
    transTable["TRANSMISSION_MODE_AUTO"] = TRANSMISSION_MODE_AUTO;
49
    transTableSetup = true;
50
  }
51

    
52
  StringIntMap::const_iterator i = transTable.find(t);
53
  if (i == transTable.end()) {
54
    std::cerr << "Fatal Error: no translation for \"" << t << "\" in " << __FILE__ << ":" << __LINE__ << "\n";
55
    exit(1);
56
  }
57
  return i->second;
58
}