Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbtuneparamscommon.cpp @ 23bc8293

History | View | Annotate | Download (1.65 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

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

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

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

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

    
45
  StringIntMap::const_iterator i = transTable.find(t);
46
  if (i == transTable.end()) {
47
    std::cerr << "Fatal Error: no translation for \"" << t << "\" in " << __FILE__ << ":" << __LINE__ << "\n";
48
    exit(1);
49
  }
50
  return i->second;
51
}