gst/: Even more bored tonight: Implement next/resync/push.

Original commit message from CVS:
* gst/common.h:
* gst/gstmodule.c: (init_gst):
* gst/pygstiterator.c: (pygst_iterator_iter_next),
(pygst_iterator_next), (pygst_iterator_push),
(pygst_iterator_resync):
Even more bored tonight: Implement next/resync/push.
Register type so we can call methods and so.
This commit is contained in:
Johan Dahlin 2005-10-07 01:52:28 +00:00
parent 7534ba0486
commit 8ff948737b
4 changed files with 60 additions and 9 deletions

View file

@ -1,3 +1,13 @@
2005-10-06 Johan Dahlin <johan@gnome.org>
* gst/common.h:
* gst/gstmodule.c: (init_gst):
* gst/pygstiterator.c: (pygst_iterator_iter_next),
(pygst_iterator_next), (pygst_iterator_push),
(pygst_iterator_resync):
Even more bored tonight: Implement next/resync/push.
Register type so we can call methods and so.
2005-10-06 Johan Dahlin <johan@gnome.org>
* codegen/argtypes.py:

View file

@ -23,6 +23,7 @@
#define __COMMON_H__
#include <Python.h>
#include <pygobject.h>
#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
@ -48,6 +49,14 @@ typedef struct {
PyObject *func, *data;
} PyGstCustomNotify;
typedef struct {
PyObject_HEAD
GstIterator *iter;
} PyGstIterator;
PyTypeObject PyGstIterator_Type;
/* from gst-types.c */
/* gboolean pygst_data_from_pyobject(PyObject *object, GstData **data); */
/* PyObject *pygst_data_to_pyobject(GstData *data); */

View file

@ -194,6 +194,7 @@ init_gst (void)
NULL);
PyDict_SetItemString(d, "RemoveError", PyGstExc_RemoveError);
REGISTER_TYPE(d, PyGstIterator_Type, "Iterator");
pygstminiobject_register_class(d, "GstMiniObject", GST_TYPE_MINI_OBJECT,

View file

@ -20,15 +20,7 @@
* Author: Johan Dahlin <johan@gnome.org>
*/
#include <gst/gstiterator.h>
#include <Python.h>
#include <pygobject.h>
#include "pygstobject.h"
typedef struct {
PyObject_HEAD
GstIterator *iter;
} PyGstIterator;
#include "common.h"
static void
pygst_iterator_dealloc(PyGstIterator *self)
@ -59,6 +51,7 @@ pygst_iterator_iter_next(PyGstIterator *self)
}
break;
case GST_ITERATOR_RESYNC:
/* XXX: add/raise gst.IteratorResync */
PyErr_SetString(PyExc_TypeError, "Resync");
break;
case GST_ITERATOR_ERROR:
@ -72,6 +65,43 @@ pygst_iterator_iter_next(PyGstIterator *self)
return retval;
}
static PyObject *
pygst_iterator_next(PyGstIterator *self)
{
/* Be compatible with Pythons API rather than GStreamers */
return pygst_iterator_iter_next(self);
}
static PyObject *
pygst_iterator_push(PyGstIterator *self, PyObject *args)
{
PyGstIterator *other;
if (!PyArg_ParseTuple(args, "O!:push", &PyGstIterator_Type, &other))
return NULL;
gst_iterator_push(self->iter, other->iter);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
pygst_iterator_resync(PyGstIterator *self)
{
gst_iterator_resync(self->iter);
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef _PyGstIterator_methods[] = {
{ "next", (PyCFunction)pygst_iterator_next, METH_NOARGS },
{ "push", (PyCFunction)pygst_iterator_push, METH_VARARGS },
{ "resync", (PyCFunction)pygst_iterator_resync, METH_NOARGS },
{ NULL, NULL, 0 }
};
PyTypeObject PyGstIterator_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
@ -101,6 +131,7 @@ PyTypeObject PyGstIterator_Type = {
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)pygst_iterator_iter_next, /* tp_iternext */
_PyGstIterator_methods, /* tp_methods */
};
PyObject*