Revision 23bc8293 src/dvbttuneparams.cpp

View differences:

src/dvbttuneparams.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
#include <map>
24 24
#include <iostream>
25 25
#include <cstdlib>
26 26
#include "tune.h"
......
45 45
{
46 46
}
47 47

  
48
// transTable is an auxillary mapping from
49
// string keywords (eg FEC_1_2) to numbers
50
// FEC_1_2. Used in parsing. See translate() and
51
// DVBTTuneParams::createFromTZAP() 
52

  
53
typedef std::map<std::string, int> StringIntMap;
54
static StringIntMap transTable;
55
static bool transTableSetup = false;
56

  
57
static int translate(const std::string &t) 
58
{
59
  if (!transTableSetup) {
60
    transTable["INVERSION_AUTO"] = INVERSION_AUTO;
61
    transTable["INVERSION_OFF"] = INVERSION_OFF;
62
    transTable["INVERSION_ON"] = INVERSION_ON;
63
    transTable["FEC_NONE"] = FEC_NONE;
64
    transTable["FEC_1_2"] = FEC_1_2;
65
    transTable["FEC_2_3"] = FEC_2_3;
66
    transTable["FEC_3_4"] = FEC_3_4;
67
    transTable["QAM_16"] = QAM_16;
68
    transTable["QAM_64"] = QAM_64;
69
    transTable["GUARD_INTERVAL_1_4"] = GUARD_INTERVAL_1_4;
70
    transTable["GUARD_INTERVAL_1_8"] = GUARD_INTERVAL_1_8;
71
    transTable["GUARD_INTERVAL_1_16"] = GUARD_INTERVAL_1_16;
72
    transTable["GUARD_INTERVAL_1_32"] = GUARD_INTERVAL_1_32;
73
    transTable["HIERARCHY_NONE"] = HIERARCHY_NONE;
74
    transTable["BANDWIDTH_7_MHZ"] = BANDWIDTH_7_MHZ;
75
    transTable["BANDWIDTH_8_MHZ"] = BANDWIDTH_8_MHZ;
76
    transTable["TRANSMISSION_MODE_2K"] = TRANSMISSION_MODE_2K;
77
    transTable["TRANSMISSION_MODE_8K"] = TRANSMISSION_MODE_8K;
78
    transTableSetup = true;
79
  }
80

  
81
  StringIntMap::const_iterator i = transTable.find(t);
82
  if (i == transTable.end()) {
83
    std::cerr << "Fatal Error: no translation for \"" << t << "\" in " << __FILE__ << ":" << __LINE__ << "\n";
84
    exit(1);
85
  }
86
  return i->second;
87
}
88 48

  
89 49
DVBTTuneParams *DVBTTuneParams::createFromTZAP(const std::string &line)
90 50
{
......
100 60

  
101 61
  DVBTTuneParams *p = new DVBTTuneParams(newName, vpid, apid);
102 62
  p->freq = toUnsignedLong(v[1]);
103
  p->inv = translate(v[2]);
104
  p->bandw = translate(v[3]);
105
  p->fec1 = translate(v[4]);
106
  p->fec2 = translate(v[5]);
107
  p->qam = translate(v[6]);
108
  p->mode = translate(v[7]);
109
  p->guard = translate(v[8]);
110
  p->hier = translate(v[9]);
63
  p->inv = translateTuneParam(v[2]);
64
  p->bandw = translateTuneParam(v[3]);
65
  p->fec1 = translateTuneParam(v[4]);
66
  p->fec2 = translateTuneParam(v[5]);
67
  p->qam = translateTuneParam(v[6]);
68
  p->mode = translateTuneParam(v[7]);
69
  p->guard = translateTuneParam(v[8]);
70
  p->hier = translateTuneParam(v[9]);
111 71
  return p;
112 72
}
113 73

  

Also available in: Unified diff