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

namespace Gst.Rtp {

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

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

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

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

		[GLib.Property ("max-reorder")]
		public int MaxReorder {
			get {
				GLib.Value val = GetProperty ("max-reorder");
				int ret = (int) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("max-reorder", val);
				val.Dispose ();
			}
		}

		[GLib.Property ("source-info")]
		public bool SourceInfo {
			get {
				GLib.Value val = GetProperty ("source-info");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				GLib.Value val = new GLib.Value(value);
				SetProperty("source-info", val);
				val.Dispose ();
			}
		}

		[GLib.Property ("stats")]
		public Gst.Structure Stats {
			get {
				GLib.Value val = GetProperty ("stats");
				Gst.Structure ret = (Gst.Structure) val;
				val.Dispose ();
				return ret;
			}
		}

		public Gst.Pad Sinkpad {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("sinkpad"));
					return GLib.Object.GetObject((*raw_ptr)) as Gst.Pad;
				}
			}
		}

		public Gst.Pad Srcpad {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("srcpad"));
					return GLib.Object.GetObject((*raw_ptr)) as Gst.Pad;
				}
			}
		}

		public uint ClockRate {
			get {
				unsafe {
					uint* raw_ptr = (uint*)(((byte*)Handle) + abi_info.GetFieldOffset("clock_rate"));
					return (*raw_ptr);
				}
			}
		}

		public Gst.Segment Segment {
			get {
				unsafe {
					IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + abi_info.GetFieldOffset("segment"));
					return Gst.Segment.New ((*raw_ptr));
				}
			}
		}

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

		static SetCapsNativeDelegate SetCaps_cb_delegate;
		static SetCapsNativeDelegate SetCapsVMCallback {
			get {
				if (SetCaps_cb_delegate == null)
					SetCaps_cb_delegate = new SetCapsNativeDelegate (SetCaps_cb);
				return SetCaps_cb_delegate;
			}
		}

		static void OverrideSetCaps (GLib.GType gtype)
		{
			OverrideSetCaps (gtype, SetCapsVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetCapsNativeDelegate (IntPtr inst, IntPtr caps);

		static bool SetCaps_cb (IntPtr inst, IntPtr caps)
		{
			try {
				RTPBaseDepayload __obj = GLib.Object.GetObject (inst, false) as RTPBaseDepayload;
				bool __result;
				__result = __obj.OnSetCaps (caps == IntPtr.Zero ? null : (Gst.Caps) GLib.Opaque.GetOpaque (caps, typeof (Gst.Caps), false));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Rtp.RTPBaseDepayload), ConnectionMethod="OverrideSetCaps")]
		protected virtual bool OnSetCaps (Gst.Caps caps)
		{
			return InternalSetCaps (caps);
		}

		private bool InternalSetCaps (Gst.Caps caps)
		{
			SetCapsNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("set_caps"));
				unmanaged = (SetCapsNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(SetCapsNativeDelegate));
			}
			if (unmanaged == null) return false;

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

		static ProcessNativeDelegate Process_cb_delegate;
		static ProcessNativeDelegate ProcessVMCallback {
			get {
				if (Process_cb_delegate == null)
					Process_cb_delegate = new ProcessNativeDelegate (Process_cb);
				return Process_cb_delegate;
			}
		}

		static void OverrideProcess (GLib.GType gtype)
		{
			OverrideProcess (gtype, ProcessVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr ProcessNativeDelegate (IntPtr inst, IntPtr in_param);

		static IntPtr Process_cb (IntPtr inst, IntPtr in_param)
		{
			try {
				RTPBaseDepayload __obj = GLib.Object.GetObject (inst, false) as RTPBaseDepayload;
				Gst.Buffer __result;
				__result = __obj.OnProcess (in_param == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (in_param, typeof (Gst.Buffer), 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.Rtp.RTPBaseDepayload), ConnectionMethod="OverrideProcess")]
		protected virtual Gst.Buffer OnProcess (Gst.Buffer in_param)
		{
			return InternalProcess (in_param);
		}

		private Gst.Buffer InternalProcess (Gst.Buffer in_param)
		{
			ProcessNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("process"));
				unmanaged = (ProcessNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(ProcessNativeDelegate));
			}
			if (unmanaged == null) return null;

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

		static PacketLostNativeDelegate PacketLost_cb_delegate;
		static PacketLostNativeDelegate PacketLostVMCallback {
			get {
				if (PacketLost_cb_delegate == null)
					PacketLost_cb_delegate = new PacketLostNativeDelegate (PacketLost_cb);
				return PacketLost_cb_delegate;
			}
		}

		static void OverridePacketLost (GLib.GType gtype)
		{
			OverridePacketLost (gtype, PacketLostVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool PacketLostNativeDelegate (IntPtr inst, IntPtr evnt);

		static bool PacketLost_cb (IntPtr inst, IntPtr evnt)
		{
			try {
				RTPBaseDepayload __obj = GLib.Object.GetObject (inst, false) as RTPBaseDepayload;
				bool __result;
				__result = __obj.OnPacketLost (evnt == IntPtr.Zero ? null : (Gst.Event) GLib.Opaque.GetOpaque (evnt, typeof (Gst.Event), false));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Rtp.RTPBaseDepayload), ConnectionMethod="OverridePacketLost")]
		protected virtual bool OnPacketLost (Gst.Event evnt)
		{
			return InternalPacketLost (evnt);
		}

		private bool InternalPacketLost (Gst.Event evnt)
		{
			PacketLostNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("packet_lost"));
				unmanaged = (PacketLostNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(PacketLostNativeDelegate));
			}
			if (unmanaged == null) return false;

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

		static HandleEventNativeDelegate HandleEvent_cb_delegate;
		static HandleEventNativeDelegate HandleEventVMCallback {
			get {
				if (HandleEvent_cb_delegate == null)
					HandleEvent_cb_delegate = new HandleEventNativeDelegate (HandleEvent_cb);
				return HandleEvent_cb_delegate;
			}
		}

		static void OverrideHandleEvent (GLib.GType gtype)
		{
			OverrideHandleEvent (gtype, HandleEventVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool HandleEventNativeDelegate (IntPtr inst, IntPtr evnt);

		static bool HandleEvent_cb (IntPtr inst, IntPtr evnt)
		{
			try {
				RTPBaseDepayload __obj = GLib.Object.GetObject (inst, false) as RTPBaseDepayload;
				bool __result;
				__result = __obj.OnHandleEvent (evnt == IntPtr.Zero ? null : (Gst.Event) GLib.Opaque.GetOpaque (evnt, typeof (Gst.Event), false));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.Rtp.RTPBaseDepayload), ConnectionMethod="OverrideHandleEvent")]
		protected virtual bool OnHandleEvent (Gst.Event evnt)
		{
			return InternalHandleEvent (evnt);
		}

		private bool InternalHandleEvent (Gst.Event evnt)
		{
			HandleEventNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("handle_event"));
				unmanaged = (HandleEventNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(HandleEventNativeDelegate));
			}
			if (unmanaged == null) return false;

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

		static ProcessRtpPacketNativeDelegate ProcessRtpPacket_cb_delegate;
		static ProcessRtpPacketNativeDelegate ProcessRtpPacketVMCallback {
			get {
				if (ProcessRtpPacket_cb_delegate == null)
					ProcessRtpPacket_cb_delegate = new ProcessRtpPacketNativeDelegate (ProcessRtpPacket_cb);
				return ProcessRtpPacket_cb_delegate;
			}
		}

		static void OverrideProcessRtpPacket (GLib.GType gtype)
		{
			OverrideProcessRtpPacket (gtype, ProcessRtpPacketVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr ProcessRtpPacketNativeDelegate (IntPtr inst, IntPtr rtp_buffer);

		static IntPtr ProcessRtpPacket_cb (IntPtr inst, IntPtr rtp_buffer)
		{
			try {
				RTPBaseDepayload __obj = GLib.Object.GetObject (inst, false) as RTPBaseDepayload;
				Gst.Buffer __result;
				__result = __obj.OnProcessRtpPacket (Gst.Rtp.RTPBuffer.New (rtp_buffer));
				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.Rtp.RTPBaseDepayload), ConnectionMethod="OverrideProcessRtpPacket")]
		protected virtual Gst.Buffer OnProcessRtpPacket (Gst.Rtp.RTPBuffer rtp_buffer)
		{
			return InternalProcessRtpPacket (rtp_buffer);
		}

		private Gst.Buffer InternalProcessRtpPacket (Gst.Rtp.RTPBuffer rtp_buffer)
		{
			ProcessRtpPacketNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("process_rtp_packet"));
				unmanaged = (ProcessRtpPacketNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(ProcessRtpPacketNativeDelegate));
			}
			if (unmanaged == null) return null;

			IntPtr native_rtp_buffer = GLib.Marshaller.StructureToPtrAlloc (rtp_buffer);
			IntPtr __result = unmanaged (this.Handle, native_rtp_buffer);
			Marshal.FreeHGlobal (native_rtp_buffer);
			return __result == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (__result, typeof (Gst.Buffer), 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("set_caps"
							, Gst.Element.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // set_caps
							, null
							, "process"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("process"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // process
							, "set_caps"
							, "packet_lost"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("packet_lost"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // packet_lost
							, "process"
							, "handle_event"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("handle_event"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // handle_event
							, "packet_lost"
							, "process_rtp_packet"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("process_rtp_packet"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // process_rtp_packet
							, "handle_event"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 3 // _gst_reserved
							, "process_rtp_packet"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

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

		public bool IsSourceInfoEnabled { 
			get {
				bool raw_ret = gst_rtp_base_depayload_is_source_info_enabled(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

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

		public Gst.FlowReturn Push(Gst.Buffer out_buf) {
			int raw_ret = gst_rtp_base_depayload_push(Handle, out_buf == null ? IntPtr.Zero : out_buf.Handle);
			Gst.FlowReturn ret = (Gst.FlowReturn) raw_ret;
			return ret;
		}

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

		public Gst.FlowReturn PushList(Gst.BufferList out_list) {
			int raw_ret = gst_rtp_base_depayload_push_list(Handle, out_list == null ? IntPtr.Zero : out_list.Handle);
			Gst.FlowReturn ret = (Gst.FlowReturn) raw_ret;
			return ret;
		}

		[DllImport("gstrtp-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtp_base_depayload_set_source_info_enabled(IntPtr raw, bool enable);

		public bool SourceInfoEnabled { 
			set {
				gst_rtp_base_depayload_set_source_info_enabled(Handle, value);
			}
		}


		static RTPBaseDepayload ()
		{
			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("sinkpad"
							, Gst.Element.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // sinkpad
							, null
							, "srcpad"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("srcpad"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // srcpad
							, "sinkpad"
							, "clock_rate"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("clock_rate"
							, -1
							, (uint) Marshal.SizeOf(typeof(uint)) // clock_rate
							, "srcpad"
							, "segment"
							, (long) Marshal.OffsetOf(typeof(GstRTPBaseDepayload_clock_rateAlign), "clock_rate")
							, 0
							),
						new GLib.AbiField("segment"
							, -1
							, (uint) Marshal.SizeOf(typeof(Gst.Segment)) // segment
							, "clock_rate"
							, "need_newsegment"
							, (long) Marshal.OffsetOf(typeof(GstRTPBaseDepayload_segmentAlign), "segment")
							, 0
							),
						new GLib.AbiField("need_newsegment"
							, -1
							, (uint) Marshal.SizeOf(typeof(bool)) // need_newsegment
							, "segment"
							, "priv"
							, (long) Marshal.OffsetOf(typeof(GstRTPBaseDepayload_need_newsegmentAlign), "need_newsegment")
							, 0
							),
						new GLib.AbiField("priv"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, "need_newsegment"
							, "_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 GstRTPBaseDepayload_clock_rateAlign
		{
			sbyte f1;
			private uint clock_rate;
		}

		[StructLayout(LayoutKind.Sequential)]
		public struct GstRTPBaseDepayload_segmentAlign
		{
			sbyte f1;
			private Gst.Segment segment;
		}

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


		// End of the ABI representation.

#endregion
	}
}