add possibility to set demux buffer size for PES Reader, Section Reader and TS Recorder
authorghost <andreas.monzner@multimedia-labs.de>
Wed, 20 Oct 2010 22:24:44 +0000 (00:24 +0200)
committerghost <andreas.monzner@multimedia-labs.de>
Wed, 20 Oct 2010 22:25:20 +0000 (00:25 +0200)
lib/dvb/demux.cpp
lib/dvb/demux.h
lib/dvb/idemux.h

index 4fba8fa85b8359b1c2ac0f2d7fd28e8bf072c2c2..081059b95bc8a5bd949493930d8e940a2732f8f8 100644 (file)
@@ -247,6 +247,14 @@ eDVBSectionReader::~eDVBSectionReader()
                ::close(fd);
 }
 
+RESULT eDVBSectionReader::setBufferSize(int size)
+{
+       int res=::ioctl(fd, DMX_SET_BUFFER_SIZE, size);
+       if (res < 0)
+               eDebug("eDVBSectionReader DMX_SET_BUFFER_SIZE failed(%m)");
+       return res;
+}
+
 RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask)
 {
        RESULT res;
@@ -279,8 +287,7 @@ RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask)
        memcpy(sct.filter.mask, mask.mask, DMX_FILTER_SIZE);
 #if HAVE_DVB_API_VERSION >= 3
        memcpy(sct.filter.mode, mask.mode, DMX_FILTER_SIZE);
-       if (::ioctl(fd, DMX_SET_BUFFER_SIZE, 8192*8) < 0)
-               eDebug("DMX_SET_BUFFER_SIZE failed(%m)");
+       setBufferSize(8192*8);
 #endif
        
        res = ::ioctl(fd, DMX_SET_FILTER, &sct);
@@ -352,7 +359,7 @@ eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res):
        
        if (m_fd >= 0)
        {
-               ::ioctl(m_fd, DMX_SET_BUFFER_SIZE, 64*1024);
+               setBufferSize(64*1024);
                ::fcntl(m_fd, F_SETFL, O_NONBLOCK);
                m_notifier = eSocketNotifier::create(context, m_fd, eSocketNotifier::Read, false);
                CONNECT(m_notifier->activated, eDVBPESReader::data);
@@ -364,6 +371,14 @@ eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res):
        }
 }
 
+RESULT eDVBPESReader::setBufferSize(int size)
+{
+       int res = ::ioctl(m_fd, DMX_SET_BUFFER_SIZE, size);
+       if (res < 0)
+               eDebug("eDVBPESReader DMX_SET_BUFFER_SIZE failed(%m)");
+       return res;
+}
+
 DEFINE_REF(eDVBPESReader)
 
 eDVBPESReader::~eDVBPESReader()
@@ -484,7 +499,7 @@ eDVBTSRecorder::eDVBTSRecorder(eDVBDemux *demux): m_demux(demux)
        m_running = 0;
        m_target_fd = -1;
        m_thread = new eDVBRecordFileThread();
-  CONNECT(m_thread->m_event, eDVBTSRecorder::filepushEvent);
+       CONNECT(m_thread->m_event, eDVBTSRecorder::filepushEvent);
 #ifndef HAVE_ADD_PID
        m_demux->m_dvr_busy = 1;
 #endif
@@ -536,8 +551,8 @@ RESULT eDVBTSRecorder::start()
                eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename);
                return -3;
        }
-       
-       ::ioctl(m_source_fd, DMX_SET_BUFFER_SIZE, 1024*1024);
+
+       setBufferSize(1024*1024);
 
        dmx_pes_filter_params flt;
 #if HAVE_DVB_API_VERSION > 3
@@ -577,6 +592,14 @@ RESULT eDVBTSRecorder::start()
        return 0;
 }
 
+RESULT eDVBTSRecorder::setBufferSize(int size)
+{
+       int res = ::ioctl(m_source_fd, DMX_SET_BUFFER_SIZE, size);
+       if (res < 0)
+               eDebug("eDVBTSRecorder DMX_SET_BUFFER_SIZE failed(%m)");
+       return res;
+}
+
 RESULT eDVBTSRecorder::addPID(int pid)
 {
        if (m_pids.find(pid) != m_pids.end())
index 7a697d49db27b5473db29b4d07b77bf800a5202f..d43c41bb6733cee2760cef8fc7992f12363b2755 100644 (file)
@@ -56,9 +56,9 @@ class eDVBSectionReader: public iDVBSectionReader, public Object
        void data(int);
        ePtr<eSocketNotifier> notifier;
 public:
-       
        eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
        virtual ~eDVBSectionReader();
+       RESULT setBufferSize(int size);
        RESULT start(const eDVBSectionFilterMask &mask);
        RESULT stop();
        RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn);
@@ -76,6 +76,7 @@ class eDVBPESReader: public iDVBPESReader, public Object
 public:
        eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
        virtual ~eDVBPESReader();
+       RESULT setBufferSize(int size);
        RESULT start(int pid);
        RESULT stop();
        RESULT connectRead(const Slot2<void,const __u8*, int> &read, ePtr<eConnection> &conn);
@@ -90,6 +91,7 @@ public:
        eDVBTSRecorder(eDVBDemux *demux);
        ~eDVBTSRecorder();
 
+       RESULT setBufferSize(int size);
        RESULT start();
        RESULT addPID(int pid);
        RESULT removePID(int pid);
index e92b1e75c6df7e89442a7cfc25b10d006774992f..86b35fdb0d42c676614921ec5efa31b90e47423c 100644 (file)
@@ -6,6 +6,7 @@
 class iDVBSectionReader: public iObject
 {
 public:
+       virtual RESULT setBufferSize(int size)=0;
        virtual RESULT start(const eDVBSectionFilterMask &mask)=0;
        virtual RESULT stop()=0;
        virtual RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn)=0;
@@ -15,6 +16,7 @@ public:
 class iDVBPESReader: public iObject
 {
 public:
+       virtual RESULT setBufferSize(int size)=0;
        virtual RESULT start(int pid)=0;
        virtual RESULT stop()=0;
        virtual RESULT connectRead(const Slot2<void,const __u8*, int> &read, ePtr<eConnection> &conn)=0;
@@ -26,6 +28,7 @@ public:
 class iDVBTSRecorder: public iObject
 {
 public:
+       virtual RESULT setBufferSize(int size) = 0;
        virtual RESULT start() = 0;
        virtual RESULT addPID(int pid) = 0;
        virtual RESULT removePID(int pid) = 0;