From 23ba503641e6691f1942de14f449652036e80524 Mon Sep 17 00:00:00 2001 From: pieterg Date: Mon, 15 Aug 2011 15:17:12 +0200 Subject: [PATCH] pmt: add python getCaIds wrapper and move it to a SWIG interface file --- lib/dvb/pmt.cpp | 34 +++++----------------------------- lib/dvb/pmt.h | 2 +- lib/python/Makefile.inc | 3 ++- lib/python/enigma_python.i | 1 + lib/python/python_pmt.i | 30 ++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 lib/python/python_pmt.i diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 639793db861..4049591191e 100755 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -314,42 +314,18 @@ void eDVBServicePMTHandler::OCready(int error) m_OC.stop(); } -PyObject *eDVBServicePMTHandler::getCaIds(bool pair) +void eDVBServicePMTHandler::getCaIds(std::vector &caids, std::vector &ecmpids) { - ePyObject ret; - program prog; - if ( !getProgramInfo(prog) ) + if (!getProgramInfo(prog)) { - if (pair) + for (std::list::iterator it = prog.caids.begin(); it != prog.caids.end(); ++it) { - int cnt=prog.caids.size(); - if (cnt) - { - ret=PyList_New(cnt); - std::list::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 set(prog.caids.begin(), prog.caids.end()); - std::set::iterator it(set.begin()); - int cnt=set.size(); - ret=PyList_New(cnt); - while(cnt--) - PyList_SET_ITEM(ret, cnt, PyInt_FromLong((it++)->caid)); + caids.push_back(it->caid); + ecmpids.push_back(it->capid); } } - - return ret ? (PyObject*)ret : (PyObject*)PyList_New(0); } int eDVBServicePMTHandler::getProgramInfo(program &program) diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h index 05886d22f75..f356aedb47f 100644 --- a/lib/dvb/pmt.h +++ b/lib/dvb/pmt.h @@ -120,7 +120,7 @@ class eDVBServicePMTHandler: public eDVBPMTParser int getProgramInfo(program &program); int getDataDemux(ePtr &demux); int getDecodeDemux(ePtr &demux); - PyObject *getCaIds(bool pair=false); // caid / ecmpid pair + void getCaIds(std::vector &caids, std::vector &ecmpids); int getPVRChannel(ePtr &pvr_channel); int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; } diff --git a/lib/python/Makefile.inc b/lib/python/Makefile.inc index f2ceb9c7b98..f5d67f65a9e 100644 --- a/lib/python/Makefile.inc +++ b/lib/python/Makefile.inc @@ -25,7 +25,8 @@ EXTRA_DIST += \ python/python_service.i \ python/python_dvb.i \ python/python_base.i \ - python/python_console.i + python/python_console.i \ + python/python_pmt.i @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/python/enigma_python.Pcpp@am__quote@ diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 56fbbc40238..04e1ce58332 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -148,6 +148,7 @@ typedef long time_t; %include %include +%include %immutable eSocketNotifier::activated; %include diff --git a/lib/python/python_pmt.i b/lib/python/python_pmt.i new file mode 100644 index 00000000000..57e359be32c --- /dev/null +++ b/lib/python/python_pmt.i @@ -0,0 +1,30 @@ +%extend eDVBServicePMTHandler { +PyObject *eDVBServicePMTHandler::getCaIds(bool pair) +{ + ePyObject ret; + std::vector caids, ecmpids; + self->getCaIds(caids, ecmpids); + int cnt = caids.size(); + + ret = PyList_New(cnt); + + for (unsigned int i = 0; i < cnt; i++) + { + if (pair) + { + ePyObject tuple = PyTuple_New(2); + PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(caids[i])); + PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(ecmpids[i])); + PyList_SET_ITEM(ret, i, tuple); + } + else + { + PyList_SET_ITEM(ret, i, PyInt_FromLong(caids[i])); + } + } + + return ret; +} +}; + +%ignore eDVBServicePMTHandler::getCaIds;