fix resend capmt when ci is plugged into the slot
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 29 Nov 2005 23:32:01 +0000 (23:32 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Tue, 29 Nov 2005 23:32:01 +0000 (23:32 +0000)
lib/dvb_ci/dvbci.cpp
lib/dvb_ci/dvbci.h
lib/dvb_ci/dvbci_appmgr.cpp
lib/dvb_ci/dvbci_camgr.cpp
lib/dvb_ci/dvbci_mmi.cpp
lib/dvb_ci/dvbci_session.cpp

index 9a551df0e5ddfa81ab16e59ba7d083cb3b33c106..b15fcce39fdecaa8f4a54d4d8dde7deaeb9316ad 100644 (file)
@@ -83,22 +83,32 @@ int eDVBCIInterfaces::enableTS(int slotid, int enable)
        if( (slot = getSlot(slotid)) == 0 )
                return -1;
 
        if( (slot = getSlot(slotid)) == 0 )
                return -1;
 
-       if (enable)
+       return slot->enableTS(enable);
+}
+
+int eDVBCIInterfaces::initialize(int slotid)
+{
+       eDVBCISlot *slot;
+
+       if( (slot = getSlot(slotid)) == 0 )
+               return -1;
+
+       slot->resetPrevSentCAPMTVersion();
+       PMTHandlerList::iterator it = m_pmt_handlers.begin();
+       while (it != m_pmt_handlers.end())
        {
        {
-               slot->resetPrevSentCAPMTVersion();
-               PMTHandlerList::iterator it = m_pmt_handlers.begin();
-               while (it != m_pmt_handlers.end())
+               if ( it->cislot == slot )
                {
                {
-                       if ( it->cislot == slot )
-                               slot->sendCAPMT(it->pmthandler);  // send capmt
-                       ++it;
+                       slot->sendCAPMT(it->pmthandler);  // send capmt
+                       break;
                }
                }
+               ++it;
        }
 
        }
 
-       return slot->enableTS(enable);
+       return slot->initialize();
 }
 
 }
 
-int eDVBCIInterfaces::initialize(int slotid)
+int eDVBCIInterfaces::sendCAPMT(int slotid)
 {
        eDVBCISlot *slot;
 
 {
        eDVBCISlot *slot;
 
@@ -110,11 +120,14 @@ int eDVBCIInterfaces::initialize(int slotid)
        while (it != m_pmt_handlers.end())
        {
                if ( it->cislot == slot )
        while (it != m_pmt_handlers.end())
        {
                if ( it->cislot == slot )
+               {
                        slot->sendCAPMT(it->pmthandler);  // send capmt
                        slot->sendCAPMT(it->pmthandler);  // send capmt
+                       return 0;
+               }
                ++it;
        }
 
                ++it;
        }
 
-       return slot->initialize();
+       return -1;
 }
 
 int eDVBCIInterfaces::startMMI(int slotid)
 }
 
 int eDVBCIInterfaces::startMMI(int slotid)
@@ -213,7 +226,7 @@ void eDVBCIInterfaces::removePMTHandler(eDVBServicePMTHandler *pmthandler)
        if (it != m_pmt_handlers.end())
        {
                eDVBCISlot *slot = it->cislot;
        if (it != m_pmt_handlers.end())
        {
                eDVBCISlot *slot = it->cislot;
-               eDVBServicePMTHandler *pmthandler = it->pmthandler;
+//             eDVBServicePMTHandler *pmthandler = it->pmthandler;
                m_pmt_handlers.erase(it);
                if (slot && !--slot->use_count)
                {
                m_pmt_handlers.erase(it);
                if (slot && !--slot->use_count)
                {
@@ -362,6 +375,21 @@ eDVBCISlot::~eDVBCISlot()
        enableTS(0);
 }
 
        enableTS(0);
 }
 
+void eDVBCISlot::setAppManager( eDVBCIApplicationManagerSession *session )
+{
+       application_manager=session;
+}
+
+void eDVBCISlot::setMMIManager( eDVBCIMMISession *session )
+{
+       mmi_session = session;
+}
+
+void eDVBCISlot::setCAManager( eDVBCICAManagerSession *session )
+{
+       ca_manager = session;
+}
+
 int eDVBCISlot::getSlotID()
 {
        return slotid;
 int eDVBCISlot::getSlotID()
 {
        return slotid;
@@ -445,7 +473,7 @@ int eDVBCISlot::sendCAPMT(eDVBServicePMTHandler *pmthandler, const std::vector<u
                eDebug("no ca_manager (no CI plugged?)");
                return -1;
        }
                eDebug("no ca_manager (no CI plugged?)");
                return -1;
        }
-       const std::vector<uint16_t> &caids = ids.empty() && ca_manager ? ca_manager->getCAIDs() : ids;
+       const std::vector<uint16_t> &caids = ids.empty() ? ca_manager->getCAIDs() : ids;
        ePtr<eTable<ProgramMapSection> > ptr;
        if (pmthandler->getPMT(ptr))
                return -1;
        ePtr<eTable<ProgramMapSection> > ptr;
        if (pmthandler->getPMT(ptr))
                return -1;
@@ -523,5 +551,9 @@ int eDVBCISlot::enableTS(int enable)
        return 0;
 }
 
        return 0;
 }
 
+void eDVBCISlot::resendCAPMT()
+{
+       eDVBCIInterfaces::getInstance()->sendCAPMT(slotid);
+}
 
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");
 
 eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");
index a0e832c1a5fc7f242b4d0dd9c679686b2d7ccef9..fc6323e84b75e27dbf127409317699f5017fb1a3 100644 (file)
@@ -24,6 +24,9 @@ private:
        int state;
        enum {stateRemoved, stateInserted};
        uint8_t prev_sent_capmt_version;
        int state;
        enum {stateRemoved, stateInserted};
        uint8_t prev_sent_capmt_version;
+       eDVBCIApplicationManagerSession *application_manager;
+       eDVBCICAManagerSession *ca_manager;
+       eDVBCIMMISession *mmi_session;
 public:
        int use_count;
 
 public:
        int use_count;
 
@@ -31,11 +34,15 @@ public:
        ~eDVBCISlot();
        
        int send(const unsigned char *data, size_t len);
        ~eDVBCISlot();
        
        int send(const unsigned char *data, size_t len);
-       
-       eDVBCIApplicationManagerSession *application_manager;
-       eDVBCICAManagerSession *ca_manager;
-       eDVBCIMMISession *mmi_session;
-       
+
+       void setAppManager( eDVBCIApplicationManagerSession *session );
+       void setMMIManager( eDVBCIMMISession *session );
+       void setCAManager( eDVBCICAManagerSession *session );
+
+       eDVBCIApplicationManagerSession *getAppManager() { return application_manager; }
+       eDVBCIMMISession *getMMIManager() { return mmi_session; }
+       eDVBCICAManagerSession *getCAManager() { return ca_manager; }
+
        int getSlotID();
        int reset();
        int initialize();
        int getSlotID();
        int reset();
        int initialize();
@@ -45,6 +52,7 @@ public:
        int answerEnq(char *value);
        int cancelEnq();
        int getMMIState();
        int answerEnq(char *value);
        int cancelEnq();
        int getMMIState();
+       void resendCAPMT();
        int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
        uint8_t getPrevSentCAPMTVersion() const { return prev_sent_capmt_version; }
        void resetPrevSentCAPMTVersion() { prev_sent_capmt_version = 0xFF; }
        int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
        uint8_t getPrevSentCAPMTVersion() const { return prev_sent_capmt_version; }
        void resetPrevSentCAPMTVersion() { prev_sent_capmt_version = 0xFF; }
@@ -99,6 +107,7 @@ public:
        int cancelEnq(int slot);
        int getMMIState(int slot);
        int enableTS(int slot, int enable);
        int cancelEnq(int slot);
        int getMMIState(int slot);
        int enableTS(int slot, int enable);
+       int sendCAPMT(int slot);
 };
 
 #endif
 };
 
 #endif
index 7843554d685e4df51c5197af51e58e9bf682e988..f5231fceb1abc20ef43f1ee8757a72a5af4ef656 100644 (file)
@@ -6,12 +6,12 @@
 eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(eDVBCISlot *tslot)
 {
        slot = tslot;
 eDVBCIApplicationManagerSession::eDVBCIApplicationManagerSession(eDVBCISlot *tslot)
 {
        slot = tslot;
-       slot->application_manager       = this;
+       slot->setAppManager(this);
 }
 
 eDVBCIApplicationManagerSession::~eDVBCIApplicationManagerSession()
 {
 }
 
 eDVBCIApplicationManagerSession::~eDVBCIApplicationManagerSession()
 {
-       slot = 0;
+       slot->setAppManager(NULL);
 }
 
 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
 }
 
 int eDVBCIApplicationManagerSession::receivedAPDU(const unsigned char *tag,const void *data, int len)
index 1d172b1cc2ed98b69e79a77ff9a3f3fe46a17cbb..cd10ae33e4ce4e3e6b737bc3e1f98ab73a418f84 100644 (file)
@@ -5,12 +5,12 @@
 eDVBCICAManagerSession::eDVBCICAManagerSession(eDVBCISlot *tslot)
 {
        slot = tslot;
 eDVBCICAManagerSession::eDVBCICAManagerSession(eDVBCISlot *tslot)
 {
        slot = tslot;
-       slot->ca_manager = this;
+       slot->setCAManager(this);
 }
 
 eDVBCICAManagerSession::~eDVBCICAManagerSession()
 {
 }
 
 eDVBCICAManagerSession::~eDVBCICAManagerSession()
 {
-       slot->ca_manager = 0;
+       slot->setCAManager(NULL);
 }
 
 int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
 }
 
 int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
@@ -31,6 +31,7 @@ int eDVBCICAManagerSession::receivedAPDU(const unsigned char *tag, const void *d
                                printf("%04x ", (((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
                                caids.push_back((((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
                        }
                                printf("%04x ", (((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
                                caids.push_back((((const unsigned char*)data)[i]<<8)|(((const unsigned char*)data)[i+1]));
                        }
+                       slot->resendCAPMT();
                        printf("\n");
                        break;
                default:
                        printf("\n");
                        break;
                default:
index 8ac4748c398079b2480795a80d89af1f98fac578..5ef7ebbcb5a962fe5fbf839b277a16bc50247c9c 100644 (file)
@@ -19,12 +19,12 @@ return list;
 eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot)
 {
        slot = tslot;
 eDVBCIMMISession::eDVBCIMMISession(eDVBCISlot *tslot)
 {
        slot = tslot;
-       slot->mmi_session = this;
+       slot->setMMIManager(this);
 }
 
 eDVBCIMMISession::~eDVBCIMMISession()
 {
 }
 
 eDVBCIMMISession::~eDVBCIMMISession()
 {
-       slot->mmi_session = 0;
+       slot->setMMIManager(NULL);
 }
 
 int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
 }
 
 int eDVBCIMMISession::receivedAPDU(const unsigned char *tag, const void *data, int len)
index 1bd3d18b96ba16de6454f3e283a0730eb70524a6..4b2a8d72c305ea85e53b17ac4ec28a64028c27ec 100644 (file)
@@ -136,7 +136,7 @@ eDVBCISession *eDVBCISession::createSession(eDVBCISlot *slot, const unsigned cha
                printf("session: %p\n",session);
                break;
        case 0x00020041:
                printf("session: %p\n",session);
                break;
        case 0x00020041:
-               session=slot->application_manager = new eDVBCIApplicationManagerSession(slot);
+               session=new eDVBCIApplicationManagerSession(slot);
                printf("APPLICATION MANAGER\n");
                break;
        case 0x00030041:
                printf("APPLICATION MANAGER\n");
                break;
        case 0x00030041: