4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief DVBDemuxHandles non-inline non-template implementation */
31 #include "DVBDemuxHandles.hh"
32 //#include "DVBDemuxHandles.ih"
35 #include <boost/format.hpp>
36 #include <sys/socket.h>
37 #include <sys/ioctl.h>
39 #include <senf/Utils/Exception.hh>
42 //#include "DVBDemuxHandles.mpp"
44 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // senf::DVBDemuxHandles
49 prefix_ void senf::DVBDemuxSectionSocketProtocol::init_client(unsigned short adapter, unsigned short device)
52 std::string devDemux = str( boost::format("/dev/dvb/adapter%d/demux%d") % adapter % device);
53 int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
55 SENF_THROW_SYSTEM_EXCEPTION("Could not open demux device of DVB adapter ") << devDemux << ".";
60 prefix_ unsigned senf::DVBDemuxSectionSocketProtocol::available()
66 prefix_ void senf::DVBDemuxSectionSocketProtocol::setSectionFilter(unsigned short int pid, unsigned char filter, unsigned int flags, unsigned char mask, unsigned char mode, unsigned int timeout)
69 struct dmx_sct_filter_params sec_filter;
70 ::memset(&sec_filter, 0, sizeof(struct dmx_sct_filter_params));
72 sec_filter.filter.filter[0] = filter;
73 sec_filter.filter.mask[0] = mask;
74 sec_filter.filter.mode[0] = mode;
75 sec_filter.flags = flags;
77 if (::ioctl(fd(), DMX_SET_FILTER, &sec_filter) < 0)
78 SENF_THROW_SYSTEM_EXCEPTION("Could not set section filter of DVB adapter.");
81 // ----------------------------------------------------------------
83 prefix_ void senf::DVBDemuxPESSocketProtocol::init_client(unsigned short adapter, unsigned short device)
86 std::string devDemux = str( boost::format(
87 "/dev/dvb/adapter%d/demux%d") % adapter % device);
88 int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
90 SENF_THROW_SYSTEM_EXCEPTION("Could not open demux device of DVB adapter ") << devDemux << ".";
94 prefix_ unsigned senf::DVBDemuxPESSocketProtocol::available()
100 prefix_ void senf::DVBDemuxPESSocketProtocol::setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)
104 struct dmx_pes_filter_params pes_filter;
105 ::memset(&pes_filter, 0, sizeof(struct dmx_pes_filter_params));
106 pes_filter.pid = pid;
107 pes_filter.input = input;
108 pes_filter.output = output;
109 pes_filter.pes_type = pesType;
110 pes_filter.flags = flags;
112 if (::ioctl(fd(), DMX_SET_PES_FILTER, &pes_filter) < 0)
113 SENF_THROW_SYSTEM_EXCEPTION("Could not set PES filter of DVB adapter.");
116 // ----------------------------------------------------------------
118 prefix_ void senf::DVBDvrSocketProtocol::init_client(unsigned short adapter, unsigned short device)
121 std::string devDvr = str( boost::format(
122 "/dev/dvb/adapter%d/dvr%d") % adapter % device);
123 int f = open(devDvr.c_str(), O_RDONLY | O_NONBLOCK);
125 SENF_THROW_SYSTEM_EXCEPTION("Could not open dvr device of DVB adapter ") << devDvr << ".";
129 prefix_ unsigned senf::DVBDvrSocketProtocol::available()
135 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 //#include "DVBDemuxHandles.mpp"
143 // c-file-style: "senf"
144 // indent-tabs-mode: nil
145 // ispell-local-dictionary: "american"
146 // compile-command: "scons -u test"
147 // comment-column: 40