25 #include <boost/shared_ptr.hpp> 31 unsigned int senf::DVBSocketController::controllerNr(0);
35 : frontendHandle( frontendHandle_ ),
36 type( frontendHandle.protocol().getInfo().
type ),
41 event(
"senf::DVBSocketController::readEvent",
43 senf::scheduler::FdEvent::EV_PRIO, false )
77 dir.
node().
add(
"section" + senf::str(sectionNr), wrap->dir);
85 dir.
node().
add(
"pes"+ senf::str(pesNr), wrap->dir);
91 struct dvb_frontend_parameters frontend;
94 if (input.find(
":") == std::string::npos)
96 if (mode.c_str()[0]==
'a')
105 if (mode.c_str()[0]==
'a') {
108 tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
109 frontend.u.qpsk.fec_inner);
112 tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
113 frontend.u.qam.fec_inner, frontend.u.qam.modulation);
116 tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
117 frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
118 frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
119 frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
128 tuneDVB_S_sync(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
129 frontend.u.qpsk.fec_inner);
132 tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
133 frontend.u.qam.fec_inner, frontend.u.qam.modulation);
136 tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
137 frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
138 frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
139 frontend.u.ofdm.guard_interval,
140 frontend.u.ofdm.hierarchy_information);
150 struct dvb_frontend_parameters frontend;
157 tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
158 frontend.u.qpsk.fec_inner);
161 tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
162 frontend.u.qam.fec_inner, frontend.u.qam.modulation);
165 tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
166 frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
167 frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
168 frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
176 fe_spectral_inversion_t inversion,
177 fe_bandwidth_t bandwidth,
178 fe_code_rate_t code_rate_HP,
179 fe_code_rate_t code_rate_LP,
180 fe_modulation_t constellation,
181 fe_transmit_mode_t transmission_mode,
182 fe_guard_interval_t guard_interval,
183 fe_hierarchy_t hierarchy_information
188 <<
getTypeString() <<
" for this operation you need a DVB-T Card!";
201 hierarchy_information);
205 fe_spectral_inversion_t inversion,
206 unsigned int symbole_rate,
207 fe_code_rate_t code_rate)
211 <<
getTypeString() <<
" for this operation you need a DVB-S Card!";
216 frontendHandle.
protocol().
tuneDVB_S(frequency, inversion, symbole_rate, code_rate);
220 fe_spectral_inversion_t inversion,
221 unsigned int symbol_rate,
222 fe_code_rate_t fec_inner,
223 fe_modulation_t modulation
228 <<
getTypeString() <<
" for this operation you need a DVB-C Card!";
234 frontendHandle.
protocol().
tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
239 struct dvb_frontend_parameters frontend;
240 dvb_frontend_event ev;
247 frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
250 ev =
tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
251 frontend.u.qam.fec_inner, frontend.u.qam.modulation);
254 ev =
tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
255 frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
256 frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
257 frontend.u.ofdm.guard_interval,
258 frontend.u.ofdm.hierarchy_information);
267 fe_spectral_inversion_t inversion,
268 fe_bandwidth_t bandwidth,
269 fe_code_rate_t code_rate_HP,
270 fe_code_rate_t code_rate_LP,
271 fe_modulation_t constellation,
272 fe_transmit_mode_t transmission_mode,
273 fe_guard_interval_t guard_interval,
274 fe_hierarchy_t hierarchy_information
279 <<
getTypeString() <<
" for this operation you need a DVB-T Card!";
293 hierarchy_information);
303 fe_spectral_inversion_t inversion,
304 unsigned int symbole_rate, fe_code_rate_t code_rate)
308 <<
getTypeString() <<
" for this operation you need a DVB-S Card!";
314 frontendHandle.
protocol().
tuneDVB_S(frequency, inversion, symbole_rate, code_rate);
322 fe_spectral_inversion_t inversion,
323 unsigned int symbol_rate,
324 fe_code_rate_t fec_inner,
325 fe_modulation_t modulation
330 <<
getTypeString() <<
" for this operation you need a DVB-C Card!";
336 frontendHandle.
protocol().
tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
378 const char* cConf = conf.c_str();
379 std::stringstream info;
384 uint32_t ber, uncorrected_blocks;
393 for (
unsigned int i = 0; i < conf.size(); ++i) {
398 info <<
"signal " << signal;
401 info <<
"snr " << snr;
404 info <<
"ber " << ber;
407 info <<
"unc " << uncorrected_blocks;
422 if (status & FE_HAS_LOCK)
423 return s +=
"HAS LOCK";
424 if (status & FE_HAS_CARRIER)
426 if (status & FE_HAS_VITERBI)
428 if (status & FE_HAS_SYNC)
430 if (status & FE_HAS_SIGNAL)
432 if (status & FE_TIMEDOUT)
434 if (status & FE_REINIT)
445 prefix_ void senf::DVBSocketController::readEvent(
int event)
451 prefix_ void senf::DVBSocketController::initConsole()
453 namespace fty = console::factory;
454 namespace kw = console::kw;
456 dir.
doc(
"DVB Controller " + senf::str(controllerNr));
460 .doc(
"Shows actual type of card DVB-{T, S, C}") );
463 .doc(
"Returns a string which shows actual tuning status.\n" 464 "'S' prints signal strength (in hex)\n" 465 "'s' prints singal to noise ration (in hex)\n" 466 "'b' prints bit error rate (in hex)\n" 467 "'u' prints uncorrected blocks (in hex)\n" 468 "'f' prints readable overal status e.g. 'Has Lock'\n\n" 469 "These characters can be used to form the output. Be aware, some\n" 470 "features may not be supported be your current driver implementation\n" 471 "and could end in throwing an exception!")
472 .arg(
"conf",
"Ssbuf", kw::default_value =
"Ssbuf") );
475 .doc(
"tunes to channel listet in the configfile.")
476 .arg(
"channel",
"channel to tune")
477 .arg(
"mode",
"mode 'sync' or 'async'", kw::default_value =
"async") );
dvb_frontend_event tuneDVB_C_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbol_rate, fe_code_rate_t fec_inner, fe_modulation_t modulation)
Tunes a DVB-C device.
Protocol & protocol()
Access the protocol interface.
void tuneTo(std::string const &channel)
Tunes a DVB device to a channel.
#define SENF_THROW_SYSTEM_EXCEPTION(desc)
uint32_t bitErrorRate() const
Returns the current bit error rate for the signal.
void tuneDVB_C(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbol_rate, fe_code_rate_t fec_inner, fe_modulation_t modulation)
Tunes a DVB-C device.
boost::function< void(const struct dvb_frontend_event &)> Callback
Callback which is called when an asynchronous tuning succeeds.
dvb_frontend_event tuneTo_sync(std::string const &channel)
Tunes a DVB device given by the type of the DVBFrontendHandle.
dvb_frontend_event tuneDVB_T_sync(unsigned int frequency, fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth, fe_code_rate_t code_rate_HP, fe_code_rate_t code_rate_LP, fe_modulation_t constellation, fe_transmit_mode_t transmission_mode, fe_guard_interval_t guard_interval, fe_hierarchy_t hierarsourcechy_information)
Tunes a DVB-T device.
Helperclass for configuration and controlling DVB devices.
console::ScopedDirectory dir
unspecified_keyword_type parser
fe_type_t getType()
Returns the type of the card. The type is defined in frontend.h.
dvb_frontend_event tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate)
Tunes a DVB-S device.
DVBDemuxPESHandle createDVBDemuxPESHandle(int adapternumber=0, int demuxnumber=0, bool addToConsole=false)
std::string status2String(fe_status_t status)
Returns a human readable status information.
static SENF_CLOCKSERVICE_CONSTEXPR clock_type seconds(int64_type const &v)
std::string getTypeString()
Returns the type of the card.
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
DVBSocketController(DVBFrontendHandle frontendHandle_=DVBFrontendHandle(0, 0), const Callback &cb=NULL)
void tuneDVB_T(unsigned int frequency, fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth, fe_code_rate_t code_rate_HP, fe_code_rate_t code_rate_LP, fe_modulation_t constellation, fe_transmit_mode_t transmission_mode, fe_guard_interval_t guard_interval, fe_hierarchy_t hierarchy_information)
Tunes a DVB-T device.
DirectoryNode & doc(std::string const &doc)
unsigned int signalToNoiseRatio() const
Returns the signal to noise ratio.
DVBDemuxSectionHandle createDVBDemuxSectionHandle(int adapternumber=0, int demuxnumber=0, bool addToConsole=false)
bool waitOOBReadable(senf::ClockService::clock_type timeout=senf::ClockService::clock_type(-1)) const
Wait, until read of prioritized data on the handle does not block (ignoring blocking state) ...
StatsDataCollectorKernel signal
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)
unsigned int bitErrorRate() const
Returns the bit error rate.
dvb_frontend_event getEvent() const
fe_status_t status() const
This ioctl call returns status information about the front-end.
void tuneDVB_T(unsigned int frequency, fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth, fe_code_rate_t code_rate_HP, fe_code_rate_t code_rate_LP, fe_modulation_t constellation, fe_transmit_mode_t transmission_mode, fe_guard_interval_t guard_interval, fe_hierarchy_t hierarchy_information) const
Tunes a DVB-T device.
Helperclass for configuration and controlling DVB protocol handles.
DirectoryNode & node() const
void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate)
Tunes a DVB-S device.
dvb_frontend_parameters getFrontendParam(std::string configLine)
unsigned int signalStrength() const
Returns the signal strength.
void addToConsole(DVBDemuxSectionHandle sh)
Adds an DVBDemuxSectionHandle to the console.
void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate) const
Tunes a DVB-S device.
void tuneDVB_C(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbol_rate, fe_code_rate_t fec_inner, fe_modulation_t modulation) const
Tunes a DVB-C device.
std::string getConfigLine(std::string channel)
std::string getTuneInfo(const std::string &conf="Ssbuf")
Returns a string which shows actual tuning status.
void setNonBlock(bool on=true) const
int16_t signalNoiseRatio() const
Returns current signal-to-noise ratio.
uint32_t uncorrectedBlocks() const
Returns the number of uncorrected blocks.
int16_t signalStrength() const
Returns current signal strength.
void tuneToCMD(std::string const &input, std::string const &mode="async")
Tunes a DVB device given by the type of the DVBFrontendHandle.
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)