switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Socket / Protocols / DVB / DVBProtocolWrapper.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 //   Anton Gillert <atx@berlios.de>
27
28
29 #ifndef HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_
30 #define HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_ 1
31
32 // Custom includes
33 #include <senf/Utils/Console/ScopedDirectory.hh>
34 #include <senf/Utils/Console/Traits.hh>
35 #include "DVBDemuxHandles.hh"
36
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38
39 SENF_CONSOLE_REGISTER_ENUM( dmx_input_t, (DMX_IN_FRONTEND)(DMX_IN_DVR) );
40 SENF_CONSOLE_REGISTER_ENUM( dmx_output_t, (DMX_OUT_DECODER)(DMX_OUT_TAP)(DMX_OUT_TS_TAP) );
41 SENF_CONSOLE_REGISTER_ENUM( dmx_pes_type_t, (DMX_PES_AUDIO0)(DMX_PES_VIDEO0)(DMX_PES_TELETEXT0)(DMX_PES_SUBTITLE0)(DMX_PES_PCR0)
42         (DMX_PES_AUDIO1)(DMX_PES_VIDEO1)(DMX_PES_TELETEXT1)(DMX_PES_SUBTITLE1)(DMX_PES_PCR1)
43         (DMX_PES_AUDIO2)(DMX_PES_VIDEO2)(DMX_PES_TELETEXT2)(DMX_PES_SUBTITLE2)(DMX_PES_PCR2)
44         (DMX_PES_AUDIO3)(DMX_PES_VIDEO3)(DMX_PES_TELETEXT3)(DMX_PES_SUBTITLE3)(DMX_PES_PCR3)
45         (DMX_PES_OTHER));
46
47 namespace senf {
48
49     /** \brief Helperclass for configuration and controlling DVB protocol handles.
50
51      */
52     class DVBSectionProtocolWrapper : public DVBProtocolWrapper
53     {
54     private:
55         const DVBDemuxSectionSocketProtocol& protocol;
56
57     public:
58         enum Flags {CHECK_CRC = DMX_CHECK_CRC,
59             ONESHOT = DMX_ONESHOT,
60             IMMEDIATE_START = DMX_IMMEDIATE_START,
61             KERNEL_CLIENT = DMX_KERNEL_CLIENT};
62         senf::console::ScopedDirectory<DVBSectionProtocolWrapper> dir;
63
64         DVBSectionProtocolWrapper(senf::DVBDemuxSectionHandle sh);
65         ~DVBSectionProtocolWrapper() { }
66
67         void setSectionFilter(unsigned short int pid, u_int8_t filter,
68                 unsigned int flags, u_int8_t mask, u_int8_t mode, unsigned int timeout);
69
70         void setBufferSize(unsigned long size);
71                                 ///< Set the size of the circular buffer used for filtered data.
72                                 /**< The default size is two maximum sized sections, i.e. if
73                                      this function is not called a buffer size of 2 * 4096 bytes
74                                      will be used.
75                                      \param[in] size Size of circular buffer. */
76         void startFiltering();  ///< Starts filtering
77         void stopFiltering();   ///< Stops filtering
78     };
79
80     SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBSectionProtocolWrapper, Flags,
81             (CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT));
82
83
84     class DVBPESProtocolWrapper : public senf::DVBProtocolWrapper
85     {
86     private:
87         const senf::DVBDemuxPESSocketProtocol& protocol;
88
89     public:
90         enum Flags {CHECK_CRC = DMX_CHECK_CRC,
91             ONESHOT = DMX_ONESHOT,
92             IMMEDIATE_START = DMX_IMMEDIATE_START,
93             KERNEL_CLIENT = DMX_KERNEL_CLIENT};
94         senf::console::ScopedDirectory<DVBPESProtocolWrapper> dir;
95
96         DVBPESProtocolWrapper(senf::DVBDemuxPESHandle sh);
97         ~DVBPESProtocolWrapper() { };
98
99         void setPESFilter(unsigned short int pid, dmx_input_t input,
100                 dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags);
101         void startFiltering(); ///< Starts filtering
102         void stopFiltering();  ///< Stops filtering
103     };
104
105     SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBPESProtocolWrapper, Flags,
106             (CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT));
107 }
108
109 //-/////////////////////////////////////////////////////////////////////////////////////////////////
110 #include "DVBProtocolWrapper.cci"
111 //#include "DVBProtocolWrapper.ct"
112 //#include "DVBProtocolWrapper.cti"
113 #endif
114