mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
add a .data to buffers; it feels more natural to me than doing str(buffer) compared to the other properties.
Original commit message from CVS: * gst/gst-types.defs: * gst/gstbuffer.override: * gst/pygstminiobject.c: (pygstminiobject_new_noref): * testsuite/test_buffer.py: add a .data to buffers; it feels more natural to me than doing str(buffer) compared to the other properties. make sub_buffer test for data
This commit is contained in:
parent
dc83edf73e
commit
23b365140e
5 changed files with 36 additions and 10 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2005-09-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gst-types.defs:
|
||||
* gst/gstbuffer.override:
|
||||
* gst/pygstminiobject.c: (pygstminiobject_new_noref):
|
||||
* testsuite/test_buffer.py:
|
||||
add a .data to buffers; it feels more natural to me than doing
|
||||
str(buffer) compared to the other properties.
|
||||
make sub_buffer test for data
|
||||
|
||||
2005-09-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gst.override:
|
||||
|
|
|
@ -145,12 +145,13 @@
|
|||
(c-name "GstBuffer")
|
||||
(gtype-id "GST_TYPE_BUFFER")
|
||||
(fields
|
||||
'("guint8" "data")
|
||||
'("guint" "size")
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GstClockTime" "duration")
|
||||
'("GstCaps*" "caps")
|
||||
'("guint64" "offset")
|
||||
'("guint64" "offset_end")
|
||||
'("GstCaps*" "caps")
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -408,6 +408,21 @@ _wrap_gst_buffer_flag_unset(PyObject *self, PyObject *args)
|
|||
return Py_None;
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.data
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_data(PyObject *self, void *closure)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
g_assert (self);
|
||||
buf = pyg_boxed_get (self, GstBuffer);
|
||||
g_assert (buf);
|
||||
|
||||
return PyString_FromStringAndSize((const gchar*) GST_BUFFER_DATA(buf),
|
||||
(gint) GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.timestamp
|
||||
static PyObject *
|
||||
|
|
|
@ -224,25 +224,25 @@ pygstminiobject_new (GstMiniObject *obj)
|
|||
* Returns: a reference to the wrapper for the GstMiniObject.
|
||||
*/
|
||||
PyObject *
|
||||
pygstminiobject_new_noref(GstMiniObject *obj)
|
||||
pygstminiobject_new_noref (GstMiniObject *obj)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
PyGstMiniObject *self;
|
||||
|
||||
if (obj == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/* create wrapper */
|
||||
PyTypeObject *tp = pygstminiobject_lookup_class(G_OBJECT_TYPE(obj));
|
||||
PyTypeObject *tp = pygstminiobject_lookup_class (G_OBJECT_TYPE (obj));
|
||||
if (!tp)
|
||||
g_warning ("Couldn't get class for type object : %p", obj);
|
||||
/* need to bump type refcount if created with
|
||||
pygstminiobject_new_with_interfaces(). fixes bug #141042 */
|
||||
if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE)
|
||||
Py_INCREF(tp);
|
||||
self = PyObject_GC_New(PyGstMiniObject, tp);
|
||||
Py_INCREF (tp);
|
||||
self = PyObject_GC_New (PyGstMiniObject, tp);
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
/* DO NOT REF !! */
|
||||
|
@ -252,15 +252,15 @@ pygstminiobject_new_noref(GstMiniObject *obj)
|
|||
self->inst_dict = NULL;
|
||||
self->weakreflist = NULL;
|
||||
/* save wrapper pointer so we can access it later */
|
||||
Py_INCREF(self);
|
||||
Py_INCREF (self);
|
||||
|
||||
GST_DEBUG ("inserting self %p in the table for object %p", self, obj);
|
||||
state = pyg_gil_state_ensure();
|
||||
g_hash_table_insert (_miniobjs, (gpointer) obj, (gpointer) self);
|
||||
pyg_gil_state_release(state);
|
||||
|
||||
PyObject_GC_Track((PyObject *)self);
|
||||
return (PyObject *)self;
|
||||
PyObject_GC_Track ((PyObject *)self);
|
||||
return (PyObject *) self;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -64,7 +64,7 @@ class BufferTest(unittest.TestCase):
|
|||
|
||||
sub = buffer.create_sub(16, 16)
|
||||
self.assertEquals(sub.size, 16)
|
||||
#self.assertEquals(sub.data, buffer.data[16:32])
|
||||
self.assertEquals(sub.data, buffer.data[16:32])
|
||||
self.assertEquals(sub.offset, gst.CLOCK_TIME_NONE)
|
||||
|
||||
def testBufferMerge(self):
|
||||
|
|
Loading…
Reference in a new issue