From a088475b9d22c6c6ce7b7dee24262dd8aab48342 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Wed, 29 Jan 2020 12:58:59 +0200 Subject: Bind gst_buffer_new_wrapped() manually The memory must be allocated with g_malloc() as we will free it again later with g_free(), as such allocate and copy the array that is passed in. --- sources/custom/Buffer.cs | 10 ++++++++++ sources/generated/Gst/Buffer.cs | 8 -------- sources/generated/gstreamer-sharp-api.xml | 6 +++--- sources/gstreamer-sharp.metadata | 3 +-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sources/custom/Buffer.cs b/sources/custom/Buffer.cs index 464ad7e..5d0cb68 100644 --- a/sources/custom/Buffer.cs +++ b/sources/custom/Buffer.cs @@ -46,5 +46,15 @@ namespace Gst { return (ulong) native_dest_size; } + + [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr gst_buffer_new_wrapped(IntPtr data, UIntPtr n_length); + + public Buffer (byte[] data) + { + IntPtr ptr = GLib.Marshaller.Malloc((ulong) data.Length); + Marshal.Copy(data, 0, ptr, data.Length); + Raw = gst_buffer_new_wrapped(ptr, new UIntPtr((ulong) data.Length)); + } } } diff --git a/sources/generated/Gst/Buffer.cs b/sources/generated/Gst/Buffer.cs index 39293e5..cc3e305 100644 --- a/sources/generated/Gst/Buffer.cs +++ b/sources/generated/Gst/Buffer.cs @@ -580,14 +580,6 @@ namespace Gst { Marshal.FreeHGlobal (native_parms); } - [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr gst_buffer_new_wrapped(byte[] data, UIntPtr n_length); - - public Buffer (byte[] data) - { - Raw = gst_buffer_new_wrapped(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length))); - } - [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr gst_buffer_new_wrapped_bytes(IntPtr bytes); diff --git a/sources/generated/gstreamer-sharp-api.xml b/sources/generated/gstreamer-sharp-api.xml index a381805..bc0cd66 100644 --- a/sources/generated/gstreamer-sharp-api.xml +++ b/sources/generated/gstreamer-sharp-api.xml @@ -6150,10 +6150,10 @@ - + diff --git a/sources/gstreamer-sharp.metadata b/sources/gstreamer-sharp.metadata index dde15c4..73fa0a1 100644 --- a/sources/gstreamer-sharp.metadata +++ b/sources/gstreamer-sharp.metadata @@ -321,8 +321,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ref true - guint8* - n_length + true guint8* guint8* guint8* -- cgit v1.2.3