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

namespace Gst {

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

#region Autogenerated code
	public partial class ControlBinding : Gst.Object {

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

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

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

		[GLib.Property ("object")]
		public Gst.Object Object {
			get {
				GLib.Value val = GetProperty ("object");
				Gst.Object ret = (Gst.Object) val;
				val.Dispose ();
				return ret;
			}
		}

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

		public IntPtr Pspec {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("pspec"));
					return (*raw_ptr);
				}
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_control_binding_set_disabled(IntPtr raw, bool disabled);

		public bool Disabled {
			set  {
				gst_control_binding_set_disabled(Handle, value);
			}
		}

		static SyncValuesNativeDelegate SyncValues_cb_delegate;
		static SyncValuesNativeDelegate SyncValuesVMCallback {
			get {
				if (SyncValues_cb_delegate == null)
					SyncValues_cb_delegate = new SyncValuesNativeDelegate (SyncValues_cb);
				return SyncValues_cb_delegate;
			}
		}

		static void OverrideSyncValues (GLib.GType gtype)
		{
			OverrideSyncValues (gtype, SyncValuesVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SyncValuesNativeDelegate (IntPtr inst, IntPtr _object, ulong timestamp, ulong last_sync);

		static bool SyncValues_cb (IntPtr inst, IntPtr _object, ulong timestamp, ulong last_sync)
		{
			try {
				ControlBinding __obj = GLib.Object.GetObject (inst, false) as ControlBinding;
				bool __result;
				__result = __obj.OnSyncValues (GLib.Object.GetObject(_object) as Gst.Object, timestamp, last_sync);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.ControlBinding), ConnectionMethod="OverrideSyncValues")]
		protected virtual bool OnSyncValues (Gst.Object _object, ulong timestamp, ulong last_sync)
		{
			return InternalSyncValues (_object, timestamp, last_sync);
		}

		private bool InternalSyncValues (Gst.Object _object, ulong timestamp, ulong last_sync)
		{
			SyncValuesNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("sync_values"));
				unmanaged = (SyncValuesNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(SyncValuesNativeDelegate));
			}
			if (unmanaged == null) return false;

			bool __result = unmanaged (this.Handle, _object == null ? IntPtr.Zero : _object.Handle, timestamp, last_sync);
			return __result;
		}

		static GetValueNativeDelegate GetValue_cb_delegate;
		static GetValueNativeDelegate GetValueVMCallback {
			get {
				if (GetValue_cb_delegate == null)
					GetValue_cb_delegate = new GetValueNativeDelegate (GetValue_cb);
				return GetValue_cb_delegate;
			}
		}

		static void OverrideGetValue (GLib.GType gtype)
		{
			OverrideGetValue (gtype, GetValueVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetValueNativeDelegate (IntPtr inst, ulong timestamp);

		static IntPtr GetValue_cb (IntPtr inst, ulong timestamp)
		{
			try {
				ControlBinding __obj = GLib.Object.GetObject (inst, false) as ControlBinding;
				GLib.Value __result;
				__result = __obj.OnGetValue (timestamp);
				return GLib.Marshaller.StructureToPtrAlloc (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.ControlBinding), ConnectionMethod="OverrideGetValue")]
		protected virtual GLib.Value OnGetValue (ulong timestamp)
		{
			return InternalGetValue (timestamp);
		}

		private GLib.Value InternalGetValue (ulong timestamp)
		{
			GetValueNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("get_value"));
				unmanaged = (GetValueNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(GetValueNativeDelegate));
			}
			if (unmanaged == null) return GLib.Value.Empty;

			IntPtr __result = unmanaged (this.Handle, timestamp);
			return (GLib.Value) Marshal.PtrToStructure (__result, typeof (GLib.Value));
		}


		// 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("sync_values"
							, Gst.Object.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // sync_values
							, null
							, "get_value"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("get_value"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // get_value
							, "sync_values"
							, "get_value_array"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("get_value_array"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // get_value_array
							, "get_value"
							, "get_g_value_array"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("get_g_value_array"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // get_g_value_array
							, "get_value_array"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, "get_g_value_array"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_control_binding_get_g_value_array(IntPtr raw, ulong timestamp, ulong interval, uint n_values, IntPtr[] values);

		public bool GetGValueArray(ulong timestamp, ulong interval, GLib.Value[] values) {
			int cnt_values = values == null ? 0 : values.Length;
			IntPtr[] native_values = new IntPtr [cnt_values];
			for (int i = 0; i < cnt_values; i++)
				native_values [i] = GLib.Marshaller.StructureToPtrAlloc (values[i]);
			bool raw_ret = gst_control_binding_get_g_value_array(Handle, timestamp, interval, (uint) (values == null ? 0 : values.Length), native_values);
			bool ret = raw_ret;
			for (int i = 0; i < native_values.Length; i++) {
				values [i] = (GLib.Value) Marshal.PtrToStructure (native_values[i], typeof (GLib.Value));
				Marshal.FreeHGlobal (native_values[i]);
			}
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_control_binding_get_value(IntPtr raw, ulong timestamp);

		public GLib.Value GetValue(ulong timestamp) {
			IntPtr raw_ret = gst_control_binding_get_value(Handle, timestamp);
			GLib.Value ret = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value));
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_control_binding_is_disabled(IntPtr raw);

		public bool IsDisabled { 
			get {
				bool raw_ret = gst_control_binding_is_disabled(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_control_binding_sync_values(IntPtr raw, IntPtr _object, ulong timestamp, ulong last_sync);

		public bool SyncValues(Gst.Object _object, ulong timestamp, ulong last_sync) {
			bool raw_ret = gst_control_binding_sync_values(Handle, _object == null ? IntPtr.Zero : _object.Handle, timestamp, last_sync);
			bool ret = raw_ret;
			return ret;
		}


		// 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("name"
							, Gst.Object.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // name
							, null
							, "pspec"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("pspec"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // pspec
							, "name"
							, "object"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("object"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // object
							, "pspec"
							, "disabled"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("disabled"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // disabled
							, "object"
							, "ABI"
							, (long) Marshal.OffsetOf(typeof(GstControlBinding_disabledAlign), "disabled")
							, 0
							),
						// union struct ABI.abi
							new GLib.AbiField("ABI.abi.priv"
								, -1
								, (uint) Marshal.SizeOf(typeof(IntPtr)) // ABI.abi.priv
								, "disabled"
								, null
								, (uint) Marshal.SizeOf(typeof(IntPtr))
								, 0
								),
						// End ABI.abi

						// union struct ABI
							new GLib.AbiField("ABI._gst_reserved"
								, -1
								, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // ABI._gst_reserved
								, "disabled"
								, null
								, (uint) Marshal.SizeOf(typeof(IntPtr))
								, 0
								),
						// End ABI

						new GLib.AbiField("ABI"
							, -1
							, new List<List<string>>() {  // union ABI
						new List<string>() {"ABI.abi.priv"},
						new List<string>() {"ABI._gst_reserved"}
					  }
							, "disabled"
							, null
							, 0
							),
					});

				return _abi_info;
			}
		}

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


		// End of the ABI representation.

#endregion
	}
}
