DVBDemuxHandles.cc

Go to the documentation of this file.
00001 // $Id: DVBDemuxHandles.cc 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Thorsten Horstmann <tho@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #include "DVBDemuxHandles.hh"
00027 //#include "DVBDemuxHandles.ih"
00028 
00029 // Custom includes
00030 #include <boost/format.hpp>
00031 #include <sys/socket.h>
00032 #include <sys/ioctl.h>
00033 #include <fcntl.h>
00034 #include <senf/Utils/Exception.hh>
00035 
00036 
00037 //#include "DVBDemuxHandles.mpp"
00038 #define prefix_
00039 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00040 
00041 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00042 // senf::DVBDemuxHandles
00043 
00044 prefix_ void senf::DVBDemuxSectionSocketProtocol::init_client(unsigned short adapter, unsigned short device)
00045     const
00046 {
00047     std::string devDemux = str( boost::format("/dev/dvb/adapter%d/demux%d") % adapter % device);
00048     int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
00049     if (f < 0) {
00050         SENF_THROW_SYSTEM_EXCEPTION("Could not open demux device of DVB adapter ") << devDemux << ".";
00051     }
00052     fd(f);
00053 }
00054 
00055 prefix_ unsigned senf::DVBDemuxSectionSocketProtocol::available()
00056     const
00057 {
00058     return 4096;
00059 }
00060 
00061 prefix_ void senf::DVBDemuxSectionSocketProtocol::setSectionFilter(unsigned short int pid, unsigned char filter, unsigned int flags, unsigned char mask, unsigned char mode, unsigned int timeout)
00062     const
00063 {
00064     struct dmx_sct_filter_params sec_filter;
00065     ::memset(&sec_filter, 0, sizeof(struct dmx_sct_filter_params));
00066     sec_filter.pid = pid;
00067     sec_filter.filter.filter[0] = filter;
00068     sec_filter.filter.mask[0] = mask;
00069     sec_filter.filter.mode[0] = mode;
00070     sec_filter.flags = flags;
00071 
00072     if (::ioctl(fd(), DMX_SET_FILTER, &sec_filter) < 0)
00073         SENF_THROW_SYSTEM_EXCEPTION("Could not set section filter of DVB adapter.");
00074 }
00075 
00076 // ----------------------------------------------------------------
00077 
00078 prefix_ void senf::DVBDemuxPESSocketProtocol::init_client(unsigned short adapter, unsigned short device)
00079     const
00080 {
00081     std::string devDemux = str( boost::format(
00082             "/dev/dvb/adapter%d/demux%d") % adapter % device);
00083     int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
00084     if (f < 0)
00085         SENF_THROW_SYSTEM_EXCEPTION("Could not open demux device of DVB adapter ") << devDemux << ".";
00086     fd(f);
00087 }
00088 
00089 prefix_ unsigned senf::DVBDemuxPESSocketProtocol::available()
00090     const
00091 {
00092     return 4096; //???
00093 }
00094 
00095 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)
00096     const
00097 {
00098 
00099     struct dmx_pes_filter_params pes_filter;
00100         ::memset(&pes_filter, 0, sizeof(struct dmx_pes_filter_params));
00101         pes_filter.pid = pid;
00102         pes_filter.input = input;
00103         pes_filter.output = output;
00104         pes_filter.pes_type = pesType;
00105         pes_filter.flags = flags;
00106 
00107     if (::ioctl(fd(), DMX_SET_PES_FILTER, &pes_filter) < 0)
00108         SENF_THROW_SYSTEM_EXCEPTION("Could not set PES filter of DVB adapter.");
00109 }
00110 
00111 // ----------------------------------------------------------------
00112 
00113 prefix_ void senf::DVBDvrSocketProtocol::init_client(unsigned short adapter, unsigned short device)
00114     const
00115 {
00116     std::string devDvr = str( boost::format(
00117             "/dev/dvb/adapter%d/dvr%d") % adapter % device);
00118     int f = open(devDvr.c_str(), O_RDONLY | O_NONBLOCK);
00119     if (f < 0)
00120         SENF_THROW_SYSTEM_EXCEPTION("Could not open dvr device of DVB adapter ") << devDvr << ".";
00121     fd(f);
00122 }
00123 
00124 prefix_ unsigned senf::DVBDvrSocketProtocol::available()
00125     const
00126 {
00127     return 188;
00128 }
00129 
00130 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00131 #undef prefix_
00132 //#include "DVBDemuxHandles.mpp"
00133 
00134 
00135 // Local Variables:
00136 // mode: c++
00137 // fill-column: 100
00138 // c-file-style: "senf"
00139 // indent-tabs-mode: nil
00140 // ispell-local-dictionary: "american"
00141 // compile-command: "scons -u test"
00142 // comment-column: 40
00143 // End: