DVBSocketController.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 #ifndef HH_SENF_Socket_Protocols_DVB_DVBSocketController_
15 #define HH_SENF_Socket_Protocols_DVB_DVBSocketController_ 1
16 
17 // Custom includes
18 #include <string>
19 #include <linux/dvb/frontend.h>
20 #include "DVBFrontendHandle.hh"
21 #include "DVBDemuxHandles.hh"
22 #include "DVBConfigParser.hh"
25 
27 namespace senf {
28 
29 #define MPE_TABLEID 62
30 
46 class DVBSocketController : boost::noncopyable
47 {
48 public:
49 
51 
52  typedef boost::function<void (const struct dvb_frontend_event & )> Callback;
54 
55  DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), const Callback & cb = NULL);
57 
58  DVBDemuxSectionHandle createDVBDemuxSectionHandle( int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
59  DVBDemuxPESHandle createDVBDemuxPESHandle( int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
60 
63 
71 
77  void tuneToCMD(std::string const & input, std::string const & mode = "async");
79 
87  void tuneTo(std::string const & channel);
89 
95  void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
97 
100  void tuneDVB_T(unsigned int frequency,
101  fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
102  fe_code_rate_t code_rate_HP, /* high priority stream code rate */
103  fe_code_rate_t code_rate_LP, /* low priority stream code rate */
104  fe_modulation_t constellation, /* modulation type (see above) */
105  fe_transmit_mode_t transmission_mode,
106  fe_guard_interval_t guard_interval,
107  fe_hierarchy_t hierarchy_information);
109 
112  void tuneDVB_C(unsigned int frequency,
113  fe_spectral_inversion_t inversion, unsigned int symbol_rate,
114  fe_code_rate_t fec_inner, fe_modulation_t modulation);
116 
119  dvb_frontend_event tuneTo_sync(std::string const & channel );
121 
132  dvb_frontend_event tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
134 
142  dvb_frontend_event tuneDVB_T_sync(unsigned int frequency,
143  fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
144  fe_code_rate_t code_rate_HP, /* high priority stream code rate */
145  fe_code_rate_t code_rate_LP, /* low priority stream code rate */
146  fe_modulation_t constellation, /* modulation type (see above) */
147  fe_transmit_mode_t transmission_mode,
148  fe_guard_interval_t guard_interval,
149  fe_hierarchy_t hierarsourcechy_information);
151 
160  dvb_frontend_event tuneDVB_C_sync(unsigned int frequency,
161  fe_spectral_inversion_t inversion, unsigned int symbol_rate,
162  fe_code_rate_t fec_inner, fe_modulation_t modulation);
164 
172  fe_type_t getType();
173 
174  std::string getTypeString();
175 
178  std::string status2String(fe_status_t status);
180 
183  unsigned int bitErrorRate() const;
184 
190  unsigned int signalToNoiseRatio() const;
192 
198  unsigned int signalStrength() const;
200 
205  std::string getTuneInfo(const std::string & conf ="Ssbuf");
207 
216 private:
217  DVBFrontendHandle frontendHandle;
218  fe_type_t type;
219  DVBConfigParser parser;
220  Callback cb;
221  static unsigned int controllerNr;
222  unsigned int sectionNr;
223  unsigned int pesNr;
224  scheduler::FdEvent event;
225  void readEvent(int i);
226  void initConsole();
227 };
228 
229 }
230 
232 //#include "DVBSocketController.cci"
233 //#include "DVBSocketController.ct"
234 //#include "DVBSocketController.cti"
235 #endif
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.
void tuneTo(std::string const &channel)
Tunes a DVB device to a channel.
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
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.
std::string getTypeString()
Returns the type of the card.
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.
unsigned int signalToNoiseRatio() const
Returns the signal to noise ratio.
DVBDemuxSectionHandle createDVBDemuxSectionHandle(int adapternumber=0, int demuxnumber=0, bool addToConsole=false)
unsigned int bitErrorRate() const
Returns the bit error rate.
DVBDemuxHandles public header.
DVBDemuxHandles public header.
DVBFrontendHandle public header.
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.
unsigned int signalStrength() const
Returns the signal strength.
void addToConsole(DVBDemuxSectionHandle sh)
Adds an DVBDemuxSectionHandle to the console.
std::string getTuneInfo(const std::string &conf="Ssbuf")
Returns a string which shows actual tuning status.
ProtocolClientSocketHandle< DVBFrontendSocketProtocol > DVBFrontendHandle
void tuneToCMD(std::string const &input, std::string const &mode="async")
Tunes a DVB device given by the type of the DVBFrontendHandle.