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

namespace Gst.Base {

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

#region Autogenerated code
	public partial class PushSrc : Gst.Base.BaseSrc {

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

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

		static CreateNativeDelegate Create_cb_delegate;
		static CreateNativeDelegate CreateVMCallback {
			get {
				if (Create_cb_delegate == null)
					Create_cb_delegate = new CreateNativeDelegate (Create_cb);
				return Create_cb_delegate;
			}
		}

		static void OverrideCreate (GLib.GType gtype)
		{
			OverrideCreate (gtype, CreateVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int CreateNativeDelegate (IntPtr inst, ref IntPtr buf);

		static int Create_cb (IntPtr inst, ref IntPtr buf)
		{
			try {
				PushSrc __obj = GLib.Object.GetObject (inst, false) as PushSrc;
				Gst.FlowReturn __result;
				Gst.Buffer mybuf = buf == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buf, typeof (Gst.Buffer), true);
				__result = __obj.OnCreate (ref mybuf);
				buf = mybuf == null ? IntPtr.Zero : mybuf.Handle;
				return (int) __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Base.PushSrc), ConnectionMethod="OverrideCreate")]
		protected virtual Gst.FlowReturn OnCreate (ref Gst.Buffer buf)
		{
			return InternalCreate (ref buf);
		}

		private Gst.FlowReturn InternalCreate (ref Gst.Buffer buf)
		{
			CreateNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("create"));
				unmanaged = (CreateNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(CreateNativeDelegate));
			}
			if (unmanaged == null) return (Gst.FlowReturn) 0;

			IntPtr native_buf = buf == null ? IntPtr.Zero : buf.Handle ;
			int __result = unmanaged (this.Handle, ref native_buf);
			buf = native_buf == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (native_buf, typeof (Gst.Buffer), true);
			return (Gst.FlowReturn) __result;
		}

		static AllocNativeDelegate Alloc_cb_delegate;
		static AllocNativeDelegate AllocVMCallback {
			get {
				if (Alloc_cb_delegate == null)
					Alloc_cb_delegate = new AllocNativeDelegate (Alloc_cb);
				return Alloc_cb_delegate;
			}
		}

		static void OverrideAlloc (GLib.GType gtype)
		{
			OverrideAlloc (gtype, AllocVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int AllocNativeDelegate (IntPtr inst, out IntPtr buf);

		static int Alloc_cb (IntPtr inst, out IntPtr buf)
		{
			try {
				PushSrc __obj = GLib.Object.GetObject (inst, false) as PushSrc;
				Gst.FlowReturn __result;
				Gst.Buffer mybuf;
				__result = __obj.OnAlloc (out mybuf);
				buf = mybuf == null ? IntPtr.Zero : mybuf.Handle;
				return (int) __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Base.PushSrc), ConnectionMethod="OverrideAlloc")]
		protected virtual Gst.FlowReturn OnAlloc (out Gst.Buffer buf)
		{
			return InternalAlloc (out buf);
		}

		private Gst.FlowReturn InternalAlloc (out Gst.Buffer buf)
		{
			AllocNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("alloc"));
				unmanaged = (AllocNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AllocNativeDelegate));
			}
			if (unmanaged == null) throw new InvalidOperationException ("No base method to invoke");

			IntPtr native_buf;
			int __result = unmanaged (this.Handle, out native_buf);
			buf = native_buf == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (native_buf, typeof (Gst.Buffer), true);
			return (Gst.FlowReturn) __result;
		}

		static FillNativeDelegate Fill_cb_delegate;
		static FillNativeDelegate FillVMCallback {
			get {
				if (Fill_cb_delegate == null)
					Fill_cb_delegate = new FillNativeDelegate (Fill_cb);
				return Fill_cb_delegate;
			}
		}

		static void OverrideFill (GLib.GType gtype)
		{
			OverrideFill (gtype, FillVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int FillNativeDelegate (IntPtr inst, IntPtr buf);

		static int Fill_cb (IntPtr inst, IntPtr buf)
		{
			try {
				PushSrc __obj = GLib.Object.GetObject (inst, false) as PushSrc;
				Gst.FlowReturn __result;
				__result = __obj.OnFill (buf == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buf, typeof (Gst.Buffer), false));
				return (int) __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Base.PushSrc), ConnectionMethod="OverrideFill")]
		protected virtual Gst.FlowReturn OnFill (Gst.Buffer buf)
		{
			return InternalFill (buf);
		}

		private Gst.FlowReturn InternalFill (Gst.Buffer buf)
		{
			FillNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("fill"));
				unmanaged = (FillNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(FillNativeDelegate));
			}
			if (unmanaged == null) return (Gst.FlowReturn) 0;

			int __result = unmanaged (this.Handle, buf == null ? IntPtr.Zero : buf.Handle);
			return (Gst.FlowReturn) __result;
		}


		// 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("create"
							, Gst.Base.BaseSrc.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // create
							, null
							, "alloc"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("alloc"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // alloc
							, "create"
							, "fill"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("fill"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // fill
							, "alloc"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, "fill"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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


		static PushSrc ()
		{
			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("_gst_reserved"
							, Gst.Base.BaseSrc.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // _gst_reserved
							, null
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
