Make GstSDPMessage an opaque structure
authorThibault Saunier <tsaunier@igalia.com>
Mon, 19 Mar 2018 12:42:04 +0000 (09:42 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 21 Mar 2018 12:22:38 +0000 (09:22 -0300)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=794483

sources/generated/Gst.Rtsp/RTSPExtensionAdapter.cs
sources/generated/Gst.Sdp/Global.cs
sources/generated/Gst.Sdp/SDPMessage.cs
sources/generated/gstreamer-sharp-abi.c
sources/generated/gstreamer-sharp-abi.cs
sources/generated/gstreamer-sharp-api.xml
sources/gstreamer-sharp.metadata

index 4a60f34..91e88ac 100644 (file)
@@ -100,7 +100,7 @@ namespace Gst.Rtsp {
                        try {
                                IRTSPExtensionImplementor __obj = GLib.Object.GetObject (inst, false) as IRTSPExtensionImplementor;
                                Gst.Rtsp.RTSPResult __result;
-                               __result = __obj.ParseSdp (Gst.Sdp.SDPMessage.New (sdp), s == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (s, typeof (Gst.Structure), false));
+                               __result = __obj.ParseSdp (sdp == IntPtr.Zero ? null : (Gst.Sdp.SDPMessage) GLib.Opaque.GetOpaque (sdp, typeof (Gst.Sdp.SDPMessage), false), s == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (s, typeof (Gst.Structure), false));
                                return (int) __result;
                        } catch (Exception e) {
                                GLib.ExceptionManager.RaiseUnhandledException (e, true);
@@ -357,10 +357,8 @@ namespace Gst.Rtsp {
                static extern int gst_rtsp_extension_parse_sdp(IntPtr raw, IntPtr sdp, IntPtr s);
 
                public Gst.Rtsp.RTSPResult ParseSdp(Gst.Sdp.SDPMessage sdp, Gst.Structure s) {
-                       IntPtr native_sdp = GLib.Marshaller.StructureToPtrAlloc (sdp);
-                       int raw_ret = gst_rtsp_extension_parse_sdp(Handle, native_sdp, s == null ? IntPtr.Zero : s.Handle);
+                       int raw_ret = gst_rtsp_extension_parse_sdp(Handle, sdp == null ? IntPtr.Zero : sdp.Handle, s == null ? IntPtr.Zero : s.Handle);
                        Gst.Rtsp.RTSPResult ret = (Gst.Rtsp.RTSPResult) raw_ret;
-                       Marshal.FreeHGlobal (native_sdp);
                        return ret;
                }
 
index 4782c2c..0f8da90 100644 (file)
@@ -67,23 +67,20 @@ namespace Gst.Sdp {
 
                public static string SdpMessageAsUri(string scheme, Gst.Sdp.SDPMessage msg) {
                        IntPtr native_scheme = GLib.Marshaller.StringToPtrGStrdup (scheme);
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       IntPtr raw_ret = gst_sdp_message_as_uri(native_scheme, native_msg);
+                       IntPtr raw_ret = gst_sdp_message_as_uri(native_scheme, msg == null ? IntPtr.Zero : msg.Handle);
                        string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
                        GLib.Marshaller.Free (native_scheme);
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
                [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
-               static extern int gst_sdp_message_new(IntPtr msg);
+               static extern int gst_sdp_message_new(out IntPtr msg);
 
                public static Gst.Sdp.SDPResult SdpMessageNew(out Gst.Sdp.SDPMessage msg) {
-                       IntPtr native_msg = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Gst.Sdp.SDPMessage)));
-                       int raw_ret = gst_sdp_message_new(native_msg);
+                       IntPtr native_msg;
+                       int raw_ret = gst_sdp_message_new(out native_msg);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       msg = Gst.Sdp.SDPMessage.New (native_msg);
-                       Marshal.FreeHGlobal (native_msg);
+                       msg = native_msg == IntPtr.Zero ? null : (Gst.Sdp.SDPMessage) GLib.Opaque.GetOpaque (native_msg, typeof (Gst.Sdp.SDPMessage), true);
                        return ret;
                }
 
@@ -91,10 +88,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_parse_buffer(byte[] data, uint size, IntPtr msg);
 
                public static Gst.Sdp.SDPResult SdpMessageParseBuffer(byte[] data, uint size, Gst.Sdp.SDPMessage msg) {
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       int raw_ret = gst_sdp_message_parse_buffer(data, size, native_msg);
+                       int raw_ret = gst_sdp_message_parse_buffer(data, size, msg == null ? IntPtr.Zero : msg.Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
@@ -103,11 +98,9 @@ namespace Gst.Sdp {
 
                public static Gst.Sdp.SDPResult SdpMessageParseUri(string uri, Gst.Sdp.SDPMessage msg) {
                        IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       int raw_ret = gst_sdp_message_parse_uri(native_uri, native_msg);
+                       int raw_ret = gst_sdp_message_parse_uri(native_uri, msg == null ? IntPtr.Zero : msg.Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
                        GLib.Marshaller.Free (native_uri);
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
index 2f8e2a2..3496573 100644 (file)
@@ -9,58 +9,125 @@ namespace Gst.Sdp {
        using System.Runtime.InteropServices;
 
 #region Autogenerated code
-       [StructLayout(LayoutKind.Sequential)]
-       public partial struct SDPMessage : IEquatable<SDPMessage> {
+       public partial class SDPMessage : GLib.Opaque {
 
-               public string Version;
-               public Gst.Sdp.SDPOrigin Origin;
-               public string SessionName;
-               public string Information;
-               public string Uri;
-               private IntPtr EmailsPtr;
-               public IntPtr[] Emails {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (EmailsPtr); }
-                       set { EmailsPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
-               }
-               private IntPtr PhonesPtr;
-               public IntPtr[] Phones {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (PhonesPtr); }
-                       set { PhonesPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_version(IntPtr raw);
+
+               public string Version {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_version(Handle);
+                               string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("version"));
+                                       *raw_ptr = GLib.Marshaller.StringToPtrGStrdup (value);
+                               }
+                       }
                }
-               public Gst.Sdp.SDPConnection Connection;
-               private IntPtr BandwidthsPtr;
-               public IntPtr[] Bandwidths {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (BandwidthsPtr); }
-                       set { BandwidthsPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_origin(IntPtr raw);
+
+               public Gst.Sdp.SDPOrigin Origin {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_origin(Handle);
+                               Gst.Sdp.SDPOrigin ret = Gst.Sdp.SDPOrigin.New (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("origin"));
+                                       *raw_ptr = GLib.Marshaller.StructureToPtrAlloc (value);
+                               }
+                       }
                }
-               private IntPtr TimesPtr;
-               public IntPtr[] Times {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (TimesPtr); }
-                       set { TimesPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_session_name(IntPtr raw);
+
+               public string SessionName {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_session_name(Handle);
+                               string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("session_name"));
+                                       *raw_ptr = GLib.Marshaller.StringToPtrGStrdup (value);
+                               }
+                       }
                }
-               private IntPtr ZonesPtr;
-               public IntPtr[] Zones {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (ZonesPtr); }
-                       set { ZonesPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_information(IntPtr raw);
+
+               public string Information {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_information(Handle);
+                               string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("information"));
+                                       *raw_ptr = GLib.Marshaller.StringToPtrGStrdup (value);
+                               }
+                       }
                }
-               public Gst.Sdp.SDPKey Key;
-               private IntPtr AttributesPtr;
-               public IntPtr[] Attributes {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (AttributesPtr); }
-                       set { AttributesPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_uri(IntPtr raw);
+
+               public string Uri {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_uri(Handle);
+                               string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("uri"));
+                                       *raw_ptr = GLib.Marshaller.StringToPtrGStrdup (value);
+                               }
+                       }
                }
-               private IntPtr MediasPtr;
-               public IntPtr[] Medias {
-                       get { return GLib.Marshaller.StructArrayFromNullTerminatedIntPtr<IntPtr> (MediasPtr); }
-                       set { MediasPtr = GLib.Marshaller.StructArrayToNullTerminatedStructArrayIntPtr<IntPtr> (value); }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_connection(IntPtr raw);
+
+               public Gst.Sdp.SDPConnection Connection {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_connection(Handle);
+                               Gst.Sdp.SDPConnection ret = Gst.Sdp.SDPConnection.New (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("connection"));
+                                       *raw_ptr = GLib.Marshaller.StructureToPtrAlloc (value);
+                               }
+                       }
                }
 
-               public static Gst.Sdp.SDPMessage Zero = new Gst.Sdp.SDPMessage ();
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern IntPtr gst_sdp_message_get_key(IntPtr raw);
 
-               public static Gst.Sdp.SDPMessage New(IntPtr raw) {
-                       if (raw == IntPtr.Zero)
-                               return Gst.Sdp.SDPMessage.Zero;
-                       return (Gst.Sdp.SDPMessage) Marshal.PtrToStructure (raw, typeof (Gst.Sdp.SDPMessage));
+               public Gst.Sdp.SDPKey Key {
+                       get  {
+                               IntPtr raw_ret = gst_sdp_message_get_key(Handle);
+                               Gst.Sdp.SDPKey ret = Gst.Sdp.SDPKey.New (raw_ret);
+                               return ret;
+                       }
+                       set {
+                               unsafe {
+                                       IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("key"));
+                                       *raw_ptr = GLib.Marshaller.StructureToPtrAlloc (value);
+                               }
+                       }
                }
 
                [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
@@ -78,14 +145,10 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_attribute(IntPtr raw, IntPtr key, IntPtr value);
 
                public Gst.Sdp.SDPResult AddAttribute(string key, string value) {
-                       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_key = GLib.Marshaller.StringToPtrGStrdup (key);
                        IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
-                       int raw_ret = gst_sdp_message_add_attribute(this_as_native, native_key, native_value);
+                       int raw_ret = gst_sdp_message_add_attribute(Handle, native_key, native_value);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_key);
                        GLib.Marshaller.Free (native_value);
                        return ret;
@@ -99,13 +162,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_bandwidth(IntPtr raw, IntPtr bwtype, uint bandwidth);
 
                public Gst.Sdp.SDPResult AddBandwidth(string bwtype, uint bandwidth) {
-                       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_bwtype = GLib.Marshaller.StringToPtrGStrdup (bwtype);
-                       int raw_ret = gst_sdp_message_add_bandwidth(this_as_native, native_bwtype, bandwidth);
+                       int raw_ret = gst_sdp_message_add_bandwidth(Handle, native_bwtype, bandwidth);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_bwtype);
                        return ret;
                }
@@ -114,13 +173,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_email(IntPtr raw, IntPtr email);
 
                public Gst.Sdp.SDPResult AddEmail(string email) {
-                       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_email = GLib.Marshaller.StringToPtrGStrdup (email);
-                       int raw_ret = gst_sdp_message_add_email(this_as_native, native_email);
+                       int raw_ret = gst_sdp_message_add_email(Handle, native_email);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_email);
                        return ret;
                }
@@ -129,13 +184,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_media(IntPtr raw, IntPtr media);
 
                public Gst.Sdp.SDPResult AddMedia(Gst.Sdp.SDPMedia media) {
-                       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_media = GLib.Marshaller.StructureToPtrAlloc (media);
-                       int raw_ret = gst_sdp_message_add_media(this_as_native, native_media);
+                       int raw_ret = gst_sdp_message_add_media(Handle, native_media);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_media);
                        return ret;
                }
@@ -144,13 +195,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_phone(IntPtr raw, IntPtr phone);
 
                public Gst.Sdp.SDPResult AddPhone(string phone) {
-                       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_phone = GLib.Marshaller.StringToPtrGStrdup (phone);
-                       int raw_ret = gst_sdp_message_add_phone(this_as_native, native_phone);
+                       int raw_ret = gst_sdp_message_add_phone(Handle, native_phone);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_phone);
                        return ret;
                }
@@ -159,8 +206,6 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_time(IntPtr raw, IntPtr start, IntPtr stop, IntPtr[] repeat);
 
                public Gst.Sdp.SDPResult AddTime(string start, string stop, string[] repeat) {
-                       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_start = GLib.Marshaller.StringToPtrGStrdup (start);
                        IntPtr native_stop = GLib.Marshaller.StringToPtrGStrdup (stop);
                        int cnt_repeat = repeat == null ? 0 : repeat.Length;
@@ -168,10 +213,8 @@ namespace Gst.Sdp {
                        for (int i = 0; i < cnt_repeat; i++)
                                native_repeat [i] = GLib.Marshaller.StringToPtrGStrdup (repeat[i]);
                        native_repeat [cnt_repeat] = IntPtr.Zero;
-                       int raw_ret = gst_sdp_message_add_time(this_as_native, native_start, native_stop, native_repeat);
+                       int raw_ret = gst_sdp_message_add_time(Handle, native_start, native_stop, native_repeat);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_start);
                        GLib.Marshaller.Free (native_stop);
                        for (int i = 0; i < native_repeat.Length - 1; i++) {
@@ -185,14 +228,10 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_add_zone(IntPtr raw, IntPtr adj_time, IntPtr typed_time);
 
                public Gst.Sdp.SDPResult AddZone(string adj_time, string typed_time) {
-                       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_adj_time = GLib.Marshaller.StringToPtrGStrdup (adj_time);
                        IntPtr native_typed_time = GLib.Marshaller.StringToPtrGStrdup (typed_time);
-                       int raw_ret = gst_sdp_message_add_zone(this_as_native, native_adj_time, native_typed_time);
+                       int raw_ret = gst_sdp_message_add_zone(Handle, native_adj_time, native_typed_time);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_adj_time);
                        GLib.Marshaller.Free (native_typed_time);
                        return ret;
@@ -202,12 +241,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_as_text(IntPtr raw);
 
                public string AsText() {
-                       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_sdp_message_as_text(this_as_native);
+                       IntPtr raw_ret = gst_sdp_message_as_text(Handle);
                        string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -215,12 +250,8 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_attributes_len(IntPtr raw);
 
                public uint AttributesLen() {
-                       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_sdp_message_attributes_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_attributes_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -228,12 +259,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_attributes_to_caps(IntPtr raw, IntPtr caps);
 
                public Gst.Sdp.SDPResult AttributesToCaps(Gst.Caps caps) {
-                       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);
-                       int raw_ret = gst_sdp_message_attributes_to_caps(this_as_native, caps == null ? IntPtr.Zero : caps.Handle);
+                       int raw_ret = gst_sdp_message_attributes_to_caps(Handle, caps == null ? IntPtr.Zero : caps.Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -241,12 +268,19 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_bandwidths_len(IntPtr raw);
 
                public uint BandwidthsLen() {
-                       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_sdp_message_bandwidths_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_bandwidths_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
+                       return ret;
+               }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern int gst_sdp_message_copy(IntPtr raw, out IntPtr copy);
+
+               public Gst.Sdp.SDPResult Copy(out Gst.Sdp.SDPMessage copy) {
+                       IntPtr native_copy;
+                       int raw_ret = gst_sdp_message_copy(Handle, out native_copy);
+                       Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
+                       copy = native_copy == IntPtr.Zero ? null : (Gst.Sdp.SDPMessage) GLib.Opaque.GetOpaque (native_copy, typeof (Gst.Sdp.SDPMessage), true);
                        return ret;
                }
 
@@ -254,12 +288,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_dump(IntPtr raw);
 
                public Gst.Sdp.SDPResult Dump() {
-                       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);
-                       int raw_ret = gst_sdp_message_dump(this_as_native);
+                       int raw_ret = gst_sdp_message_dump(Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -267,12 +297,17 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_emails_len(IntPtr raw);
 
                public uint EmailsLen() {
-                       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_sdp_message_emails_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_emails_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
+                       return ret;
+               }
+
+               [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
+               static extern int gst_sdp_message_free(IntPtr raw);
+
+               public Gst.Sdp.SDPResult Free() {
+                       int raw_ret = gst_sdp_message_free(Handle);
+                       Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
                        return ret;
                }
 
@@ -280,12 +315,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_attribute(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPAttribute GetAttribute(uint idx) {
-                       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_sdp_message_get_attribute(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_attribute(Handle, idx);
                        Gst.Sdp.SDPAttribute ret = Gst.Sdp.SDPAttribute.New (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -293,13 +324,9 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_attribute_val(IntPtr raw, IntPtr key);
 
                public string GetAttributeVal(string key) {
-                       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_key = GLib.Marshaller.StringToPtrGStrdup (key);
-                       IntPtr raw_ret = gst_sdp_message_get_attribute_val(this_as_native, native_key);
+                       IntPtr raw_ret = gst_sdp_message_get_attribute_val(Handle, native_key);
                        string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_key);
                        return ret;
                }
@@ -308,13 +335,9 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_attribute_val_n(IntPtr raw, IntPtr key, uint nth);
 
                public string GetAttributeValN(string key, uint nth) {
-                       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_key = GLib.Marshaller.StringToPtrGStrdup (key);
-                       IntPtr raw_ret = gst_sdp_message_get_attribute_val_n(this_as_native, native_key, nth);
+                       IntPtr raw_ret = gst_sdp_message_get_attribute_val_n(Handle, native_key, nth);
                        string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_key);
                        return ret;
                }
@@ -323,12 +346,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_bandwidth(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPBandwidth GetBandwidth(uint idx) {
-                       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_sdp_message_get_bandwidth(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_bandwidth(Handle, idx);
                        Gst.Sdp.SDPBandwidth ret = Gst.Sdp.SDPBandwidth.New (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -336,12 +355,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_email(IntPtr raw, uint idx);
 
                public string GetEmail(uint idx) {
-                       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_sdp_message_get_email(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_email(Handle, idx);
                        string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -349,12 +364,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_media(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPMedia GetMedia(uint idx) {
-                       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_sdp_message_get_media(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_media(Handle, idx);
                        Gst.Sdp.SDPMedia ret = Gst.Sdp.SDPMedia.New (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -362,12 +373,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_phone(IntPtr raw, uint idx);
 
                public string GetPhone(uint idx) {
-                       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_sdp_message_get_phone(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_phone(Handle, idx);
                        string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -375,12 +382,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_time(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPTime GetTime(uint idx) {
-                       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_sdp_message_get_time(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_time(Handle, idx);
                        Gst.Sdp.SDPTime ret = Gst.Sdp.SDPTime.New (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -388,12 +391,8 @@ namespace Gst.Sdp {
                static extern IntPtr gst_sdp_message_get_zone(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPZone GetZone(uint idx) {
-                       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_sdp_message_get_zone(this_as_native, idx);
+                       IntPtr raw_ret = gst_sdp_message_get_zone(Handle, idx);
                        Gst.Sdp.SDPZone ret = Gst.Sdp.SDPZone.New (raw_ret);
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -401,12 +400,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_init(IntPtr raw);
 
                public Gst.Sdp.SDPResult Init() {
-                       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);
-                       int raw_ret = gst_sdp_message_init(this_as_native);
+                       int raw_ret = gst_sdp_message_init(Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -414,13 +409,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_attribute(IntPtr raw, int idx, IntPtr attr);
 
                public Gst.Sdp.SDPResult InsertAttribute(int idx, Gst.Sdp.SDPAttribute attr) {
-                       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_attr = GLib.Marshaller.StructureToPtrAlloc (attr);
-                       int raw_ret = gst_sdp_message_insert_attribute(this_as_native, idx, native_attr);
+                       int raw_ret = gst_sdp_message_insert_attribute(Handle, idx, native_attr);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_attr);
                        return ret;
                }
@@ -429,13 +420,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_bandwidth(IntPtr raw, int idx, IntPtr bw);
 
                public Gst.Sdp.SDPResult InsertBandwidth(int idx, Gst.Sdp.SDPBandwidth bw) {
-                       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_bw = GLib.Marshaller.StructureToPtrAlloc (bw);
-                       int raw_ret = gst_sdp_message_insert_bandwidth(this_as_native, idx, native_bw);
+                       int raw_ret = gst_sdp_message_insert_bandwidth(Handle, idx, native_bw);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_bw);
                        return ret;
                }
@@ -444,13 +431,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_email(IntPtr raw, int idx, IntPtr email);
 
                public Gst.Sdp.SDPResult InsertEmail(int idx, string email) {
-                       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_email = GLib.Marshaller.StringToPtrGStrdup (email);
-                       int raw_ret = gst_sdp_message_insert_email(this_as_native, idx, native_email);
+                       int raw_ret = gst_sdp_message_insert_email(Handle, idx, native_email);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_email);
                        return ret;
                }
@@ -459,13 +442,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_phone(IntPtr raw, int idx, IntPtr phone);
 
                public Gst.Sdp.SDPResult InsertPhone(int idx, string phone) {
-                       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_phone = GLib.Marshaller.StringToPtrGStrdup (phone);
-                       int raw_ret = gst_sdp_message_insert_phone(this_as_native, idx, native_phone);
+                       int raw_ret = gst_sdp_message_insert_phone(Handle, idx, native_phone);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_phone);
                        return ret;
                }
@@ -474,13 +453,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_time(IntPtr raw, int idx, IntPtr t);
 
                public Gst.Sdp.SDPResult InsertTime(int idx, Gst.Sdp.SDPTime t) {
-                       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_t = GLib.Marshaller.StructureToPtrAlloc (t);
-                       int raw_ret = gst_sdp_message_insert_time(this_as_native, idx, native_t);
+                       int raw_ret = gst_sdp_message_insert_time(Handle, idx, native_t);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_t);
                        return ret;
                }
@@ -489,13 +464,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_insert_zone(IntPtr raw, int idx, IntPtr zone);
 
                public Gst.Sdp.SDPResult InsertZone(int idx, Gst.Sdp.SDPZone zone) {
-                       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_zone = GLib.Marshaller.StructureToPtrAlloc (zone);
-                       int raw_ret = gst_sdp_message_insert_zone(this_as_native, idx, native_zone);
+                       int raw_ret = gst_sdp_message_insert_zone(Handle, idx, native_zone);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_zone);
                        return ret;
                }
@@ -504,12 +475,8 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_medias_len(IntPtr raw);
 
                public uint MediasLen() {
-                       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_sdp_message_medias_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_medias_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -517,13 +484,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_parse_keymgmt(IntPtr raw, out IntPtr mikey);
 
                public Gst.Sdp.SDPResult ParseKeymgmt(out Gst.Sdp.MIKEYMessage mikey) {
-                       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_mikey;
-                       int raw_ret = gst_sdp_message_parse_keymgmt(this_as_native, out native_mikey);
+                       int raw_ret = gst_sdp_message_parse_keymgmt(Handle, out native_mikey);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        mikey = native_mikey == IntPtr.Zero ? null : (Gst.Sdp.MIKEYMessage) GLib.Opaque.GetOpaque (native_mikey, typeof (Gst.Sdp.MIKEYMessage), true);
                        return ret;
                }
@@ -532,12 +495,8 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_phones_len(IntPtr raw);
 
                public uint PhonesLen() {
-                       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_sdp_message_phones_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_phones_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -545,12 +504,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_attribute(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemoveAttribute(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_attribute(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_attribute(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -558,12 +513,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_bandwidth(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemoveBandwidth(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_bandwidth(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_bandwidth(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -571,12 +522,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_email(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemoveEmail(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_email(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_email(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -584,12 +531,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_phone(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemovePhone(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_phone(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_phone(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -597,12 +540,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_time(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemoveTime(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_time(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_time(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -610,12 +549,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_remove_zone(IntPtr raw, uint idx);
 
                public Gst.Sdp.SDPResult RemoveZone(uint idx) {
-                       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);
-                       int raw_ret = gst_sdp_message_remove_zone(this_as_native, idx);
+                       int raw_ret = gst_sdp_message_remove_zone(Handle, idx);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -623,13 +558,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_attribute(IntPtr raw, uint idx, IntPtr attr);
 
                public Gst.Sdp.SDPResult ReplaceAttribute(uint idx, Gst.Sdp.SDPAttribute attr) {
-                       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_attr = GLib.Marshaller.StructureToPtrAlloc (attr);
-                       int raw_ret = gst_sdp_message_replace_attribute(this_as_native, idx, native_attr);
+                       int raw_ret = gst_sdp_message_replace_attribute(Handle, idx, native_attr);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_attr);
                        return ret;
                }
@@ -638,13 +569,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_bandwidth(IntPtr raw, uint idx, IntPtr bw);
 
                public Gst.Sdp.SDPResult ReplaceBandwidth(uint idx, Gst.Sdp.SDPBandwidth bw) {
-                       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_bw = GLib.Marshaller.StructureToPtrAlloc (bw);
-                       int raw_ret = gst_sdp_message_replace_bandwidth(this_as_native, idx, native_bw);
+                       int raw_ret = gst_sdp_message_replace_bandwidth(Handle, idx, native_bw);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_bw);
                        return ret;
                }
@@ -653,13 +580,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_email(IntPtr raw, uint idx, IntPtr email);
 
                public Gst.Sdp.SDPResult ReplaceEmail(uint idx, string email) {
-                       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_email = GLib.Marshaller.StringToPtrGStrdup (email);
-                       int raw_ret = gst_sdp_message_replace_email(this_as_native, idx, native_email);
+                       int raw_ret = gst_sdp_message_replace_email(Handle, idx, native_email);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_email);
                        return ret;
                }
@@ -668,13 +591,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_phone(IntPtr raw, uint idx, IntPtr phone);
 
                public Gst.Sdp.SDPResult ReplacePhone(uint idx, string phone) {
-                       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_phone = GLib.Marshaller.StringToPtrGStrdup (phone);
-                       int raw_ret = gst_sdp_message_replace_phone(this_as_native, idx, native_phone);
+                       int raw_ret = gst_sdp_message_replace_phone(Handle, idx, native_phone);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_phone);
                        return ret;
                }
@@ -683,13 +602,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_time(IntPtr raw, uint idx, IntPtr t);
 
                public Gst.Sdp.SDPResult ReplaceTime(uint idx, Gst.Sdp.SDPTime t) {
-                       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_t = GLib.Marshaller.StructureToPtrAlloc (t);
-                       int raw_ret = gst_sdp_message_replace_time(this_as_native, idx, native_t);
+                       int raw_ret = gst_sdp_message_replace_time(Handle, idx, native_t);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_t);
                        return ret;
                }
@@ -698,13 +613,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_replace_zone(IntPtr raw, uint idx, IntPtr zone);
 
                public Gst.Sdp.SDPResult ReplaceZone(uint idx, Gst.Sdp.SDPZone zone) {
-                       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_zone = GLib.Marshaller.StructureToPtrAlloc (zone);
-                       int raw_ret = gst_sdp_message_replace_zone(this_as_native, idx, native_zone);
+                       int raw_ret = gst_sdp_message_replace_zone(Handle, idx, native_zone);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        Marshal.FreeHGlobal (native_zone);
                        return ret;
                }
@@ -713,15 +624,11 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_connection(IntPtr raw, IntPtr nettype, IntPtr addrtype, IntPtr address, uint ttl, uint addr_number);
 
                public Gst.Sdp.SDPResult SetConnection(string nettype, string addrtype, string address, uint ttl, uint addr_number) {
-                       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_nettype = GLib.Marshaller.StringToPtrGStrdup (nettype);
                        IntPtr native_addrtype = GLib.Marshaller.StringToPtrGStrdup (addrtype);
                        IntPtr native_address = GLib.Marshaller.StringToPtrGStrdup (address);
-                       int raw_ret = gst_sdp_message_set_connection(this_as_native, native_nettype, native_addrtype, native_address, ttl, addr_number);
+                       int raw_ret = gst_sdp_message_set_connection(Handle, native_nettype, native_addrtype, native_address, ttl, addr_number);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_nettype);
                        GLib.Marshaller.Free (native_addrtype);
                        GLib.Marshaller.Free (native_address);
@@ -732,13 +639,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_information(IntPtr raw, IntPtr information);
 
                public Gst.Sdp.SDPResult SetInformation(string information) {
-                       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_information = GLib.Marshaller.StringToPtrGStrdup (information);
-                       int raw_ret = gst_sdp_message_set_information(this_as_native, native_information);
+                       int raw_ret = gst_sdp_message_set_information(Handle, native_information);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_information);
                        return ret;
                }
@@ -747,14 +650,10 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_key(IntPtr raw, IntPtr type, IntPtr data);
 
                public Gst.Sdp.SDPResult SetKey(string type, string data) {
-                       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_type = GLib.Marshaller.StringToPtrGStrdup (type);
                        IntPtr native_data = GLib.Marshaller.StringToPtrGStrdup (data);
-                       int raw_ret = gst_sdp_message_set_key(this_as_native, native_type, native_data);
+                       int raw_ret = gst_sdp_message_set_key(Handle, native_type, native_data);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_type);
                        GLib.Marshaller.Free (native_data);
                        return ret;
@@ -764,18 +663,14 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_origin(IntPtr raw, IntPtr username, IntPtr sess_id, IntPtr sess_version, IntPtr nettype, IntPtr addrtype, IntPtr addr);
 
                public Gst.Sdp.SDPResult SetOrigin(string username, string sess_id, string sess_version, string nettype, string addrtype, string addr) {
-                       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_username = GLib.Marshaller.StringToPtrGStrdup (username);
                        IntPtr native_sess_id = GLib.Marshaller.StringToPtrGStrdup (sess_id);
                        IntPtr native_sess_version = GLib.Marshaller.StringToPtrGStrdup (sess_version);
                        IntPtr native_nettype = GLib.Marshaller.StringToPtrGStrdup (nettype);
                        IntPtr native_addrtype = GLib.Marshaller.StringToPtrGStrdup (addrtype);
                        IntPtr native_addr = GLib.Marshaller.StringToPtrGStrdup (addr);
-                       int raw_ret = gst_sdp_message_set_origin(this_as_native, native_username, native_sess_id, native_sess_version, native_nettype, native_addrtype, native_addr);
+                       int raw_ret = gst_sdp_message_set_origin(Handle, native_username, native_sess_id, native_sess_version, native_nettype, native_addrtype, native_addr);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_username);
                        GLib.Marshaller.Free (native_sess_id);
                        GLib.Marshaller.Free (native_sess_version);
@@ -789,13 +684,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_session_name(IntPtr raw, IntPtr session_name);
 
                public Gst.Sdp.SDPResult SetSessionName(string session_name) {
-                       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_session_name = GLib.Marshaller.StringToPtrGStrdup (session_name);
-                       int raw_ret = gst_sdp_message_set_session_name(this_as_native, native_session_name);
+                       int raw_ret = gst_sdp_message_set_session_name(Handle, native_session_name);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_session_name);
                        return ret;
                }
@@ -804,13 +695,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_uri(IntPtr raw, IntPtr uri);
 
                public Gst.Sdp.SDPResult SetUri(string uri) {
-                       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_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
-                       int raw_ret = gst_sdp_message_set_uri(this_as_native, native_uri);
+                       int raw_ret = gst_sdp_message_set_uri(Handle, native_uri);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_uri);
                        return ret;
                }
@@ -819,13 +706,9 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_set_version(IntPtr raw, IntPtr version);
 
                public Gst.Sdp.SDPResult SetVersion(string version) {
-                       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_version = GLib.Marshaller.StringToPtrGStrdup (version);
-                       int raw_ret = gst_sdp_message_set_version(this_as_native, native_version);
+                       int raw_ret = gst_sdp_message_set_version(Handle, native_version);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        GLib.Marshaller.Free (native_version);
                        return ret;
                }
@@ -834,12 +717,8 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_times_len(IntPtr raw);
 
                public uint TimesLen() {
-                       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_sdp_message_times_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_times_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -847,12 +726,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_uninit(IntPtr raw);
 
                public Gst.Sdp.SDPResult Uninit() {
-                       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);
-                       int raw_ret = gst_sdp_message_uninit(this_as_native);
+                       int raw_ret = gst_sdp_message_uninit(Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -860,12 +735,8 @@ namespace Gst.Sdp {
                static extern uint gst_sdp_message_zones_len(IntPtr raw);
 
                public uint ZonesLen() {
-                       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_sdp_message_zones_len(this_as_native);
+                       uint raw_ret = gst_sdp_message_zones_len(Handle);
                        uint ret = raw_ret;
-                       ReadNative (this_as_native, ref this);
-                       System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
                        return ret;
                }
 
@@ -874,23 +745,20 @@ namespace Gst.Sdp {
 
                public static string AsUri(string scheme, Gst.Sdp.SDPMessage msg) {
                        IntPtr native_scheme = GLib.Marshaller.StringToPtrGStrdup (scheme);
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       IntPtr raw_ret = gst_sdp_message_as_uri(native_scheme, native_msg);
+                       IntPtr raw_ret = gst_sdp_message_as_uri(native_scheme, msg == null ? IntPtr.Zero : msg.Handle);
                        string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
                        GLib.Marshaller.Free (native_scheme);
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
                [DllImport("libgstsdp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
-               static extern int gst_sdp_message_new(IntPtr msg);
+               static extern int gst_sdp_message_new(out IntPtr msg);
 
                public static Gst.Sdp.SDPResult New(out Gst.Sdp.SDPMessage msg) {
-                       IntPtr native_msg = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Gst.Sdp.SDPMessage)));
-                       int raw_ret = gst_sdp_message_new(native_msg);
+                       IntPtr native_msg;
+                       int raw_ret = gst_sdp_message_new(out native_msg);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       msg = Gst.Sdp.SDPMessage.New (native_msg);
-                       Marshal.FreeHGlobal (native_msg);
+                       msg = native_msg == IntPtr.Zero ? null : (Gst.Sdp.SDPMessage) GLib.Opaque.GetOpaque (native_msg, typeof (Gst.Sdp.SDPMessage), true);
                        return ret;
                }
 
@@ -898,10 +766,8 @@ namespace Gst.Sdp {
                static extern int gst_sdp_message_parse_buffer(byte[] data, uint size, IntPtr msg);
 
                public static Gst.Sdp.SDPResult ParseBuffer(byte[] data, uint size, Gst.Sdp.SDPMessage msg) {
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       int raw_ret = gst_sdp_message_parse_buffer(data, size, native_msg);
+                       int raw_ret = gst_sdp_message_parse_buffer(data, size, msg == null ? IntPtr.Zero : msg.Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
@@ -910,46 +776,163 @@ namespace Gst.Sdp {
 
                public static Gst.Sdp.SDPResult ParseUri(string uri, Gst.Sdp.SDPMessage msg) {
                        IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
-                       IntPtr native_msg = GLib.Marshaller.StructureToPtrAlloc (msg);
-                       int raw_ret = gst_sdp_message_parse_uri(native_uri, native_msg);
+                       int raw_ret = gst_sdp_message_parse_uri(native_uri, msg == null ? IntPtr.Zero : msg.Handle);
                        Gst.Sdp.SDPResult ret = (Gst.Sdp.SDPResult) raw_ret;
                        GLib.Marshaller.Free (native_uri);
-                       Marshal.FreeHGlobal (native_msg);
                        return ret;
                }
 
-               static void ReadNative (IntPtr native, ref Gst.Sdp.SDPMessage target)
-               {
-                       target = New (native);
-               }
+               public SDPMessage(IntPtr raw) : base(raw) {}
 
-               public bool Equals (SDPMessage other)
-               {
-                       return true && Version.Equals (other.Version) && Origin.Equals (other.Origin) && SessionName.Equals (other.SessionName) && Information.Equals (other.Information) && Uri.Equals (other.Uri) && EmailsPtr.Equals (other.EmailsPtr) && PhonesPtr.Equals (other.PhonesPtr) && Connection.Equals (other.Connection) && BandwidthsPtr.Equals (other.BandwidthsPtr) && TimesPtr.Equals (other.TimesPtr) && ZonesPtr.Equals (other.ZonesPtr) && Key.Equals (other.Key) && AttributesPtr.Equals (other.AttributesPtr) && MediasPtr.Equals (other.MediasPtr);
-               }
 
-               public override bool Equals (object other)
-               {
-                       return other is SDPMessage && Equals ((SDPMessage) other);
+               // Internal representation of the wrapped structure ABI.
+               static GLib.AbiStruct _abi_info = null;
+               static public GLib.AbiStruct abi_info {
+                       get {
+                               if (_abi_info == null)
+                                       _abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
+                                               new GLib.AbiField("version"
+                                                       , 0
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // version
+                                                       , null
+                                                       , "origin"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("origin"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(Gst.Sdp.SDPOrigin)) // origin
+                                                       , "version"
+                                                       , "session_name"
+                                                       , (long) Marshal.OffsetOf(typeof(GstSDPMessage_originAlign), "origin")
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("session_name"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // session_name
+                                                       , "origin"
+                                                       , "information"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("information"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // information
+                                                       , "session_name"
+                                                       , "uri"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("uri"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // uri
+                                                       , "information"
+                                                       , "emails"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("emails"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // emails
+                                                       , "uri"
+                                                       , "phones"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("phones"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // phones
+                                                       , "emails"
+                                                       , "connection"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("connection"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(Gst.Sdp.SDPConnection)) // connection
+                                                       , "phones"
+                                                       , "bandwidths"
+                                                       , (long) Marshal.OffsetOf(typeof(GstSDPMessage_connectionAlign), "connection")
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("bandwidths"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // bandwidths
+                                                       , "connection"
+                                                       , "times"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("times"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // times
+                                                       , "bandwidths"
+                                                       , "zones"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("zones"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // zones
+                                                       , "times"
+                                                       , "key"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("key"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(Gst.Sdp.SDPKey)) // key
+                                                       , "zones"
+                                                       , "attributes"
+                                                       , (long) Marshal.OffsetOf(typeof(GstSDPMessage_keyAlign), "key")
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("attributes"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // attributes
+                                                       , "key"
+                                                       , "medias"
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                               new GLib.AbiField("medias"
+                                                       , -1
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr)) // medias
+                                                       , "attributes"
+                                                       , null
+                                                       , (uint) Marshal.SizeOf(typeof(IntPtr))
+                                                       , 0
+                                                       ),
+                                       });
+
+                               return _abi_info;
+                       }
                }
 
-               public override int GetHashCode ()
+               [StructLayout(LayoutKind.Sequential)]
+               public struct GstSDPMessage_originAlign
                {
-                       return this.GetType ().FullName.GetHashCode () ^ Version.GetHashCode () ^ Origin.GetHashCode () ^ SessionName.GetHashCode () ^ Information.GetHashCode () ^ Uri.GetHashCode () ^ EmailsPtr.GetHashCode () ^ PhonesPtr.GetHashCode () ^ Connection.GetHashCode () ^ BandwidthsPtr.GetHashCode () ^ TimesPtr.GetHashCode () ^ ZonesPtr.GetHashCode () ^ Key.GetHashCode () ^ AttributesPtr.GetHashCode () ^ MediasPtr.GetHashCode ();
+                       sbyte f1;
+                       private Gst.Sdp.SDPOrigin origin;
                }
 
-               public static explicit operator GLib.Value (Gst.Sdp.SDPMessage boxed)
+               [StructLayout(LayoutKind.Sequential)]
+               public struct GstSDPMessage_connectionAlign
                {
-                       GLib.Value val = GLib.Value.Empty;
-                       val.Init (Gst.Sdp.SDPMessage.GType);
-                       val.Val = boxed;
-                       return val;
+                       sbyte f1;
+                       private Gst.Sdp.SDPConnection connection;
                }
 
-               public static explicit operator Gst.Sdp.SDPMessage (GLib.Value val)
+               [StructLayout(LayoutKind.Sequential)]
+               public struct GstSDPMessage_keyAlign
                {
-                       return (Gst.Sdp.SDPMessage) val.Val;
+                       sbyte f1;
+                       private Gst.Sdp.SDPKey key;
                }
+
+
+               // End of the ABI representation.
+
 #endregion
        }
 }
index ce96957..1e42011 100644 (file)
@@ -821,6 +821,21 @@ int main (int argc, char *argv[]) {
        g_print("\"sizeof(GstMIKEYPayload)\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) sizeof(GstMIKEYPayload));
        g_print("\"GstMIKEYPayload.type\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstMIKEYPayload, type));
        g_print("\"GstMIKEYPayload.len\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstMIKEYPayload, len));
+       g_print("\"sizeof(GstSDPMessage)\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) sizeof(GstSDPMessage));
+       g_print("\"GstSDPMessage.version\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, version));
+       g_print("\"GstSDPMessage.origin\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, origin));
+       g_print("\"GstSDPMessage.session_name\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, session_name));
+       g_print("\"GstSDPMessage.information\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, information));
+       g_print("\"GstSDPMessage.uri\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, uri));
+       g_print("\"GstSDPMessage.emails\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, emails));
+       g_print("\"GstSDPMessage.phones\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, phones));
+       g_print("\"GstSDPMessage.connection\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, connection));
+       g_print("\"GstSDPMessage.bandwidths\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, bandwidths));
+       g_print("\"GstSDPMessage.times\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, times));
+       g_print("\"GstSDPMessage.zones\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, zones));
+       g_print("\"GstSDPMessage.key\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, key));
+       g_print("\"GstSDPMessage.attributes\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, attributes));
+       g_print("\"GstSDPMessage.medias\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstSDPMessage, medias));
        g_print("\"sizeof(GstTagDemuxClass)\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) sizeof(GstTagDemuxClass));
        g_print("\"GstTagDemuxClass.min_start_size\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstTagDemuxClass, min_start_size));
        g_print("\"GstTagDemuxClass.min_end_size\": \"%" G_GUINT64_FORMAT "\"\n", (guint64) G_STRUCT_OFFSET(GstTagDemuxClass, min_end_size));
index 8b7177c..27332da 100644 (file)
@@ -816,6 +816,21 @@ namespace AbiTester {
                        Console.WriteLine("\"sizeof(GstMIKEYPayload)\": \"" + Gst.Sdp.MIKEYPayload.abi_info.Size + "\"");
                        Console.WriteLine("\"GstMIKEYPayload.type\": \"" + Gst.Sdp.MIKEYPayload.abi_info.GetFieldOffset("type") + "\"");
                        Console.WriteLine("\"GstMIKEYPayload.len\": \"" + Gst.Sdp.MIKEYPayload.abi_info.GetFieldOffset("len") + "\"");
+                       Console.WriteLine("\"sizeof(GstSDPMessage)\": \"" + Gst.Sdp.SDPMessage.abi_info.Size + "\"");
+                       Console.WriteLine("\"GstSDPMessage.version\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("version") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.origin\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("origin") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.session_name\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("session_name") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.information\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("information") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.uri\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("uri") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.emails\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("emails") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.phones\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("phones") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.connection\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("connection") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.bandwidths\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("bandwidths") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.times\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("times") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.zones\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("zones") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.key\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("key") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.attributes\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("attributes") + "\"");
+                       Console.WriteLine("\"GstSDPMessage.medias\": \"" + Gst.Sdp.SDPMessage.abi_info.GetFieldOffset("medias") + "\"");
                        Console.WriteLine("\"sizeof(GstTagDemuxClass)\": \"" + Gst.Tags.TagDemux.class_abi.Size + "\"");
                        Console.WriteLine("\"GstTagDemuxClass.min_start_size\": \"" + Gst.Tags.TagDemux.class_abi.GetFieldOffset("min_start_size") + "\"");
                        Console.WriteLine("\"GstTagDemuxClass.min_end_size\": \"" + Gst.Tags.TagDemux.class_abi.GetFieldOffset("min_end_size") + "\"");
index ff61c3e..733ca4e 100644 (file)
         </parameters>
       </method>
     </struct>
-    <boxed name="SDPMessage" cname="GstSDPMessage" opaque="false" hidden="false">
+    <boxed name="SDPMessage" cname="GstSDPMessage" opaque="true" hidden="false">
       <method name="GetType" cname="gst_sdp_message_get_type" shared="true">
         <return-type type="GType" />
       </method>
index 232115d..7099647 100644 (file)
@@ -371,4 +371,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
        <attr path="//*[contains(@cname, 'gst_reserved_p')]" name="padding">true</attr>
        <attr path="//*[contains(@cname, 'gst_reserved_i')]" name="padding">true</attr>
        <attr path="//*[contains(@cname, 'gst_reserved')]" name="padding">true</attr>
+
+       <attr path="/api/namespace/boxed[@cname='GstSDPMessage']" name="opaque">true</attr>
 </metadata>