ad938a7cc33decafcd325737b71d4b4fb358a8ba
[senf.git] / Socket / DVBSectionHandle.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 "DVBSectionHandle.hh"
28 //#include "DVBSectionHandle.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 "DVBSectionHandle.mpp"
43 #define prefix_
44 ///////////////////////////////cc.p////////////////////////////////////////
45
46 ///////////////////////////////////////////////////////////////////////////
47 // senf::DVBSectionProtocol
48
49 prefix_ void senf::DVBSectionProtocol::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::DVBSectionProtocol::available()
59     const
60 {
61     return 4096;
62 }
63
64 prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBSectionProtocol::clone()
65     const
66 {
67     return std::auto_ptr<SocketProtocol>(new DVBSectionProtocol());
68 }
69
70
71 prefix_ void senf::DVBSectionProtocol::setSectionFilter(
72         unsigned short pid,
73         unsigned char table_id)
74     const
75 {
76     struct dmx_sct_filter_params sec_filter;
77     memset(&sec_filter, 0, sizeof (struct dmx_sct_filter_params));
78     sec_filter.pid = pid;
79     sec_filter.filter.filter[0] = table_id;
80     sec_filter.filter.mask[0] = 0xff;
81     sec_filter.flags = DMX_IMMEDIATE_START;
82     sec_filter.flags |= DMX_CHECK_CRC;
83     setSectionFilter( &sec_filter );
84 }
85
86
87 prefix_ void senf::DVBSectionProtocol::setSectionFilter(struct dmx_sct_filter_params *filter)
88     const
89 {
90     if (::ioctl(body().fd(), DMX_SET_FILTER, filter) < 0)
91         throw SystemException(errno);
92 }
93
94 ///////////////////////////////cc.e////////////////////////////////////////
95 #undef prefix_
96 //#include "DVBSectionHandle.mpp"
97
98 \f
99 // Local Variables:
100 // mode: c++
101 // fill-column: 100
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"
106 // comment-column: 40
107 // End: