From c09393b5b94d124b76eeb6ff1981f25d63f229c2 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 1 Dec 2006 17:41:28 +0000 Subject: [PATCH] gst/: Add implementation of gst.Pad.set_setcaps_function(). Original commit message from CVS: * gst/common.h: * gst/gstpad.override: Add implementation of gst.Pad.set_setcaps_function(). --- ChangeLog | 6 ++++++ gst/common.h | 1 + gst/gstpad.override | 49 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/ChangeLog b/ChangeLog index cf028eb839..ab14c59414 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-01 Edward Hervey + + * gst/common.h: + * gst/gstpad.override: + Add implementation of gst.Pad.set_setcaps_function(). + 2006-11-28 Edward Hervey * configure.ac: diff --git a/gst/common.h b/gst/common.h index c276416949..e3957ee247 100644 --- a/gst/common.h +++ b/gst/common.h @@ -42,6 +42,7 @@ typedef struct { GClosure *chain_function; GClosure *get_function; GClosure *getcaps_function; + GClosure *setcaps_function; } PyGstPadPrivate; typedef struct { diff --git a/gst/gstpad.override b/gst/gstpad.override index f042cd9529..39335b74d7 100644 --- a/gst/gstpad.override +++ b/gst/gstpad.override @@ -80,6 +80,7 @@ free_pad_private (gpointer data) INVALIDATE_CLOSURE (private->chain_function) INVALIDATE_CLOSURE (private->get_function) INVALIDATE_CLOSURE (private->getcaps_function) + INVALIDATE_CLOSURE (private->setcaps_function) #undef INVALIDATE_CLOSURE } @@ -347,6 +348,54 @@ _wrap_gst_pad_set_event_function (PyGObject *self, kwargs, event_function) } +%% +override gst_pad_set_setcaps_function kwargs + +static void EXCEPTION_HANDLER +handle_setcaps_function_exception (GValue *ret, guint n, const GValue *params) +{ + GstElement *element = GST_ELEMENT (gst_pad_get_parent (g_value_get_object (¶ms[0]))); + + if (!_pygst_element_check_error (element)) { + g_assert_not_reached (); /* only returns FALSE when there's no error */ + } +} + +static gboolean +call_setcaps_function (GstPad *pad, GstCaps *caps) +{ + GClosure *closure; + GValue ret = { 0, }; + GValue args[2] = { { 0, }, { 0, } }; + gboolean bool; + + g_value_init (&ret, G_TYPE_BOOLEAN); + g_value_set_boolean (&ret, FALSE); + g_value_init (&args[0], GST_TYPE_PAD); + g_value_init (&args[1], GST_TYPE_CAPS); + g_value_set_object (&args[0], pad); + gst_value_set_caps (&args[1], (const GstCaps*) caps); + closure = pad_private(pad)->setcaps_function; + + g_closure_invoke (closure, &ret, 2, args, NULL); + + bool = g_value_get_boolean (&ret); + + g_value_unset (&ret); + g_value_unset (&args[0]); + g_value_unset (&args[1]); + return bool; +} + +static PyObject* +_wrap_gst_pad_set_setcaps_function (PyGObject *self, + PyObject *args, + PyObject *kwargs) +{ + SET_PAD_CLOSURE (self, args, + kwargs, setcaps_function) +} + %% override-slot GstPad.tp_repr static PyObject *