From 282abc30ff8b564f904f458a38d64bcde2731344 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 13 Mar 2006 11:19:10 +0000 Subject: [PATCH] gst/: Added base elements override file. Original commit message from CVS: * gst/Makefile.am: * gst/gst.override: * gst/gstbase.override: Added base elements override file. * gst/gstpad.override: Added override for gst_pad_alloc_buffer_and_set_caps --- ChangeLog | 9 ++ gst/Makefile.am | 3 +- gst/gst.override | 1 + gst/gstbase.override | 262 +++++++++++++++++++++++++++++++++++++++++++ gst/gstpad.override | 30 +++++ 5 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 gst/gstbase.override diff --git a/ChangeLog b/ChangeLog index ab1924db20..644bcdf2a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-03-13 Edward Hervey + + * gst/Makefile.am: + * gst/gst.override: + * gst/gstbase.override: + Added base elements override file. + * gst/gstpad.override: + Added override for gst_pad_alloc_buffer_and_set_caps + 2006-03-10 Edward Hervey * gst/gst.override: diff --git a/gst/Makefile.am b/gst/Makefile.am index a99686985b..c1dc268659 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -57,7 +57,8 @@ GST_OVERRIDES = \ gstpad.override \ gststructure.override \ gsttaglist.override \ - gstlibs.override + gstlibs.override \ + gstbase.override GST_DEFS = gst.defs gst-types.defs gst-extrafuncs.defs libs.defs base.defs CLEANFILES = gst.c diff --git a/gst/gst.override b/gst/gst.override index a517b87bd9..5af1839d24 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -246,6 +246,7 @@ include gststructure.override gsttaglist.override gstlibs.override + gstbase.override %% init { diff --git a/gst/gstbase.override b/gst/gstbase.override new file mode 100644 index 0000000000..925e60f0da --- /dev/null +++ b/gst/gstbase.override @@ -0,0 +1,262 @@ +/* -*- 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 + */ + +%% +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 ("WHAT THE HEL????"); + 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) + flow = GST_BASE_SRC_CLASS(klass)->create(GST_BASE_SRC(self->obj), offset, size, &buffer); + 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) + ret = GST_BASE_SRC_CLASS(klass)->get_size(GST_BASE_SRC(self->obj), &size); + 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; +} diff --git a/gst/gstpad.override b/gst/gstpad.override index 5997613b7c..255f222fec 100644 --- a/gst/gstpad.override +++ b/gst/gstpad.override @@ -785,6 +785,36 @@ _wrap_gst_pad_alloc_buffer (PyGObject *self, PyObject * args, PyObject *kwargs) return ret; } %% +override gst_pad_alloc_buffer_and_set_caps kwargs +static PyObject * +_wrap_gst_pad_alloc_buffer_and_set_caps (PyGObject *self, PyObject * args, PyObject *kwargs) +{ + static char *kwlist[] = {"offset", "size", "caps", NULL}; + guint64 offset; + gint size; + PyObject *pcaps; + GstCaps *caps; + PyObject *ret; + GstBuffer *buf; + GstFlowReturn res; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "KiO:GstPad.alloc_buffer_and_set_caps", + kwlist, &offset, &size, &pcaps)) + return NULL; + caps = pyg_boxed_get(pcaps, GstCaps); + res = gst_pad_alloc_buffer_and_set_caps (GST_PAD(pygobject_get(self)), + offset, size, caps, &buf); + ret = PyList_New(2); + PyList_SetItem(ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, res)); + if (res != GST_FLOW_OK) { + PyList_SetItem(ret, 1, Py_None); + } else { + PyList_SetItem(ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buf))); + } + return ret; +} +%% override gst_pad_pull_range kwargs static PyObject * _wrap_gst_pad_pull_range (PyGObject *self, PyObject * args, PyObject *kwargs)