From: tho Date: Thu, 9 Aug 2007 08:07:28 +0000 (+0000) Subject: added adapter & device parameters to dvb handles X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=74e753584f5271c3b9edffdb7ceee73a6a1de5c7;p=senf.git added adapter & device parameters to dvb handles git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@385 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBAdapter/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc index f3fe77e..3a95687 100644 --- a/Examples/DVBAdapter/MPEdec.cc +++ b/Examples/DVBAdapter/MPEdec.cc @@ -49,7 +49,8 @@ class MySniffer senf::DVBDemuxSectionHandle handle; public: - MySniffer() + MySniffer(unsigned short adapter=0, unsigned short device=0) + : handle( adapter, device ) { struct dmx_sct_filter_params sec_filter; memset(&sec_filter, 0, sizeof (struct dmx_sct_filter_params)); diff --git a/Examples/DVBAdapter/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc index 9eccad3..edce523 100644 --- a/Examples/DVBAdapter/ULEdec.cc +++ b/Examples/DVBAdapter/ULEdec.cc @@ -24,18 +24,19 @@ #include "ULEdec.hh" +#include #include "Packets/PacketData.hh" #include "Utils/hexdump.hh" #include "Utils/membind.hh" #define PID 271 -#define TS_SYNC 0x47 #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -ULEdec::ULEdec() +ULEdec::ULEdec(unsigned short adapter, unsigned short device) + : demuxHandle( adapter, device ), dvrHandle( adapter, device ) { struct dmx_pes_filter_params pes_filter; memset(&pes_filter, 0, sizeof (struct dmx_pes_filter_params)); @@ -60,7 +61,7 @@ void ULEdec::handleEvent(senf::FileHandle, senf::Scheduler::EventId event) dvrHandle.read( ts_packet.data() ); // Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control. - if ( (ts_packet->sync_byte() != TS_SYNC) || + if ( (ts_packet->sync_byte() != TRANSPORT_PACKET_SYNC_BYTE) || (ts_packet->transport_error_indicator() == true) || (ts_packet->transport_scrmbl_ctrl() != 0)) { diff --git a/Examples/DVBAdapter/ULEdec.hh b/Examples/DVBAdapter/ULEdec.hh index 4392574..7dcf9f8 100644 --- a/Examples/DVBAdapter/ULEdec.hh +++ b/Examples/DVBAdapter/ULEdec.hh @@ -22,12 +22,6 @@ // Definition of non-inline non-template functions -#include -#include -#include -#include -#include - #include "Scheduler/Scheduler.hh" #include "Packets/MPEGDVBBundle/TransportPacket.hh" #include "Packets/MPEGDVBBundle/SNDUPacket.hh" @@ -37,7 +31,7 @@ class ULEdec { public: - ULEdec(); + ULEdec(unsigned short adapter=0, unsigned short device=0); private: typedef senf::PacketData::iterator iterator; diff --git a/Packets/MPEGDVBBundle/TransportPacket.test.cc b/Packets/MPEGDVBBundle/TransportPacket.test.cc index 98f020f..ee98b3c 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.test.cc +++ b/Packets/MPEGDVBBundle/TransportPacket.test.cc @@ -38,7 +38,7 @@ using namespace senf; BOOST_AUTO_UNIT_TEST(transportPacket_packet) { - // TransportStream-Packet containing a MPE encoded section with an IPv6 ping packet, + // TransportStream-Packet containing a ULE encoded IPv6 ping packet, // captured with dvbsnoop unsigned char data[] = { 0x47, 0x41, 0x0f, 0x1e, 0x00, 0x80, 0x4c, 0x86, diff --git a/Socket/Protocols/DVB/DVBDemuxHandles.cc b/Socket/Protocols/DVB/DVBDemuxHandles.cc index 2abb6f9..5ca2de0 100644 --- a/Socket/Protocols/DVB/DVBDemuxHandles.cc +++ b/Socket/Protocols/DVB/DVBDemuxHandles.cc @@ -27,15 +27,10 @@ //#include "DVBDemuxHandles.ih" // Custom includes -#include +#include #include -#include -#include #include -#include -#include #include - #include "Utils/Exception.hh" //#include "DVBDemuxHandles.mpp" @@ -45,10 +40,12 @@ /////////////////////////////////////////////////////////////////////////// // senf::DVBDemuxHandles -prefix_ void senf::DVBDemuxSectionProtocol::init_client() +prefix_ void senf::DVBDemuxSectionProtocol::init_client(unsigned short adapter, unsigned short device) const { - int fd = open("/dev/dvb/adapter0/demux0", O_RDONLY | O_NONBLOCK); + std::string devDemux = str( boost::format( + "/dev/dvb/adapter%d/demux%d") % adapter % device); + int fd = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK); if (fd < 0) throw SystemException(errno); body().fd(fd); @@ -75,10 +72,12 @@ prefix_ void senf::DVBDemuxSectionProtocol::setSectionFilter(struct dmx_sct_filt // ---------------------------------------------------------------- -prefix_ void senf::DVBDemuxPESProtocol::init_client() +prefix_ void senf::DVBDemuxPESProtocol::init_client(unsigned short adapter, unsigned short device) const { - int fd = open("/dev/dvb/adapter0/demux0", O_RDONLY | O_NONBLOCK); + std::string devDemux = str( boost::format( + "/dev/dvb/adapter%d/demux%d") % adapter % device); + int fd = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK); if (fd < 0) throw SystemException(errno); body().fd(fd); @@ -105,10 +104,12 @@ prefix_ void senf::DVBDemuxPESProtocol::setPESFilter(struct dmx_pes_filter_param // ---------------------------------------------------------------- -prefix_ void senf::DVBDvrProtocol::init_client() +prefix_ void senf::DVBDvrProtocol::init_client(unsigned short adapter, unsigned short device) const { - int fd = open("/dev/dvb/adapter0/dvr0", O_RDONLY | O_NONBLOCK); + std::string devDvr = str( boost::format( + "/dev/dvb/adapter%d/dvr%d") % adapter % device); + int fd = open(devDvr.c_str(), O_RDONLY | O_NONBLOCK); if (fd < 0) throw SystemException(errno); body().fd(fd); diff --git a/Socket/Protocols/DVB/DVBDemuxHandles.hh b/Socket/Protocols/DVB/DVBDemuxHandles.hh index 15093fc..341bf0b 100644 --- a/Socket/Protocols/DVB/DVBDemuxHandles.hh +++ b/Socket/Protocols/DVB/DVBDemuxHandles.hh @@ -64,7 +64,7 @@ namespace senf { ///\name Constructors ///@{ - void init_client() const; ///< xxx + void init_client(unsigned short adapter=0, unsigned short device=0) const; ///< xxx /**< \note This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor */ @@ -99,7 +99,7 @@ namespace senf { ///\name Constructors ///@{ - void init_client() const; ///< xxx + void init_client(unsigned short adapter=0, unsigned short device=0) const; ///< xxx /**< \note This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor */ @@ -136,7 +136,7 @@ namespace senf { ///\name Constructors ///@{ - void init_client() const; ///< xxx + void init_client(unsigned short adapter=0, unsigned short device=0) const; ///< xxx /**< \note This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor */ diff --git a/Socket/Protocols/DVB/DVBFrontendHandle.cc b/Socket/Protocols/DVB/DVBFrontendHandle.cc index 0799ec3..eda5a1b 100644 --- a/Socket/Protocols/DVB/DVBFrontendHandle.cc +++ b/Socket/Protocols/DVB/DVBFrontendHandle.cc @@ -27,16 +27,10 @@ //#include "DVBFrontendHandle.ih" // Custom includes -#include +#include #include -#include -#include #include -#include -#include #include -#include "Socket/SocketHandle.hh" - #include "Utils/Exception.hh" //#include "DVBFrontendHandle.mpp" @@ -46,10 +40,12 @@ /////////////////////////////////////////////////////////////////////////// // senf::DVBFrontendHandle -prefix_ void senf::DVBFrontendProtocol::init_client() +prefix_ void senf::DVBFrontendProtocol::init_client(uint8_t adapter, boost::uint8_t device) const { - int fd = open("/dev/dvb/adapter0/frontend0", O_RDONLY | O_NONBLOCK); + std::string devFrontend = str( boost::format( + "/dev/dvb/adapter%d/frontend%d") % adapter % device); + int fd = open(devFrontend.c_str(), O_RDONLY | O_NONBLOCK); if (fd < 0) throw SystemException(errno); body().fd(fd); diff --git a/Socket/Protocols/DVB/DVBFrontendHandle.hh b/Socket/Protocols/DVB/DVBFrontendHandle.hh index c1f628c..3e9dc8c 100644 --- a/Socket/Protocols/DVB/DVBFrontendHandle.hh +++ b/Socket/Protocols/DVB/DVBFrontendHandle.hh @@ -27,6 +27,8 @@ #define HH_DVBFrontendHandle_ 1 // Custom includes +#include +#include #include "Socket/BufferingPolicy.hh" #include "Socket/FramingPolicy.hh" #include "Socket/CommunicationPolicy.hh" @@ -34,8 +36,6 @@ #include "Socket/ProtocolClientSocketHandle.hh" #include "Socket/SocketProtocol.hh" -#include - //#include "DVBFrontendHandle.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -65,7 +65,7 @@ namespace senf { ///\name Constructors ///@{ - void init_client() const; ///< xxx + void init_client(boost::uint8_t adapter=0, boost::uint8_t device=0) const; ///< xxx /**< \note This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor */