From 211d70fe8a326748743da7642f8b1f3ca10adc94 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 5 Jan 2007 15:00:59 +0000 Subject: add eDVBServicePMTHandler::program::createPythonObject --- lib/dvb/pmt.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'lib/dvb/pmt.cpp') diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp index 8db4ba9f..1b1455e4 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; +} -- cgit v1.2.3