- if (outbuf == NULL)
- return SRD_ERR_ARGS; /* TODO: More specific error? */
- if (outbuflen == NULL)
- return SRD_ERR_ARGS; /* TODO: More specific error? */
-
- /* TODO: Error handling. */
- py_mod = dec->py_mod;
- Py_XINCREF(py_mod);
- py_func = dec->py_decodefunc;
- Py_XINCREF(py_func);
-
- /* Create a Python tuple of size 1. */
- if (!(py_args = PyTuple_New(1))) { /* NEWREF */
- ret = SRD_ERR_PYTHON; /* TODO: More specific error? */
- goto err_run_decref_func;
- }
-
- /* Get the input buffer as Python "string" (byte array). */
- /* TODO: int vs. uint64_t for 'inbuflen'? */
-
- py_value = Py_BuildValue("{sisiss#}",
- "time", _timehack,
- "duration", 10,
- "data", inbuf, inbuflen / _unitsize
- );
-
- /*
- * IMPORTANT: PyTuple_SetItem() "steals" a reference to py_value!
- * That means we are no longer responsible for Py_XDECREF()'ing it.
- * It will automatically be free'd when the 'py_args' tuple is free'd.
- */
- if (PyTuple_SetItem(py_args, 0, py_value) != 0) { /* STEAL */
- ret = SRD_ERR_PYTHON; /* TODO: More specific error? */
- Py_XDECREF(py_value); /* TODO: Ref. stolen upon error? */
- goto err_run_decref_args;
- }
-
- if (!(py_res = PyObject_CallObject(py_func, py_args))) { /* NEWREF */
- ret = SRD_ERR_PYTHON; /* TODO: More specific error? */
- goto err_run_decref_args;
- }