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 std::string status2String(fe_status_t status);
14 class DVBSocketController : boost::noncopyable
17 senf::console::ScopedDirectory<DVBSocketController> dir;
19 typedef boost::function<void (const struct dvb_frontend_event & )> Callback;
21 DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), DVBDemuxSectionHandle sectionHandle_ = DVBDemuxSectionHandle(0,0), const Callback & cb = NULL);
22 ~DVBSocketController();
24 std::string tuneToCMD( const std::string & channel, const std::string & mode = "async");
26 void tuneTo(const std::string & channel);
28 void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
29 ///< Tunes a DVB-S device
30 /**< Tunes a DVB-S device. Needs full configuration */
31 void tuneDVB_T(unsigned int frequency,
32 fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
33 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
34 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
35 fe_modulation_t constellation, /* modulation type (see above) */
36 fe_transmit_mode_t transmission_mode,
37 fe_guard_interval_t guard_interval,
38 fe_hierarchy_t hierarchy_information); ///< Tunes a DVB-T device
39 /**< Tunes a DVB-T device. Needs full configuration */
40 void tuneDVB_C(unsigned int frequency,
41 fe_spectral_inversion_t inversion, unsigned int symbol_rate,
42 fe_code_rate_t fec_inner, fe_modulation_t modulation);
44 dvb_frontend_event tuneTo_sync( const std::string & channel );
46 dvb_frontend_event tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
47 ///< Tunes a DVB-S device
48 /**< Tunes a DVB-S device. Needs full configuration */
49 dvb_frontend_event tuneDVB_T_sync(unsigned int frequency,
50 fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
51 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
52 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
53 fe_modulation_t constellation, /* modulation type (see above) */
54 fe_transmit_mode_t transmission_mode,
55 fe_guard_interval_t guard_interval,
56 fe_hierarchy_t hierarsourcechy_information); ///< Tunes a DVB-T device
57 /**< Tunes a DVB-T device. Needs full configuration */
58 dvb_frontend_event tuneDVB_C_sync(unsigned int frequency,
59 fe_spectral_inversion_t inversion, unsigned int symbol_rate,
60 fe_code_rate_t fec_inner, fe_modulation_t modulation);
64 std::string getTypeString();
66 std::string status2String(fe_status_t status);
67 unsigned int bitErrorRate();
68 unsigned int signalToNoiseRatio();
69 unsigned int signalStrength();
71 void setSectionFilter(unsigned short int pid,
72 unsigned char filter = 62,
73 unsigned int flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC,
74 unsigned char mask = 0xff,
75 unsigned char mode = 0,
76 unsigned int timeout = 0);
78 void setBufferSize(unsigned long size);
79 ///< set the size of the circular buffer used for filtered data.
80 /**< The default size is two maximum sized sections, i.e. if this
81 function is not called a buffer size of 2 * 4096 bytes will
83 \param[in] size Size of circular buffer. */
85 void startFiltering();
89 std::string getTuneInfo(const std::string & conf ="Ssbuf"); ///< Returns a string which shows actual tuning status
90 /**< Returns a string which shows actual tuning status.
91 "S" prints signal strength (in hex)
92 "s" prints singal to noise ration (in hex)
93 "b" prints bit error rate (in hex)
94 "u" prints uncorrected blocks (in hex)
95 "f" prints readable overal status e.g. "Has Lock"
96 These characters can be used to form the output. Be aware, some
97 features may not be supported be your current driver implementation and
98 could end in throwing an exception!*/
100 DVBFrontendHandle frontendHandle;
101 senf::DVBDemuxSectionHandle sectionHandle;
103 DVBConfigParser parser;
105 senf::scheduler::FdEvent event;
107 void readEvent(int i);
112 #endif /*DVBSOCKETCONTROLLER_HH_*/