mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-11 10:56:38 +00:00
ec44907858
This creates strings of the proper size, unlike the previous patch.
905 lines
25 KiB
C
905 lines
25 KiB
C
/* -*- Mode: C; ; c-basic-offset: 4 -*- */
|
|
/* gst-python
|
|
* Copyright (C) 2006 Edward Hervey
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
* Author: Johan Dahlin <johan@gnome.org>
|
|
*/
|
|
|
|
%%
|
|
override GstBaseSrc__proxy_do_create
|
|
static GstFlowReturn
|
|
_wrap_GstBaseSrc__proxy_do_create (GstBaseSrc * self,
|
|
guint64 offset,
|
|
guint size,
|
|
GstBuffer ** buf)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_self;
|
|
GstFlowReturn retval = GST_FLOW_ERROR;
|
|
PyObject *py_ret;
|
|
PyObject *py_flow;
|
|
PyObject *py_buffer;
|
|
PyObject *py_args;
|
|
PyObject *py_method;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_args = PyTuple_New(2);
|
|
PyTuple_SET_ITEM(py_args, 0, PyLong_FromUnsignedLongLong(offset));
|
|
PyTuple_SET_ITEM(py_args, 1, PyInt_FromLong(size));
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_create");
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, py_args);
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
/* process the python return value */
|
|
/* Should be a list containing the gst.FlowReturn and the gst.Buffer */
|
|
if (PyTuple_Check(py_ret)) {
|
|
/* gst.FlowReturn */
|
|
py_flow = PyTuple_GetItem(py_ret, 0);
|
|
|
|
if (!py_flow) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_ret);
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
if (py_flow == Py_None) {
|
|
GST_ERROR ("None return flow is not valid");
|
|
goto beach;
|
|
}
|
|
|
|
GST_DEBUG ("py_flow:%p", py_flow);
|
|
|
|
if (pyg_enum_get_value(GST_TYPE_FLOW_RETURN, py_flow, (gint*) &retval)) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_ret);
|
|
Py_DECREF(py_flow);
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
retval = GST_FLOW_ERROR;
|
|
goto beach;
|
|
}
|
|
|
|
py_buffer = PyTuple_GetItem(py_ret, 1);
|
|
if (!py_buffer) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_ret);
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
if (pygstminiobject_check(py_buffer, &PyGstBuffer_Type)) {
|
|
*buf = GST_BUFFER (pygstminiobject_get (py_buffer));
|
|
gst_buffer_ref (*buf);
|
|
} else {
|
|
*buf = NULL;
|
|
}
|
|
}
|
|
|
|
Py_DECREF(py_ret);
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
|
|
beach:
|
|
pyg_gil_state_release(__py_state);
|
|
|
|
return retval;
|
|
}
|
|
%%
|
|
override GstBaseSrc__do_create kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseSrc__do_create (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "offset", "size", NULL };
|
|
PyGObject *self;
|
|
guint64 offset;
|
|
guint size;
|
|
PyObject *py_ret;
|
|
GstFlowReturn flow;
|
|
GstBuffer *buffer = NULL;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!KI:GstBaseSrc.create",
|
|
kwlist, &PyGstBaseSrc_Type, &self, &offset, &size))
|
|
return NULL;
|
|
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_SRC_CLASS(klass)->create) {
|
|
pyg_begin_allow_threads;
|
|
flow = GST_BASE_SRC_CLASS(klass)->create(GST_BASE_SRC(self->obj), offset, size, &buffer);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.set_caps not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
/* We now need to return a tuple with (flow, buffer) */
|
|
if (buffer)
|
|
py_ret = PyTuple_New(2);
|
|
else
|
|
py_ret = PyTuple_New(1);
|
|
|
|
PyTuple_SET_ITEM(py_ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, flow));
|
|
|
|
if (buffer)
|
|
PyTuple_SET_ITEM(py_ret, 1, pygstminiobject_new(GST_MINI_OBJECT (buffer)));
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstBaseSrc__proxy_do_get_size
|
|
static gboolean
|
|
_wrap_GstBaseSrc__proxy_do_get_size (GstBaseSrc * self,
|
|
guint64 * size)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_self;
|
|
gboolean ret = FALSE;
|
|
PyObject *py_method;
|
|
PyObject *py_ret;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_get_size");
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, NULL);
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
/*
|
|
If the method returned a numeric, the return value will be TRUE.
|
|
For ANY other case, we don't set size and the return value is FALSE.
|
|
*/
|
|
|
|
if (PyLong_Check(py_ret)) {
|
|
*size = PyLong_AsUnsignedLongLongMask(py_ret);
|
|
ret = TRUE;
|
|
}
|
|
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_self);
|
|
Py_DECREF(py_ret);
|
|
|
|
beach:
|
|
pyg_gil_state_release(__py_state);
|
|
|
|
return ret;
|
|
}
|
|
%%
|
|
override GstBaseSrc__do_get_size kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseSrc__do_get_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", NULL };
|
|
PyGObject *self;
|
|
gboolean ret;
|
|
guint64 size = 0;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GstBaseSrc.get_size",
|
|
kwlist, &PyGstBaseSrc_Type, &self))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_SRC_CLASS(klass)->get_size) {
|
|
pyg_begin_allow_threads;
|
|
ret = GST_BASE_SRC_CLASS(klass)->get_size(GST_BASE_SRC(self->obj), &size);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.get_size not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyLong_FromUnsignedLongLong(size);
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstBaseSrc__proxy_do_get_times
|
|
static void
|
|
_wrap_GstBaseSrc__proxy_do_get_times (GstBaseSrc * self,
|
|
GstBuffer *buffer,
|
|
GstClockTime * start,
|
|
GstClockTime * end)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_args;
|
|
PyObject *py_self;
|
|
PyObject *py_method;
|
|
PyObject *py_ret;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
return;
|
|
}
|
|
|
|
py_args = Py_BuildValue ("(N)",
|
|
pygstminiobject_new((GstMiniObject *)buffer));
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_get_times");
|
|
|
|
Py_DECREF(py_self);
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, py_args);
|
|
|
|
Py_DECREF(py_method);
|
|
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
/*
|
|
If the method returned a numeric, the return value will be TRUE.
|
|
For ANY other case, we don't set size and the return value is FALSE.
|
|
*/
|
|
|
|
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2))
|
|
PyArg_ParseTuple (py_ret, "KK", start, end);
|
|
|
|
Py_DECREF (py_ret);
|
|
beach:
|
|
Py_DECREF (py_args);
|
|
pyg_gil_state_release(__py_state);
|
|
return;
|
|
}
|
|
%%
|
|
override GstBaseSrc__do_get_times kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseSrc__do_get_times (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "buffer", NULL };
|
|
PyGObject *self;
|
|
PyGstMiniObject *py_buffer;
|
|
GstClockTime start = 0;
|
|
GstClockTime end = 0;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseSrc.get_times",
|
|
kwlist, &PyGstBaseSrc_Type, &self,
|
|
&PyGstBuffer_Type, &py_buffer))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_SRC_CLASS(klass)->get_times) {
|
|
pyg_begin_allow_threads;
|
|
GST_BASE_SRC_CLASS(klass)->get_times(GST_BASE_SRC(self->obj),
|
|
GST_BUFFER(py_buffer->obj),
|
|
&start, &end);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.get_times not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyTuple_New(2);
|
|
PyTuple_SetItem(py_ret, 0, PyLong_FromUnsignedLongLong(start));
|
|
PyTuple_SetItem(py_ret, 1, PyLong_FromUnsignedLongLong(end));
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstPushSrc__proxy_do_create
|
|
static GstFlowReturn
|
|
_wrap_GstPushSrc__proxy_do_create (GstPushSrc * self,
|
|
GstBuffer **buffer)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_self;
|
|
PyObject *py_method;
|
|
PyObject *py_ret;
|
|
PyGstMiniObject *py_buffer;
|
|
PyObject *py_flow;
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_create");
|
|
|
|
Py_DECREF(py_self);
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, NULL);
|
|
|
|
Py_DECREF(py_method);
|
|
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
/*
|
|
If the method returned a numeric, the return value will be TRUE.
|
|
For ANY other case, we don't set size and the return value is FALSE.
|
|
*/
|
|
|
|
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2)) {
|
|
PyArg_ParseTuple (py_ret, "O!O!", &PyGEnum_Type, &py_flow,
|
|
&PyGstBuffer_Type, &py_buffer);
|
|
*buffer = GST_BUFFER (((PyGstMiniObject*) self)->obj);
|
|
gst_buffer_ref (*buffer);
|
|
pyg_enum_get_value(GST_TYPE_FLOW_RETURN, py_flow, (gint*)&ret);
|
|
}
|
|
|
|
Py_DECREF (py_ret);
|
|
beach:
|
|
pyg_gil_state_release(__py_state);
|
|
return ret;
|
|
}
|
|
%%
|
|
override GstPushSrc__do_create kwargs
|
|
static PyObject *
|
|
_wrap_GstPushSrc__do_create (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", NULL };
|
|
PyGObject *self;
|
|
GstBuffer *buffer;
|
|
GstFlowReturn flow;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstPushSrc.create",
|
|
kwlist, &PyGstPushSrc_Type, &self))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_PUSH_SRC_CLASS(klass)->create) {
|
|
pyg_begin_allow_threads;
|
|
flow = GST_PUSH_SRC_CLASS(klass)->create(GST_PUSH_SRC(self->obj),
|
|
(GstBuffer**) &buffer);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstPushSrc.create not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyTuple_New(2);
|
|
PyList_SetItem(py_ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, flow));
|
|
PyList_SetItem(py_ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buffer)));
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstBaseTransform__proxy_do_get_unit_size
|
|
static gboolean
|
|
_wrap_GstBaseTransform__proxy_do_get_unit_size (GstBaseTransform * self,
|
|
GstCaps * caps,
|
|
guint * size)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_self;
|
|
PyObject *py_caps;
|
|
gboolean ret = FALSE;
|
|
PyObject *py_args;
|
|
PyObject *py_method;
|
|
PyObject *py_ret;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
if (caps)
|
|
py_caps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
|
else {
|
|
Py_INCREF (Py_None);
|
|
py_caps = Py_None;
|
|
}
|
|
|
|
py_args = PyTuple_New(1);
|
|
PyTuple_SET_ITEM(py_args, 0, py_caps);
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_get_unit_size");
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, py_args);
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
goto beach;
|
|
}
|
|
|
|
/*
|
|
If the method returned a numeric, the return value will be TRUE.
|
|
For ANY other case, we don't set size and the return value is FALSE.
|
|
*/
|
|
|
|
if (PyInt_Check(py_ret)) {
|
|
*size = PyInt_AsLong(py_ret);
|
|
ret = TRUE;
|
|
}
|
|
|
|
Py_DECREF(py_method);
|
|
Py_DECREF(py_args);
|
|
Py_DECREF(py_self);
|
|
Py_DECREF(py_ret);
|
|
|
|
beach:
|
|
pyg_gil_state_release(__py_state);
|
|
return ret;
|
|
}
|
|
%%
|
|
override GstBaseTransform__do_get_unit_size kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseTransform__do_get_unit_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "caps", NULL };
|
|
PyGObject *self;
|
|
PyGObject *caps;
|
|
gboolean ret;
|
|
guint size = 0;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseTransform.get_unit_size",
|
|
kwlist, &PyGstBaseTransform_Type, &self, &PyGstCaps_Type, &caps))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_TRANSFORM_CLASS(klass)->get_unit_size) {
|
|
pyg_begin_allow_threads;
|
|
ret = GST_BASE_TRANSFORM_CLASS(klass)->get_unit_size(GST_BASE_TRANSFORM(self->obj), GST_CAPS(caps->obj), &size);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.get_unit_size not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyLong_FromUnsignedLongLong(size);
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstBaseTransform__proxy_do_transform_size
|
|
static gboolean
|
|
_wrap_GstBaseTransform__proxy_do_transform_size (GstBaseTransform * self,
|
|
GstPadDirection direction,
|
|
GstCaps * caps,
|
|
guint size,
|
|
GstCaps * othercaps,
|
|
guint * othersize)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_self = NULL;
|
|
PyObject *py_direction = NULL;
|
|
PyObject *py_caps = NULL;
|
|
PyObject *py_size = NULL;
|
|
PyObject *py_othercaps = NULL;
|
|
PyObject *py_args = NULL;
|
|
PyObject *py_method = NULL;
|
|
PyObject *py_ret = NULL;
|
|
gboolean ret = FALSE;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_direction = pyg_enum_from_gtype(GST_TYPE_PAD_DIRECTION, direction);
|
|
|
|
if (caps)
|
|
py_caps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
|
else {
|
|
Py_INCREF (Py_None);
|
|
py_caps = Py_None;
|
|
}
|
|
|
|
py_size = PyInt_FromLong(size);
|
|
|
|
if (othercaps)
|
|
py_othercaps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
|
else {
|
|
Py_INCREF (Py_None);
|
|
py_othercaps = Py_None;
|
|
}
|
|
|
|
py_args = PyTuple_New(4);
|
|
PyTuple_SET_ITEM(py_args, 0, py_direction);
|
|
PyTuple_SET_ITEM(py_args, 1, py_caps);
|
|
PyTuple_SET_ITEM(py_args, 2, py_size);
|
|
PyTuple_SET_ITEM(py_args, 3, py_othercaps);
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_transform_size");
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, py_args);
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
if (PyInt_Check(py_ret)) {
|
|
*othersize = PyInt_AsLong(py_ret);
|
|
ret = TRUE;
|
|
}
|
|
|
|
beach:
|
|
Py_XDECREF(py_self);
|
|
Py_XDECREF(py_args);
|
|
Py_XDECREF(py_method);
|
|
Py_XDECREF(py_ret);
|
|
|
|
pyg_gil_state_release(__py_state);
|
|
return ret;
|
|
}
|
|
%%
|
|
override GstBaseTransform__do_transform_size kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseTransform__do_transform_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "direction", "caps", "size", "othercaps", NULL };
|
|
PyGObject *self;
|
|
PyGObject *py_direction;
|
|
PyGObject *py_caps;
|
|
PyGObject *py_othercaps;
|
|
gboolean ret;
|
|
GstPadDirection direction;
|
|
guint size = 0;
|
|
guint othersize = 0;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!iO!:GstBaseTransform.get_unit_size",
|
|
kwlist, &PyGstBaseTransform_Type, &self, &PyGEnum_Type, &py_direction,
|
|
&PyGstCaps_Type, &py_caps, &size, &PyGstCaps_Type, &py_othercaps))
|
|
return NULL;
|
|
|
|
pyg_enum_get_value(GST_TYPE_PAD_DIRECTION,
|
|
(PyObject *) py_direction, (gint *) &direction);
|
|
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_TRANSFORM_CLASS(klass)->transform_size) {
|
|
pyg_begin_allow_threads;
|
|
ret = GST_BASE_TRANSFORM_CLASS(klass)->transform_size(GST_BASE_TRANSFORM(self->obj),
|
|
direction, GST_CAPS(py_caps->obj), size,
|
|
GST_CAPS(py_othercaps->obj), &othersize);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.transform_size not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyLong_FromUnsignedLongLong(othersize);
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override GstBaseSink__proxy_do_get_times
|
|
static void
|
|
_wrap_GstBaseSink__proxy_do_get_times (GstBaseSink * self,
|
|
GstBuffer *buffer,
|
|
GstClockTime * start,
|
|
GstClockTime * end)
|
|
{
|
|
PyGILState_STATE __py_state;
|
|
PyObject *py_args;
|
|
PyObject *py_self;
|
|
PyObject *py_method;
|
|
PyObject *py_ret;
|
|
|
|
__py_state = pyg_gil_state_ensure();
|
|
|
|
py_self = pygobject_new((GObject *) self);
|
|
if (!py_self) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
pyg_gil_state_release(__py_state);
|
|
return;
|
|
}
|
|
|
|
py_args = Py_BuildValue ("(N)",
|
|
pygstminiobject_new((GstMiniObject *)buffer));
|
|
|
|
py_method = PyObject_GetAttrString(py_self, "do_get_times");
|
|
|
|
Py_DECREF(py_self);
|
|
|
|
if (!py_method) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
py_ret = PyObject_CallObject(py_method, py_args);
|
|
|
|
Py_DECREF(py_method);
|
|
|
|
if (!py_ret) {
|
|
if (PyErr_Occurred())
|
|
PyErr_Print();
|
|
goto beach;
|
|
}
|
|
|
|
/*
|
|
If the method returned a numeric, the return value will be TRUE.
|
|
For ANY other case, we don't set size and the return value is FALSE.
|
|
*/
|
|
|
|
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2))
|
|
PyArg_ParseTuple (py_ret, "KK", start, end);
|
|
|
|
Py_DECREF (py_ret);
|
|
beach:
|
|
Py_DECREF (py_args);
|
|
pyg_gil_state_release(__py_state);
|
|
return;
|
|
}
|
|
%%
|
|
override GstBaseSink__do_get_times kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseSink__do_get_times (PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "buffer", NULL };
|
|
PyGObject *self;
|
|
PyGstMiniObject *py_buffer;
|
|
GstClockTime start = 0;
|
|
GstClockTime end = 0;
|
|
PyObject *py_ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseSink.get_times",
|
|
kwlist, &PyGstBaseSink_Type, &self,
|
|
&PyGstBuffer_Type, &py_buffer))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_SINK_CLASS(klass)->get_times) {
|
|
pyg_begin_allow_threads;
|
|
GST_BASE_SINK_CLASS(klass)->get_times(GST_BASE_SINK(self->obj),
|
|
GST_BUFFER(py_buffer->obj),
|
|
&start, &end);
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSink.get_times not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
|
|
py_ret = PyTuple_New(2);
|
|
PyTuple_SetItem(py_ret, 0, PyLong_FromUnsignedLongLong(start));
|
|
PyTuple_SetItem(py_ret, 1, PyLong_FromUnsignedLongLong(end));
|
|
|
|
return py_ret;
|
|
}
|
|
%%
|
|
override gst_base_sink_query_latency noargs
|
|
static PyObject *
|
|
_wrap_gst_base_sink_query_latency (PyGObject *self)
|
|
{
|
|
gboolean res, live = FALSE, upstream_live = FALSE;
|
|
GstClockTime minlat = GST_CLOCK_TIME_NONE, maxlat = GST_CLOCK_TIME_NONE;
|
|
|
|
res = gst_base_sink_query_latency (GST_BASE_SINK (self->obj), &live, &upstream_live,
|
|
&minlat, &maxlat);
|
|
return Py_BuildValue("(OOOKK)",
|
|
PyBool_FromLong(res),
|
|
PyBool_FromLong(live),
|
|
PyBool_FromLong(upstream_live),
|
|
minlat, maxlat);
|
|
}
|
|
%%
|
|
override gst_base_src_query_latency noargs
|
|
static PyObject *
|
|
_wrap_gst_base_src_query_latency (PyGObject *self)
|
|
{
|
|
gboolean res, live = FALSE;
|
|
GstClockTime minlat = GST_CLOCK_TIME_NONE, maxlat = GST_CLOCK_TIME_NONE;
|
|
|
|
res = gst_base_src_query_latency (GST_BASE_SRC (self->obj), &live,
|
|
&minlat, &maxlat);
|
|
return Py_BuildValue("(OOKK)",
|
|
PyBool_FromLong(res),
|
|
PyBool_FromLong(live),
|
|
minlat, maxlat);
|
|
}
|
|
%%
|
|
override GstBaseTransform__do_src_event kwargs
|
|
static PyObject *
|
|
_wrap_GstBaseTransform__do_src_event(PyObject *cls, PyObject *args, PyObject *kwargs)
|
|
{
|
|
gpointer klass;
|
|
static char *kwlist[] = { "self", "event", NULL };
|
|
PyGObject *self;
|
|
int ret;
|
|
PyGstMiniObject *event;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!:GstBaseTransform.src_event", kwlist, &PyGstBaseTransform_Type, &self, &PyGstEvent_Type, &event))
|
|
return NULL;
|
|
klass = g_type_class_ref(pyg_type_from_object(cls));
|
|
if (GST_BASE_TRANSFORM_CLASS(klass)->src_event) {
|
|
pyg_begin_allow_threads;
|
|
ret = GST_BASE_TRANSFORM_CLASS(klass)->src_event(GST_BASE_TRANSFORM(self->obj),
|
|
gst_event_ref (GST_EVENT(event->obj)));
|
|
pyg_end_allow_threads;
|
|
} else {
|
|
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.src_event not implemented");
|
|
g_type_class_unref(klass);
|
|
return NULL;
|
|
}
|
|
g_type_class_unref(klass);
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
|
%%
|
|
override gst_adapter_take kwargs
|
|
static PyObject *
|
|
_wrap_gst_adapter_take(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
{
|
|
static char *kwlist[] = { "nbytes", NULL };
|
|
PyObject *py_nbytes = NULL;
|
|
guint nbytes = 0;
|
|
guint8 *ret;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstAdapter.take", kwlist, &py_nbytes))
|
|
return NULL;
|
|
if (py_nbytes) {
|
|
if (PyLong_Check(py_nbytes))
|
|
nbytes = PyLong_AsUnsignedLong(py_nbytes);
|
|
else if (PyInt_Check(py_nbytes))
|
|
nbytes = PyInt_AsLong(py_nbytes);
|
|
else
|
|
PyErr_SetString(PyExc_TypeError, "Parameter 'nbytes' must be an int or a long");
|
|
if (PyErr_Occurred())
|
|
return NULL;
|
|
}
|
|
pyg_begin_allow_threads;
|
|
ret = gst_adapter_take(GST_ADAPTER(self->obj), nbytes);
|
|
pyg_end_allow_threads;
|
|
if (ret) {
|
|
PyObject *py_ret = PyString_FromStringAndSize((gchar*) ret, nbytes);
|
|
g_free(ret);
|
|
return py_ret;
|
|
}
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|
|
%%
|
|
override gst_adapter_peek kwargs
|
|
static PyObject *
|
|
_wrap_gst_adapter_peek(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
{
|
|
static char *kwlist[] = { "size", NULL };
|
|
PyObject *py_size = NULL;
|
|
const guint8 *ret;
|
|
guint size = 0;
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstAdapter.peek", kwlist, &py_size))
|
|
return NULL;
|
|
if (py_size) {
|
|
if (PyLong_Check(py_size))
|
|
size = PyLong_AsUnsignedLong(py_size);
|
|
else if (PyInt_Check(py_size))
|
|
size = PyInt_AsLong(py_size);
|
|
else
|
|
PyErr_SetString(PyExc_TypeError, "Parameter 'size' must be an int or a long");
|
|
if (PyErr_Occurred())
|
|
return NULL;
|
|
}
|
|
pyg_begin_allow_threads;
|
|
ret = gst_adapter_peek(GST_ADAPTER(self->obj), size);
|
|
pyg_end_allow_threads;
|
|
if (ret)
|
|
return PyString_FromStringAndSize((gchar*) ret, size);
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|