From: Felix Domke Date: Fri, 5 Jan 2007 15:00:59 +0000 (+0000) Subject: add eDVBServicePMTHandler::program::createPythonObject X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=211d70fe8a326748743da7642f8b1f3ca10adc94 add eDVBServicePMTHandler::program::createPythonObject --- diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 8db4ba9..1b1455e 100644 --- a/lib/dvb/pmt.cpp +++ b/lib/dvb/pmt.cpp @@ -856,3 +856,46 @@ 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; +} + +PyObject *eDVBServicePMTHandler::program::createPythonObject() +{ + PyObject *r = PyDict_New(); + + PyObject *l = PyList_New(0); + + PyList_Append(l, createTuple(0, "pat")); + + if (pmtPid != -1) + PyList_Append(l, createTuple(pmtPid, "pmt")); + + for (std::vector::const_iterator + i(videoStreams.begin()); + i != videoStreams.end(); ++i) + PyList_Append(l, createTuple(i->pid, "video")); + + for (std::vector::const_iterator + i(audioStreams.begin()); + i != audioStreams.end(); ++i) + PyList_Append(l, createTuple(i->pid, "audio")); + + for (std::vector::const_iterator + i(subtitleStreams.begin()); + i != subtitleStreams.end(); ++i) + PyList_Append(l, createTuple(i->pid, "subtitle")); + + PyList_Append(l, createTuple(pcrPid, "pcr")); + + if (textPid != -1) + PyList_Append(l, createTuple(textPid, "text")); + + PyDict_SetItemString(r, "pids", l); + return r; +} diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h index 086619d..a0820c5 100644 --- a/lib/dvb/pmt.h +++ b/lib/dvb/pmt.h @@ -163,6 +163,8 @@ public: int pmtPid; int textPid; bool isCrypted() { return !caids.empty(); } + + PyObject *createPythonObject(); }; int getProgramInfo(struct program &program);