e54b3f92c17ed185a6152c5dbbf5461556d87dfb
[senf.git] / Socket / Protocols / DVB / DVBDemuxHandles.cc
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 //     Thorsten Horstmann <tho@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 /** \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 f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
49     if (f < 0)
50         throwErrno();
51     fd(f);
52 }
53
54 prefix_ unsigned senf::DVBDemuxSectionProtocol::available()
55     const
56 {
57     return 4096;
58 }
59
60 prefix_ void senf::DVBDemuxSectionProtocol::setSectionFilter(struct dmx_sct_filter_params *filter)
61     const
62 {
63     if (::ioctl(fd(), DMX_SET_FILTER, filter) < 0)
64         throwErrno();
65 }
66
67 // ----------------------------------------------------------------
68
69 prefix_ void senf::DVBDemuxPESProtocol::init_client(unsigned short adapter, unsigned short device)
70     const
71 {
72     std::string devDemux = str( boost::format(
73             "/dev/dvb/adapter%d/demux%d") % adapter % device);
74     int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
75     if (f < 0)
76         throwErrno();
77     fd(f);
78 }
79
80 prefix_ unsigned senf::DVBDemuxPESProtocol::available()
81     const
82 {
83     return 4096; //???
84 }
85
86 prefix_ void senf::DVBDemuxPESProtocol::setPESFilter(struct dmx_pes_filter_params *filter)
87     const
88 {
89     if (::ioctl(fd(), DMX_SET_PES_FILTER, filter) < 0)
90         throwErrno();
91 }
92
93 // ----------------------------------------------------------------
94
95 prefix_ void senf::DVBDvrProtocol::init_client(unsigned short adapter, unsigned short device)
96     const
97 {
98     std::string devDvr = str( boost::format(
99             "/dev/dvb/adapter%d/dvr%d") % adapter % device);
100     int f = open(devDvr.c_str(), O_RDONLY | O_NONBLOCK);
101     if (f < 0)
102         throwErrno();
103     fd(f);
104 }
105
106 prefix_ unsigned senf::DVBDvrProtocol::available()
107     const
108 {
109     return 188;
110 }
111
112 ///////////////////////////////cc.e////////////////////////////////////////
113 #undef prefix_
114 //#include "DVBDemuxHandles.mpp"
115
116 \f
117 // Local Variables:
118 // mode: c++
119 // fill-column: 100
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // comment-column: 40
125 // End: