Revision 23bc8293

View differences:

src/Makefile.am
15 15
    signals.cpp configfile.cpp scheduler.cpp fakedemuxer.cpp faketuner.cpp	\
16 16
    faketunermanager.cpp recording.cpp utils.cpp stringrep.cpp			\
17 17
    transform.c tune.c ringbuffy.c remux.c ctools.c psfilter.cpp	        \
18
    dvbstuneparams.cpp dvbctuneparams.cpp
18
    dvbstuneparams.cpp dvbctuneparams.cpp dvbtuneparamscommon.cpp
19 19

  
20 20
dvbsched_SOURCES =						\
21 21
    unixclientsocket.cpp stringutil.cpp				\
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

  
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

  
src/dvbtuneparamscommon.cpp
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
}
src/dvbtuneparamscommon.h
1
#if !defined __DVBTUNEPARAMSCOMMON_H
2
#define __DVBTUNEPARAMSCOMMON_H
3

  
4
#include <string>
5

  
6
int translateTuneParam(const std::string &t);
7

  
8
#endif // __DVBTUNEPARAMSCOMMON_H

Also available in: Unified diff