added documentation note for SocketProtocol::available()
[senf.git] / Socket / DVBDemuxHandles.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.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 xxx
25  */
26
27 #include "DVBDemuxHandles.hh"
28 //#include "DVBDemuxHandles.ih"
29
30 // Custom includes
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <iostream>
34 #include <string>
35 #include <sys/ioctl.h>
36 #include <linux/sockios.h>
37 #include <stdio.h>
38 #include <fcntl.h>
39
40 #include "Utils/Exception.hh"
41
42 //#include "DVBDemuxHandles.mpp"
43 #define prefix_
44 ///////////////////////////////cc.p////////////////////////////////////////
45
46 ///////////////////////////////////////////////////////////////////////////
47 // senf::DVBDemuxHandles
48
49 prefix_ void senf::DVBDemuxSectionProtocol::init_client()
50     const
51 {
52     int fd = open("/dev/dvb/adapter0/demux0", O_RDONLY | O_NONBLOCK);
53     if (fd < 0)
54         throw SystemException(errno);
55     body().fd(fd);
56 }
57
58 prefix_ unsigned senf::DVBDemuxSectionProtocol::available()
59     const
60 {
61     return 4096;
62 }
63
64 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBDemuxSectionProtocol::clone()
65     const
66 {
67     return std::auto_ptr<SocketProtocol>(new DVBDemuxSectionProtocol());
68 }
69
70 prefix_ void senf::DVBDemuxSectionProtocol::setSectionFilter(struct dmx_sct_filter_params *filter)
71     const
72 {
73     if (::ioctl(body().fd(), DMX_SET_FILTER, filter) < 0)
74         throw SystemException(errno);
75 }
76
77 // ----------------------------------------------------------------
78
79 prefix_ void senf::DVBDemuxPESProtocol::init_client()
80     const
81 {
82     int fd = open("/dev/dvb/adapter0/demux0", O_RDONLY | O_NONBLOCK);
83     if (fd < 0)
84         throw SystemException(errno);
85     body().fd(fd);
86 }
87
88 prefix_ unsigned senf::DVBDemuxPESProtocol::available()
89     const
90 {
91     return 4096; //???
92 }
93
94 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBDemuxPESProtocol::clone()
95     const
96 {
97     return std::auto_ptr<SocketProtocol>(new DVBDemuxPESProtocol());
98 }
99
100 prefix_ void senf::DVBDemuxPESProtocol::setPESFilter(struct dmx_pes_filter_params *filter)
101     const
102 {
103     if (::ioctl(body().fd(), DMX_SET_PES_FILTER, filter) < 0)
104         throw SystemException(errno);
105 }
106
107 // ----------------------------------------------------------------
108
109 prefix_ void senf::DVBDvrProtocol::init_client()
110     const
111 {
112     int fd = open("/dev/dvb/adapter0/dvr0", O_RDONLY | O_NONBLOCK);
113     if (fd < 0)
114         throw SystemException(errno);
115     body().fd(fd);
116 }
117
118 prefix_ unsigned senf::DVBDvrProtocol::available()
119     const
120 {
121     return 188;
122 }
123
124 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBDvrProtocol::clone()
125     const
126 {
127     return std::auto_ptr<SocketProtocol>(new DVBDvrProtocol());
128 }
129
130 ///////////////////////////////cc.e////////////////////////////////////////
131 #undef prefix_
132 //#include "DVBDemuxHandles.mpp"
133
134 \f
135 // Local Variables:
136 // mode: c++
137 // fill-column: 100
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"
142 // comment-column: 40
143 // End: