GNOME Bugzilla – Bug 324162
[API] Add gst_buffer_make_meta_writable or similar
Last modified: 2006-01-18 14:47:27 UTC
It is dangerous to do modifications to the metadata of a buffer like: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gstplaybin.c.diff?r1=1.73&r2=1.74 Because buffers are refcounted, only the creator of a buffer can be sure that the metadata can be safely modified. One option is to call gst_buffer_make_writable, but that will copy the data block unnecessarily. I'dlike to add a core utility function called something like gst_buffer_make_meta_writable that will check the refcount on the MiniObject. If the refcount is 1, then the metadata is modifiable, otherwise create a subbuffer of the entire contents and return that instead. This would also remove the ugly bit of code in basetransform that checks the refcount itself.
Created attachment 57460 [details] [review] New API - gst_buffer_is_metadata_writable and gst_buffer_make_metadata_writable
Please review.
Looks quite fine to me dogs.
Reviewed By: Andy Wingo * gst/gstbuffer.c: (gst_buffer_is_metadata_writable), (gst_buffer_make_metadata_writable): * gst/gstbuffer.h: Add gst_buffer_(is|make)_metadata_writable as analogues of gst_buffer_(is|make)_writable. * libs/gst/base/gstbasetransform.c: (gst_base_transform_prepare_output_buf): * plugins/elements/gstcapsfilter.c: (gst_capsfilter_prepare_buf): Use name gst_buffer_(is|make)_metadata_writable functions. * tests/check/gst/gstbuffer.c: (GST_START_TEST), (gst_test_suite): Test gst_buffer_(is|make)_metadata_writable (Closes: #324162)
Re-opening until after core release tonight.
Re-committed after 0.10.2