[DVBCI] Fix to work dvbci on vtuner.
authorhschang <chang@dev3>
Wed, 14 Jun 2017 06:41:50 +0000 (15:41 +0900)
committerhschang <chang@dev3>
Wed, 14 Jun 2017 06:41:50 +0000 (15:41 +0900)
lib/dvb/Makefile.am
lib/dvb/ecm.cpp [new file with mode: 0644]
lib/dvb/ecm.h [new file with mode: 0644]
lib/dvb_ci/dvbci.cpp
lib/dvb_ci/dvbci.h

index f4216d9..00fdd53 100644 (file)
@@ -29,6 +29,7 @@ libenigma_dvb_a_SOURCES = \
        sec.cpp \
        subtitle.cpp \
        teletext.cpp \
        sec.cpp \
        subtitle.cpp \
        teletext.cpp \
+       ecm.cpp \
        tstools.cpp \
        volume.cpp \
        fbc.cpp \
        tstools.cpp \
        volume.cpp \
        fbc.cpp \
@@ -63,6 +64,7 @@ dvbinclude_HEADERS = \
        specs.h \
        subtitle.h \
        teletext.h \
        specs.h \
        subtitle.h \
        teletext.h \
+       ecm.h \
        tstools.h \
        volume.h \
        fbc.h \
        tstools.h \
        volume.h \
        fbc.h \
diff --git a/lib/dvb/ecm.cpp b/lib/dvb/ecm.cpp
new file mode 100644 (file)
index 0000000..ff9bb59
--- /dev/null
@@ -0,0 +1,58 @@
+#include <lib/base/eerror.h>
+#include <lib/dvb/ecm.h>
+#include <lib/dvb/idemux.h>
+#include <lib/gdi/gpixmap.h>
+
+
+DEFINE_REF(eDVBECMParser);
+
+
+
+eDVBECMParser::eDVBECMParser(iDVBDemux *demux)
+{
+       
+       if (demux->createPESReader(eApp, m_pes_reader))
+               eDebug("failed to create ECM PES reader!");
+       else
+               m_pes_reader->connectRead(slot(*this, &eDVBECMParser::processData), m_read_connection);
+}
+
+eDVBECMParser::~eDVBECMParser()
+{
+}
+
+
+
+int eDVBECMParser::start(int pid)
+{
+
+
+       if (m_pes_reader)
+       {
+               m_pid = pid;
+               return m_pes_reader->start(pid);
+       }
+       else
+               return -1;
+}
+
+int eDVBECMParser::stop()
+{
+       if (m_pes_reader)
+       {
+               eDebug("stop ecm");
+               return m_pes_reader->stop();
+       }
+       return -1;
+}
+
+void eDVBECMParser::processData(const __u8 *p, int len)
+{
+}
+
+void eDVBECMParser::processPESPacket(__u8 *pkt, int len)
+{
+}
+
+
diff --git a/lib/dvb/ecm.h b/lib/dvb/ecm.h
new file mode 100644 (file)
index 0000000..f0cd5f2
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef __lib_dvb_ecm_h
+#define __lib_dvb_ecm_h
+
+#include <lib/base/object.h>
+#include <lib/dvb/idvb.h>
+#include <lib/dvb/pesparse.h>
+#include <lib/dvb/pmt.h>
+#include <lib/gdi/gpixmap.h>
+#include <map>
+
+
+class eDVBECMParser: public iObject, public ePESParser, public Object
+{
+       DECLARE_REF(eDVBECMParser);
+public:
+       eDVBECMParser(iDVBDemux *demux);
+       virtual ~eDVBECMParser();
+       int start(int pid);
+       int stop();     
+       void processData(const __u8 *p, int len);
+private:
+       void processPESPacket(__u8 *pkt, int len);      
+       int m_pid;
+       
+       ePtr<iDVBPESReader> m_pes_reader;
+       ePtr<eConnection> m_read_connection;
+       
+};
+
+#endif
index cd59eda..60a64dd 100644 (file)
@@ -225,7 +225,10 @@ void eDVBCIInterfaces::ciRemoved(eDVBCISlot *slot)
                if (slot->linked_next)
                        slot->linked_next->setSource(slot->current_source);
                else // last CI in chain
                if (slot->linked_next)
                        slot->linked_next->setSource(slot->current_source);
                else // last CI in chain
+               {
                        setInputSource(slot->current_tuner, slot->current_source);
                        setInputSource(slot->current_tuner, slot->current_source);
+                       slot->removeVtunerPid();
+               }
                slot->linked_next = 0;
                slot->use_count=0;
                slot->plugged=true;
                slot->linked_next = 0;
                slot->use_count=0;
                slot->plugged=true;
@@ -389,6 +392,7 @@ void eDVBCIInterfaces::recheckPMTHandlers()
                                                        eDebug("The CI in Slot %d has said it can handle caid %04x... so use it", ci_it->getSlotID(), *z);
                                                        useThis = true;
                                                        user_mapped = false;
                                                        eDebug("The CI in Slot %d has said it can handle caid %04x... so use it", ci_it->getSlotID(), *z);
                                                        useThis = true;
                                                        user_mapped = false;
+                                                       ci_it->addVtunerPid(pmthandler);
                                                        break;
                                                }
                                        }
                                                        break;
                                                }
                                        }
@@ -495,7 +499,7 @@ void eDVBCIInterfaces::recheckPMTHandlers()
                                                data_source tuner_source = TUNER_A;
                                                switch (tunernum)
                                                {
                                                data_source tuner_source = TUNER_A;
                                                switch (tunernum)
                                                {
-                                                       case 0 ... 18:
+                                                       case 0 ... 22:
                                                                tuner_source = (data_source)tunernum;
                                                                break;
                                                        default:
                                                                tuner_source = (data_source)tunernum;
                                                                break;
                                                        default:
@@ -592,7 +596,10 @@ void eDVBCIInterfaces::removePMTHandler(eDVBServicePMTHandler *pmthandler)
                                if (slot->linked_next)
                                        slot->linked_next->setSource(slot->current_source);
                                else
                                if (slot->linked_next)
                                        slot->linked_next->setSource(slot->current_source);
                                else
+                               {
                                        setInputSource(slot->current_tuner, slot->current_source);
                                        setInputSource(slot->current_tuner, slot->current_source);
+                                       slot->removeVtunerPid();
+                               }
 
                                if (base_slot != slot)
                                {
 
                                if (base_slot != slot)
                                {
@@ -645,7 +652,7 @@ int eDVBCIInterfaces::getMMIState(int slotid)
        return slot->getMMIState();
 }
 
        return slot->getMMIState();
 }
 
-static const char *tuner_source[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "CI0", "CI1", "CI2", "CI3"};
+static const char *tuner_source[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "CI0", "CI1", "CI2", "CI3"};
 
 int eDVBCIInterfaces::setInputSource(int tuner_no, data_source source)
 {
 
 int eDVBCIInterfaces::setInputSource(int tuner_no, data_source source)
 {
@@ -1039,6 +1046,13 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
        {
                perror(filename);
        }
        {
                perror(filename);
        }
+
+       for(int i = 0; i < NUM_OF_ECM ; i++)
+       {
+               m_ecm[i] = 0;
+       }
+       ecm_num = 0;
+       
 }
 
 eDVBCISlot::~eDVBCISlot()
 }
 
 eDVBCISlot::~eDVBCISlot()
@@ -1306,4 +1320,42 @@ int eDVBCISlot::setClockRate(int rate)
        return -1;
 }
 
        return -1;
 }
 
+void eDVBCISlot::addVtunerPid(eDVBServicePMTHandler *pmthandler)
+{
+       ePtr<iDVBDemux> demux;
+       eDVBServicePMTHandler::program p;
+               
+       if (!pmthandler->getDataDemux(demux) && !ecm_num)
+       {
+       
+               if (!pmthandler->getProgramInfo(p))
+               {
+                       for (std::list<eDVBServicePMTHandler::program::capid_pair>::const_iterator i(p.caids.begin());
+                                               i != p.caids.end(); ++i)
+                       {
+                               if (i->capid >= 0)
+                               {
+                                       eDebug("PES Start ECM PID = %d Caid = %d ecm_num=%d", i->capid, i->caid, ecm_num);
+                                       m_ecm[ecm_num] = new eDVBECMParser(demux);
+                                       m_ecm[ecm_num++]->start(i->capid);
+                               }
+                       }
+               }
+       }
+
+}
+
+void eDVBCISlot::removeVtunerPid(void)
+{
+       for(int i = 0; i < ecm_num ; i++)
+       {
+               if(m_ecm[i])
+               {
+                       m_ecm[i]->stop();
+                       m_ecm[i] = 0;
+               }
+       }
+       ecm_num = 0;
+}
+
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");
index ec82ec2..4a49d7c 100644 (file)
@@ -4,6 +4,7 @@
 #ifndef SWIG
 
 #include <lib/base/ebase.h>
 #ifndef SWIG
 
 #include <lib/base/ebase.h>
+#include <lib/dvb/ecm.h>
 #include <lib/service/iservice.h>
 #include <lib/python/python.h>
 #include <set>
 #include <lib/service/iservice.h>
 #include <lib/python/python.h>
 #include <set>
@@ -35,7 +36,7 @@ struct queueData
 
 enum data_source
 {
 
 enum data_source
 {
-       TUNER_A=0, TUNER_B, TUNER_C, TUNER_D, TUNER_E, TUNER_F, TUNER_G, TUNER_H, TUNER_I, TUNER_J, TUNER_K, TUNER_L, TUNER_M, TUNER_N, TUNER_O, TUNER_P, TUNER_Q, TUNER_R, CI_A, CI_B, CI_C, CI_D
+       TUNER_A=0, TUNER_B, TUNER_C, TUNER_D, TUNER_E, TUNER_F, TUNER_G, TUNER_H, TUNER_I, TUNER_J, TUNER_K, TUNER_L, TUNER_M, TUNER_N, TUNER_O, TUNER_P, TUNER_Q, TUNER_R, TUNER_S, TUNER_T, TUNER_U, TUNER_V, CI_A, CI_B, CI_C, CI_D
 };
 
 typedef std::pair<std::string, uint32_t> providerPair;
 };
 
 typedef std::pair<std::string, uint32_t> providerPair;
@@ -66,6 +67,10 @@ class eDVBCISlot: public iObject, public Object
        bool user_mapped;
        void data(int);
        bool plugged;
        bool user_mapped;
        void data(int);
        bool plugged;
+
+#define NUM_OF_ECM             32
+       ePtr<eDVBECMParser> m_ecm[NUM_OF_ECM];
+       int ecm_num;
 public:
        enum {stateRemoved, stateInserted, stateInvalid, stateResetted};
        eDVBCISlot(eMainloop *context, int nr);
 public:
        enum {stateRemoved, stateInserted, stateInvalid, stateResetted};
        eDVBCISlot(eMainloop *context, int nr);
@@ -95,6 +100,8 @@ public:
        int getNumOfServices() { return running_services.size(); }
        int setSource(data_source source);
        int setClockRate(int);
        int getNumOfServices() { return running_services.size(); }
        int setSource(data_source source);
        int setClockRate(int);
+       void addVtunerPid(eDVBServicePMTHandler *pmthandler);
+       void removeVtunerPid(void);
 };
 
 struct CIPmtHandler
 };
 
 struct CIPmtHandler