4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief DVBFrontendHandle public header */
26 #ifndef HH_SENF_Socket_Protocols_DVB_DVBFrontendHandle_
27 #define HH_SENF_Socket_Protocols_DVB_DVBFrontendHandle_ 1
30 #include <boost/cstdint.hpp>
31 #include <boost/bind.hpp>
32 #include <boost/function.hpp>
33 #include <linux/dvb/frontend.h>
34 #include "../../../Socket/FramingPolicy.hh"
35 #include "../../../Socket/CommunicationPolicy.hh"
36 #include "../../../Socket/ReadWritePolicy.hh"
37 #include "../../../Socket/ProtocolClientSocketHandle.hh"
38 #include "../../../Socket/SocketProtocol.hh"
44 //#include "DVBFrontendHandle.mpp"
45 ///////////////////////////////hh.p////////////////////////////////////////
49 /// \addtogroup concrete_protocol_group
52 typedef MakeSocketPolicy<
54 DatagramFramingPolicy,
55 UnconnectedCommunicationPolicy,
58 > ::policy DVBFrontend_Policy; ///< Socket Policy for DVBFrontendSocketProtocol
61 /** \brief SocketProtocol for the dvb frontend device
63 The DVB frontend device controls the tuner and DVB demodulator hardware.
66 class DVBFrontendSocketProtocol
67 : public ConcreteSocketProtocol<DVBFrontend_Policy, DVBFrontendSocketProtocol>
70 dvb_frontend_event tune(const struct dvb_frontend_parameters & frontend);
71 struct dvb_frontend_event waitTune(const struct dvb_frontend_parameters & frontend);
72 struct dvb_frontend_event asyncTune(const struct dvb_frontend_parameters & frontend);
73 boost::function<struct dvb_frontend_event (const struct dvb_frontend_parameters & frontend)> cb2_X_Tune;
75 ///////////////////////////////////////////////////////////////////////////
80 void init_client(unsigned const short adapter = 0, unsigned const short device = 0);
81 ///< Opens the specified frontend device in read-only mode.
82 /**< \note This member is implicitly called from the
83 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
88 void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
89 ///< Tunes a DVB-C device
90 /**< Tunes a DVB-C device. Needs full configuration */
91 void tuneDVB_T(unsigned int frequency,
92 fe_spectral_inversion_t inversion,
93 fe_bandwidth_t bandwidth,
94 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
95 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
96 fe_modulation_t constellation, /* modulation type (see above) */
97 fe_transmit_mode_t transmission_mode,
98 fe_guard_interval_t guard_interval,
99 fe_hierarchy_t hierarchy_information
100 ); ///< Tunes a DVB-T device
101 /**< Tunes a DVB-T device. Needs full configuration */
102 void tuneDVB_C(unsigned int frequency,
103 fe_spectral_inversion_t inversion,
104 unsigned int symbol_rate,
105 fe_code_rate_t fec_inner,
106 fe_modulation_t modulation);
107 ///< Tunes a DVB-C device
108 /**< Tunes a DVB-C device. Needs full configuration */
109 struct dvb_frontend_info getInfo() const; ///< Returns information struct.
110 /**< Returns information struct, which contains information
111 about the device which is associated with the current frontend.*/
112 struct dvb_frontend_parameters getFrontendParam() const; ///< Returns dvb_frontend_parameters struct.
113 /**< Returns dvb_frontend_parameters struct, which contains the actual
114 configuration of the device.*/
115 void setFrequency(unsigned int frequency); ///< Sets frequency
116 /**< Sets frequency. This can be done for all device types.*/
117 void setInversion(fe_spectral_inversion_t inversion); ///< Sets inversion
118 /**< Sets inversion. This can be done for all device types.*/
119 void setCodeRate(fe_code_rate_t fec_inner); ///< Sets code rate
120 /**< Sets code rate. This can be done for all device types. Attention
121 for DVB-T devices the high and low priority stream code rate will be set to
123 void setSymbolRate(unsigned int symbol_rate); ///< Sets symbol rate
124 /**< Sets symbol rate. This can only be done for DVB-S or DVB-C devices.
125 Other attempts will throw an exception.*/
126 void setModulation(fe_modulation_t modulation); ///< Sets modulation
127 /**< Sets modulation. This can only be done for DVB-T or DVB-C devices.
128 Other attempts will throw an exception.*/
129 void setBandwidth(fe_bandwidth_t bandwidth); ///< Sets bandwidth
130 /**< Sets bandwidth. This can only be done for DVB-T devices.
131 Other attempts will throw an exception.*/
132 void setHighPriorityCodeRate(fe_code_rate_t code_rate_HP); ///< Sets high priority stream code rate
133 /**< Sets high priority stream code rate. This can only be done for DVB-T devices.
134 Other attempts will throw an exception.*/
135 void setLowPriorityCodeRate(fe_code_rate_t code_rate_LP); ///< Sets low priority stream code rate
136 /**< Sets low priority stream code rate. This can only be done for DVB-T devices.
137 Other attempts will throw an exception.*/
138 void setGuardInterval(fe_guard_interval_t guard_interval); ///< Sets guard interval
139 /**< Sets guard interval. This can only be done for DVB-T devices.
140 Other attempts will throw an exception.*/
141 void setHierarchyInformation(fe_hierarchy_t hierarchy_information); ///< Sets hierarchy information
142 /**< Sets hierarchy information. This can only be done for DVB-T devices.
143 Other attempts will throw an exception.*/
146 ///\name Abstract Interface Implementation
149 unsigned available() const; ///< Returns always <tt>0</tt>
150 /**< Returns always <tt>0</tt>, since the DVB frontend
151 socket is not readable. */
152 bool eof() const; ///< Returns always <tt>false</tt>
153 /**< Returns always <tt>false</tt>, since the DVB frontend
154 socket does not support the notion of EOF. */
158 int16_t signalStrength() const; ///< Returns current signal strength
159 /**< Returns the signal strength value for the signal
160 currently received by the front-end. For this method,
161 read-only access to the device is sufficient.*/
163 int16_t signalNoiseRatio() const;
164 ///< Returns current signal-to-noise ratio
165 /**< Returns the signal-to-noise ratio for the signal
166 currently received by the front-end. For this method,
167 read-only access to the device is sufficient. */
169 uint32_t bitErrorRate() const; ///< Returns the current bit error rate for the signal
170 /**< Returns the bit error rate for the signal currently
171 received/demodulated by the front-end. For this method,
172 read-only access to the device is sufficient. */
175 typedef ProtocolClientSocketHandle<DVBFrontendSocketProtocol> DVBFrontendHandle;
181 ///////////////////////////////hh.e////////////////////////////////////////
182 //#include "DVBFrontendHandle.cci"
183 //#include "DVBFrontendHandle.ct"
184 //#include "DVBFrontendHandle.cti"
191 // c-file-style: "senf"
192 // indent-tabs-mode: nil
193 // ispell-local-dictionary: "american"
194 // compile-command: "scons -u test"
195 // comment-column: 40