One of our customers tries to create an app based on
which uses gst_buffer_copy().
My default gstreamer-1.16.2 Gentoo gir files does not contain that function at all. For latest git sources it is listed as introspectable=“0”.
Do we have any idea?
salewski@nuc ~ $ grep gst_buffer_copy /opt/gtk/share/gir-1.0/Gst-1.0.gir
gst_buffer_copy_into().</doc>
gst_buffer_copy_into().</doc>
use gst_buffer_copy_region(). This method tries to share the memory objects
<method name="copy" c:identifier="gst_buffer_copy" introspectable="0">
Check gst_buffer_copy_deep() if you want to force the data
c:identifier="gst_buffer_copy_deep"
<method name="copy_into" c:identifier="gst_buffer_copy_into">
<method name="copy_region" c:identifier="gst_buffer_copy_region">
glib:get-type="gst_buffer_copy_flags_get_type"
line="491">A set of flags that can be provided to the gst_buffer_copy_into()
gst_buffer_copy(). The passed-in @buf will be unreffed in that case, and the
salewski@nuc ~ $ grep gst_buffer_copy /usr/share/gir-1.0/Gst-1.0.gir
gst_buffer_copy_into().</doc>
gst_buffer_copy_into().</doc>
use gst_buffer_copy_region(). This method tries to share the memory objects
c:identifier="gst_buffer_copy_deep"
<method name="copy_into" c:identifier="gst_buffer_copy_into">
<method name="copy_region" c:identifier="gst_buffer_copy_region">
glib:get-type="gst_buffer_copy_flags_get_type"
line="488">A set of flags that can be provided to the gst_buffer_copy_into()
gst_buffer_copy(). The passed-in @buf will be unreffed in that case, and the
salewski@nuc ~ $ grep gst_buffer_copy ~/.nimble/pkgs/gintro-0.8.5/gintro/gst.nim
proc gst_buffer_copy_deep(self: ptr Buffer00): ptr Buffer00 {.
result.impl = gst_buffer_copy_deep(cast[ptr Buffer00](self.impl))
proc gst_buffer_copy_into(self: ptr Buffer00; src: ptr Buffer00; flags: BufferCopyFlags;
toBool(gst_buffer_copy_into(cast[ptr Buffer00](self.impl), cast[ptr Buffer00](src.impl), flags, offset, size))
proc gst_buffer_copy_region(self: ptr Buffer00; flags: BufferCopyFlags; offset: uint64;
result.impl = gst_buffer_copy_region(cast[ptr Buffer00](self.impl), flags, offset, size)
But as you can see it’s defined in the header and only as an inline function. This potentially breaks bindings (and does break the C# bindings for example).
gobject-introspection picking up inline function and handling them exactly like normal functions although their symbol is not available in the shared library is discussed in this issue.
On the GStreamer side this will be fixed by this MR by also providing non-inline functions inside the shared library for these, so we don’t have to wait for gobject-introspection to be fixed first.
For pre-1.18 (and generally), you would use gst_mini_object_copy() for copying any kind of miniobject, including GstBuffer. You can call any GstMiniObject function on GstBuffer and other miniobjects.
On the C side, gst_buffer_copy() was a macro until 1.18 that simply called `gst_mini_object_copy().
I was going to replace gst_buffer_copy() by gst_buffer_copy_deep() which seems to be available by gobject-introspection?
From the C API docs for gst_buffer_copy() we have
This will only copy the buffer’s data to a newly allocated memory if needed (if the type of memory requires it), otherwise the underlying data is just referenced.
My fear is that gst_mini_object_copy() does not support this optimization.
That was added in this commit apparently. I think the reason here was that otherwise the Python bindings end up generating useless and dangerous bindings. Having them skipped doesn’t seem correct but also was not a problem for any other bindings in the last 5 years it seems.
Realistically you’ll need manual bindings for all the miniobject API anyway or otherwise it’s of rather limited use, will be inflexible and likely involve far more copies of data than needed.