Declare GstVideoOverlayComposition/Rectangle as opaque type and subclasses of Gst.MiniObject

This changes the API.

Without this change all usage will cause memory corruption and simply
does not work.
This commit is contained in:
Sebastian Dröge 2020-01-28 16:50:57 +02:00
parent a7ac9ee4fb
commit c5090bdd21
6 changed files with 57 additions and 91 deletions

View file

@ -52,15 +52,13 @@ namespace Gst.Video {
static extern IntPtr gst_buffer_add_video_overlay_composition_meta(IntPtr buf, IntPtr comp);
public static Gst.Video.VideoOverlayCompositionMeta BufferAddVideoOverlayCompositionMeta(Gst.Buffer buf, Gst.Video.VideoOverlayComposition comp) {
IntPtr native_comp = GLib.Marshaller.StructureToPtrAlloc (comp);
IntPtr raw_ret = gst_buffer_add_video_overlay_composition_meta(buf == null ? IntPtr.Zero : buf.Handle, native_comp);
IntPtr raw_ret = gst_buffer_add_video_overlay_composition_meta(buf == null ? IntPtr.Zero : buf.Handle, comp == null ? IntPtr.Zero : comp.Handle);
Gst.Video.VideoOverlayCompositionMeta ret = Gst.Video.VideoOverlayCompositionMeta.New (raw_ret);
Marshal.FreeHGlobal (native_comp);
return ret;
}
public static Gst.Video.VideoOverlayCompositionMeta BufferAddVideoOverlayCompositionMeta(Gst.Buffer buf) {
return BufferAddVideoOverlayCompositionMeta (buf, Gst.Video.VideoOverlayComposition.Zero);
return BufferAddVideoOverlayCompositionMeta (buf, null);
}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]

View file

@ -9,26 +9,7 @@ namespace Gst.Video {
using System.Runtime.InteropServices;
#region Autogenerated code
[StructLayout(LayoutKind.Sequential)]
public partial struct VideoOverlayComposition : IEquatable<VideoOverlayComposition> {
public static Gst.Video.VideoOverlayComposition Zero = new Gst.Video.VideoOverlayComposition ();
public static Gst.Video.VideoOverlayComposition New(IntPtr raw) {
if (raw == IntPtr.Zero)
return Gst.Video.VideoOverlayComposition.Zero;
return (Gst.Video.VideoOverlayComposition) Marshal.PtrToStructure (raw, typeof (Gst.Video.VideoOverlayComposition));
}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_composition_new(IntPtr rectangle);
public static VideoOverlayComposition New(Gst.Video.VideoOverlayRectangle rectangle)
{
VideoOverlayComposition result = VideoOverlayComposition.New (gst_video_overlay_composition_new(rectangle == null ? IntPtr.Zero : rectangle.Handle));
return result;
}
public partial class VideoOverlayComposition : Gst.MiniObject {
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_composition_get_type();
@ -45,38 +26,35 @@ namespace Gst.Video {
static extern void gst_video_overlay_composition_add_rectangle(IntPtr raw, IntPtr rectangle);
public void AddRectangle(Gst.Video.VideoOverlayRectangle rectangle) {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
gst_video_overlay_composition_add_rectangle(this_as_native, rectangle == null ? IntPtr.Zero : rectangle.Handle);
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
gst_video_overlay_composition_add_rectangle(Handle, rectangle == null ? IntPtr.Zero : rectangle.Handle);
}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool gst_video_overlay_composition_blend(IntPtr raw, IntPtr video_buf);
public bool Blend(Gst.Video.VideoFrame video_buf) {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
IntPtr native_video_buf = GLib.Marshaller.StructureToPtrAlloc (video_buf);
bool raw_ret = gst_video_overlay_composition_blend(this_as_native, native_video_buf);
bool raw_ret = gst_video_overlay_composition_blend(Handle, native_video_buf);
bool ret = raw_ret;
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
Marshal.FreeHGlobal (native_video_buf);
return ret;
}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_composition_copy(IntPtr raw);
public Gst.Video.VideoOverlayComposition Copy() {
IntPtr raw_ret = gst_video_overlay_composition_copy(Handle);
Gst.Video.VideoOverlayComposition ret = raw_ret == IntPtr.Zero ? null : (Gst.Video.VideoOverlayComposition) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Video.VideoOverlayComposition), true);
return ret;
}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_composition_get_rectangle(IntPtr raw, uint n);
public Gst.Video.VideoOverlayRectangle GetRectangle(uint n) {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
IntPtr raw_ret = gst_video_overlay_composition_get_rectangle(this_as_native, n);
IntPtr raw_ret = gst_video_overlay_composition_get_rectangle(Handle, n);
Gst.Video.VideoOverlayRectangle ret = raw_ret == IntPtr.Zero ? null : (Gst.Video.VideoOverlayRectangle) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Video.VideoOverlayRectangle), false);
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
return ret;
}
@ -85,12 +63,8 @@ namespace Gst.Video {
public uint Seqnum {
get {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
uint raw_ret = gst_video_overlay_composition_get_seqnum(this_as_native);
uint raw_ret = gst_video_overlay_composition_get_seqnum(Handle);
uint ret = raw_ret;
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
return ret;
}
}
@ -99,12 +73,8 @@ namespace Gst.Video {
static extern IntPtr gst_video_overlay_composition_make_writable(IntPtr raw);
public Gst.Video.VideoOverlayComposition MakeWritable() {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
IntPtr raw_ret = gst_video_overlay_composition_make_writable(this_as_native);
Gst.Video.VideoOverlayComposition ret = Gst.Video.VideoOverlayComposition.New (raw_ret);
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
IntPtr raw_ret = gst_video_overlay_composition_make_writable(Handle);
Gst.Video.VideoOverlayComposition ret = raw_ret == IntPtr.Zero ? null : (Gst.Video.VideoOverlayComposition) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Video.VideoOverlayComposition), true);
return ret;
}
@ -112,47 +82,36 @@ namespace Gst.Video {
static extern uint gst_video_overlay_composition_n_rectangles(IntPtr raw);
public uint NRectangles() {
IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
uint raw_ret = gst_video_overlay_composition_n_rectangles(this_as_native);
uint raw_ret = gst_video_overlay_composition_n_rectangles(Handle);
uint ret = raw_ret;
ReadNative (this_as_native, ref this);
System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
return ret;
}
static void ReadNative (IntPtr native, ref Gst.Video.VideoOverlayComposition target)
public VideoOverlayComposition(IntPtr raw) : base(raw) {}
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_composition_new(IntPtr rectangle);
public VideoOverlayComposition (Gst.Video.VideoOverlayRectangle rectangle)
{
target = New (native);
Raw = gst_video_overlay_composition_new(rectangle == null ? IntPtr.Zero : rectangle.Handle);
}
public bool Equals (VideoOverlayComposition other)
{
return true;
// Internal representation of the wrapped structure ABI.
static GLib.AbiStruct _abi_info = null;
static public new GLib.AbiStruct abi_info {
get {
if (_abi_info == null)
_abi_info = new GLib.AbiStruct (Gst.MiniObject.abi_info.Fields);
return _abi_info;
}
}
public override bool Equals (object other)
{
return other is VideoOverlayComposition && Equals ((VideoOverlayComposition) other);
}
public override int GetHashCode ()
{
return this.GetType ().FullName.GetHashCode ();
}
// End of the ABI representation.
public static explicit operator GLib.Value (Gst.Video.VideoOverlayComposition boxed)
{
GLib.Value val = GLib.Value.Empty;
val.Init (Gst.Video.VideoOverlayComposition.GType);
val.Val = boxed;
return val;
}
public static explicit operator Gst.Video.VideoOverlayComposition (GLib.Value val)
{
return (Gst.Video.VideoOverlayComposition) val.Val;
}
#endregion
}
}

View file

@ -14,9 +14,13 @@ namespace Gst.Video {
public Gst.Meta Meta;
private IntPtr _overlay;
public Gst.Video.VideoOverlayComposition overlay {
get { return Gst.Video.VideoOverlayComposition.New (_overlay); }
public Gst.Video.VideoOverlayComposition Overlay {
get {
return _overlay == IntPtr.Zero ? null : (Gst.Video.VideoOverlayComposition) GLib.Opaque.GetOpaque (_overlay, typeof (Gst.Video.VideoOverlayComposition), false);
}
set {
_overlay = value == null ? IntPtr.Zero : value.Handle;
}
}
public static Gst.Video.VideoOverlayCompositionMeta Zero = new Gst.Video.VideoOverlayCompositionMeta ();
@ -40,7 +44,7 @@ namespace Gst.Video {
public bool Equals (VideoOverlayCompositionMeta other)
{
return true && Meta.Equals (other.Meta) && overlay.Equals (other.overlay);
return true && Meta.Equals (other.Meta) && Overlay.Equals (other.Overlay);
}
public override bool Equals (object other)
@ -50,7 +54,7 @@ namespace Gst.Video {
public override int GetHashCode ()
{
return this.GetType ().FullName.GetHashCode () ^ Meta.GetHashCode () ^ overlay.GetHashCode ();
return this.GetType ().FullName.GetHashCode () ^ Meta.GetHashCode () ^ Overlay.GetHashCode ();
}
private static GLib.GType GType {

View file

@ -9,7 +9,7 @@ namespace Gst.Video {
using System.Runtime.InteropServices;
#region Autogenerated code
public partial class VideoOverlayRectangle : GLib.Opaque {
public partial class VideoOverlayRectangle : Gst.MiniObject {
[DllImport("gstvideo-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_video_overlay_rectangle_get_type();
@ -153,11 +153,10 @@ namespace Gst.Video {
// Internal representation of the wrapped structure ABI.
static GLib.AbiStruct _abi_info = null;
static public GLib.AbiStruct abi_info {
static public new GLib.AbiStruct abi_info {
get {
if (_abi_info == null)
_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{
});
_abi_info = new GLib.AbiStruct (Gst.MiniObject.abi_info.Fields);
return _abi_info;
}

View file

@ -28472,7 +28472,7 @@
<return-type type="guint32" />
</method>
</struct>
<boxed name="VideoOverlayComposition" cname="GstVideoOverlayComposition" opaque="false" hidden="false">
<boxed name="VideoOverlayComposition" cname="GstVideoOverlayComposition" opaque="true" hidden="false" parent="GstMiniObject">
<method name="GetType" cname="gst_video_overlay_composition_get_type" shared="true">
<return-type type="GType" />
</method>
@ -28541,7 +28541,7 @@
</return-type>
</method>
</struct>
<boxed name="VideoOverlayRectangle" cname="GstVideoOverlayRectangle" opaque="true" hidden="false">
<boxed name="VideoOverlayRectangle" cname="GstVideoOverlayRectangle" opaque="true" hidden="false" parent="GstMiniObject">
<method name="GetType" cname="gst_video_overlay_rectangle_get_type" shared="true">
<return-type type="GType" />
</method>

View file

@ -68,6 +68,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
<attr path="/api/namespace/boxed[@cname='GstSample']" name="opaque">true</attr>
<attr path="/api/namespace/boxed[@cname='GstSample']" name="parent">GstMiniObject</attr>
<!-- GstVideoOverlayComposition fixes -->
<attr path="/api/namespace/boxed[@cname='GstVideoOverlayComposition']" name="opaque">true</attr>
<attr path="/api/namespace/boxed[@cname='GstVideoOverlayComposition']" name="parent">GstMiniObject</attr>
<attr path="/api/namespace/boxed[@cname='GstVideoOverlayRectangle']" name="opaque">true</attr>
<attr path="/api/namespace/boxed[@cname='GstVideoOverlayRectangle']" name="parent">GstMiniObject</attr>
<attr path="/api/namespace/boxed[@cname='GstAudioInfo']" name="opaque">true</attr>
<attr path="/api/namespace/boxed[@cname='GstVideoInfo']" name="opaque">true</attr>
<attr path="/api/namespace/boxed[@cname='GstAtomicQueue']" name="opaque">true</attr>