Move sourcecode into 'senf/' directory
[senf.git] / senf / Socket / Protocols / DVB / DVBDemuxHandles.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief DVBDemuxHandles public header */
25
26 #ifndef HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_
27 #define HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_ 1
28
29 // Custom includes
30 #include "../../../Socket/FramingPolicy.hh"
31 #include "../../../Socket/CommunicationPolicy.hh"
32 #include "../../../Socket/ReadWritePolicy.hh"
33 #include "../../../Socket/ProtocolClientSocketHandle.hh"
34 #include "DVBDemuxSocketProtocol.hh"
35
36 //#include "DVBDemuxHandles.mpp"
37 #include <boost/enable_shared_from_this.hpp>
38 #include <boost/shared_ptr.hpp>
39 #include <iostream>
40 ///////////////////////////////hh.p////////////////////////////////////////
41
42 namespace senf {
43
44     /// \addtogroup concrete_protocol_group
45     /// @{
46
47     typedef MakeSocketPolicy<
48         NoAddressingPolicy,
49         DatagramFramingPolicy,
50         UnconnectedCommunicationPolicy,
51         ReadablePolicy,
52         NotWriteablePolicy
53         >::policy DVBDemux_Policy;   ///< Socket Policy for xxxx
54
55     /** \brief Baseclass of various DVBProtocolWrappers which are defined in DVBProtocolWrapper.hh 
56      */
57     class DVBProtocolWrapper :public boost::enable_shared_from_this<DVBProtocolWrapper> {
58         public:
59             DVBProtocolWrapper(){}
60             virtual ~DVBProtocolWrapper(){}
61     };
62     /** \brief Baseclass for DVBSocketProtocols which want use Wrappers for console. 
63     */
64     class DVBSocketProtocol : public virtual SocketProtocol {
65 private:
66         boost::shared_ptr<DVBProtocolWrapper> wrap_;
67 public:
68         DVBSocketProtocol() {}
69         ~DVBSocketProtocol() {}
70         
71         void addWrapper(boost::shared_ptr<DVBProtocolWrapper> wrap)/**< Binds a wrapper to a DVBProtocol, 
72                                                                         so if it is closed the functionality of the wrapper is automatically removed from console.*/ 
73         {
74             wrap_ = wrap;
75         }
76         virtual void close(){
77             wrap_.reset();
78             SocketProtocol::close();
79
80         }
81     };
82     
83     
84     class DVBDemuxSectionSocketProtocol
85         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDemuxSectionSocketProtocol>,
86           public DVBDemuxSocketProtocol, 
87           public DVBSocketProtocol
88     {
89     
90     public:
91         ///////////////////////////////////////////////////////////////////////////
92         // internal interface
93
94         ///\name Constructors
95         ///@{
96
97         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
98                                         /**< \note This member is implicitly called from the
99                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
100                                              constructor */
101
102         ///@}
103         ///\name Abstract Interface Implementation
104         ///@{
105         
106         unsigned available() const;
107
108         ///@}
109         
110         void setSectionFilter(unsigned short int pid, 
111                 unsigned char filter= 0x3e,
112                 unsigned int flags= DMX_IMMEDIATE_START | DMX_CHECK_CRC, 
113                 unsigned char mask = 0xff, 
114                 unsigned char mode =0x00,
115                 unsigned int timeout =0x00) const;
116         
117     };
118
119     typedef ProtocolClientSocketHandle<DVBDemuxSectionSocketProtocol> DVBDemuxSectionHandle;
120     
121     // ----------------------------------------------------------------
122     
123     /** \brief xxx
124      */
125     class DVBDemuxPESSocketProtocol
126         : public ConcreteSocketProtocol<DVBDemux_Policy,DVBDemuxPESSocketProtocol>,
127           public DVBDemuxSocketProtocol,
128           public DVBSocketProtocol
129     {
130     public:
131         ///////////////////////////////////////////////////////////////////////////
132         // internal interface
133
134         ///\name Constructors
135         ///@{
136
137         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
138                                         /**< \note This member is implicitly called from the
139                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
140                                              constructor */
141
142         ///@}
143         ///\name Abstract Interface Implementation
144         ///@{
145         
146         unsigned available() const;
147
148         ///@}
149         
150         void setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)const;    
151     };
152
153     typedef ProtocolClientSocketHandle<DVBDemuxPESSocketProtocol> DVBDemuxPESHandle;
154
155     
156     // ----------------------------------------------------------------
157     
158     
159     /** \brief xxx
160          */
161     class DVBDvrSocketProtocol
162         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDvrSocketProtocol>,
163           public DVBDemuxSocketProtocol
164     {
165     public:
166         ///////////////////////////////////////////////////////////////////////////
167         // internal interface
168
169         ///\name Constructors
170         ///@{
171
172         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
173                                         /**< \note This member is implicitly called from the
174                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
175                                              constructor */
176
177         ///@}
178         ///\name Abstract Interface Implementation
179         ///@{
180         
181         unsigned available() const;
182
183         ///@}
184      };
185
186      typedef ProtocolClientSocketHandle<DVBDvrSocketProtocol> DVBDvrHandle;
187
188     ///@}
189     
190 }
191
192 ///////////////////////////////hh.e////////////////////////////////////////
193 //#include "DVBDemuxHandles.cci"
194 //#include "DVBDemuxHandles.ct"
195 //#include "DVBDemuxHandles.cti"
196 #endif
197
198 \f
199 // Local Variables:
200 // mode: c++
201 // fill-column: 100
202 // c-file-style: "senf"
203 // indent-tabs-mode: nil
204 // ispell-local-dictionary: "american"
205 // compile-command: "scons -u test"
206 // comment-column: 40
207 // End: