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