X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/0e3e7773e5d8e7ff159316db3de7fcfad57bb9e8..999ddaa2a3953f5e16549483cd8deb021685fc5b:/lib/dvb/pmt.cpp?ds=sidebyside diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index bdb10b18..7f560c8e 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -141,7 +141,7 @@ void eDVBServicePMTHandler::PATready(int) PyObject *eDVBServicePMTHandler::getCaIds() { - PyObject *ret=0; + ePyObject ret; program prog; @@ -157,7 +157,7 @@ PyObject *eDVBServicePMTHandler::getCaIds() } } - return ret ? ret : PyList_New(0); + return ret ? (PyObject*)ret : (PyObject*)PyList_New(0); } int eDVBServicePMTHandler::getProgramInfo(struct program &program) @@ -544,7 +544,7 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, } } else { - serviceEvent(eventTuneFailed); + serviceEvent(eventNoResources); return res; } @@ -856,3 +856,52 @@ void eDVBCAService::sendCAPMT() ++m_sendstate; } } + +static PyObject *createTuple(int pid, const char *type) +{ + PyObject *r = PyTuple_New(2); + PyTuple_SetItem(r, 0, PyInt_FromLong(pid)); + PyTuple_SetItem(r, 1, PyString_FromString(type)); + return r; +} + +static inline PyList_AppendSteal(PyObject *list, PyObject *item) +{ + PyList_Append(list, item); + Py_DECREF(item); +} + +PyObject *eDVBServicePMTHandler::program::createPythonObject() +{ + PyObject *r = PyDict_New(); + + PyObject *l = PyList_New(0); + + PyList_AppendSteal(l, createTuple(0, "pat")); + + if (pmtPid != -1) + PyList_AppendSteal(l, createTuple(pmtPid, "pmt")); + + for (std::vector::const_iterator + i(videoStreams.begin()); + i != videoStreams.end(); ++i) + PyList_AppendSteal(l, createTuple(i->pid, "video")); + + for (std::vector::const_iterator + i(audioStreams.begin()); + i != audioStreams.end(); ++i) + PyList_AppendSteal(l, createTuple(i->pid, "audio")); + + for (std::vector::const_iterator + i(subtitleStreams.begin()); + i != subtitleStreams.end(); ++i) + PyList_AppendSteal(l, createTuple(i->pid, "subtitle")); + + PyList_AppendSteal(l, createTuple(pcrPid, "pcr")); + + if (textPid != -1) + PyList_AppendSteal(l, createTuple(textPid, "text")); + + PyDict_SetItemString(r, "pids", l); + return r; +}