GNOME Bugzilla – Bug 577847
gst.Buffer undocumented slices usage
Last modified: 2012-12-17 11:35:06 UTC
Hello, first thanks for this Python wrapper and for GStreamer. I had to deal with appsrc which wants a GstBuffer as input and I had to read the wrapper code to realize that setting data happens using slices. Please consider documenting it.
do you mean strings ? If so, that's the normal way of using 'data' in python AFAIK (i.e. if you read from a file you'll get a string).
Strings in Python don't support mutable slices. Reading from the buffer is easy and intuitive, but writing data on a buffer is not documented. buf = gst.Buffer (size); buf[:size] = data
proper usage : buf.data = "this is the content of my buffer" or even simpler: buf = gst.Buffer ("this is the content of my buffer") The example you gave is completely bogus, you can't create a gst.Buffer() with an integer argument. That should have errored out. There's no gst-python specific documentation. Closing bug.
I'm sorry for the wrong constructor. >>> buf = gst.Buffer () >>> buf.data = "test" Traceback (most recent call last):
+ Trace 214184
This is what I'm using now: >>> buf = gst.buffer_new_and_alloc (4) >>> buf[:4] = "test" >>> print buf test >>> So please document: 1. gst.Buffer (str) constructor, which is not in the C core reference so I couldn't realize that and the only constructor in the pygst reference has clearly no arguments 2. assignable/deletable slices
Closing this bug now, gst-python is only an extension module to pygi now and this bug doesn't make much sense anymore in this context.