Improve support GstBuffer attributes, r/w support for timestamp.

Original commit message from CVS:
* gst/gst-types.defs:
* gst/gstbuffer.override:
* testsuite/test_buffer.py:

Improve support GstBuffer attributes, r/w support for timestamp.
This commit is contained in:
Johan Dahlin 2004-12-14 16:53:09 +00:00
parent 563d5b9533
commit f51f43e1d9
5 changed files with 67 additions and 23 deletions

View file

@ -1,3 +1,11 @@
2004-12-14 Johan Dahlin <johan@gnome.org>
* gst/gst-types.defs:
* gst/gstbuffer.override:
* testsuite/test_buffer.py:
Improve support GstBuffer attributes, r/w support for timestamp.
2004-11-29 Johan Dahlin <johan@gnome.org>
* configure.ac: Post release version bump

2
common

@ -1 +1 @@
Subproject commit ded6dc5186cb7f8c64cb06a8591b9f787122c6f1
Subproject commit b2638c100721f67b280c3b43b21f1ce1c9b5e316

View file

@ -162,10 +162,16 @@
(copy-func "gst_buffer_copy")
(release-func "gst_data_unref")
(fields
;; GstData fields
'("GType" "data_type")
'("guint16" "flags")
;; GstBuffer fields
'("guint" "size")
'("guint" "maxsize")
'("guint64" "offset")
'("guint64" "offset_end")
'("GstClockTime" "timestamp")
)
)

View file

@ -117,28 +117,18 @@ _wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs)
return Py_None;
}
%%
override-slot GstBuffer.tp_getattr
PyObject *
_wrap_gst_buffer_tp_getattr(PyGObject *self, char *attr)
override-attr GstBuffer.data_type
static PyObject*
_wrap_gst_buffer__get_data_type(PyGObject *self, void *closure)
{
/* We have some GstData methods since it's not a subclass */
if (!strcmp(attr, "type"))
return pyg_type_wrapper_new(GST_DATA_TYPE(self->obj));
else if (!strcmp(attr, "flags"))
return PyInt_FromLong(GST_DATA_FLAGS(self->obj));
#if 0
else if (!strcmp(attr, "size"))
return PyInt_FromLong(GST_BUFFER_SIZE(self->obj));
#endif
else if (!strcmp(attr, "maxsize"))
return PyInt_FromLong(GST_BUFFER_MAXSIZE(self->obj));
/* XXX: timestamp and duration */
else if (!strcmp(attr, "offset"))
return PyInt_FromLong(GST_BUFFER_OFFSET(self->obj));
else if (!strcmp(attr, "offset_end"))
return PyInt_FromLong(GST_BUFFER_OFFSET_END(self->obj));
return Py_FindMethod(_PyGstBuffer_methods, (PyObject*)self, attr);
return pyg_type_wrapper_new(GST_DATA_TYPE(self->obj));
}
%%
override-attr GstBuffer.flags
static PyObject*
_wrap_gst_buffer__get_flags(PyGObject *self, void *closure)
{
return PyInt_FromLong(GST_DATA_FLAGS(self->obj));
}
%%
override-attr GstBuffer.size
@ -169,6 +159,25 @@ _wrap_gst_buffer__get_offset_end(PyGObject *self, void *closure)
return PyInt_FromLong(GST_BUFFER_OFFSET_END(self->obj));
}
%%
override-attr GstBuffer.timestamp
static PyObject *
_wrap_gst_buffer__get_timestamp(PyGObject *self, void *closure)
{
return PyInt_FromLong(GST_BUFFER(self->obj)->timestamp);
}
static int
_wrap_gst_buffer__set_timestamp(PyGBoxed *self, PyObject *value, void *closure)
{
gint val;
val = PyInt_AsLong(value);
if (PyErr_Occurred())
return -1;
pyg_boxed_get(self, GstBuffer)->timestamp = val;
return 0;
}
%%
override-slot GstBuffer.tp_str
static PyObject *
_wrap_gst_buffer_tp_str(PyGObject *self)

View file

@ -1,5 +1,5 @@
import sys
from common import gst, unittest
from common import gobject, gst, unittest
class BufferTest(unittest.TestCase):
def testBufferBuffer(self):
@ -80,5 +80,26 @@ class BufferTest(unittest.TestCase):
buffer.flag_unset(gst.BUFFER_IN_CAPS)
assert not buffer.flag_is_set(gst.BUFFER_IN_CAPS)
def testAttrType(self):
buffer = gst.Buffer()
assert hasattr(buffer, "data_type")
# XXX: Expose this in gobject
#assert isinstance(buffer.data_type, gobject.GType)
assert buffer.data_type == buffer.__gtype__
def testAttrFlags(self):
buffer = gst.Buffer()
assert hasattr(buffer, "flags")
assert isinstance(buffer.flags, int)
def testAttrTimestamp(self):
buffer = gst.Buffer()
assert hasattr(buffer, "timestamp")
assert isinstance(buffer.timestamp, int)
assert buffer.timestamp == -1
buffer.timestamp = 0
assert buffer.timestamp == 0
if __name__ == "__main__":
unittest.main()