// 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 Task : Gst.Object {

		public Task (IntPtr raw) : base(raw) {}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_task_new(GstSharp.TaskFunctionNative func, IntPtr user_data, GLib.DestroyNotify notify);

		public Task (Gst.TaskFunction func, IntPtr user_data, GLib.DestroyNotify notify) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Task)) {
				var vals = new List<GLib.Value> ();
				var names = new List<string> ();
				CreateNativeObject (names.ToArray (), vals.ToArray ());
				return;
			}
			GstSharp.TaskFunctionWrapper func_wrapper = new GstSharp.TaskFunctionWrapper (func);
			Raw = gst_task_new(func_wrapper.NativeDelegate, user_data, notify);
		}

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

		public Gst.TaskState State {
			get  {
				int raw_ret = gst_task_get_state(Handle);
				Gst.TaskState ret = (Gst.TaskState) raw_ret;
				return ret;
			}
		}

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

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

		public GLib.RecMutex Lock {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("lock"));
					return new GLib.RecMutex((*raw_ptr));
				}
			}
			set  {
				gst_task_set_lock(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		public Gst.TaskFunction Func {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("func"));
					 GstSharp.TaskFunctionNative del = (GstSharp.TaskFunctionNative)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(GstSharp.TaskFunctionNative));
					return GstSharp.TaskFunctionWrapper.GetManagedDelegate ((del));
				}
			}
		}

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

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


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

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

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

		public static void CleanupAll() {
			gst_task_cleanup_all();
		}

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

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

		public Gst.TaskPool Pool { 
			get {
				IntPtr raw_ret = gst_task_get_pool(Handle);
				Gst.TaskPool ret = GLib.Object.GetObject(raw_ret, true) as Gst.TaskPool;
				return ret;
			}
			set {
				gst_task_set_pool(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

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

		public bool Join() {
			bool raw_ret = gst_task_join(Handle);
			bool ret = raw_ret;
			return ret;
		}

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

		public bool Pause() {
			bool raw_ret = gst_task_pause(Handle);
			bool ret = raw_ret;
			return ret;
		}

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

		public bool Resume() {
			bool raw_ret = gst_task_resume(Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_task_set_enter_callback(IntPtr raw, GstSharp.TaskThreadFuncNative enter_func, IntPtr user_data, GLib.DestroyNotify notify);

		public Gst.TaskThreadFunc EnterCallback { 
			set {
				GstSharp.TaskThreadFuncWrapper value_wrapper = new GstSharp.TaskThreadFuncWrapper (value);
				IntPtr user_data;
				GLib.DestroyNotify notify;
				if (value == null) {
					user_data = IntPtr.Zero;
					notify = null;
				} else {
					user_data = (IntPtr) GCHandle.Alloc (value_wrapper);
					notify = GLib.DestroyHelper.NotifyHandler;
				}
				gst_task_set_enter_callback(Handle, value_wrapper.NativeDelegate, user_data, notify);
			}
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_task_set_leave_callback(IntPtr raw, GstSharp.TaskThreadFuncNative leave_func, IntPtr user_data, GLib.DestroyNotify notify);

		public Gst.TaskThreadFunc LeaveCallback { 
			set {
				GstSharp.TaskThreadFuncWrapper value_wrapper = new GstSharp.TaskThreadFuncWrapper (value);
				IntPtr user_data;
				GLib.DestroyNotify notify;
				if (value == null) {
					user_data = IntPtr.Zero;
					notify = null;
				} else {
					user_data = (IntPtr) GCHandle.Alloc (value_wrapper);
					notify = GLib.DestroyHelper.NotifyHandler;
				}
				gst_task_set_leave_callback(Handle, value_wrapper.NativeDelegate, user_data, notify);
			}
		}

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

		public bool SetState(Gst.TaskState state) {
			bool raw_ret = gst_task_set_state(Handle, (int) state);
			bool ret = raw_ret;
			return ret;
		}

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

		public bool Start() {
			bool raw_ret = gst_task_start(Handle);
			bool ret = raw_ret;
			return ret;
		}

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

		public bool Stop() {
			bool raw_ret = gst_task_stop(Handle);
			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("state"
							, Gst.Object.abi_info.Fields
							, (uint) Marshal.SizeOf(System.Enum.GetUnderlyingType(typeof(Gst.TaskState))) // state
							, null
							, "cond"
							, (long) Marshal.OffsetOf(typeof(GstTask_stateAlign), "state")
							, 0
							),
						new GLib.AbiField("cond"
							, -1
							, (uint) Marshal.SizeOf(typeof(GLib.Cond.ABI)) // cond
							, "state"
							, "lock"
							, (long) Marshal.OffsetOf(typeof(GstTask_condAlign), "cond")
							, 0
							),
						new GLib.AbiField("lock"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // lock
							, "cond"
							, "func"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("func"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // func
							, "lock"
							, "user_data"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("user_data"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // user_data
							, "func"
							, "notify"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("notify"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // notify
							, "user_data"
							, "running"
							, (long) Marshal.OffsetOf(typeof(GstTask_notifyAlign), "notify")
							, 0
							),
						new GLib.AbiField("running"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // running
							, "notify"
							, "thread"
							, (long) Marshal.OffsetOf(typeof(GstTask_runningAlign), "running")
							, 0
							),
						new GLib.AbiField("thread"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // thread
							, "running"
							, "priv"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("priv"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, "thread"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, "priv"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstTask_stateAlign
		{
			sbyte f1;
			private Gst.TaskState state;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstTask_condAlign
		{
			sbyte f1;
			private GLib.Cond.ABI cond;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstTask_notifyAlign
		{
			sbyte f1;
			private GLib.DestroyNotify notify;
		}

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


		// End of the ABI representation.

#endregion
	}
}
