From f63c95390b4027d2fbdf7e8537435d6a058014a9 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 3 May 2004 09:10:26 +0000 Subject: [PATCH] codegen/codegen.py: Resync (add support for tp_as_buffer) Original commit message from CVS: * codegen/codegen.py: Resync (add support for tp_as_buffer) * gst/gst.override: Support buffer interface for GstBuffer. Move stuff into common.h, fix wrapping for gst_pad_template_get_caps_by_name --- ChangeLog | 8 +++ codegen/codegen.py | 4 +- configure.ac | 10 ++++ gst/gst-types.defs | 8 +-- gst/gst.override | 116 +++++++++++++++++++++++++++++----------- gst/interfaces.override | 10 ++-- gst/play.override | 10 ++-- 7 files changed, 122 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44d3433157..2cf12ead19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-05-03 Johan Dahlin + + * codegen/codegen.py: Resync (add support for tp_as_buffer) + + * gst/gst.override: Support buffer interface for GstBuffer. Move + stuff into common.h, fix wrapping for + gst_pad_template_get_caps_by_name + 2004-05-01 Johan Dahlin * testsuite/runtests.py (gettestnames): Cleanup diff --git a/codegen/codegen.py b/codegen/codegen.py index d348314da6..0c9fdfe993 100644 --- a/codegen/codegen.py +++ b/codegen/codegen.py @@ -74,7 +74,7 @@ class Wrapper: ' (reprfunc)%(tp_str)s, /* tp_str */\n' \ ' (getattrofunc)0, /* tp_getattro */\n' \ ' (setattrofunc)0, /* tp_setattro */\n' \ - ' 0, /* tp_as_buffer */\n' \ + ' (PyBufferProcs*)%(tp_as_buffer)s, /* tp_as_buffer */\n' \ ' Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */\n' \ ' NULL, /* Documentation string */\n' \ ' (traverseproc)0, /* tp_traverse */\n' \ @@ -100,7 +100,7 @@ class Wrapper: slots_list = ['tp_getattr', 'tp_setattr', 'tp_compare', 'tp_repr', 'tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'tp_hash', - 'tp_call', 'tp_str', 'tp_richcompare', 'tp_iter', + 'tp_call', 'tp_str', 'tp_as_buffer', 'tp_richcompare', 'tp_iter', 'tp_iternext', 'tp_descr_get', 'tp_descr_set', 'tp_init', 'tp_alloc', 'tp_new', 'tp_free', 'tp_is_gc'] diff --git a/configure.ac b/configure.ac index c4492dd802..36cc35487a 100644 --- a/configure.ac +++ b/configure.ac @@ -77,6 +77,7 @@ dnl AC_MSG_RESULT($PYGTK_CODEGEN) PYGTK_CODEGEN="$PYTHON \$(top_srcdir)/codegen/codegen.py" AC_SUBST(PYGTK_CODEGEN) +dnl Interfaces AC_MSG_CHECKING(for GStreamer interfaces include dir) PKG_CHECK_MODULES(GST_INTERFACES, gstreamer-interfaces-$GST_MAJORMINOR, HAVE_INTERFACES=yes,HAVE_INTERFACES=no) @@ -84,6 +85,7 @@ AM_CONDITIONAL(BUILD_INTERFACES, test "x$HAVE_INTERFACES" = "xyes") AC_SUBST(GST_INTERFACES_CFLAGS) AC_SUBST(GST_INTERFACES_LIBS) +dnl Play AC_MSG_CHECKING(for GStreamer play include dir) PKG_CHECK_MODULES(GST_PLAY, gstreamer-play-$GST_MAJORMINOR, HAVE_PLAY=yes,HAVE_PLAY=no) @@ -91,6 +93,14 @@ AM_CONDITIONAL(BUILD_PLAY, test "x$HAVE_PLAY" = "xyes") AC_SUBST(GST_PLAY_CFLAGS) AC_SUBST(GST_PLAY_LIBS) +dnl Editor +AC_MSG_CHECKING(for GStreamer editor include dir) +PKG_CHECK_MODULES(GST_EDITOR, gst-editor-libs >= 0.7.0, + HAVE_EDITOR=yes,HAVE_EDITOR=no) +AM_CONDITIONAL(BUILD_EDITOR, test "x$HAVE_EDITOR" = "xyes") +AC_SUBST(GST_EDITOR_CFLAGS) +AC_SUBST(GST_EDITOR_LIBS) + AC_CHECK_PROG(HAVE_XMLTO, xmlto, true, false) AC_CHECK_PROG(HAVE_XMLCATALOG, xmlcatalog, true, false) diff --git a/gst/gst-types.defs b/gst/gst-types.defs index 2d43c716f6..d85f0fec64 100644 --- a/gst/gst-types.defs +++ b/gst/gst-types.defs @@ -169,6 +169,7 @@ (gtype-id "GST_TYPE_CAPS") ) +; Defined in arg-types.py ;(define-boxed Data ; (in-module "Gst") ; (c-name "GstData") @@ -177,12 +178,13 @@ ; (release-func "gst_data_free") ;) -(define-boxed Event +; HACK, should be boxed +(define-pointer Event (in-module "Gst") (c-name "GstEvent") (gtype-id "GST_TYPE_EVENT") - (copy-func "gst_event_copy") - (release-func "gst_data_unref") +; (copy-func "gst_event_copy") +; (release-func "gst_event_unref") ) (define-boxed GError diff --git a/gst/gst.override b/gst/gst.override index a8a65d2b9f..83d00fc2de 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -22,34 +22,18 @@ */ %% headers -#include - #ifdef HAVE_CONFIG_H # include #endif -#include "pygobject.h" +#include "common.h" + #include #include #include #include #include -#if PY_VERSION_HEX < 0x02030000 - typedef destructor freefunc; -#endif -typedef struct { - PyGObject *pad; - PyObject *link_function; - PyObject *event_function; - PyObject *chain_function; - PyObject *get_function; -} PyGstPadPrivate; - -typedef struct { - PyObject *func, *data; -} PyGstCustomNotify; - extern gboolean pygst_data_from_pyobject (PyObject *object, GstData **data); static PyObject *_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs); @@ -58,11 +42,10 @@ include gstpad-handlers.override %% init -/* This is due to a bug in PyGTK 2.3.91, should be removed when we can require - * a newer version. - */ PyGstPipeline_Type.tp_new = PyType_GenericNew; PyGstThread_Type.tp_new = PyType_GenericNew; +PyGstQueue_Type.tp_new = PyType_GenericNew; +PyGstBin_Type.tp_new = PyType_GenericNew; // Shouldn't this be enough? %% modulename gst %% @@ -202,6 +185,24 @@ _wrap_gst_element_get_pad_list(PyGObject *self) return list; } %% +override gst_element_get_pad_template_list noargs +static PyObject * +_wrap_gst_element_get_pad_template_list(PyGObject *self) +{ + GList *l, *pads; + PyObject *list; + + pads = (GList*)gst_element_get_pad_template_list(GST_ELEMENT(self->obj)); + + list = PyList_New(0); + for (l = pads; l; l = l->next) { + GstPad *pad = (GstPad*)l->data; + PyList_Append(list, pygobject_new(G_OBJECT(pad))); + } + + return list; +} +%% override gst_element_set_state kwargs static PyObject * _wrap_gst_element_set_state(PyGObject *self, PyObject *args, PyObject *kwargs) @@ -1001,7 +1002,7 @@ _wrap_gst_pad_template_get_caps(PyGObject *self) return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); } %% -override gst_type_fidn_factory_get_caps noargs +override gst_type_find_factory_get_caps noargs static PyObject * _wrap_gst_type_find_factory_get_caps(PyGObject *self) { @@ -1009,18 +1010,19 @@ _wrap_gst_type_find_factory_get_caps(PyGObject *self) return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); } %% -override gst_pad_template_get_caps_ny_name kwargs +override gst_pad_template_get_caps_by_name kwargs static PyObject * _wrap_gst_pad_template_get_caps_by_name(PyGObject *self, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "name", NULL }; - char *name; - GstCaps *ret; + static char *kwlist[] = { "name", NULL }; + char *name; + GstCaps *ret; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstPadTemplate.get_caps_by_name", kwlist, &name)) - return NULL; - ret = (GstCaps*)gst_pad_template_get_caps_by_name(GST_PAD_TEMPLATE(self->obj), name); - return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstPadTemplate.get_caps_by_name", kwlist, &name)) + return NULL; + ret = (GstCaps*)gst_pad_template_get_caps_by_name(GST_PAD_TEMPLATE(self->obj), name); + /* pyg_boxed_new handles NULL checking */ + return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE); } %% override gst_type_find_factory_get_caps noargs @@ -1076,3 +1078,57 @@ _wrap_gst_element_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { return _wrap_gst_element_factory_make(NULL, args, kwargs); } +%% +override-slot GstBuffer.tp_as_buffer +static int +gst_buffer_getreadbuffer(PyGObject *self, int index, const void **ptr) +{ + if ( index != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent string segment"); + return -1; + } + + *ptr = GST_BUFFER_DATA(self->obj); + return GST_BUFFER_SIZE(self->obj); +} + +static int +gst_buffer_getsegcount(PyGObject *self, int *lenp) +{ + if (lenp) + *lenp = GST_BUFFER_SIZE(self->obj); + return 1; +} + + +static int +gst_buffer_getcharbuf(PyGObject *self, int index, const char **ptr) +{ + if ( index != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent string segment"); + return -1; + } + + *ptr = GST_BUFFER_DATA(self->obj); + return GST_BUFFER_SIZE(self->obj); +} + +#if 0 +static int +string_buffer_getwritebuf(PyStringObject *self, int index, const void **ptr) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot use string as modifiable buffer"); + return -1; +} + +#endif + +static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = { + (getreadbufferproc)gst_buffer_getreadbuffer, + (getwritebufferproc)NULL, + (getsegcountproc)gst_buffer_getsegcount, + (getcharbufferproc)gst_buffer_getcharbuf, +}; diff --git a/gst/interfaces.override b/gst/interfaces.override index 8159bf062c..1c21bd0ced 100644 --- a/gst/interfaces.override +++ b/gst/interfaces.override @@ -21,9 +21,12 @@ */ %% headers -#include +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "common.h" -#include "pygobject.h" #include #include #include @@ -34,9 +37,6 @@ headers #include #include -#if PY_VERSION_HEX < 0x02030000 - typedef destructor freefunc; -#endif %% modulename gst.interfaces %% diff --git a/gst/play.override b/gst/play.override index ed49282000..5069776df3 100644 --- a/gst/play.override +++ b/gst/play.override @@ -21,15 +21,17 @@ */ %% headers -#include +#ifdef HAVE_CONFIG_H +# include +#endif + +#include #include "pygobject.h" + #include #include -#if PY_VERSION_HEX < 0x02030000 - typedef destructor freefunc; -#endif %% modulename gst.play %%