Statistics
| Branch: | Tag: | Revision:

dvbd / src / dvbtuneparamscommon.cpp @ bcb74979

History | View | Annotate | Download (1.67 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["QAM_16"] = QAM_16;
32
    transTable["QAM_32"] = QAM_32;
33
    transTable["QAM_64"] = QAM_64;
34
    transTable["GUARD_INTERVAL_1_4"] = GUARD_INTERVAL_1_4;
35
    transTable["GUARD_INTERVAL_1_8"] = GUARD_INTERVAL_1_8;
36
    transTable["GUARD_INTERVAL_1_16"] = GUARD_INTERVAL_1_16;
37
    transTable["GUARD_INTERVAL_1_32"] = GUARD_INTERVAL_1_32;
38
    transTable["HIERARCHY_NONE"] = HIERARCHY_NONE;
39
    transTable["BANDWIDTH_7_MHZ"] = BANDWIDTH_7_MHZ;
40
    transTable["BANDWIDTH_8_MHZ"] = BANDWIDTH_8_MHZ;
41
    transTable["TRANSMISSION_MODE_2K"] = TRANSMISSION_MODE_2K;
42
    transTable["TRANSMISSION_MODE_8K"] = TRANSMISSION_MODE_8K;
43
    transTableSetup = true;
44
  }
45

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