// 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
	[StructLayout(LayoutKind.Sequential)]
	public partial struct Meta : IEquatable<Meta> {

		public Gst.MetaFlags Flags;
		private IntPtr _info;

		public Gst.MetaInfo info {
			get { return Gst.MetaInfo.New (_info); }
		}

		public static Gst.Meta Zero = new Gst.Meta ();

		public static Gst.Meta New(IntPtr raw) {
			if (raw == IntPtr.Zero)
				return Gst.Meta.Zero;
			return (Gst.Meta) Marshal.PtrToStructure (raw, typeof (Gst.Meta));
		}

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

		public int CompareSeqnum(Gst.Meta meta2) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_meta2 = GLib.Marshaller.StructureToPtrAlloc (meta2);
			int raw_ret = gst_meta_compare_seqnum(this_as_native, native_meta2);
			int ret = raw_ret;
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			Marshal.FreeHGlobal (native_meta2);
			return ret;
		}

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

		public ulong Seqnum { 
			get {
				IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
				System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
				ulong raw_ret = gst_meta_get_seqnum(this_as_native);
				ulong ret = raw_ret;
				ReadNative (this_as_native, ref this);
				System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
				return ret;
			}
		}

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

		public bool Serialize(Gst.ByteArrayInterface data) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			IntPtr native_data = GLib.Marshaller.StructureToPtrAlloc (data);
			bool raw_ret = gst_meta_serialize(this_as_native, native_data);
			bool ret = raw_ret;
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			Marshal.FreeHGlobal (native_data);
			return ret;
		}

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

		public bool SerializeSimple(IntPtr[] data) {
			IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
			System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
			bool raw_ret = gst_meta_serialize_simple(this_as_native, data);
			bool ret = raw_ret;
			ReadNative (this_as_native, ref this);
			System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_meta_api_type_aggregate_params(IntPtr api, IntPtr aggregated_params, IntPtr params0, IntPtr params1);

		public static bool ApiTypeAggregateParams(GLib.GType api, Gst.Structure aggregated_params, Gst.Structure params0, Gst.Structure params1) {
			bool raw_ret = gst_meta_api_type_aggregate_params(api.Val, aggregated_params == null ? IntPtr.Zero : aggregated_params.Handle, params0 == null ? IntPtr.Zero : params0.Handle, params1 == null ? IntPtr.Zero : params1.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_meta_api_type_has_tag(IntPtr api, uint tag);

		public static bool ApiTypeHasTag(GLib.GType api, uint tag) {
			bool raw_ret = gst_meta_api_type_has_tag(api.Val, tag);
			bool ret = raw_ret;
			return ret;
		}

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

		public static GLib.GType ApiTypeRegister(string api, string[] tags) {
			IntPtr native_api = GLib.Marshaller.StringToPtrGStrdup (api);
			IntPtr native_tags = GLib.Marshaller.StringArrayToStrvPtr(tags, true);
			IntPtr raw_ret = gst_meta_api_type_register(native_api, native_tags);
			GLib.GType ret = new GLib.GType(raw_ret);
			GLib.Marshaller.Free (native_api);
			GLib.Marshaller.StrFreeV (native_tags);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_meta_api_type_set_params_aggregator(IntPtr api, GstSharp.AllocationMetaParamsAggregatorNative aggregator);

		public static void ApiTypeSetParamsAggregator(GLib.GType api, Gst.AllocationMetaParamsAggregator aggregator) {
			GstSharp.AllocationMetaParamsAggregatorWrapper aggregator_wrapper = new GstSharp.AllocationMetaParamsAggregatorWrapper (aggregator);
			gst_meta_api_type_set_params_aggregator(api.Val, aggregator_wrapper.NativeDelegate);
		}

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

		public static bool ApiTypeTagsContainOnly(GLib.GType api, string[] valid_tags) {
			IntPtr native_valid_tags = GLib.Marshaller.StringArrayToStrvPtr(valid_tags, true);
			bool raw_ret = gst_meta_api_type_tags_contain_only(api.Val, native_valid_tags);
			bool ret = raw_ret;
			GLib.Marshaller.StrFreeV (native_valid_tags);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_meta_deserialize(IntPtr buffer, byte data, UIntPtr size, out uint consumed);

		public static Gst.Meta Deserialize(Gst.Buffer buffer, byte data, ulong size, out uint consumed) {
			IntPtr raw_ret = gst_meta_deserialize(buffer == null ? IntPtr.Zero : buffer.Handle, data, new UIntPtr (size), out consumed);
			Gst.Meta ret = Gst.Meta.New (raw_ret);
			return ret;
		}

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

		public static Gst.MetaInfo GetInfo(string impl) {
			IntPtr native_impl = GLib.Marshaller.StringToPtrGStrdup (impl);
			IntPtr raw_ret = gst_meta_get_info(native_impl);
			Gst.MetaInfo ret = Gst.MetaInfo.New (raw_ret);
			GLib.Marshaller.Free (native_impl);
			return ret;
		}

		[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_meta_register_custom(IntPtr name, IntPtr tags, GstSharp.CustomMetaTransformFunctionNative transform_func, IntPtr user_data, GLib.DestroyNotify destroy_data);

		public static Gst.MetaInfo RegisterCustom(string name, string[] tags, Gst.CustomMetaTransformFunction transform_func) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			IntPtr native_tags = GLib.Marshaller.StringArrayToStrvPtr(tags, true);
			GstSharp.CustomMetaTransformFunctionWrapper transform_func_wrapper = new GstSharp.CustomMetaTransformFunctionWrapper (transform_func);
			IntPtr user_data;
			GLib.DestroyNotify destroy_data;
			if (transform_func == null) {
				user_data = IntPtr.Zero;
				destroy_data = null;
			} else {
				user_data = (IntPtr) GCHandle.Alloc (transform_func_wrapper);
				destroy_data = GLib.DestroyHelper.NotifyHandler;
			}
			IntPtr raw_ret = gst_meta_register_custom(native_name, native_tags, transform_func_wrapper.NativeDelegate, user_data, destroy_data);
			Gst.MetaInfo ret = Gst.MetaInfo.New (raw_ret);
			GLib.Marshaller.Free (native_name);
			GLib.Marshaller.StrFreeV (native_tags);
			return ret;
		}

		public static Gst.MetaInfo RegisterCustom(string name, string[] tags) {
			return RegisterCustom (name, tags, null);
		}

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

		public static Gst.MetaInfo RegisterCustomSimple(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			IntPtr raw_ret = gst_meta_register_custom_simple(native_name);
			Gst.MetaInfo ret = Gst.MetaInfo.New (raw_ret);
			GLib.Marshaller.Free (native_name);
			return ret;
		}

		static void ReadNative (IntPtr native, ref Gst.Meta target)
		{
			target = New (native);
		}

		public bool Equals (Meta other)
		{
			return true && Flags.Equals (other.Flags) && info.Equals (other.info);
		}

		public override bool Equals (object other)
		{
			return other is Meta && Equals ((Meta) other);
		}

		public override int GetHashCode ()
		{
			return this.GetType ().FullName.GetHashCode () ^ Flags.GetHashCode () ^ info.GetHashCode ();
		}

		private static GLib.GType GType {
			get { return GLib.GType.Pointer; }
		}
#endregion
	}
}
