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