From 7af09f359cf713de095246bf0dae2763b1c7d135 Mon Sep 17 00:00:00 2001 From: Stephen Thompson Date: Wed, 28 Nov 2018 14:49:39 +0000 Subject: [PATCH] Added Python support for Polaris Vega. (#17) Added ndiOpenNetwork, ndiCloseNetwork, ndiGetPHSRNumberOfHandles, ndiGetPHRQHandle to python module. Changed char to int in ndiPVWRFromFile. --- ndicapimodule.cxx | 77 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/ndicapimodule.cxx b/ndicapimodule.cxx index 3d18a50..65a565f 100644 --- a/ndicapimodule.cxx +++ b/ndicapimodule.cxx @@ -617,6 +617,31 @@ static PyObject* Py_ndiOpen(PyObject* module, PyObject* args) return NULL; } +/* Open a networked tracker*/ +static PyObject* Py_ndiOpenNetwork(PyObject* module, PyObject* args) +{ + ndicapi* pol; + char* hostname; + int port; + PyNdicapi* self; + + if (PyArg_ParseTuple(args, "si:plOpenNetwork", &hostname, &port)) + { + pol = ndiOpenNetwork(hostname, port); + if (pol == NULL) + { + Py_INCREF(Py_None); + return Py_None; + } + self = PyObject_NEW(PyNdicapi, &PyNdicapiType); + self->pl_ndicapi = pol; + Py_INCREF(self); + return (PyObject*)self; + } + + return NULL; +} + static PyObject* Py_ndiGetDeviceName(PyObject* module, PyObject* args) { ndicapi* pol; @@ -650,6 +675,21 @@ static PyObject* Py_ndiClose(PyObject* module, PyObject* args) return NULL; } +/* close a networked tracker */ +static PyObject* Py_ndiCloseNetwork(PyObject* module, PyObject* args) +{ + ndicapi* pol; + + if (PyArg_ParseTuple(args, "O&:plClose", &_ndiConverter, &pol)) + { + ndiCloseNetwork(pol); + Py_INCREF(Py_None); + return Py_None; + } + + return NULL; +} + static PyObject* Py_ndiSetThreadMode(PyObject* module, PyObject* args) { ndicapi* pol; @@ -822,12 +862,12 @@ PyCommandMacro(ndi3D, "3D:%c%d") static PyObject* Py_ndiPVWRFromFile(PyObject* module, PyObject* args) { - char port; + int port; int result; char* filename; ndicapi* pol; - if (PyArg_ParseTuple(args, "O&cs:plPVWRFromFile", + if (PyArg_ParseTuple(args, "O&is:plPVWRFromFile", &_ndiConverter, &pol, &port, &filename)) { result = ndiPVWRFromFile(pol, port, filename); @@ -1297,6 +1337,34 @@ static PyObject* Py_ndiGetIRCHKSourceXY(PyObject* module, PyObject* args) return NULL; } +static PyObject* Py_ndiGetPHSRNumberOfHandles (PyObject* module, PyObject* args) +{ + int result; + ndicapi* pol; + + if (PyArg_ParseTuple(args, "O&:plGetPHSRNumberOfHandles", + &_ndiConverter, &pol)) + { + result = ndiGetPHSRNumberOfHandles(pol); + return PyInt_FromLong(result); + } + return NULL; +} + +static PyObject* Py_ndiGetPHRQHandle (PyObject* module, PyObject* args) +{ + int result; + ndicapi* pol; + + if (PyArg_ParseTuple(args, "O&:plGetPHRQHandle", + &_ndiConverter, &pol)) + { + result = ndiGetPHRQHandle(pol); + return PyInt_FromLong(result); + } + return NULL; +} + static PyObject* Py_ndiRelativeTransform(PyObject* module, PyObject* args) { double a[8]; @@ -1446,8 +1514,10 @@ static PyMethodDef NdicapiMethods[] = Py_NDIMethodMacro(ndiDeviceName), Py_NDIMethodMacro(ndiProbe), Py_NDIMethodMacro(ndiOpen), + Py_NDIMethodMacro(ndiOpenNetwork), Py_NDIMethodMacro(ndiGetDeviceName), Py_NDIMethodMacro(ndiClose), + Py_NDIMethodMacro(ndiCloseNetwork), Py_NDIMethodMacro(ndiSetThreadMode), Py_NDIMethodMacro(ndiCommand), @@ -1530,6 +1600,9 @@ static PyMethodDef NdicapiMethods[] = Py_NDIMethodMacro(ndiGetIRCHKNumberOfSources), Py_NDIMethodMacro(ndiGetIRCHKSourceXY), + Py_NDIMethodMacro(ndiGetPHSRNumberOfHandles), + Py_NDIMethodMacro(ndiGetPHRQHandle), + Py_NDIMethodMacro(ndiIRED), Py_NDIMethodMacro(ndi3D), -- GitLab