add - untested - multituner support
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 15 Nov 2005 21:59:48 +0000 (21:59 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 15 Nov 2005 21:59:48 +0000 (21:59 +0000)
lib/dvb/demux.cpp
lib/dvb/demux.h
lib/dvb/dvb.cpp

index f52bb60..d2a2a54 100644 (file)
@@ -34,8 +34,35 @@ eDVBDemux::~eDVBDemux()
 {
 }
 
 {
 }
 
+int eDVBDemux::openDemux(void)
+{
+       char filename[128];
+#if HAVE_DVB_API_VERSION < 3
+       snprintf(filename, 128, "/dev/dvb/card%d/demux%d", adapter, demux);
+#else
+       snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", adapter, demux);
+#endif
+       return ::open(filename, O_RDWR);
+}
+
 DEFINE_REF(eDVBDemux)
 
 DEFINE_REF(eDVBDemux)
 
+RESULT eDVBDemux::setSourceFrontend(int fenum)
+{
+       int fd = openDemux();
+       int res = ::ioctl(fd, DMX_SET_SOURCE, DMX_SOURCE_FRONT0 + fenum);
+       ::close(fd);
+       return res;
+}
+
+RESULT eDVBDemux::setSourcePVR(int pvrnum)
+{
+       int fd = openDemux();
+       int res = ::ioctl(fd, DMX_SET_SOURCE, DMX_SOURCE_DVR0 + pvrnum);
+       ::close(fd);
+       return res;
+}
+
 RESULT eDVBDemux::createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)
 {
        RESULT res;
 RESULT eDVBDemux::createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)
 {
        RESULT res;
@@ -61,13 +88,7 @@ RESULT eDVBDemux::getMPEGDecoder(ePtr<iTSMPEGDecoder> &decoder)
 
 RESULT eDVBDemux::getSTC(pts_t &pts)
 {
 
 RESULT eDVBDemux::getSTC(pts_t &pts)
 {
-       char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       sprintf(filename, "/dev/dvb/card%d/demux%d", adapter, demux);
-#else
-       sprintf(filename, "/dev/dvb/adapter%d/demux%d", adapter, demux);
-#endif
-       int fd = ::open(filename, O_RDWR);
+       int fd = openDemux();
        
        if (fd < 0)
                return -ENODEV;
        
        if (fd < 0)
                return -ENODEV;
@@ -131,14 +152,7 @@ void eDVBSectionReader::data(int)
 eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux)
 {
        char filename[128];
 eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux)
 {
        char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
-#else
-       sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
-#endif
-       fd = ::open(filename, O_RDWR);
-       
-       eDebug("eDVBSectionReader has fd %d", fd);
+       fd = demux->openDemux();
        
        if (fd >= 0)
        {
        
        if (fd >= 0)
        {
@@ -345,16 +359,10 @@ RESULT eDVBTSRecorder::connectEvent(const Slot1<void,int> &event, ePtr<eConnecti
 
 RESULT eDVBTSRecorder::startPID(int pid)
 {
 
 RESULT eDVBTSRecorder::startPID(int pid)
 {
-       char filename[128];
-#if HAVE_DVB_API_VERSION < 3
-       snprintf(filename, 128, "/dev/dvb/card%d/demux%d", m_demux->adapter, m_demux->demux);
-#else
-       snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", m_demux->adapter, m_demux->demux);
-#endif
-       int fd = ::open(filename, O_RDWR);
+       int fd = m_demux->openDemux();
        if (fd < 0)
        {
        if (fd < 0)
        {
-               eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename);
+               eDebug("FAILED to open demux in ts recoder (%m)");
                return -1;
        }
 
                return -1;
        }
 
index 08d9f43..d3a369f 100644 (file)
@@ -6,23 +6,17 @@
 
 class eDVBDemux: public iDVBDemux
 {
 
 class eDVBDemux: public iDVBDemux
 {
-       int adapter, demux;
-       
-       int m_dvr_busy;
-       friend class eDVBSectionReader;
-       friend class eDVBAudio;
-       friend class eDVBVideo;
-       friend class eDVBPCR;
-       friend class eDVBTSRecorder;
-       friend class eDVBCAService;
-       Signal1<void, int> m_event;
+       DECLARE_REF(eDVBDemux);
 public:
        enum {
                evtFlush
        };
 public:
        enum {
                evtFlush
        };
-       DECLARE_REF(eDVBDemux);
        eDVBDemux(int adapter, int demux);
        virtual ~eDVBDemux();
        eDVBDemux(int adapter, int demux);
        virtual ~eDVBDemux();
+       
+       RESULT setSourceFrontend(int fenum);
+       RESULT setSourcePVR(int pvrnum);
+       
        RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
        RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
        RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader);
        RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
        RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
        RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader);
@@ -30,6 +24,19 @@ public:
        RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
        RESULT flush();
        RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
        RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
        RESULT flush();
        RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
+private:
+       int adapter, demux;
+       
+       int m_dvr_busy;
+       friend class eDVBSectionReader;
+       friend class eDVBAudio;
+       friend class eDVBVideo;
+       friend class eDVBPCR;
+       friend class eDVBTSRecorder;
+       friend class eDVBCAService;
+       Signal1<void, int> m_event;
+       
+       int openDemux(void);
 };
 
 class eDVBSectionReader: public iDVBSectionReader, public Object
 };
 
 class eDVBSectionReader: public iDVBSectionReader, public Object
index ed972bf..0201b33 100644 (file)
@@ -233,6 +233,10 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr<eDVBA
                if ((!i->m_inuse) && ((!fe) || (i->m_adapter == fe->m_adapter)))
                {
                        demux = new eDVBAllocatedDemux(i);
                if ((!i->m_inuse) && ((!fe) || (i->m_adapter == fe->m_adapter)))
                {
                        demux = new eDVBAllocatedDemux(i);
+                       if (fe)
+                               demux->get().setSourceFrontend(fe->m_frontend->getID());
+                       else
+                               demux->get().setSourcePVR(0);
                        eDebug("demux found");
                        return 0;
                }
                        eDebug("demux found");
                        return 0;
                }