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

namespace Gst.Tags {

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

#region Autogenerated code
	public partial class TagDemux : Gst.Element {

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

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

		static IdentifyTagNativeDelegate IdentifyTag_cb_delegate;
		static IdentifyTagNativeDelegate IdentifyTagVMCallback {
			get {
				if (IdentifyTag_cb_delegate == null)
					IdentifyTag_cb_delegate = new IdentifyTagNativeDelegate (IdentifyTag_cb);
				return IdentifyTag_cb_delegate;
			}
		}

		static void OverrideIdentifyTag (GLib.GType gtype)
		{
			OverrideIdentifyTag (gtype, IdentifyTagVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool IdentifyTagNativeDelegate (IntPtr inst, IntPtr buffer, bool start_tag, uint tag_size);

		static bool IdentifyTag_cb (IntPtr inst, IntPtr buffer, bool start_tag, uint tag_size)
		{
			try {
				TagDemux __obj = GLib.Object.GetObject (inst, false) as TagDemux;
				bool __result;
				__result = __obj.OnIdentifyTag (buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buffer, typeof (Gst.Buffer), false), start_tag, tag_size);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Tags.TagDemux), ConnectionMethod="OverrideIdentifyTag")]
		protected virtual bool OnIdentifyTag (Gst.Buffer buffer, bool start_tag, uint tag_size)
		{
			return InternalIdentifyTag (buffer, start_tag, tag_size);
		}

		private bool InternalIdentifyTag (Gst.Buffer buffer, bool start_tag, uint tag_size)
		{
			IdentifyTagNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("identify_tag"));
				unmanaged = (IdentifyTagNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(IdentifyTagNativeDelegate));
			}
			if (unmanaged == null) return false;

			bool __result = unmanaged (this.Handle, buffer == null ? IntPtr.Zero : buffer.Handle, start_tag, tag_size);
			return __result;
		}

		static ParseTagNativeDelegate ParseTag_cb_delegate;
		static ParseTagNativeDelegate ParseTagVMCallback {
			get {
				if (ParseTag_cb_delegate == null)
					ParseTag_cb_delegate = new ParseTagNativeDelegate (ParseTag_cb);
				return ParseTag_cb_delegate;
			}
		}

		static void OverrideParseTag (GLib.GType gtype)
		{
			OverrideParseTag (gtype, ParseTagVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int ParseTagNativeDelegate (IntPtr inst, IntPtr buffer, bool start_tag, uint tag_size, IntPtr tags);

		static int ParseTag_cb (IntPtr inst, IntPtr buffer, bool start_tag, uint tag_size, IntPtr tags)
		{
			try {
				TagDemux __obj = GLib.Object.GetObject (inst, false) as TagDemux;
				Gst.Tags.TagDemuxResult __result;
				__result = __obj.OnParseTag (buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buffer, typeof (Gst.Buffer), false), start_tag, tag_size, tags == IntPtr.Zero ? null : (Gst.TagList) GLib.Opaque.GetOpaque (tags, typeof (Gst.TagList), 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.Tags.TagDemux), ConnectionMethod="OverrideParseTag")]
		protected virtual Gst.Tags.TagDemuxResult OnParseTag (Gst.Buffer buffer, bool start_tag, uint tag_size, Gst.TagList tags)
		{
			return InternalParseTag (buffer, start_tag, tag_size, tags);
		}

		private Gst.Tags.TagDemuxResult InternalParseTag (Gst.Buffer buffer, bool start_tag, uint tag_size, Gst.TagList tags)
		{
			ParseTagNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("parse_tag"));
				unmanaged = (ParseTagNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(ParseTagNativeDelegate));
			}
			if (unmanaged == null) return (Gst.Tags.TagDemuxResult) 0;

			int __result = unmanaged (this.Handle, buffer == null ? IntPtr.Zero : buffer.Handle, start_tag, tag_size, tags == null ? IntPtr.Zero : tags.Handle);
			return (Gst.Tags.TagDemuxResult) __result;
		}

		static MergeTagsNativeDelegate MergeTags_cb_delegate;
		static MergeTagsNativeDelegate MergeTagsVMCallback {
			get {
				if (MergeTags_cb_delegate == null)
					MergeTags_cb_delegate = new MergeTagsNativeDelegate (MergeTags_cb);
				return MergeTags_cb_delegate;
			}
		}

		static void OverrideMergeTags (GLib.GType gtype)
		{
			OverrideMergeTags (gtype, MergeTagsVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr MergeTagsNativeDelegate (IntPtr inst, IntPtr start_tags, IntPtr end_tags);

		static IntPtr MergeTags_cb (IntPtr inst, IntPtr start_tags, IntPtr end_tags)
		{
			try {
				TagDemux __obj = GLib.Object.GetObject (inst, false) as TagDemux;
				Gst.TagList __result;
				__result = __obj.OnMergeTags (start_tags == IntPtr.Zero ? null : (Gst.TagList) GLib.Opaque.GetOpaque (start_tags, typeof (Gst.TagList), false), end_tags == IntPtr.Zero ? null : (Gst.TagList) GLib.Opaque.GetOpaque (end_tags, typeof (Gst.TagList), false));
				return __result == null ? IntPtr.Zero : __result.OwnedCopy;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Tags.TagDemux), ConnectionMethod="OverrideMergeTags")]
		protected virtual Gst.TagList OnMergeTags (Gst.TagList start_tags, Gst.TagList end_tags)
		{
			return InternalMergeTags (start_tags, end_tags);
		}

		private Gst.TagList InternalMergeTags (Gst.TagList start_tags, Gst.TagList end_tags)
		{
			MergeTagsNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("merge_tags"));
				unmanaged = (MergeTagsNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(MergeTagsNativeDelegate));
			}
			if (unmanaged == null) return null;

			IntPtr __result = unmanaged (this.Handle, start_tags == null ? IntPtr.Zero : start_tags.Handle, end_tags == null ? IntPtr.Zero : end_tags.Handle);
			return __result == IntPtr.Zero ? null : (Gst.TagList) GLib.Opaque.GetOpaque (__result, typeof (Gst.TagList), true);
		}


		// 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("min_start_size"
							, Gst.Element.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(uint)) // min_start_size
							, null
							, "min_end_size"
							, (long) Marshal.OffsetOf(typeof(GstTagDemux_min_start_sizeAlign), "min_start_size")
							, 0
							),
						new GLib.AbiField("min_end_size"
							, -1
							, (uint) Marshal.SizeOf(typeof(uint)) // min_end_size
							, "min_start_size"
							, "identify_tag"
							, (long) Marshal.OffsetOf(typeof(GstTagDemux_min_end_sizeAlign), "min_end_size")
							, 0
							),
						new GLib.AbiField("identify_tag"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // identify_tag
							, "min_end_size"
							, "parse_tag"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("parse_tag"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // parse_tag
							, "identify_tag"
							, "merge_tags"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("merge_tags"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // merge_tags
							, "parse_tag"
							, "reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // reserved
							, "merge_tags"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}

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

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


		// End of the ABI representation.

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

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


		static TagDemux ()
		{
			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("priv"
							, Gst.Element.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, null
							, "reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 4 // reserved
							, "priv"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _abi_info;
			}
		}


		// End of the ABI representation.

#endregion
	}
}
