1 #ifndef DVBSOCKETCONTROLLER_HH_
2 #define DVBSOCKETCONTROLLER_HH_
4 #include "DVBFrontendHandle.hh"
5 #include "DVBDemuxHandles.hh"
8 #include <linux/dvb/frontend.h>
9 #include "senf/Scheduler/Scheduler.hh"
10 #include "DVBConfigParser.hh"
11 #include "senf/Console.hh"
13 #define MPE_TABLEID 62
16 std::string status2String(fe_status_t status);
17 class DVBSocketController : boost::noncopyable
20 senf::console::ScopedDirectory<DVBSocketController> dir;
22 typedef boost::function<void (const struct dvb_frontend_event & )> Callback;
24 DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), DVBDemuxSectionHandle sectionHandle_ = DVBDemuxSectionHandle(0,0), const Callback & cb = NULL);
25 ~DVBSocketController();
27 void tuneToCMD( const std::string & channel, const std::string & mode = "async");
29 void tuneTo(const std::string & channel);
31 void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
32 ///< Tunes a DVB-S device
33 /**< Tunes a DVB-S device. Needs full configuration */
34 void tuneDVB_T(unsigned int frequency,
35 fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
36 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
37 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
38 fe_modulation_t constellation, /* modulation type (see above) */
39 fe_transmit_mode_t transmission_mode,
40 fe_guard_interval_t guard_interval,
41 fe_hierarchy_t hierarchy_information); ///< Tunes a DVB-T device
42 /**< Tunes a DVB-T device. Needs full configuration */
43 void tuneDVB_C(unsigned int frequency,
44 fe_spectral_inversion_t inversion, unsigned int symbol_rate,
45 fe_code_rate_t fec_inner, fe_modulation_t modulation);
47 dvb_frontend_event tuneTo_sync( const std::string & channel );
49 dvb_frontend_event tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
50 ///< Tunes a DVB-S device
51 /**< Tunes a DVB-S device. Needs full configuration */
52 dvb_frontend_event tuneDVB_T_sync(unsigned int frequency,
53 fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
54 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
55 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
56 fe_modulation_t constellation, /* modulation type (see above) */
57 fe_transmit_mode_t transmission_mode,
58 fe_guard_interval_t guard_interval,
59 fe_hierarchy_t hierarsourcechy_information); ///< Tunes a DVB-T device
60 /**< Tunes a DVB-T device. Needs full configuration */
61 dvb_frontend_event tuneDVB_C_sync(unsigned int frequency,
62 fe_spectral_inversion_t inversion, unsigned int symbol_rate,
63 fe_code_rate_t fec_inner, fe_modulation_t modulation);
67 std::string getTypeString();
69 std::string status2String(fe_status_t status);
70 unsigned int bitErrorRate();
71 unsigned int signalToNoiseRatio();
72 unsigned int signalStrength();
74 void setSectionFilter(unsigned short int pid,
75 u_int8_t filter = MPE_TABLEID,
76 unsigned int flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC,
79 unsigned int timeout = 0);
81 void setBufferSize(unsigned long size);
82 ///< set the size of the circular buffer used for filtered data.
83 /**< The default size is two maximum sized sections, i.e. if this
84 function is not called a buffer size of 2 * 4096 bytes will
86 \param[in] size Size of circular buffer. */
88 void startFiltering();
92 std::string getTuneInfo(const std::string & conf ="Ssbuf"); ///< Returns a string which shows actual tuning status
93 /**< Returns a string which shows actual tuning status.
94 "S" prints signal strength (in hex)
95 "s" prints singal to noise ration (in hex)
96 "b" prints bit error rate (in hex)
97 "u" prints uncorrected blocks (in hex)
98 "f" prints readable overal status e.g. "Has Lock"
99 These characters can be used to form the output. Be aware, some
100 features may not be supported be your current driver implementation and
101 could end in throwing an exception!*/
103 DVBFrontendHandle frontendHandle;
104 senf::DVBDemuxSectionHandle sectionHandle;
106 DVBConfigParser parser;
108 senf::scheduler::FdEvent event;
110 void readEvent(int i);
115 #endif /*DVBSOCKETCONTROLLER_HH_*/