17 #include <boost/assign/std/map.hpp> 24 senf::DVBConfigParser::DVBParams
const senf::DVBConfigParser::params;
26 prefix_ senf::DVBConfigParser::DVBParams::DVBParams()
29 boost::assign::insert(inversion)
30 (
"INVERSION_OFF", INVERSION_OFF )
31 (
"INVERSION_ON", INVERSION_ON )
32 (
"INVERSION_AUTO", INVERSION_AUTO );
33 boost::assign::insert(bandwidth)
34 (
"BANDWIDTH_6_MHZ", BANDWIDTH_6_MHZ)
35 (
"BANDWIDTH_7_MHZ", BANDWIDTH_7_MHZ)
36 (
"BANDWIDTH_8_MHZ", BANDWIDTH_8_MHZ);
37 boost::assign::insert(code_rate)
46 (
"FEC_AUTO", FEC_AUTO)
47 (
"FEC_NONE", FEC_NONE);
48 boost::assign::insert(guard_interval)
49 (
"GUARD_INTERVAL_1_16", GUARD_INTERVAL_1_16)
50 (
"GUARD_INTERVAL_1_32", GUARD_INTERVAL_1_32)
51 (
"GUARD_INTERVAL_1_4", GUARD_INTERVAL_1_4)
52 (
"GUARD_INTERVAL_1_8", GUARD_INTERVAL_1_8);
53 boost::assign::insert(hierarchy)
54 (
"HIERARCHY_1", HIERARCHY_1)
55 (
"HIERARCHY_2", HIERARCHY_2)
56 (
"HIERARCHY_4", HIERARCHY_4)
57 (
"HIERARCHY_NONE", HIERARCHY_NONE);
58 boost::assign::insert(modulation)
65 boost::assign::insert(transmit_mode)
66 (
"TRANSMISSION_MODE_2K", TRANSMISSION_MODE_2K)
67 (
"TRANSMISSION_MODE_8K", TRANSMISSION_MODE_8K);
74 initConfigFile(configFilePath_);
82 prefix_ void senf::DVBConfigParser::initConfigFile(std::string configFilePath_)
84 if (configFilePath_.size() == 0) {
85 if ( !(::getenv (
"HOME")) )
87 std::string configPath (::getenv (
"HOME"));
90 configPath +=
"/.szap/channels.conf";
93 configPath +=
"/.czap/channels.conf";
96 configPath +=
"/.tzap/channels.conf";
101 configFilePath_ = configPath;
103 configFilePath = configFilePath_;
104 configFile.open( configFilePath.c_str(), std::ios_base::in);
105 if (configFile.bad())
112 std::string configLine;
114 transform(channel.begin(), channel.end(), channel.begin(), ::toupper);
116 configFile.open( configFilePath.c_str(), std::ios_base::in);
117 if (configFile.bad())
120 while (configFile.good()) {
121 getline( configFile, configLine );
123 transform(configLine.begin(), configLine.end(), configLine.begin(), ::toupper);
124 pos = configLine.find(channel);
126 if (pos != std::string::npos && pos == 0) {
138 struct dvb_frontend_parameters frontend;
139 transform(configLine.begin(), configLine.end(), configLine.begin(), ::toupper);
140 boost::char_separator<char> sep(
":");
141 tokenizer tokens(configLine, sep);
144 frontend = getFrontendParamDVB_S(tokens);
147 frontend = getFrontendParamDVB_C(tokens);
150 frontend = getFrontendParamDVB_T(tokens);
158 prefix_ dvb_frontend_parameters
159 senf::DVBConfigParser::getFrontendParamDVB_T(
const tokenizer & tokens)
161 struct dvb_frontend_parameters frontend;
162 std::istringstream isst;
164 enum { p_Frequency=1, p_Inversion, p_Bandwidth, p_hp_code_rate, p_lp_code_rate, p_Mudualtion, p_Transmission, p_guard, p_hierarchy};
165 std::vector<std::string> words (tokens.begin(), tokens.end());
167 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
172 isst.str(words[p_Frequency]);
176 frontend.frequency = number;
178 if (params.inversion.find(words[p_Inversion]) == params.inversion.end())
180 frontend.inversion = params.inversion.find(words[p_Inversion])->second;
182 if (params.bandwidth.find(words[p_Bandwidth]) == params.bandwidth.end())
184 frontend.u.ofdm.bandwidth = params.bandwidth.find(words[p_Bandwidth])->second;
186 if (params.code_rate.find(words[p_hp_code_rate]) == params.code_rate.end())
188 frontend.u.ofdm.code_rate_HP = params.code_rate.find(words[p_hp_code_rate])->second;
190 if (params.code_rate.find(words[p_lp_code_rate]) == params.code_rate.end())
192 frontend.u.ofdm.code_rate_LP = params.code_rate.find(words[p_lp_code_rate])->second;
194 if (params.modulation.find(words[p_Mudualtion]) == params.modulation.end())
196 frontend.u.ofdm.constellation = params.modulation.find(words[p_Mudualtion])->second;
198 if (params.transmit_mode.find(words[p_Transmission]) == params.transmit_mode.end())
200 frontend.u.ofdm.transmission_mode = params.transmit_mode.find(words[p_Transmission])->second;
202 if (params.guard_interval.find(words[p_guard]) == params.guard_interval.end())
204 frontend.u.ofdm.guard_interval = params.guard_interval.find(words[p_guard])->second;
206 if (params.hierarchy.find(words[p_hierarchy]) == params.hierarchy.end())
208 frontend.u.ofdm.hierarchy_information = params.hierarchy.find(words[p_hierarchy])->second;
213 prefix_ dvb_frontend_parameters
214 senf::DVBConfigParser::getFrontendParamDVB_S(
const tokenizer & tokens)
216 struct dvb_frontend_parameters frontend;
217 std::istringstream isst;
219 enum { p_Frequency=1, p_Inversion, p_Symbole, p_code_rate};
220 std::vector<std::string> words (tokens.begin(), tokens.end());
222 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
224 if (words.size() < 5)
227 isst.str(words[p_Frequency]);
231 frontend.frequency = number;
233 if (params.inversion.find(words[p_Inversion]) == params.inversion.end())
235 frontend.inversion = params.inversion.find(words[p_Inversion])->second;
237 isst.str(words[p_Symbole]);
241 frontend.u.qpsk.symbol_rate = number;
243 if (params.code_rate.find(words[p_code_rate]) == params.code_rate.end())
245 frontend.u.qpsk.fec_inner = params.code_rate.find(words[p_code_rate])->second;
250 prefix_ dvb_frontend_parameters
251 senf::DVBConfigParser::getFrontendParamDVB_C(
const tokenizer & tokens)
253 struct dvb_frontend_parameters frontend;
254 std::istringstream isst;
256 enum { p_Frequency=1, p_Inversion, p_Symbole, p_code_rate, p_modulation};
257 std::vector<std::string> words (++tokens.begin(), tokens.end());
259 ::memset(&frontend, 0,
sizeof(
struct dvb_frontend_parameters));
261 if (words.size() < 6)
264 isst.str(words[p_Frequency]);
268 frontend.frequency = number;
270 if (params.inversion.find(words[p_Inversion]) == params.inversion.end())
272 frontend.inversion = params.inversion.find(words[p_Inversion])->second;
274 isst.str(words[p_Symbole]);
278 frontend.u.qam.symbol_rate = number;
280 if (params.code_rate.find(words[p_code_rate]) == params.code_rate.end())
282 frontend.u.qam.fec_inner = params.code_rate.find(words[p_code_rate])->second;
284 if (params.modulation.find(words[p_modulation]) == params.modulation.end())
286 frontend.u.qam.modulation = params.modulation.find(words[p_modulation])->second;
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
DVBConfigParser(fe_type_t type_, const std::string &configFilePath="")
DVBDemuxHandles public header.
dvb_frontend_parameters getFrontendParam(std::string configLine)
std::string getConfigLine(std::string channel)