DVBSocketController.hh

Go to the documentation of this file.
00001 // $Id: DVBSocketController.hh 1736 2010-10-18 16:13:56Z tho $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Anton Gillert <atx@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 
00024 #ifndef HH_SENF_Socket_Protocols_DVB_DVBSocketController_
00025 #define HH_SENF_Socket_Protocols_DVB_DVBSocketController_ 1
00026 
00027 // Custom includes
00028 #include <string>
00029 #include <linux/dvb/frontend.h>
00030 #include "DVBFrontendHandle.hh"
00031 #include "DVBDemuxHandles.hh"
00032 #include "DVBConfigParser.hh"
00033 #include <senf/Scheduler/FdEvent.hh>
00034 #include <senf/Utils/Console/ScopedDirectory.hh>
00035 
00037 namespace senf {
00038 
00039 #define MPE_TABLEID 62
00040 
00056 class DVBSocketController : boost::noncopyable
00057 {
00058 public:
00059 
00060     console::ScopedDirectory<DVBSocketController> dir;
00061 
00062     typedef boost::function<void (const struct dvb_frontend_event & )> Callback;
00064 
00065     DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), const Callback & cb = NULL);
00066     ~DVBSocketController();
00067 
00068     DVBDemuxSectionHandle createDVBDemuxSectionHandle(  int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
00069     DVBDemuxPESHandle createDVBDemuxPESHandle(  int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
00070 
00071     void addToConsole(DVBDemuxSectionHandle sh);
00073 
00079     void addToConsole(DVBDemuxPESHandle sh);
00081 
00087     void tuneToCMD(std::string const & input, std::string const & mode = "async");
00089 
00097     void tuneTo(std::string const & channel);
00099 
00105     void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
00107 
00110     void tuneDVB_T(unsigned int frequency,
00111                     fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
00112                     fe_code_rate_t code_rate_HP, /* high priority stream code rate */
00113                     fe_code_rate_t code_rate_LP, /* low priority stream code rate */
00114                     fe_modulation_t constellation, /* modulation type (see above) */
00115                     fe_transmit_mode_t transmission_mode,
00116                     fe_guard_interval_t guard_interval,
00117                     fe_hierarchy_t hierarchy_information);
00119 
00122     void tuneDVB_C(unsigned int frequency,
00123                     fe_spectral_inversion_t inversion, unsigned int symbol_rate,
00124                     fe_code_rate_t fec_inner, fe_modulation_t modulation);
00126 
00129     dvb_frontend_event tuneTo_sync(std::string const & channel );
00131 
00142     dvb_frontend_event tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate);
00144 
00152     dvb_frontend_event tuneDVB_T_sync(unsigned int frequency,
00153                 fe_spectral_inversion_t inversion, fe_bandwidth_t bandwidth,
00154                 fe_code_rate_t code_rate_HP, /* high priority stream code rate */
00155                 fe_code_rate_t code_rate_LP, /* low priority stream code rate */
00156                 fe_modulation_t constellation, /* modulation type (see above) */
00157                 fe_transmit_mode_t transmission_mode,
00158                 fe_guard_interval_t guard_interval,
00159                 fe_hierarchy_t hierarsourcechy_information);
00161 
00170     dvb_frontend_event tuneDVB_C_sync(unsigned int frequency,
00171                 fe_spectral_inversion_t inversion, unsigned int symbol_rate,
00172                 fe_code_rate_t fec_inner, fe_modulation_t modulation);
00174 
00182     fe_type_t getType();                
00183 
00184     std::string getTypeString();        
00185 
00188     std::string status2String(fe_status_t status);
00190 
00193     unsigned int bitErrorRate();        
00194 
00200     unsigned int signalToNoiseRatio();  
00201 
00207     unsigned int signalStrength();      
00208 
00213     std::string getTuneInfo(const std::string & conf ="Ssbuf");
00215 
00224 private:
00225     DVBFrontendHandle frontendHandle;
00226     fe_type_t type;
00227     DVBConfigParser parser;
00228     Callback cb;
00229     static unsigned int controllerNr;
00230     unsigned int sectionNr;
00231     unsigned int pesNr;
00232     scheduler::FdEvent event;
00233     void readEvent(int i);
00234     void initConsole();
00235 };
00236 
00237 }
00238 
00240 //#include "DVBSocketController.cci"
00241 //#include "DVBSocketController.ct"
00242 //#include "DVBSocketController.cti"
00243 #endif