added adapter & device parameters to dvb handles
tho [Thu, 9 Aug 2007 08:07:28 +0000 (08:07 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@385 270642c3-0616-0410-b53a-bc976706d245

Examples/DVBAdapter/MPEdec.cc
Examples/DVBAdapter/ULEdec.cc
Examples/DVBAdapter/ULEdec.hh
Packets/MPEGDVBBundle/TransportPacket.test.cc
Socket/Protocols/DVB/DVBDemuxHandles.cc
Socket/Protocols/DVB/DVBDemuxHandles.hh
Socket/Protocols/DVB/DVBFrontendHandle.cc
Socket/Protocols/DVB/DVBFrontendHandle.hh

index f3fe77e..3a95687 100644 (file)
@@ -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));
index 9eccad3..edce523 100644 (file)
 
 #include "ULEdec.hh"
 
+#include <linux/dvb/dmx.h> 
 #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)) 
     {
index 4392574..7dcf9f8 100644 (file)
 
 // Definition of non-inline non-template functions
 
-#include <string>
-#include <iostream>
-#include <iomanip>
-#include <sys/ioctl.h>
-#include <linux/dvb/dmx.h> 
-
 #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;
index 98f020f..ee98b3c 100644 (file)
@@ -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,
index 2abb6f9..5ca2de0 100644 (file)
 //#include "DVBDemuxHandles.ih"
 
 // Custom includes
-#include <sys/types.h>
+#include <boost/format.hpp>
 #include <sys/socket.h>
-#include <iostream>
-#include <string>
 #include <sys/ioctl.h>
-#include <linux/sockios.h>
-#include <stdio.h>
 #include <fcntl.h>
-
 #include "Utils/Exception.hh"
 
 //#include "DVBDemuxHandles.mpp"
 ///////////////////////////////////////////////////////////////////////////
 // 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);
index 15093fc..341bf0b 100644 (file)
@@ -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 */
index 0799ec3..eda5a1b 100644 (file)
 //#include "DVBFrontendHandle.ih"
 
 // Custom includes
-#include <sys/types.h>
+#include <boost/format.hpp>
 #include <sys/socket.h>
-#include <iostream>
-#include <string>
 #include <sys/ioctl.h>
-#include <linux/sockios.h>
-#include <stdio.h>
 #include <fcntl.h>
-#include "Socket/SocketHandle.hh"
-
 #include "Utils/Exception.hh"
 
 //#include "DVBFrontendHandle.mpp"
 ///////////////////////////////////////////////////////////////////////////
 // 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);
index c1f628c..3e9dc8c 100644 (file)
@@ -27,6 +27,8 @@
 #define HH_DVBFrontendHandle_ 1
 
 // Custom includes
+#include <boost/cstdint.hpp>
+#include <linux/dvb/frontend.h> 
 #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 <linux/dvb/frontend.h> 
-
 //#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 */