Merge branch 'bug_124_m2ts_support' into experimental
[enigma2.git] / lib / dvb / pmt.cpp
index dc2e9a88f75bc2f52584062f3d5e3f6afd69053d..4ad4e76f0a962e51a1c5b4b296756d430f46e7e6 100644 (file)
@@ -180,7 +180,7 @@ void eDVBServicePMTHandler::PATready(int)
                serviceEvent(eventNoPAT);
 }
 
-PyObject *eDVBServicePMTHandler::getCaIds()
+PyObject *eDVBServicePMTHandler::getCaIds(bool pair)
 {
        ePyObject ret;
 
@@ -188,20 +188,37 @@ PyObject *eDVBServicePMTHandler::getCaIds()
 
        if ( !getProgramInfo(prog) )
        {
-               int cnt=prog.caids.size();
-               if (cnt)
+               if (pair)
                {
+                       int cnt=prog.caids.size();
+                       if (cnt)
+                       {
+                               ret=PyList_New(cnt);
+                               std::list<program::capid_pair>::iterator it(prog.caids.begin());
+                               while(cnt--)
+                               {
+                                       ePyObject tuple = PyTuple_New(2);
+                                       PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->caid));
+                                       PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((it++)->capid));
+                                       PyList_SET_ITEM(ret, cnt, tuple);
+                               }
+                       }
+               }
+               else
+               {
+                       std::set<program::capid_pair> set(prog.caids.begin(), prog.caids.end());
+                       std::set<program::capid_pair>::iterator it(set.begin());
+                       int cnt=set.size();
                        ret=PyList_New(cnt);
-                       std::set<uint16_t>::iterator it(prog.caids.begin());
                        while(cnt--)
-                               PyList_SET_ITEM(ret, cnt, PyInt_FromLong(*it++));
+                               PyList_SET_ITEM(ret, cnt, PyInt_FromLong((it++)->caid));
                }
        }
 
        return ret ? (PyObject*)ret : (PyObject*)PyList_New(0);
 }
 
-int eDVBServicePMTHandler::getProgramInfo(struct program &program)
+int eDVBServicePMTHandler::getProgramInfo(program &program)
 {
        ePtr<eTable<ProgramMapSection> > ptr;
        int cached_apid_ac3 = -1;
@@ -254,7 +271,10 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                        if ((*desc)->getTag() == CA_DESCRIPTOR)
                                        {
                                                CaDescriptor *descr = (CaDescriptor*)(*desc);
-                                               program.caids.insert(descr->getCaSystemId());
+                                               program::capid_pair pair;
+                                               pair.caid = descr->getCaSystemId();
+                                               pair.capid = descr->getCaPid();
+                                               program.caids.push_back(pair);
                                        }
                                        else if ((*desc)->getTag() == REGISTRATION_DESCRIPTOR)
                                        {
@@ -518,7 +538,10 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                                        case CA_DESCRIPTOR:
                                                        {
                                                                CaDescriptor *descr = (CaDescriptor*)(*desc);
-                                                               program.caids.insert(descr->getCaSystemId());
+                                                               program::capid_pair pair;
+                                                               pair.caid = descr->getCaSystemId();
+                                                               pair.capid = descr->getCaPid();
+                                                               program.caids.push_back(pair);
                                                                break;
                                                        }
                                                        default:
@@ -638,8 +661,12 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                        program.textPid = cached_tpid;
                }
                CAID_LIST &caids = m_service->m_ca;
-               for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it)
-                       program.caids.insert(*it);
+               for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it) {
+                       program::capid_pair pair;
+                       pair.caid = *it;
+                       pair.capid = -1; // not known yet
+                       program.caids.push_back(pair);
+               }
                if ( cnt )
                        ret = 0;
        }