add function to get a list of CAIDs for a running dvb service from python
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 26 Apr 2006 17:18:52 +0000 (17:18 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Wed, 26 Apr 2006 17:18:52 +0000 (17:18 +0000)
lib/dvb/pmt.cpp
lib/dvb/pmt.h
lib/service/iservice.h
lib/service/service.cpp
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 5ea47467a5a596e60513d2f6271545b3a0c803cf..5e9c76025526b053a37ddccf49736472e9975c95 100644 (file)
@@ -5,6 +5,7 @@
 #include <lib/dvb/metaparser.h>
 #include <lib/dvb_ci/dvbci.h>
 #include <lib/dvb/epgcache.h>
 #include <lib/dvb/metaparser.h>
 #include <lib/dvb_ci/dvbci.h>
 #include <lib/dvb/epgcache.h>
+#include <dvbsi++/ca_descriptor.h>
 #include <dvbsi++/ca_program_map_section.h>
 #include <dvbsi++/teletext_descriptor.h>
 #include <dvbsi++/descriptor_tag.h>
 #include <dvbsi++/ca_program_map_section.h>
 #include <dvbsi++/teletext_descriptor.h>
 #include <dvbsi++/descriptor_tag.h>
@@ -134,6 +135,76 @@ void eDVBServicePMTHandler::PATready(int)
                serviceEvent(eventNoPAT);
 }
 
                serviceEvent(eventNoPAT);
 }
 
+PyObject *eDVBServicePMTHandler::getCaIds()
+{
+       PyObject *ret=0;
+
+       ePtr<eTable<ProgramMapSection> > ptr;
+
+       if ( ((m_service && m_service->usePMT()) || !m_service) && !m_PMT.getCurrent(ptr))
+       {
+               uint16_t caids[255];
+               memset(caids, 0, sizeof(caids));
+               std::vector<ProgramMapSection*>::const_iterator i = ptr->getSections().begin();
+               for (; i != ptr->getSections().end(); ++i)
+               {
+                       const ProgramMapSection &pmt = **i;
+                       ElementaryStreamInfoConstIterator es = pmt.getEsInfo()->begin();
+                       for (; es != pmt.getEsInfo()->end(); ++es)
+                       {
+                               for (DescriptorConstIterator desc = (*es)->getDescriptors()->begin();
+                                               desc != (*es)->getDescriptors()->end(); ++desc)
+                               {
+                                       switch ((*desc)->getTag())
+                                       {
+                                               case CA_DESCRIPTOR:
+                                               {
+                                                       CaDescriptor *cadescr = *desc;
+                                                       uint16_t caid = cadescr->getCaSystemId();
+                                                       int idx=0;
+                                                       while (caids[idx] && caids[idx] != caid)
+                                                               ++idx;
+                                                       caids[idx]=caid;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
+                               desc != pmt.getDescriptors()->end(); ++desc)
+                       {
+                               switch ((*desc)->getTag())
+                               {
+                                       case CA_DESCRIPTOR:
+                                       {
+                                               CaDescriptor *cadescr = *desc;
+                                               uint16_t caid = cadescr->getCaSystemId();
+                                               int idx=0;
+                                               while (caids[idx] && caids[idx] != caid)
+                                                       ++idx;
+                                               caids[idx]=caid;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               int cnt=0;
+               while (caids[cnt])
+                       ++cnt;
+               if (cnt)
+               {
+                       ret=PyList_New(cnt);
+                       while(cnt--)
+                               PyList_SET_ITEM(ret, cnt, PyInt_FromLong(caids[cnt]));
+               }
+       }
+
+       if (!ret)
+               ret=PyList_New(0);
+
+       return ret;
+}
+
 int eDVBServicePMTHandler::getProgramInfo(struct program &program)
 {
        ePtr<eTable<ProgramMapSection> > ptr;
 int eDVBServicePMTHandler::getProgramInfo(struct program &program)
 {
        ePtr<eTable<ProgramMapSection> > ptr;
index 79d7917c251b684c02a0739b473dcee29c974957..5149167ce31e10a4dab2127bdbd359967484d4c8 100644 (file)
@@ -6,6 +6,7 @@
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/idemux.h>
 #include <lib/dvb/esection.h>
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/idemux.h>
 #include <lib/dvb/esection.h>
+#include <lib/python/python.h>
 #include <dvbsi++/program_map_section.h>
 #include <dvbsi++/program_association_section.h>
 
 #include <dvbsi++/program_map_section.h>
 #include <dvbsi++/program_association_section.h>
 
@@ -120,6 +121,7 @@ public:
        int getProgramInfo(struct program &program);
        int getDataDemux(ePtr<iDVBDemux> &demux);
        int getDecodeDemux(ePtr<iDVBDemux> &demux);
        int getProgramInfo(struct program &program);
        int getDataDemux(ePtr<iDVBDemux> &demux);
        int getDecodeDemux(ePtr<iDVBDemux> &demux);
+       PyObject *getCaIds();
        
        int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
        int getService(eServiceReferenceDVB &service) { service = m_reference; return 0; }
        
        int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
        int getService(eServiceReferenceDVB &service) { service = m_reference; return 0; }
index 7ea8c17bd06d429c6eeee6262adc9c8812188664..53abbf1a7b08445e46c8021b260b85e3c7a69e91 100644 (file)
@@ -225,7 +225,7 @@ public:
        virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
        virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
 
        virtual SWIG_VOID(RESULT) getName(std::string &SWIG_OUTPUT)=0;
        virtual SWIG_VOID(RESULT) getEvent(ePtr<eServiceEvent> &SWIG_OUTPUT, int nownext);
 
-       enum { 
+       enum {
                sIsCrypted,  /* is encrypted (no indication if decrypt was possible) */
                sAspect,     /* aspect ratio: 0=4:3, 1=16:9, 2=whatever we need */
                sIsMultichannel, /* multichannel *available* (probably not selected) */
                sIsCrypted,  /* is encrypted (no indication if decrypt was possible) */
                sAspect,     /* aspect ratio: 0=4:3, 1=16:9, 2=whatever we need */
                sIsMultichannel, /* multichannel *available* (probably not selected) */
@@ -260,11 +260,13 @@ public:
                sComment,
                sTracknumber,
                sGenre,
                sComment,
                sTracknumber,
                sGenre,
+               sCAIDs,
        };
        };
-       enum { resNA = -1, resIsString = -2 };
+       enum { resNA = -1, resIsString = -2, resIsPyObject = -3 };
 
        virtual int getInfo(int w);
        virtual std::string getInfoString(int w);
 
        virtual int getInfo(int w);
        virtual std::string getInfoString(int w);
+       virtual PyObject *getInfoObject(int w);
 };
 
 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
 };
 
 TEMPLATE_TYPEDEF(ePtr<iServiceInformation>, iServiceInformationPtr);
index d079965b7fe90a96a42083e903628b2baf66ec35..11f88b1fe251c14170c233846e5f80ac1cd0fbc6 100644 (file)
@@ -1,8 +1,10 @@
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
+#include <lib/python/python.h>
 #include <lib/service/service.h>
 #include <lib/base/init_num.h>
 #include <lib/base/init.h>
 #include <lib/service/service.h>
 #include <lib/base/init_num.h>
 #include <lib/base/init.h>
+#include <Python.h>
 
 eServiceReference::eServiceReference(const std::string &string)
 {
 
 eServiceReference::eServiceReference(const std::string &string)
 {
@@ -190,4 +192,10 @@ std::string iServiceInformation::getInfoString(int w)
        return "";
 }
 
        return "";
 }
 
+PyObject* iServiceInformation::getInfoObject(int w)
+{
+       Py_INCREF(Py_None);
+       return Py_None;
+}
+
 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");
 eAutoInitPtr<eServiceCenter> init_eServiceCenter(eAutoInitNumbers::service, "eServiceCenter");
index a6f4eec7c2fcae1413f4f08f0b2671a80038b41b..fb84aa1863e4960ffcfa205e0f10fe7b413b273f 100644 (file)
@@ -1017,6 +1017,9 @@ int eDVBServicePlay::getInfo(int w)
 {
        eDVBServicePMTHandler::program program;
 
 {
        eDVBServicePMTHandler::program program;
 
+       if (w == sCAIDs)
+               return resIsPyObject;
+
        if (m_service_handler.getProgramInfo(program))
                return -1;
        
        if (m_service_handler.getProgramInfo(program))
                return -1;
        
@@ -1078,15 +1081,29 @@ int eDVBServicePlay::getInfo(int w)
 }
 
 std::string eDVBServicePlay::getInfoString(int w)
 }
 
 std::string eDVBServicePlay::getInfoString(int w)
-{      
+{
        switch (w)
        {
        case sProvider:
                if (!m_dvb_service) return "";
                return m_dvb_service->m_provider_name;
        default:
        switch (w)
        {
        case sProvider:
                if (!m_dvb_service) return "";
                return m_dvb_service->m_provider_name;
        default:
-               return "";
+               break;
+       }
+       return iServiceInformation::getInfoString(w);
+}
+
+PyObject *eDVBServicePlay::getInfoObject(int w)
+{
+       switch (w)
+       {
+       case sCAIDs:
+               if (m_dvb_service)
+                       return m_service_handler.getCaIds();
+       default:
+               break;
        }
        }
+       return iServiceInformation::getInfoObject(w);
 }
 
 int eDVBServicePlay::getNumberOfTracks()
 }
 
 int eDVBServicePlay::getNumberOfTracks()
index d79e6202136c18761168ec8c3cde1e7461e15df1..4b13193eb5b97de017b603e5768dd87c063678e5 100644 (file)
@@ -99,6 +99,7 @@ public:
        RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
        int getInfo(int w);
        std::string getInfoString(int w);
        RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
        int getInfo(int w);
        std::string getInfoString(int w);
+       PyObject *getInfoObject(int w);
 
                // iAudioTrackSelection 
        int getNumberOfTracks();
 
                // iAudioTrackSelection 
        int getNumberOfTracks();