X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdvb_ci%2Fdvbci.cpp;h=0a32b8f2b18e488ccb0f3a4e2890ed7e560cf248;hp=a68edea83e52357177aa23dd8bda0ef6303f7f6f;hb=c8bba1502bb3809d55fade29a0a9566875aa8745;hpb=2f95f50608f64e18a0513ac2e1b713a603db0498 diff --git a/lib/dvb_ci/dvbci.cpp b/lib/dvb_ci/dvbci.cpp index a68edea..0a32b8f 100644 --- a/lib/dvb_ci/dvbci.cpp +++ b/lib/dvb_ci/dvbci.cpp @@ -200,43 +200,39 @@ int eDVBCIInterfaces::cancelEnq(int slotid) void eDVBCIInterfaces::ciRemoved(eDVBCISlot *slot) { - eDebug("CI Slot %d: removed... usecount %d", slot->getSlotID(), slot->use_count); - for (PMTHandlerList::iterator it(m_pmt_handlers.begin()); - it != m_pmt_handlers.end(); ++it) + if (slot->use_count) { - eServiceReferenceDVB ref; - it->pmthandler->getServiceReference(ref); - eDebugCI("check %s cislot %p %d\n", ref.toString().c_str(), it->cislot, it->cislot?it->cislot->getSlotID() : -1); - slot->removeService(ref.getServiceID().get()); - if (slot->use_count && !--slot->use_count) + eDebug("CI Slot %d: removed... usecount %d", slot->getSlotID(), slot->use_count); + for (PMTHandlerList::iterator it(m_pmt_handlers.begin()); + it != m_pmt_handlers.end(); ++it) { - if (slot->linked_next) - slot->linked_next->setSource(slot->current_source); - else // last CI in chain - setInputSource(slot->current_tuner, slot->current_source); - if (it->cislot == slot) // remove the base slot - { it->cislot = slot->linked_next; - eDebugCI("base removed.. so slot is now %p", it->cislot); - } - else + else if (it->cislot) { - eDebugCI("not base removed.. %d", it->cislot->getSlotID()); - eDVBCISlot *tmp = it->cislot; - while(tmp->linked_next != slot) - tmp = tmp->linked_next; - ASSERT(tmp); - if (slot->linked_next) - tmp->linked_next = slot->linked_next; - else - tmp->linked_next = 0; + eDVBCISlot *prevSlot = it->cislot, *hSlot = it->cislot->linked_next; + while (hSlot) + { + if (hSlot == slot) { + prevSlot->linked_next = slot->linked_next; + break; + } + prevSlot = hSlot; + hSlot = hSlot->linked_next; + } } - slot->linked_next=0; - slot->user_mapped=false; } + if (slot->linked_next) + slot->linked_next->setSource(slot->current_source); + else // last CI in chain + setInputSource(slot->current_tuner, slot->current_source); + slot->linked_next = 0; + slot->use_count=0; + slot->plugged=true; + slot->user_mapped=false; + slot->removeService(0xFFFF); + recheckPMTHandlers(); } - recheckPMTHandlers(); } static bool canDescrambleMultipleServices(int slotid) @@ -268,22 +264,22 @@ void eDVBCIInterfaces::recheckPMTHandlers() eDVBCISlot *tmp = it->cislot; eDVBServicePMTHandler *pmthandler = it->pmthandler; eDVBServicePMTHandler::program p; - bool first_plugged_cis_exist = false; + bool plugged_cis_exist = false; pmthandler->getServiceReference(ref); pmthandler->getService(service); eDebugCI("recheck %p %s", pmthandler, ref.toString().c_str()); for (eSmartPtrList::iterator ci_it(m_slots.begin()); ci_it != m_slots.end(); ++ci_it) - if (ci_it->first_plugged && ci_it->getCAManager()) + if (ci_it->plugged && ci_it->getCAManager()) { - eDebug("Slot %d first plugged", ci_it->getSlotID()); - ci_it->first_plugged = false; - first_plugged_cis_exist = true; + eDebug("Slot %d plugged", ci_it->getSlotID()); + ci_it->plugged = false; + plugged_cis_exist = true; } // check if this pmt handler has already assigned CI(s) .. and this CI(s) are already running - if (!first_plugged_cis_exist) + if (!plugged_cis_exist) { while(tmp) { @@ -581,7 +577,7 @@ void eDVBCIInterfaces::removePMTHandler(eDVBServicePMTHandler *pmthandler) { if (!sameServiceExist) { - if (slot->getNumOfServices() > 1) +// if (slot->getNumOfServices() > 1) { eDebug("[eDVBCIInterfaces] remove last pmt handler for service %s send empty capmt", service_to_remove.toString().c_str()); @@ -897,14 +893,14 @@ RESULT eDVBCIInterfaces::setDescrambleRules(int slotid, SWIG_PYOBJECT(ePyObject) { --size; ePyObject caid = PyList_GET_ITEM(caid_list, size); - if (!PyInt_Check(caid)) + if (!PyLong_Check(caid)) { char buf[255]; snprintf(buf, 255, "eDVBCIInterfaces::setDescrambleRules entry in caid list is not a long it is '%s'!!", PyObject_TypeStr(caid)); PyErr_SetString(PyExc_StandardError, buf); return -1; } - int tmpcaid = PyInt_AsLong(caid); + int tmpcaid = PyLong_AsLong(caid); if (tmpcaid > 0 && tmpcaid < 0x10000) slot->possible_caids.insert(tmpcaid); else @@ -921,13 +917,29 @@ PyObject *eDVBCIInterfaces::readCICaIds(int slotid) char tmp[255]; snprintf(tmp, 255, "eDVBCIInterfaces::readCICaIds try to get CAIds for CI Slot %d... but just %d slots are available", slotid, m_slots.size()); PyErr_SetString(PyExc_StandardError, tmp); - return 0; } - int idx=0; - ePyObject list = PyList_New(slot->possible_caids.size()); - for (caidSet::iterator it = slot->possible_caids.begin(); it != slot->possible_caids.end(); ++it) - PyList_SET_ITEM(list, idx++, PyLong_FromLong(*it)); - return list; + else + { + int idx=0; + eDVBCICAManagerSession *ca_manager = slot->getCAManager(); + const std::vector *ci_caids = ca_manager ? &ca_manager->getCAIDs() : 0; + ePyObject list = PyList_New(ci_caids ? ci_caids->size() : 0); + if (ci_caids) + { + for (std::vector::const_iterator it = ci_caids->begin(); it != ci_caids->end(); ++it) + PyList_SET_ITEM(list, idx++, PyLong_FromLong(*it)); + } + return list; + } + return 0; +} + +int eDVBCIInterfaces::setCIClockRate(int slotid, int rate) +{ + eDVBCISlot *slot = getSlot(slotid); + if (slot) + return slot->setClockRate(rate); + return -1; } int eDVBCISlot::send(const unsigned char *data, size_t len) @@ -1025,7 +1037,7 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr) use_count = 0; linked_next = 0; user_mapped = false; - first_plugged = true; + plugged = true; slotid = nr; @@ -1315,4 +1327,21 @@ int eDVBCISlot::setSource(data_source source) return 0; } +int eDVBCISlot::setClockRate(int rate) +{ + char buf[64]; + snprintf(buf, 64, "/proc/stb/tsmux/ci%d_tsclk", slotid); + FILE *ci = fopen(buf, "wb"); + if (ci) + { + if (rate) + fprintf(ci, "high"); + else + fprintf(ci, "normal"); + fclose(ci); + return 0; + } + return -1; +} + eAutoInitP0 init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");