1 // $Id: DVBSocketController.hh 1119 2009-02-16 13:36:59Z tho $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Anton Gillert <atx@berlios.de>
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.
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.
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.
24 #ifndef HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_
25 #define HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_ 1
26 #include <senf/Utils/Console/Console.hh>
27 #include <senf/Utils/Console/Console.hh>
28 #include "DVBDemuxHandles.hh"
31 SENF_CONSOLE_REGISTER_ENUM( dmx_input_t, (DMX_IN_FRONTEND)(DMX_IN_DVR) )
33 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)
44 /** \brief Helperclass for configuration and controlling DVB protokoll handles.
49 class DVBSectionProtocolWrapper : public senf::DVBProtocolWrapper {
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;
58 const senf::DVBDemuxSectionSocketProtocol& protocol;
60 DVBSectionProtocolWrapper(senf::DVBDemuxSectionHandle sh) :
61 dir(this), protocol(sh.protocol()) {
63 namespace kw = senf::console::kw;
64 dir.add("buffersize", &DVBSectionProtocolWrapper::setBufferSize)
65 .doc("Set the size of the circular buffer used for filtered data.")
66 .arg("size", "in byte");
68 dir.add("start", &DVBSectionProtocolWrapper::startFiltering)
69 .doc("Starts filtering");
71 dir.add("stop", &DVBSectionProtocolWrapper::setBufferSize)
72 .doc("Stops filtering");
74 dir.node().add("filter", boost::function<void (unsigned short int, unsigned, senf::console::FlagCollection<Flags>, unsigned, unsigned, unsigned)>(senf::membind(&DVBSectionProtocolWrapper::setSectionFilter, this)))
75 .arg("pid", "pid to filter")
76 .arg("filter", "filter", kw::default_value = 62, kw::default_doc = "0x3e")
77 .arg("flags", "or-able: CHECK_CRC, ONESHOT, IMMEDIATE_START, KERNEL_CLIENT", kw::default_value = DMX_IMMEDIATE_START | DMX_CHECK_CRC, kw::default_doc = "(IMMEDIATE_START CHECK_CRC)")
78 .arg("mask", "mask", kw::default_value = 0xff, kw::default_doc = "0xff")
79 .arg("mode", "mode", kw::default_value = 0, kw::default_doc = "0x00")
80 .arg("timeout", "timeout", kw::default_value = 0, kw::default_doc = "0x00")
81 .doc("Sets parameters for section filter.");
83 dir.add("stop", &DVBSectionProtocolWrapper::setBufferSize)
84 .doc("Stops filtering");
86 ~DVBSectionProtocolWrapper() {
88 void setSectionFilter(unsigned short int pid, u_int8_t filter,
89 unsigned int flags, u_int8_t mask, u_int8_t mode,
90 unsigned int timeout) {
91 protocol.setSectionFilter(pid, timeout, flags, filter, mask, mode);
95 ///< Set the size of the circular buffer used for filtered data.
96 /**< The default size is two maximum sized sections, i.e. if
97 this function is not called a buffer size of 2 * 4096
99 \param[in] size Size of circular buffer. */
100 void setBufferSize(unsigned long size) {
101 protocol.setBufferSize(size);
104 void startFiltering() ///< Starts filtering
106 protocol.startFiltering();
109 void stopFiltering() ///< Stops filtering
111 protocol.stopFiltering();
115 SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBSectionProtocolWrapper, Flags,
116 (CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT))
119 class DVBPESProtocolWrapper : public senf::DVBProtocolWrapper {
122 enum Flags {CHECK_CRC = DMX_CHECK_CRC,
123 ONESHOT = DMX_ONESHOT,
124 IMMEDIATE_START = DMX_IMMEDIATE_START,
125 KERNEL_CLIENT = DMX_KERNEL_CLIENT};
126 senf::console::ScopedDirectory<DVBPESProtocolWrapper> dir;
128 const senf::DVBDemuxPESSocketProtocol& protocol;
130 DVBPESProtocolWrapper(senf::DVBDemuxPESHandle sh) :
131 dir(this), protocol(sh.protocol()) {
132 namespace kw = senf::console::kw;
134 dir.node().add("filter", boost::function<void ( unsigned short int, dmx_input_t, dmx_output_t, dmx_pes_type_t, senf::console::FlagCollection<Flags>)>(senf::membind(&DVBPESProtocolWrapper::setPESFilter, this)))
135 .arg("pid", "pid to filter")
136 .arg("input", "input-filter: DMX_IN_FRONTEND DMX_IN_DVR ")
137 .arg("output", "output-filter: DMX_OUT_DECODER DMX_OUT_TAP DMX_OUT_TS_TAP ")
138 .arg("pesType", "PES type: DMX_PES_AUDIO[0-3] DMX_PES_VIDEO[0-3] DMX_PES_TELETEXT[0-3], DMX_PES_SUBTITLE[0-3], DMX_PES_PCR[0-3], DMX_PES_OTHER")
139 .arg("flags", "or-able: CHECK_CRC, ONESHOT, IMMEDIATE_START, KERNEL_CLIENT", kw::default_value = DMX_IMMEDIATE_START | DMX_CHECK_CRC, kw::default_doc = "(IMMEDIATE_START CHECK_CRC)")
140 .doc("Sets parameters for PES filter.");
141 dir.add("start", &DVBPESProtocolWrapper::startFiltering)
142 .doc("Starts filtering");
144 dir.add("stop", &DVBPESProtocolWrapper::stopFiltering)
145 .doc("Stops filtering");
147 ~DVBPESProtocolWrapper() {
151 void setPESFilter(unsigned short int pid, dmx_input_t input,
152 dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags) {
153 protocol.setPESFilter(pid, input, output, pesType, flags);
155 void startFiltering() ///< Starts filtering
157 protocol.startFiltering();
160 void stopFiltering() ///< Stops filtering
162 protocol.stopFiltering();
165 SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBPESProtocolWrapper, Flags,
166 (CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT))