added adapter & device parameters to dvb handles
[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 <boost/format.hpp>
31 #include <sys/socket.h>
32 #include <sys/ioctl.h>
33 #include <fcntl.h>
34 #include "Utils/Exception.hh"
35
36 //#include "DVBDemuxHandles.mpp"
37 #define prefix_
38 ///////////////////////////////cc.p////////////////////////////////////////
39
40 ///////////////////////////////////////////////////////////////////////////
41 // senf::DVBDemuxHandles
42
43 prefix_ void senf::DVBDemuxSectionProtocol::init_client(unsigned short adapter, unsigned short device)
44     const
45 {
46     std::string devDemux = str( boost::format(
47             "/dev/dvb/adapter%d/demux%d") % adapter % device);
48     int fd = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
49     if (fd < 0)
50         throw SystemException(errno);
51     body().fd(fd);
52 }
53
54 prefix_ unsigned senf::DVBDemuxSectionProtocol::available()
55     const
56 {
57     return 4096;
58 }
59
60 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBDemuxSectionProtocol::clone()
61     const
62 {
63     return std::auto_ptr<SocketProtocol>(new DVBDemuxSectionProtocol());
64 }
65
66 prefix_ void senf::DVBDemuxSectionProtocol::setSectionFilter(struct dmx_sct_filter_params *filter)
67     const
68 {
69     if (::ioctl(body().fd(), DMX_SET_FILTER, filter) < 0)
70         throw SystemException(errno);
71 }
72
73 // ----------------------------------------------------------------
74
75 prefix_ void senf::DVBDemuxPESProtocol::init_client(unsigned short adapter, unsigned short device)
76     const
77 {
78     std::string devDemux = str( boost::format(
79             "/dev/dvb/adapter%d/demux%d") % adapter % device);
80     int fd = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
81     if (fd < 0)
82         throw SystemException(errno);
83     body().fd(fd);
84 }
85
86 prefix_ unsigned senf::DVBDemuxPESProtocol::available()
87     const
88 {
89     return 4096; //???
90 }
91
92 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBDemuxPESProtocol::clone()
93     const
94 {
95     return std::auto_ptr<SocketProtocol>(new DVBDemuxPESProtocol());
96 }
97
98 prefix_ void senf::DVBDemuxPESProtocol::setPESFilter(struct dmx_pes_filter_params *filter)
99     const
100 {
101     if (::ioctl(body().fd(), DMX_SET_PES_FILTER, filter) < 0)
102         throw SystemException(errno);
103 }
104
105 // ----------------------------------------------------------------
106
107 prefix_ void senf::DVBDvrProtocol::init_client(unsigned short adapter, unsigned short device)
108     const
109 {
110     std::string devDvr = str( boost::format(
111             "/dev/dvb/adapter%d/dvr%d") % adapter % device);
112     int fd = open(devDvr.c_str(), 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: