// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gst.WebRTC {

	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class WebRTCDataChannel : GLib.Object {

		protected WebRTCDataChannel (IntPtr raw) : base(raw) {}

		protected WebRTCDataChannel() : base(IntPtr.Zero)
		{
			CreateNativeObject (new string [0], new GLib.Value [0]);
		}

		[GLib.Property ("buffered-amount")]
		public ulong BufferedAmount {
			get {
				GLib.Value val = GetProperty ("buffered-amount");
				ulong ret = (ulong) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("buffered-amount-low-threshold")]
		public ulong BufferedAmountLowThreshold {
			get {
				GLib.Value val = GetProperty ("buffered-amount-low-threshold");
				ulong ret = (ulong) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("buffered-amount-low-threshold", val);
				val.Dispose ();
			}
		}

		[GLib.Property ("id")]
		public int Id {
			get {
				GLib.Value val = GetProperty ("id");
				int ret = (int) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("label")]
		public string Label {
			get {
				GLib.Value val = GetProperty ("label");
				string ret = (string) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("max-packet-lifetime")]
		public int MaxPacketLifetime {
			get {
				GLib.Value val = GetProperty ("max-packet-lifetime");
				int ret = (int) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("max-retransmits")]
		public int MaxRetransmits {
			get {
				GLib.Value val = GetProperty ("max-retransmits");
				int ret = (int) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("negotiated")]
		public bool Negotiated {
			get {
				GLib.Value val = GetProperty ("negotiated");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("ordered")]
		public bool Ordered {
			get {
				GLib.Value val = GetProperty ("ordered");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("priority")]
		public Gst.WebRTC.WebRTCPriorityType Priority {
			get {
				GLib.Value val = GetProperty ("priority");
				Gst.WebRTC.WebRTCPriorityType ret = (Gst.WebRTC.WebRTCPriorityType) (Enum) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("protocol")]
		public string Protocol {
			get {
				GLib.Value val = GetProperty ("protocol");
				string ret = (string) val;
				val.Dispose ();
				return ret;
			}
		}

		[GLib.Property ("ready-state")]
		public Gst.WebRTC.WebRTCDataChannelState ReadyState {
			get {
				GLib.Value val = GetProperty ("ready-state");
				Gst.WebRTC.WebRTCDataChannelState ret = (Gst.WebRTC.WebRTCDataChannelState) (Enum) val;
				val.Dispose ();
				return ret;
			}
		}

		public GLib.Mutex Lock {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("lock"));
					return new GLib.Mutex((*raw_ptr));
				}
			}
		}

		public string LabelField {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("label"));
					return GLib.Marshaller.Utf8PtrToString ((*raw_ptr));
				}
			}
		}

		public bool OrderedField {
			get {
				unsafe {
					bool* raw_ptr = (bool*)(((byte*)Handle) + abi_info.GetFieldOffset("ordered"));
					return (*raw_ptr);
				}
			}
		}

		public uint MaxPacketLifetimeField {
			get {
				unsafe {
					uint* raw_ptr = (uint*)(((byte*)Handle) + abi_info.GetFieldOffset("max_packet_lifetime"));
					return (*raw_ptr);
				}
			}
		}

		public uint MaxRetransmitsField {
			get {
				unsafe {
					uint* raw_ptr = (uint*)(((byte*)Handle) + abi_info.GetFieldOffset("max_retransmits"));
					return (*raw_ptr);
				}
			}
		}

		public string ProtocolField {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("protocol"));
					return GLib.Marshaller.Utf8PtrToString ((*raw_ptr));
				}
			}
		}

		public bool NegotiatedField {
			get {
				unsafe {
					bool* raw_ptr = (bool*)(((byte*)Handle) + abi_info.GetFieldOffset("negotiated"));
					return (*raw_ptr);
				}
			}
		}

		public int IdField {
			get {
				unsafe {
					int* raw_ptr = (int*)(((byte*)Handle) + abi_info.GetFieldOffset("id"));
					return (*raw_ptr);
				}
			}
		}

		public Gst.WebRTC.WebRTCPriorityType PriorityField {
			get {
				unsafe {
					int* raw_ptr = (int*)(((byte*)Handle) + abi_info.GetFieldOffset("priority"));
					return (Gst.WebRTC.WebRTCPriorityType) (*raw_ptr);
				}
			}
		}

		public Gst.WebRTC.WebRTCDataChannelState ReadyStateField {
			get {
				unsafe {
					int* raw_ptr = (int*)(((byte*)Handle) + abi_info.GetFieldOffset("ready_state"));
					return (Gst.WebRTC.WebRTCDataChannelState) (*raw_ptr);
				}
			}
		}

		public ulong BufferedAmountField {
			get {
				unsafe {
					ulong* raw_ptr = (ulong*)(((byte*)Handle) + abi_info.GetFieldOffset("buffered_amount"));
					return (*raw_ptr);
				}
			}
		}

		public ulong BufferedAmountLowThresholdField {
			get {
				unsafe {
					ulong* raw_ptr = (ulong*)(((byte*)Handle) + abi_info.GetFieldOffset("buffered_amount_low_threshold"));
					return (*raw_ptr);
				}
			}
		}

		[GLib.Signal("on-buffered-amount-low")]
		public event System.EventHandler OnBufferedAmountLowEvent {
			add {
				this.AddSignalHandler ("on-buffered-amount-low", value);
			}
			remove {
				this.RemoveSignalHandler ("on-buffered-amount-low", value);
			}
		}

		[GLib.Signal("send-data")]
		public event Gst.WebRTC.SendDataEventHandler SendDataEvent {
			add {
				this.AddSignalHandler ("send-data", value, typeof (Gst.WebRTC.SendDataEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("send-data", value);
			}
		}

		[GLib.Signal("on-message-string")]
		public event Gst.WebRTC.OnMessageStringEventHandler OnMessageStringEvent {
			add {
				this.AddSignalHandler ("on-message-string", value, typeof (Gst.WebRTC.OnMessageStringEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("on-message-string", value);
			}
		}

		[GLib.Signal("on-open")]
		public event System.EventHandler OnOpenEvent {
			add {
				this.AddSignalHandler ("on-open", value);
			}
			remove {
				this.RemoveSignalHandler ("on-open", value);
			}
		}

		[GLib.Signal("close")]
		public event System.EventHandler CloseEvent {
			add {
				this.AddSignalHandler ("close", value);
			}
			remove {
				this.RemoveSignalHandler ("close", value);
			}
		}

		[GLib.Signal("on-message-data")]
		public event Gst.WebRTC.OnMessageDataEventHandler OnMessageDataEvent {
			add {
				this.AddSignalHandler ("on-message-data", value, typeof (Gst.WebRTC.OnMessageDataEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("on-message-data", value);
			}
		}

		[GLib.Signal("send-string")]
		public event Gst.WebRTC.SendStringEventHandler SendStringEvent {
			add {
				this.AddSignalHandler ("send-string", value, typeof (Gst.WebRTC.SendStringEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("send-string", value);
			}
		}

		[GLib.Signal("on-error")]
		public event Gst.WebRTC.OnErrorEventHandler OnErrorEvent {
			add {
				this.AddSignalHandler ("on-error", value, typeof (Gst.WebRTC.OnErrorEventArgs));
			}
			remove {
				this.RemoveSignalHandler ("on-error", value);
			}
		}

		static OnBufferedAmountLowEventNativeDelegate OnBufferedAmountLowEvent_cb_delegate;
		static OnBufferedAmountLowEventNativeDelegate OnBufferedAmountLowEventVMCallback {
			get {
				if (OnBufferedAmountLowEvent_cb_delegate == null)
					OnBufferedAmountLowEvent_cb_delegate = new OnBufferedAmountLowEventNativeDelegate (OnBufferedAmountLowEvent_cb);
				return OnBufferedAmountLowEvent_cb_delegate;
			}
		}

		static void OverrideOnBufferedAmountLowEvent (GLib.GType gtype)
		{
			OverrideOnBufferedAmountLowEvent (gtype, OnBufferedAmountLowEventVMCallback);
		}

		static void OverrideOnBufferedAmountLowEvent (GLib.GType gtype, OnBufferedAmountLowEventNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "on-buffered-amount-low", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void OnBufferedAmountLowEventNativeDelegate (IntPtr inst);

		static void OnBufferedAmountLowEvent_cb (IntPtr inst)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnOnBufferedAmountLowEvent ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideOnBufferedAmountLowEvent")]
		protected virtual void OnOnBufferedAmountLowEvent ()
		{
			InternalOnBufferedAmountLowEvent ();
		}

		private void InternalOnBufferedAmountLowEvent ()
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (1);
			GLib.Value[] vals = new GLib.Value [1];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static OnErrorEventNativeDelegate OnErrorEvent_cb_delegate;
		static OnErrorEventNativeDelegate OnErrorEventVMCallback {
			get {
				if (OnErrorEvent_cb_delegate == null)
					OnErrorEvent_cb_delegate = new OnErrorEventNativeDelegate (OnErrorEvent_cb);
				return OnErrorEvent_cb_delegate;
			}
		}

		static void OverrideOnErrorEvent (GLib.GType gtype)
		{
			OverrideOnErrorEvent (gtype, OnErrorEventVMCallback);
		}

		static void OverrideOnErrorEvent (GLib.GType gtype, OnErrorEventNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "on-error", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void OnErrorEventNativeDelegate (IntPtr inst, IntPtr error);

		static void OnErrorEvent_cb (IntPtr inst, IntPtr error)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnOnErrorEvent (error);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideOnErrorEvent")]
		protected virtual void OnOnErrorEvent (IntPtr error)
		{
			InternalOnErrorEvent (error);
		}

		private void InternalOnErrorEvent (IntPtr error)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
			GLib.Value[] vals = new GLib.Value [2];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (error);
			inst_and_params.Append (vals [1]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static OnMessageDataEventNativeDelegate OnMessageDataEvent_cb_delegate;
		static OnMessageDataEventNativeDelegate OnMessageDataEventVMCallback {
			get {
				if (OnMessageDataEvent_cb_delegate == null)
					OnMessageDataEvent_cb_delegate = new OnMessageDataEventNativeDelegate (OnMessageDataEvent_cb);
				return OnMessageDataEvent_cb_delegate;
			}
		}

		static void OverrideOnMessageDataEvent (GLib.GType gtype)
		{
			OverrideOnMessageDataEvent (gtype, OnMessageDataEventVMCallback);
		}

		static void OverrideOnMessageDataEvent (GLib.GType gtype, OnMessageDataEventNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "on-message-data", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void OnMessageDataEventNativeDelegate (IntPtr inst, IntPtr data);

		static void OnMessageDataEvent_cb (IntPtr inst, IntPtr data)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnOnMessageDataEvent (new GLib.Bytes(data));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideOnMessageDataEvent")]
		protected virtual void OnOnMessageDataEvent (GLib.Bytes data)
		{
			InternalOnMessageDataEvent (data);
		}

		private void InternalOnMessageDataEvent (GLib.Bytes data)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
			GLib.Value[] vals = new GLib.Value [2];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (data);
			inst_and_params.Append (vals [1]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static OnMessageStringEventNativeDelegate OnMessageStringEvent_cb_delegate;
		static OnMessageStringEventNativeDelegate OnMessageStringEventVMCallback {
			get {
				if (OnMessageStringEvent_cb_delegate == null)
					OnMessageStringEvent_cb_delegate = new OnMessageStringEventNativeDelegate (OnMessageStringEvent_cb);
				return OnMessageStringEvent_cb_delegate;
			}
		}

		static void OverrideOnMessageStringEvent (GLib.GType gtype)
		{
			OverrideOnMessageStringEvent (gtype, OnMessageStringEventVMCallback);
		}

		static void OverrideOnMessageStringEvent (GLib.GType gtype, OnMessageStringEventNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "on-message-string", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void OnMessageStringEventNativeDelegate (IntPtr inst, IntPtr data);

		static void OnMessageStringEvent_cb (IntPtr inst, IntPtr data)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnOnMessageStringEvent (GLib.Marshaller.Utf8PtrToString (data));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideOnMessageStringEvent")]
		protected virtual void OnOnMessageStringEvent (string data)
		{
			InternalOnMessageStringEvent (data);
		}

		private void InternalOnMessageStringEvent (string data)
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
			GLib.Value[] vals = new GLib.Value [2];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			vals [1] = new GLib.Value (data);
			inst_and_params.Append (vals [1]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static OnOpenEventNativeDelegate OnOpenEvent_cb_delegate;
		static OnOpenEventNativeDelegate OnOpenEventVMCallback {
			get {
				if (OnOpenEvent_cb_delegate == null)
					OnOpenEvent_cb_delegate = new OnOpenEventNativeDelegate (OnOpenEvent_cb);
				return OnOpenEvent_cb_delegate;
			}
		}

		static void OverrideOnOpenEvent (GLib.GType gtype)
		{
			OverrideOnOpenEvent (gtype, OnOpenEventVMCallback);
		}

		static void OverrideOnOpenEvent (GLib.GType gtype, OnOpenEventNativeDelegate callback)
		{
			OverrideVirtualMethod (gtype, "on-open", callback);
		}
		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void OnOpenEventNativeDelegate (IntPtr inst);

		static void OnOpenEvent_cb (IntPtr inst)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnOnOpenEvent ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideOnOpenEvent")]
		protected virtual void OnOnOpenEvent ()
		{
			InternalOnOpenEvent ();
		}

		private void InternalOnOpenEvent ()
		{
			GLib.Value ret = GLib.Value.Empty;
			GLib.ValueArray inst_and_params = new GLib.ValueArray (1);
			GLib.Value[] vals = new GLib.Value [1];
			vals [0] = new GLib.Value (this);
			inst_and_params.Append (vals [0]);
			g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
			foreach (GLib.Value v in vals)
				v.Dispose ();
		}

		static SendDataEventNativeDelegate SendDataEvent_cb_delegate;
		static SendDataEventNativeDelegate SendDataEventVMCallback {
			get {
				if (SendDataEvent_cb_delegate == null)
					SendDataEvent_cb_delegate = new SendDataEventNativeDelegate (SendDataEvent_cb);
				return SendDataEvent_cb_delegate;
			}
		}

		static void OverrideSendDataEvent (GLib.GType gtype)
		{
			OverrideSendDataEvent (gtype, SendDataEventVMCallback);
		}

		static void OverrideSendDataEvent (GLib.GType gtype, SendDataEventNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("send_data"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SendDataEventNativeDelegate (IntPtr inst, IntPtr data);

		static void SendDataEvent_cb (IntPtr inst, IntPtr data)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnSendDataEvent (new GLib.Bytes(data));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideSendDataEvent")]
		protected virtual void OnSendDataEvent (GLib.Bytes data)
		{
			InternalSendDataEvent (data);
		}

		private void InternalSendDataEvent (GLib.Bytes data)
		{
			SendDataEventNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("send_data"));
				unmanaged = (SendDataEventNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(SendDataEventNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, data == null ? IntPtr.Zero : data.Handle);
		}

		static SendStringEventNativeDelegate SendStringEvent_cb_delegate;
		static SendStringEventNativeDelegate SendStringEventVMCallback {
			get {
				if (SendStringEvent_cb_delegate == null)
					SendStringEvent_cb_delegate = new SendStringEventNativeDelegate (SendStringEvent_cb);
				return SendStringEvent_cb_delegate;
			}
		}

		static void OverrideSendStringEvent (GLib.GType gtype)
		{
			OverrideSendStringEvent (gtype, SendStringEventVMCallback);
		}

		static void OverrideSendStringEvent (GLib.GType gtype, SendStringEventNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("send_string"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SendStringEventNativeDelegate (IntPtr inst, IntPtr data);

		static void SendStringEvent_cb (IntPtr inst, IntPtr data)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnSendStringEvent (GLib.Marshaller.Utf8PtrToString (data));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideSendStringEvent")]
		protected virtual void OnSendStringEvent (string data)
		{
			InternalSendStringEvent (data);
		}

		private void InternalSendStringEvent (string data)
		{
			SendStringEventNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("send_string"));
				unmanaged = (SendStringEventNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(SendStringEventNativeDelegate));
			}
			if (unmanaged == null) return;

			IntPtr native_data = GLib.Marshaller.StringToPtrGStrdup (data);
			unmanaged (this.Handle, native_data);
			GLib.Marshaller.Free (native_data);
		}

		static CloseEventNativeDelegate CloseEvent_cb_delegate;
		static CloseEventNativeDelegate CloseEventVMCallback {
			get {
				if (CloseEvent_cb_delegate == null)
					CloseEvent_cb_delegate = new CloseEventNativeDelegate (CloseEvent_cb);
				return CloseEvent_cb_delegate;
			}
		}

		static void OverrideCloseEvent (GLib.GType gtype)
		{
			OverrideCloseEvent (gtype, CloseEventVMCallback);
		}

		static void OverrideCloseEvent (GLib.GType gtype, CloseEventNativeDelegate callback)
		{
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) gtype.GetClassPtr()) + (long) class_abi.GetFieldOffset("close"));
				*raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate) callback);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void CloseEventNativeDelegate (IntPtr inst);

		static void CloseEvent_cb (IntPtr inst)
		{
			try {
				WebRTCDataChannel __obj = GLib.Object.GetObject (inst, false) as WebRTCDataChannel;
				__obj.OnCloseEvent ();
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.WebRTC.WebRTCDataChannel), ConnectionMethod="OverrideCloseEvent")]
		protected virtual void OnCloseEvent ()
		{
			InternalCloseEvent ();
		}

		private void InternalCloseEvent ()
		{
			CloseEventNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("close"));
				unmanaged = (CloseEventNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(CloseEventNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}


		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _class_abi = null;
		static public new GLib.AbiStruct class_abi {
			get {
				if (_class_abi == null)
					_class_abi = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("send_data"
							, GLib.Object.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // send_data
							, null
							, "send_string"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("send_string"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // send_string
							, "send_data"
							, "close"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("close"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // close
							, "send_string"
							, "_padding"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_padding"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _padding
							, "close"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_webrtc_data_channel_get_type();

		public static new GLib.GType GType { 
			get {
				IntPtr raw_ret = gst_webrtc_data_channel_get_type();
				GLib.GType ret = new GLib.GType(raw_ret);
				return ret;
			}
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_close(IntPtr raw);

		public void Close() {
			gst_webrtc_data_channel_close(Handle);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_buffered_amount_low(IntPtr raw);

		public void OnBufferedAmountLow() {
			gst_webrtc_data_channel_on_buffered_amount_low(Handle);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_close(IntPtr raw);

		public void OnClose() {
			gst_webrtc_data_channel_on_close(Handle);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_error(IntPtr raw, IntPtr error);

		public void OnError(IntPtr error) {
			gst_webrtc_data_channel_on_error(Handle, error);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_message_data(IntPtr raw, IntPtr data);

		public void OnMessageData(GLib.Bytes data) {
			gst_webrtc_data_channel_on_message_data(Handle, data == null ? IntPtr.Zero : data.Handle);
		}

		public void OnMessageData() {
			OnMessageData (null);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_message_string(IntPtr raw, IntPtr str);

		public void OnMessageString(string str) {
			IntPtr native_str = GLib.Marshaller.StringToPtrGStrdup (str);
			gst_webrtc_data_channel_on_message_string(Handle, native_str);
			GLib.Marshaller.Free (native_str);
		}

		public void OnMessageString() {
			OnMessageString (null);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_on_open(IntPtr raw);

		public void OnOpen() {
			gst_webrtc_data_channel_on_open(Handle);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_send_data(IntPtr raw, IntPtr data);

		public void SendData(GLib.Bytes data) {
			gst_webrtc_data_channel_send_data(Handle, data == null ? IntPtr.Zero : data.Handle);
		}

		public void SendData() {
			SendData (null);
		}

		[DllImport("gstwebrtc-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_webrtc_data_channel_send_string(IntPtr raw, IntPtr str);

		public void SendString(string str) {
			IntPtr native_str = GLib.Marshaller.StringToPtrGStrdup (str);
			gst_webrtc_data_channel_send_string(Handle, native_str);
			GLib.Marshaller.Free (native_str);
		}

		public void SendString() {
			SendString (null);
		}


		static WebRTCDataChannel ()
		{
			GtkSharp.GstreamerSharp.ObjectManager.Initialize ();
		}

		// Internal representation of the wrapped structure ABI.
		static GLib.AbiStruct _abi_info = null;
		static public new GLib.AbiStruct abi_info {
			get {
				if (_abi_info == null)
					_abi_info = new GLib.AbiStruct (new List<GLib.AbiField>{ 
						new GLib.AbiField("lock"
							, GLib.Object.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // lock
							, null
							, "label"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("label"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // label
							, "lock"
							, "ordered"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("ordered"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // ordered
							, "label"
							, "max_packet_lifetime"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_orderedAlign), "ordered")
							, 0
							),
						new GLib.AbiField("max_packet_lifetime"
							, -1
							, (uint) Marshal.SizeOf(typeof(uint)) // max_packet_lifetime
							, "ordered"
							, "max_retransmits"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_max_packet_lifetimeAlign), "max_packet_lifetime")
							, 0
							),
						new GLib.AbiField("max_retransmits"
							, -1
							, (uint) Marshal.SizeOf(typeof(uint)) // max_retransmits
							, "max_packet_lifetime"
							, "protocol"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_max_retransmitsAlign), "max_retransmits")
							, 0
							),
						new GLib.AbiField("protocol"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // protocol
							, "max_retransmits"
							, "negotiated"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("negotiated"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // negotiated
							, "protocol"
							, "id"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_negotiatedAlign), "negotiated")
							, 0
							),
						new GLib.AbiField("id"
							, -1
							, (uint) Marshal.SizeOf(typeof(int)) // id
							, "negotiated"
							, "priority"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_idAlign), "id")
							, 0
							),
						new GLib.AbiField("priority"
							, -1
							, (uint) Marshal.SizeOf(System.Enum.GetUnderlyingType(typeof(Gst.WebRTC.WebRTCPriorityType))) // priority
							, "id"
							, "ready_state"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_priorityAlign), "priority")
							, 0
							),
						new GLib.AbiField("ready_state"
							, -1
							, (uint) Marshal.SizeOf(System.Enum.GetUnderlyingType(typeof(Gst.WebRTC.WebRTCDataChannelState))) // ready_state
							, "priority"
							, "buffered_amount"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_ready_stateAlign), "ready_state")
							, 0
							),
						new GLib.AbiField("buffered_amount"
							, -1
							, (uint) Marshal.SizeOf(typeof(ulong)) // buffered_amount
							, "ready_state"
							, "buffered_amount_low_threshold"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_buffered_amountAlign), "buffered_amount")
							, 0
							),
						new GLib.AbiField("buffered_amount_low_threshold"
							, -1
							, (uint) Marshal.SizeOf(typeof(ulong)) // buffered_amount_low_threshold
							, "buffered_amount"
							, "_padding"
							, (long) Marshal.OffsetOf(typeof(GstWebRTCDataChannel_buffered_amount_low_thresholdAlign), "buffered_amount_low_threshold")
							, 0
							),
						new GLib.AbiField("_padding"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _padding
							, "buffered_amount_low_threshold"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_orderedAlign
		{
			sbyte f1;
			private bool ordered;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_max_packet_lifetimeAlign
		{
			sbyte f1;
			private uint max_packet_lifetime;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_max_retransmitsAlign
		{
			sbyte f1;
			private uint max_retransmits;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_negotiatedAlign
		{
			sbyte f1;
			private bool negotiated;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_idAlign
		{
			sbyte f1;
			private int id;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_priorityAlign
		{
			sbyte f1;
			private Gst.WebRTC.WebRTCPriorityType priority;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_ready_stateAlign
		{
			sbyte f1;
			private Gst.WebRTC.WebRTCDataChannelState ready_state;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_buffered_amountAlign
		{
			sbyte f1;
			private ulong buffered_amount;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstWebRTCDataChannel_buffered_amount_low_thresholdAlign
		{
			sbyte f1;
			private ulong buffered_amount_low_threshold;
		}


		// End of the ABI representation.

#endregion
	}
}
