DVBDemuxHandles.hh

Go to the documentation of this file.
00001 // $Id: DVBDemuxHandles.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Thorsten Horstmann <tho@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 
00026 #ifndef HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_
00027 #define HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_ 1
00028 
00029 // Custom includes
00030 #include <senf/Socket/FramingPolicy.hh>
00031 #include <senf/Socket/CommunicationPolicy.hh>
00032 #include <senf/Socket/ReadWritePolicy.hh>
00033 #include <senf/Socket/ProtocolClientSocketHandle.hh>
00034 #include "DVBDemuxSocketProtocol.hh"
00035 
00036 //#include "DVBDemuxHandles.mpp"
00037 #include <boost/enable_shared_from_this.hpp>
00038 #include <boost/shared_ptr.hpp>
00039 #include <iostream>
00040 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00041 
00042 namespace senf {
00043 
00045     //\{
00046 
00047     typedef MakeSocketPolicy<
00048         NoAddressingPolicy,
00049         DatagramFramingPolicy,
00050         UnconnectedCommunicationPolicy,
00051         ReadablePolicy,
00052         NotWriteablePolicy
00053         >::policy DVBDemux_Policy;   
00054 
00057     class DVBProtocolWrapper :public boost::enable_shared_from_this<DVBProtocolWrapper> {
00058         public:
00059             DVBProtocolWrapper() {}
00060             virtual ~DVBProtocolWrapper() {}
00061     };
00064     class DVBSocketProtocol : public virtual SocketProtocol {
00065 private:
00066         boost::shared_ptr<DVBProtocolWrapper> wrap_;
00067 public:
00068         DVBSocketProtocol() {}
00069         ~DVBSocketProtocol() {}
00070 
00071         void addWrapper(boost::shared_ptr<DVBProtocolWrapper> wrap)
00073         {
00074             wrap_ = wrap;
00075         }
00076         virtual void close()
00077         {
00078             wrap_.reset();
00079             SocketProtocol::close();
00080 
00081         }
00082     };
00083 
00084 
00085     class DVBDemuxSectionSocketProtocol
00086         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDemuxSectionSocketProtocol>,
00087           public DVBDemuxSocketProtocol,
00088           public DVBSocketProtocol
00089     {
00090 
00091     public:
00092         //-////////////////////////////////////////////////////////////////////////
00093         // internal interface
00094 
00096         //\{
00097 
00098         void init_client(unsigned short adapter=0, unsigned short device=0) const;       
00099 
00103         //\}
00105         //\{
00106 
00107         unsigned available() const;
00108 
00109         //\}
00110 
00111         void setSectionFilter(unsigned short int pid,
00112                 unsigned char filter= 0x3e,
00113                 unsigned int flags= DMX_IMMEDIATE_START | DMX_CHECK_CRC,
00114                 unsigned char mask = 0xff,
00115                 unsigned char mode =0x00,
00116                 unsigned int timeout =0x00) const;
00117 
00118     };
00119 
00120     typedef ProtocolClientSocketHandle<DVBDemuxSectionSocketProtocol> DVBDemuxSectionHandle;
00121 
00122     // ----------------------------------------------------------------
00123 
00126     class DVBDemuxPESSocketProtocol
00127         : public ConcreteSocketProtocol<DVBDemux_Policy,DVBDemuxPESSocketProtocol>,
00128           public DVBDemuxSocketProtocol,
00129           public DVBSocketProtocol
00130     {
00131     public:
00132         //-////////////////////////////////////////////////////////////////////////
00133         // internal interface
00134 
00136         //\{
00137 
00138         void init_client(unsigned short adapter=0, unsigned short device=0) const;       
00139 
00143         //\}
00145         //\{
00146 
00147         unsigned available() const;
00148 
00149         //\}
00150 
00151         void setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)const;
00152     };
00153 
00154     typedef ProtocolClientSocketHandle<DVBDemuxPESSocketProtocol> DVBDemuxPESHandle;
00155 
00156 
00157     // ----------------------------------------------------------------
00158 
00159 
00162     class DVBDvrSocketProtocol
00163         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDvrSocketProtocol>,
00164           public DVBDemuxSocketProtocol
00165     {
00166     public:
00167         //-////////////////////////////////////////////////////////////////////////
00168         // internal interface
00169 
00171         //\{
00172 
00173         void init_client(unsigned short adapter=0, unsigned short device=0) const;       
00174 
00178         //\}
00180         //\{
00181 
00182         unsigned available() const;
00183 
00184         //\}
00185      };
00186 
00187      typedef ProtocolClientSocketHandle<DVBDvrSocketProtocol> DVBDvrHandle;
00188 
00189     //\}
00190 
00191 }
00192 
00193 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00194 //#include "DVBDemuxHandles.cci"
00195 //#include "DVBDemuxHandles.ct"
00196 //#include "DVBDemuxHandles.cti"
00197 #endif
00198 
00199 
00200 // Local Variables:
00201 // mode: c++
00202 // fill-column: 100
00203 // c-file-style: "senf"
00204 // indent-tabs-mode: nil
00205 // ispell-local-dictionary: "american"
00206 // compile-command: "scons -u test"
00207 // comment-column: 40
00208 // End: