From a8a9c7e9d57815868d3fb6855eec46e3125de259 Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Fri, 4 Oct 2002 05:40:37 +0000 Subject: [PATCH] add boxed types adapt to boxed types remove obsoleted code Original commit message from CVS: add boxed types adapt to boxed types remove obsoleted code --- ChangeLog | 18 +++++++ gst/Makefile.am | 2 +- gst/gstreamer-extra.defs | 44 ++++++++++++--- gst/gstreamer.override | 98 +++++----------------------------- gstreamer/Makefile.am | 2 +- gstreamer/gstreamer-extra.defs | 44 ++++++++++++--- gstreamer/gstreamer.override | 98 +++++----------------------------- 7 files changed, 124 insertions(+), 182 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a9d80ec82..6dbbcf7367 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2002-10-04 David I. Lehn + + * README: basic info. + + * COPYING: remove the literal "^L" strings. + + * configure.ac: require GStreamer core 0.4.1. + + * gstreamer/gstreamer-extra.defs: add boxed type defs, convert buffer + get/set_data to methods vs functions. + + * gstreamer/gstreamer.overrides: remove boxed type generated code, + adapt rest to boxed types. + + * examples/gstreamer/*: set interpreter to "python" vs "python2.2", + adapt to newer generated code (Pipeline vs gst_pipeline_new()), adapt + to newer api. + 2002-05-09 David I. Lehn * examples/gstreamer/dvdplay.py: adjust state changes, diff --git a/gst/Makefile.am b/gst/Makefile.am index f7b5256246..3ef8a378ff 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -23,7 +23,7 @@ GST_INCLUDES=$(wildcard $(GST_INCLUDEDIR)/gst/*.h) gstreamer-base.defs: $(GST_INCLUDES) $(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > gstreamer-base.defs -gstreamer.defs: gstreamer-base.defs gstreamer-extra.defs +gstreamer.defs: gstreamer-base.defs gstreamer-extra.defs $(top_srcdir)/gstreamer/gstreamer-arg-types.py cat gstreamer-base.defs gstreamer-extra.defs > gstreamer.defs .defs.c: diff --git a/gst/gstreamer-extra.defs b/gst/gstreamer-extra.defs index e44d543bb2..bc51e3ab74 100644 --- a/gst/gstreamer-extra.defs +++ b/gst/gstreamer-extra.defs @@ -1,20 +1,52 @@ +;; +;; Boxed types +;; + +(define-boxed Buffer + (in-module "Gst") + (c-name "GstBuffer") + (gtype-id "GST_TYPE_BUFFER") +) + +(define-boxed BufferPool + (in-module "Gst") + (c-name "GstBufferPool") + (gtype-id "GST_TYPE_BUFFER_POOL") +) + +(define-boxed Caps + (in-module "Gst") + (c-name "GstCaps") + (gtype-id "GST_TYPE_CAPS") +) + +(define-boxed Event + (in-module "Gst") + (c-name "GstEvent") + (gtype-id "GST_TYPE_EVENT") +) + +(define-boxed Props + (in-module "Gst") + (c-name "GstProps") + (gtype-id "GST_TYPE_PROPS") +) + ;; ;; HACK ;; -(define-function gst_buffer_get_data +(define-method get_data + (of-object "GstBuffer") (c-name "gst_buffer_get_data") (return-type "char*") - (parameters - '("GstBuffer*" "buf") - ) ) -(define-function gst_buffer_set_data +(define-method set_data + (of-object "GstBuffer") (c-name "gst_buffer_set_data") (return-type "none") (parameters - '("GstBuffer*" "buf") '("char*" "data") ) ) diff --git a/gst/gstreamer.override b/gst/gstreamer.override index b27a582568..c8985d32f6 100644 --- a/gst/gstreamer.override +++ b/gst/gstreamer.override @@ -81,7 +81,7 @@ call_connect_function (GstPad *pad, GstCaps *caps) retval = (PyObject*)PyObject_CallFunction (function, "OO", pad_private(pad)->pad, - PyCObject_FromVoidPtr (caps, NULL)); + pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE)); if (PyErr_Occurred ()) { PyErr_Print (); @@ -124,7 +124,7 @@ _wrap_gst_pad_set_connect_function (PyGObject *self, override gst_pad_set_chain_function kwargs static void -call_chain_function (GstPad *pad, GstBuffer *buf) +call_chain_function(GstPad *pad, GstBuffer *buf) { PyObject *function; @@ -133,7 +133,7 @@ call_chain_function (GstPad *pad, GstBuffer *buf) PyObject_CallFunction (function, "OO", pad_private(pad)->pad, - PyCObject_FromVoidPtr (buf, NULL)); + pyg_boxed_new(GST_TYPE_BUFFER, buf, TRUE, TRUE)); if (PyErr_Occurred ()) { PyErr_Print (); @@ -142,9 +142,9 @@ call_chain_function (GstPad *pad, GstBuffer *buf) } static PyObject* -_wrap_gst_pad_set_chain_function (PyGObject *self, - PyObject *args, - PyObject *kwargs) +_wrap_gst_pad_set_chain_function(PyGObject *self, + PyObject *args, + PyObject *kwargs) { static char *kwlist[] = { "chain_function", NULL }; PyObject *chain_function; @@ -171,95 +171,41 @@ _wrap_gst_pad_set_chain_function (PyGObject *self, return Py_None; } %% -override gst_pad_push kwargs - -static PyObject* -_wrap_gst_pad_push (PyGObject *self, - PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "buffer", NULL }; - PyObject *pybuf; - GstBuffer *buf; - GstPad *pad; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GstPad.push", - kwlist, - &pybuf)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "push expecting a PyCObject"); - return NULL; - } - - pad = (GstPad*)pygobject_get(self); - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); - gst_pad_push(pad, buf); - - Py_INCREF(Py_None); - return Py_None; -} -%% override gst_buffer_get_data static PyObject* -_wrap_gst_buffer_get_data (PyObject *self, - PyObject *args) +_wrap_gst_buffer_get_data(PyObject *self) { - PyObject *pybuf; GstBuffer *buf; - if (!PyArg_ParseTuple(args, - "O:GstBuffer:get_data", - &pybuf)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "get_data expecting a PyCObject"); - return NULL; - } - - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); + buf = pyg_boxed_get(self, GstBuffer); return PyString_FromStringAndSize( GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); } %% -override gst_buffer_set_data +override gst_buffer_set_data kwargs static PyObject* -_wrap_gst_buffer_set_data (PyObject *self, - PyObject *args) +_wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *pybuf; + static char *kwlist[] = {"data", NULL}; PyObject *data; GstBuffer *buf; - if (!PyArg_ParseTuple(args, - "OO:GstBuffer:set_data", - &pybuf, &data)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "set_data expecting a PyCObject"); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer:set_data", kwlist, &data)) { return NULL; } if (!PyString_Check(data)) { - PyErr_SetString(PyExc_TypeError, "set_data expecting a string"); + PyErr_SetString(PyExc_TypeError, "data should be a string"); return NULL; } + buf = pyg_boxed_get(self, GstBuffer); if (GST_BUFFER_FLAGS(buf) & GST_BUFFER_READONLY) { PyErr_SetString(PyExc_TypeError, "set_data can't use a READONLY buffer"); return NULL; } - - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); GST_BUFFER_SIZE(buf) = PyString_Size(data); GST_BUFFER_DATA(buf) = g_new0(char, GST_BUFFER_SIZE(buf)); @@ -270,19 +216,3 @@ _wrap_gst_buffer_set_data (PyObject *self, Py_INCREF(Py_None); return Py_None; } -%% -override gst_buffer_new - -static PyObject* -_wrap_gst_buffer_new (PyObject *self, - PyObject *args) -{ - GstBuffer *newbuf; - - if (!PyArg_ParseTuple(args, ":GstBuffer:set_data")) { - return NULL; - } - - newbuf = gst_buffer_new(); - return PyCObject_FromVoidPtr (newbuf, NULL); -} diff --git a/gstreamer/Makefile.am b/gstreamer/Makefile.am index f7b5256246..3ef8a378ff 100644 --- a/gstreamer/Makefile.am +++ b/gstreamer/Makefile.am @@ -23,7 +23,7 @@ GST_INCLUDES=$(wildcard $(GST_INCLUDEDIR)/gst/*.h) gstreamer-base.defs: $(GST_INCLUDES) $(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > gstreamer-base.defs -gstreamer.defs: gstreamer-base.defs gstreamer-extra.defs +gstreamer.defs: gstreamer-base.defs gstreamer-extra.defs $(top_srcdir)/gstreamer/gstreamer-arg-types.py cat gstreamer-base.defs gstreamer-extra.defs > gstreamer.defs .defs.c: diff --git a/gstreamer/gstreamer-extra.defs b/gstreamer/gstreamer-extra.defs index e44d543bb2..bc51e3ab74 100644 --- a/gstreamer/gstreamer-extra.defs +++ b/gstreamer/gstreamer-extra.defs @@ -1,20 +1,52 @@ +;; +;; Boxed types +;; + +(define-boxed Buffer + (in-module "Gst") + (c-name "GstBuffer") + (gtype-id "GST_TYPE_BUFFER") +) + +(define-boxed BufferPool + (in-module "Gst") + (c-name "GstBufferPool") + (gtype-id "GST_TYPE_BUFFER_POOL") +) + +(define-boxed Caps + (in-module "Gst") + (c-name "GstCaps") + (gtype-id "GST_TYPE_CAPS") +) + +(define-boxed Event + (in-module "Gst") + (c-name "GstEvent") + (gtype-id "GST_TYPE_EVENT") +) + +(define-boxed Props + (in-module "Gst") + (c-name "GstProps") + (gtype-id "GST_TYPE_PROPS") +) + ;; ;; HACK ;; -(define-function gst_buffer_get_data +(define-method get_data + (of-object "GstBuffer") (c-name "gst_buffer_get_data") (return-type "char*") - (parameters - '("GstBuffer*" "buf") - ) ) -(define-function gst_buffer_set_data +(define-method set_data + (of-object "GstBuffer") (c-name "gst_buffer_set_data") (return-type "none") (parameters - '("GstBuffer*" "buf") '("char*" "data") ) ) diff --git a/gstreamer/gstreamer.override b/gstreamer/gstreamer.override index b27a582568..c8985d32f6 100644 --- a/gstreamer/gstreamer.override +++ b/gstreamer/gstreamer.override @@ -81,7 +81,7 @@ call_connect_function (GstPad *pad, GstCaps *caps) retval = (PyObject*)PyObject_CallFunction (function, "OO", pad_private(pad)->pad, - PyCObject_FromVoidPtr (caps, NULL)); + pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE)); if (PyErr_Occurred ()) { PyErr_Print (); @@ -124,7 +124,7 @@ _wrap_gst_pad_set_connect_function (PyGObject *self, override gst_pad_set_chain_function kwargs static void -call_chain_function (GstPad *pad, GstBuffer *buf) +call_chain_function(GstPad *pad, GstBuffer *buf) { PyObject *function; @@ -133,7 +133,7 @@ call_chain_function (GstPad *pad, GstBuffer *buf) PyObject_CallFunction (function, "OO", pad_private(pad)->pad, - PyCObject_FromVoidPtr (buf, NULL)); + pyg_boxed_new(GST_TYPE_BUFFER, buf, TRUE, TRUE)); if (PyErr_Occurred ()) { PyErr_Print (); @@ -142,9 +142,9 @@ call_chain_function (GstPad *pad, GstBuffer *buf) } static PyObject* -_wrap_gst_pad_set_chain_function (PyGObject *self, - PyObject *args, - PyObject *kwargs) +_wrap_gst_pad_set_chain_function(PyGObject *self, + PyObject *args, + PyObject *kwargs) { static char *kwlist[] = { "chain_function", NULL }; PyObject *chain_function; @@ -171,95 +171,41 @@ _wrap_gst_pad_set_chain_function (PyGObject *self, return Py_None; } %% -override gst_pad_push kwargs - -static PyObject* -_wrap_gst_pad_push (PyGObject *self, - PyObject *args, - PyObject *kwargs) -{ - static char *kwlist[] = { "buffer", NULL }; - PyObject *pybuf; - GstBuffer *buf; - GstPad *pad; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "O:GstPad.push", - kwlist, - &pybuf)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "push expecting a PyCObject"); - return NULL; - } - - pad = (GstPad*)pygobject_get(self); - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); - gst_pad_push(pad, buf); - - Py_INCREF(Py_None); - return Py_None; -} -%% override gst_buffer_get_data static PyObject* -_wrap_gst_buffer_get_data (PyObject *self, - PyObject *args) +_wrap_gst_buffer_get_data(PyObject *self) { - PyObject *pybuf; GstBuffer *buf; - if (!PyArg_ParseTuple(args, - "O:GstBuffer:get_data", - &pybuf)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "get_data expecting a PyCObject"); - return NULL; - } - - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); + buf = pyg_boxed_get(self, GstBuffer); return PyString_FromStringAndSize( GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); } %% -override gst_buffer_set_data +override gst_buffer_set_data kwargs static PyObject* -_wrap_gst_buffer_set_data (PyObject *self, - PyObject *args) +_wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *pybuf; + static char *kwlist[] = {"data", NULL}; PyObject *data; GstBuffer *buf; - if (!PyArg_ParseTuple(args, - "OO:GstBuffer:set_data", - &pybuf, &data)) { - return NULL; - } - - if (!PyCObject_Check(pybuf)) { - PyErr_SetString(PyExc_TypeError, "set_data expecting a PyCObject"); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer:set_data", kwlist, &data)) { return NULL; } if (!PyString_Check(data)) { - PyErr_SetString(PyExc_TypeError, "set_data expecting a string"); + PyErr_SetString(PyExc_TypeError, "data should be a string"); return NULL; } + buf = pyg_boxed_get(self, GstBuffer); if (GST_BUFFER_FLAGS(buf) & GST_BUFFER_READONLY) { PyErr_SetString(PyExc_TypeError, "set_data can't use a READONLY buffer"); return NULL; } - - buf = (GstBuffer*)PyCObject_AsVoidPtr(pybuf); GST_BUFFER_SIZE(buf) = PyString_Size(data); GST_BUFFER_DATA(buf) = g_new0(char, GST_BUFFER_SIZE(buf)); @@ -270,19 +216,3 @@ _wrap_gst_buffer_set_data (PyObject *self, Py_INCREF(Py_None); return Py_None; } -%% -override gst_buffer_new - -static PyObject* -_wrap_gst_buffer_new (PyObject *self, - PyObject *args) -{ - GstBuffer *newbuf; - - if (!PyArg_ParseTuple(args, ":GstBuffer:set_data")) { - return NULL; - } - - newbuf = gst_buffer_new(); - return PyCObject_FromVoidPtr (newbuf, NULL); -}