From 3a0177e7416e655bf96834e999f77c80a1bacfe6 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 22 Feb 2007 16:13:53 +0000 Subject: [PATCH] gst/pygstvalue.c: Implement gst.Buffer support in GValues (e.g. for caps containing buffers) Original commit message from CVS: * gst/pygstvalue.c: (pygst_value_as_pyobject), (pygst_value_init_for_pyobject), (pygst_value_from_pyobject): Implement gst.Buffer support in GValues (e.g. for caps containing buffers) --- ChangeLog | 7 +++++++ gst/pygstvalue.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 227ed348de..81176d48fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-02-22 Michael Smith + + * gst/pygstvalue.c: (pygst_value_as_pyobject), + (pygst_value_init_for_pyobject), (pygst_value_from_pyobject): + Implement gst.Buffer support in GValues (e.g. for caps containing + buffers) + 2007-02-15 David Schleef * Makefile.am: Add ACLOCAL_AMFLAGS diff --git a/gst/pygstvalue.c b/gst/pygstvalue.c index e064f0987e..625f77ddc9 100644 --- a/gst/pygstvalue.c +++ b/gst/pygstvalue.c @@ -25,7 +25,6 @@ #include "pygstvalue.h" - static PyObject *gstvalue_class = NULL; static PyObject *gstfourcc_class = NULL; static PyObject *gstintrange_class = NULL; @@ -33,6 +32,8 @@ static PyObject *gstdoublerange_class = NULL; static PyObject *gstfraction_class = NULL; static PyObject *gstfractionrange_class = NULL; +extern PyTypeObject PyGstBuffer_Type; + /** * pygst_value_as_pyobject: * @value: the GValue object. @@ -103,6 +104,8 @@ pygst_value_as_pyobject(const GValue *value, gboolean copy_boxed) pygst_value_as_pyobject (min, copy_boxed), pygst_value_as_pyobject (max, copy_boxed)), NULL); + } else if (GST_VALUE_HOLDS_BUFFER (value)) { + return pygstminiobject_new (gst_value_get_mini_object (value)); } else { gchar buf[256]; g_snprintf (buf, 256, "unknown type: %s", g_type_name (G_VALUE_TYPE (value))); @@ -144,6 +147,9 @@ pygst_value_init_for_pyobject (GValue *value, PyObject *obj) PyErr_SetString(PyExc_TypeError, "Unexpected gst.Value instance"); return FALSE; } + } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) { + PyErr_Clear (); + t = GST_TYPE_BUFFER; } else if (PyTuple_Check (obj)) { PyErr_Clear (); t = GST_TYPE_ARRAY; @@ -260,6 +266,10 @@ pygst_value_from_pyobject (GValue *value, PyObject *obj) return -1; } return 0; + } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) { + VALUE_TYPE_CHECK (value, GST_TYPE_BUFFER); + gst_value_set_buffer (value, pygstminiobject_get(obj)); + return 0; } else if (PyTuple_Check (obj)) { gint i, len; PyErr_Clear ();