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