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

namespace GstSharp {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
	internal delegate bool AllocationMetaParamsAggregatorNative(IntPtr aggregated_params, IntPtr params0, IntPtr params1);

	internal class AllocationMetaParamsAggregatorInvoker {

		AllocationMetaParamsAggregatorNative native_cb;
		IntPtr __data;
		GLib.DestroyNotify __notify;

		~AllocationMetaParamsAggregatorInvoker ()
		{
			if (__notify == null)
				return;
			__notify (__data);
		}

		internal AllocationMetaParamsAggregatorInvoker (AllocationMetaParamsAggregatorNative native_cb) : this (native_cb, IntPtr.Zero, null) {}

		internal AllocationMetaParamsAggregatorInvoker (AllocationMetaParamsAggregatorNative native_cb, IntPtr data) : this (native_cb, data, null) {}

		internal AllocationMetaParamsAggregatorInvoker (AllocationMetaParamsAggregatorNative native_cb, IntPtr data, GLib.DestroyNotify notify)
		{
			this.native_cb = native_cb;
			__data = data;
			__notify = notify;
		}

		internal Gst.AllocationMetaParamsAggregator Handler {
			get {
				return new Gst.AllocationMetaParamsAggregator(InvokeNative);
			}
		}

		bool InvokeNative (Gst.Structure aggregated_params, Gst.Structure params0, Gst.Structure params1)
		{
			bool __result = native_cb (aggregated_params == null ? IntPtr.Zero : aggregated_params.Handle, params0 == null ? IntPtr.Zero : params0.Handle, params1 == null ? IntPtr.Zero : params1.Handle);
			return __result;
		}
	}

	internal class AllocationMetaParamsAggregatorWrapper {

		public bool NativeCallback (IntPtr aggregated_params, IntPtr params0, IntPtr params1)
		{
			try {
				bool __ret = managed (aggregated_params == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (aggregated_params, typeof (Gst.Structure), false), params0 == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (params0, typeof (Gst.Structure), false), params1 == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (params1, typeof (Gst.Structure), false));
				if (release_on_call)
					gch.Free ();
				return __ret;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
				return false;
			}
		}

		bool release_on_call = false;
		GCHandle gch;

		public void PersistUntilCalled ()
		{
			release_on_call = true;
			gch = GCHandle.Alloc (this);
		}

		internal AllocationMetaParamsAggregatorNative NativeDelegate;
		Gst.AllocationMetaParamsAggregator managed;

		public AllocationMetaParamsAggregatorWrapper (Gst.AllocationMetaParamsAggregator managed)
		{
			this.managed = managed;
			if (managed != null)
				NativeDelegate = new AllocationMetaParamsAggregatorNative (NativeCallback);
		}

		public static Gst.AllocationMetaParamsAggregator GetManagedDelegate (AllocationMetaParamsAggregatorNative native)
		{
			if (native == null)
				return null;
			AllocationMetaParamsAggregatorWrapper wrapper = (AllocationMetaParamsAggregatorWrapper) native.Target;
			if (wrapper == null)
				return null;
			return wrapper.managed;
		}
	}
#endregion
}
