switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / Protocols / DVB / DVBDemuxHandles.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Thorsten Horstmann <tho@berlios.de>
27
28 /** \file
29     \brief DVBDemuxHandles public header */
30
31 #ifndef HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_
32 #define HH_SENF_Socket_Protocols_DVB_DVBDemuxHandles_ 1
33
34 // Custom includes
35 #include <senf/Socket/FramingPolicy.hh>
36 #include <senf/Socket/CommunicationPolicy.hh>
37 #include <senf/Socket/ReadWritePolicy.hh>
38 #include <senf/Socket/ProtocolClientSocketHandle.hh>
39 #include "DVBDemuxSocketProtocol.hh"
40
41 //#include "DVBDemuxHandles.mpp"
42 #include <boost/enable_shared_from_this.hpp>
43 #include <boost/shared_ptr.hpp>
44 #include <iostream>
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46
47 namespace senf {
48
49     /// \addtogroup concrete_protocol_group
50     //\{
51
52     typedef MakeSocketPolicy<
53         NoAddressingPolicy,
54         DatagramFramingPolicy,
55         UnconnectedCommunicationPolicy,
56         ReadablePolicy,
57         NotWriteablePolicy
58         >::policy DVBDemux_Policy;   ///< Socket Policy for xxxx
59
60     /** \brief Baseclass of various DVBProtocolWrappers which are defined in DVBProtocolWrapper.hh
61      */
62     class DVBProtocolWrapper :public boost::enable_shared_from_this<DVBProtocolWrapper> {
63         public:
64             DVBProtocolWrapper() {}
65             virtual ~DVBProtocolWrapper() {}
66     };
67     /** \brief Baseclass for DVBSocketProtocols which want use Wrappers for console.
68     */
69     class DVBSocketProtocol : public virtual SocketProtocol {
70 private:
71         boost::shared_ptr<DVBProtocolWrapper> wrap_;
72 public:
73         DVBSocketProtocol() {}
74         ~DVBSocketProtocol() {}
75
76         void addWrapper(boost::shared_ptr<DVBProtocolWrapper> wrap)/**< Binds a wrapper to a DVBProtocol,
77                                                                         so if it is closed the functionality of the wrapper is automatically removed from console.*/
78         {
79             wrap_ = wrap;
80         }
81         virtual void close()
82         {
83             wrap_.reset();
84             SocketProtocol::close();
85
86         }
87     };
88
89
90     class DVBDemuxSectionSocketProtocol
91         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDemuxSectionSocketProtocol>,
92           public DVBDemuxSocketProtocol,
93           public DVBSocketProtocol
94     {
95
96     public:
97         //-////////////////////////////////////////////////////////////////////////
98         // internal interface
99
100         ///\name Constructors
101         //\{
102
103         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
104                                         /**< \note This member is implicitly called from the
105                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
106                                              constructor */
107
108         //\}
109         ///\name Abstract Interface Implementation
110         //\{
111
112         unsigned available() const;
113
114         //\}
115
116         void setSectionFilter(unsigned short int pid,
117                 unsigned char filter= 0x3e,
118                 unsigned int flags= DMX_IMMEDIATE_START | DMX_CHECK_CRC,
119                 unsigned char mask = 0xff,
120                 unsigned char mode =0x00,
121                 unsigned int timeout =0x00) const;
122
123     };
124
125     typedef ProtocolClientSocketHandle<DVBDemuxSectionSocketProtocol> DVBDemuxSectionHandle;
126
127     // ----------------------------------------------------------------
128
129     /** \brief xxx
130      */
131     class DVBDemuxPESSocketProtocol
132         : public ConcreteSocketProtocol<DVBDemux_Policy,DVBDemuxPESSocketProtocol>,
133           public DVBDemuxSocketProtocol,
134           public DVBSocketProtocol
135     {
136     public:
137         //-////////////////////////////////////////////////////////////////////////
138         // internal interface
139
140         ///\name Constructors
141         //\{
142
143         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
144                                         /**< \note This member is implicitly called from the
145                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
146                                              constructor */
147
148         //\}
149         ///\name Abstract Interface Implementation
150         //\{
151
152         unsigned available() const;
153
154         //\}
155
156         void setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)const;
157     };
158
159     typedef ProtocolClientSocketHandle<DVBDemuxPESSocketProtocol> DVBDemuxPESHandle;
160
161
162     // ----------------------------------------------------------------
163
164
165     /** \brief xxx
166          */
167     class DVBDvrSocketProtocol
168         : public ConcreteSocketProtocol<DVBDemux_Policy, DVBDvrSocketProtocol>,
169           public DVBDemuxSocketProtocol
170     {
171     public:
172         //-////////////////////////////////////////////////////////////////////////
173         // internal interface
174
175         ///\name Constructors
176         //\{
177
178         void init_client(unsigned short adapter=0, unsigned short device=0) const;       ///< xxx
179                                         /**< \note This member is implicitly called from the
180                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
181                                              constructor */
182
183         //\}
184         ///\name Abstract Interface Implementation
185         //\{
186
187         unsigned available() const;
188
189         //\}
190      };
191
192      typedef ProtocolClientSocketHandle<DVBDvrSocketProtocol> DVBDvrHandle;
193
194     //\}
195
196 }
197
198 //-/////////////////////////////////////////////////////////////////////////////////////////////////
199 //#include "DVBDemuxHandles.cci"
200 //#include "DVBDemuxHandles.ct"
201 //#include "DVBDemuxHandles.cti"
202 #endif
203
204 \f
205 // Local Variables:
206 // mode: c++
207 // fill-column: 100
208 // c-file-style: "senf"
209 // indent-tabs-mode: nil
210 // ispell-local-dictionary: "american"
211 // compile-command: "scons -u test"
212 // comment-column: 40
213 // End: