From 50e7a4d8e274532c6b0519d48f91a13757c7eaeb Mon Sep 17 00:00:00 2001 From: hschang Date: Wed, 14 Jun 2017 15:41:50 +0900 Subject: [PATCH] [DVBCI] Fix to work dvbci on vtuner. --- lib/dvb/Makefile.am | 2 ++ lib/dvb/ecm.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/dvb/ecm.h | 30 +++++++++++++++++++++++++++ lib/dvb_ci/dvbci.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- lib/dvb_ci/dvbci.h | 9 +++++++- 5 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 lib/dvb/ecm.cpp create mode 100644 lib/dvb/ecm.h diff --git a/lib/dvb/Makefile.am b/lib/dvb/Makefile.am index f4216d9..00fdd53 100644 --- a/lib/dvb/Makefile.am +++ b/lib/dvb/Makefile.am @@ -29,6 +29,7 @@ libenigma_dvb_a_SOURCES = \ sec.cpp \ subtitle.cpp \ teletext.cpp \ + ecm.cpp \ tstools.cpp \ volume.cpp \ fbc.cpp \ @@ -63,6 +64,7 @@ dvbinclude_HEADERS = \ specs.h \ subtitle.h \ teletext.h \ + ecm.h \ tstools.h \ volume.h \ fbc.h \ diff --git a/lib/dvb/ecm.cpp b/lib/dvb/ecm.cpp new file mode 100644 index 0000000..ff9bb59 --- /dev/null +++ b/lib/dvb/ecm.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include + + + +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 index 0000000..f0cd5f2 --- /dev/null +++ b/lib/dvb/ecm.h @@ -0,0 +1,30 @@ +#ifndef __lib_dvb_ecm_h +#define __lib_dvb_ecm_h + +#include +#include +#include +#include +#include +#include + + +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 m_pes_reader; + ePtr m_read_connection; + +}; + +#endif diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index cd59eda..60a64dd 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -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 + { setInputSource(slot->current_tuner, slot->current_source); + slot->removeVtunerPid(); + } 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; + ci_it->addVtunerPid(pmthandler); break; } } @@ -495,7 +499,7 @@ void eDVBCIInterfaces::recheckPMTHandlers() data_source tuner_source = TUNER_A; switch (tunernum) { - case 0 ... 18: + case 0 ... 22: 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 + { setInputSource(slot->current_tuner, slot->current_source); + slot->removeVtunerPid(); + } if (base_slot != slot) { @@ -645,7 +652,7 @@ int eDVBCIInterfaces::getMMIState(int slotid) 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) { @@ -1039,6 +1046,13 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) { perror(filename); } + + for(int i = 0; i < NUM_OF_ECM ; i++) + { + m_ecm[i] = 0; + } + ecm_num = 0; + } eDVBCISlot::~eDVBCISlot() @@ -1306,4 +1320,42 @@ int eDVBCISlot::setClockRate(int rate) return -1; } +void eDVBCISlot::addVtunerPid(eDVBServicePMTHandler *pmthandler) +{ + ePtr demux; + eDVBServicePMTHandler::program p; + + if (!pmthandler->getDataDemux(demux) && !ecm_num) + { + + if (!pmthandler->getProgramInfo(p)) + { + for (std::list::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 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots"); diff --git a/lib/dvb_ci/dvbci.h b/lib/dvb_ci/dvbci.h index ec82ec2..4a49d7c 100644 --- a/lib/dvb_ci/dvbci.h +++ b/lib/dvb_ci/dvbci.h @@ -4,6 +4,7 @@ #ifndef SWIG #include +#include #include #include #include @@ -35,7 +36,7 @@ struct queueData 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 providerPair; @@ -66,6 +67,10 @@ class eDVBCISlot: public iObject, public Object bool user_mapped; void data(int); bool plugged; + +#define NUM_OF_ECM 32 + ePtr m_ecm[NUM_OF_ECM]; + int ecm_num; 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); + void addVtunerPid(eDVBServicePMTHandler *pmthandler); + void removeVtunerPid(void); }; struct CIPmtHandler -- 2.7.4