Revision 23bc8293 src/dvbctuneparams.cpp

View differences:

src/dvbctuneparams.cpp
18 18

  
19 19
#include "config.h"
20 20
#include "tuneparams.h"
21
#include "dvbtuneparamscommon.h"
21 22
#include "stringutil.h"
22 23

  
23 24
#include <map>
......
40 41
{
41 42
}
42 43

  
43
// transTable is an auxillary mapping from
44
// string keywords (eg FEC_1_2) to numbers
45
// FEC_1_2. Used in parsing. See translate() and
46
// DVBCTuneParams::createFromCZAP() 
47

  
48
typedef std::map<std::string, int> StringIntMap;
49
static StringIntMap transTable;
50
static bool transTableSetup = false;
51

  
52
static int translate(const std::string &t) 
53
{
54
  if (!transTableSetup) {
55
    transTable["INVERSION_AUTO"] = INVERSION_AUTO;
56
    transTable["INVERSION_OFF"] = INVERSION_OFF;
57
    transTable["FEC_NONE"] = FEC_NONE;
58
    transTable["FEC_1_2"] = FEC_1_2;
59
    transTable["FEC_2_3"] = FEC_2_3;
60
    transTable["FEC_3_4"] = FEC_3_4;
61
    transTable["QAM_16"] = QAM_16;
62
    transTable["QAM_32"] = QAM_32;
63
    transTable["QAM_64"] = QAM_64;
64
    transTable["GUARD_INTERVAL_1_32"] = GUARD_INTERVAL_1_32;
65
    transTable["HIERARCHY_NONE"] = HIERARCHY_NONE;
66
    transTable["BANDWIDTH_8_MHZ"] = BANDWIDTH_8_MHZ;
67
    transTable["TRANSMISSION_MODE_2K"] = TRANSMISSION_MODE_2K;
68
  }
69

  
70
  StringIntMap::const_iterator i = transTable.find(t);
71
  if (i == transTable.end()) {
72
    std::cerr << "Fatal Error: no translation for \"" << t << "\" in " << __FILE__ << ":" << __LINE__ << "\n";
73
    exit(1);
74
  }
75
  return i->second;
76
}
77

  
78 44
DVBCTuneParams *DVBCTuneParams::createFromCZAP(const std::string &line)
79 45
{
80 46
  // It is assumed that the line is a valid CZAP conf line
......
89 55

  
90 56
  DVBCTuneParams *p = new DVBCTuneParams(newName, vpid, apid);
91 57
  p->freq = toUnsignedLong(v[1]);
92
  p->inv = translate(v[2]);
58
  p->inv = translateTuneParam(v[2]);
93 59
  p->sr = toUnsignedLong(v[3]);
94
  p->fec = translate(v[4]);
95
  p->qam = translate(v[5]);
60
  p->fec = translateTuneParam(v[4]);
61
  p->qam = translateTuneParam(v[5]);
96 62
  return p;
97 63
}
98 64

  

Also available in: Unified diff