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

namespace Gst.App {

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

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

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

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

		[Gst.GLib.Property ("max-latency")]
		public long MaxLatency {
			get {
				Gst.GLib.Value val = GetProperty ("max-latency");
				long ret = (long) val;
				val.Dispose ();
				return ret;
			}
			set {
				Gst.GLib.Value val = new Gst.GLib.Value(value);
				SetProperty("max-latency", val);
				val.Dispose ();
			}
		}

		[Gst.GLib.Property ("block")]
		public bool Block {
			get {
				Gst.GLib.Value val = GetProperty ("block");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				Gst.GLib.Value val = new Gst.GLib.Value(value);
				SetProperty("block", val);
				val.Dispose ();
			}
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern ulong gst_app_src_get_max_bytes(IntPtr raw);

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_max_bytes(IntPtr raw, ulong max);

		[Gst.GLib.Property ("max-bytes")]
		public ulong MaxBytes {
			get  {
				ulong raw_ret = gst_app_src_get_max_bytes(Handle);
				ulong ret = raw_ret;
				return ret;
			}
			set  {
				gst_app_src_set_max_bytes(Handle, value);
			}
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern IntPtr gst_app_src_get_caps(IntPtr raw);

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_caps(IntPtr raw, IntPtr caps);

		[Gst.GLib.Property ("caps")]
		public Gst.Caps Caps {
			get  {
				IntPtr raw_ret = gst_app_src_get_caps(Handle);
				Gst.Caps ret = raw_ret == IntPtr.Zero ? null : (Gst.Caps) Gst.GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Caps), false);
				return ret;
			}
			set  {
				gst_app_src_set_caps(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern int gst_app_src_get_stream_type(IntPtr raw);

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_stream_type(IntPtr raw, int type);

		[Gst.GLib.Property ("stream-type")]
		public Gst.App.AppStreamType StreamType {
			get  {
				int raw_ret = gst_app_src_get_stream_type(Handle);
				Gst.App.AppStreamType ret = (Gst.App.AppStreamType) raw_ret;
				return ret;
			}
			set  {
				gst_app_src_set_stream_type(Handle, (int) value);
			}
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern long gst_app_src_get_size(IntPtr raw);

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_size(IntPtr raw, long size);

		[Gst.GLib.Property ("size")]
		public long Size {
			get  {
				long raw_ret = gst_app_src_get_size(Handle);
				long ret = raw_ret;
				return ret;
			}
			set  {
				gst_app_src_set_size(Handle, value);
			}
		}

		[Gst.GLib.Property ("format")]
		public Gst.Format Format {
			get {
				Gst.GLib.Value val = GetProperty ("format");
				Gst.Format ret = (Gst.Format) (Enum) val;
				val.Dispose ();
				return ret;
			}
			set {
				Gst.GLib.Value val = new Gst.GLib.Value((Enum) value);
				SetProperty("format", val);
				val.Dispose ();
			}
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern bool gst_app_src_get_emit_signals(IntPtr raw);

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_emit_signals(IntPtr raw, bool emit);

		[Gst.GLib.Property ("emit-signals")]
		public bool EmitSignals {
			get  {
				bool raw_ret = gst_app_src_get_emit_signals(Handle);
				bool ret = raw_ret;
				return ret;
			}
			set  {
				gst_app_src_set_emit_signals(Handle, value);
			}
		}

		[Gst.GLib.Property ("is-live")]
		public bool IsLive {
			get {
				Gst.GLib.Value val = GetProperty ("is-live");
				bool ret = (bool) val;
				val.Dispose ();
				return ret;
			}
			set {
				Gst.GLib.Value val = new Gst.GLib.Value(value);
				SetProperty("is-live", val);
				val.Dispose ();
			}
		}

		[Gst.GLib.Property ("min-latency")]
		public long MinLatency {
			get {
				Gst.GLib.Value val = GetProperty ("min-latency");
				long ret = (long) val;
				val.Dispose ();
				return ret;
			}
			set {
				Gst.GLib.Value val = new Gst.GLib.Value(value);
				SetProperty("min-latency", val);
				val.Dispose ();
			}
		}

		[Gst.GLib.Signal("seek-data")]
		public event Gst.App.SeekDataHandler SeekData {
			add {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "seek-data", typeof (Gst.App.SeekDataArgs));
				sig.AddDelegate (value);
			}
			remove {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "seek-data", typeof (Gst.App.SeekDataArgs));
				sig.RemoveDelegate (value);
			}
		}

		[Gst.GLib.Signal("push-buffer")]
		public event Gst.App.PushBufferHandler PushBuffer {
			add {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "push-buffer", typeof (Gst.App.PushBufferArgs));
				sig.AddDelegate (value);
			}
			remove {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "push-buffer", typeof (Gst.App.PushBufferArgs));
				sig.RemoveDelegate (value);
			}
		}

		[Gst.GLib.Signal("enough-data")]
		public event System.EventHandler EnoughData {
			add {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "enough-data");
				sig.AddDelegate (value);
			}
			remove {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "enough-data");
				sig.RemoveDelegate (value);
			}
		}

		[Gst.GLib.Signal("need-data")]
		public event Gst.App.NeedDataHandler NeedData {
			add {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "need-data", typeof (Gst.App.NeedDataArgs));
				sig.AddDelegate (value);
			}
			remove {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "need-data", typeof (Gst.App.NeedDataArgs));
				sig.RemoveDelegate (value);
			}
		}

		[Gst.GLib.Signal("end-of-stream")]
		public event Gst.App.EndOfStreamHandler EndOfStream {
			add {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "end-of-stream", typeof (Gst.App.EndOfStreamArgs));
				sig.AddDelegate (value);
			}
			remove {
				Gst.GLib.Signal sig = Gst.GLib.Signal.Lookup (this, "end-of-stream", typeof (Gst.App.EndOfStreamArgs));
				sig.RemoveDelegate (value);
			}
		}

		static NeedDataNativeDelegate NeedData_cb_delegate;
		static NeedDataNativeDelegate NeedDataVMCallback {
			get {
				if (NeedData_cb_delegate == null)
					NeedData_cb_delegate = new NeedDataNativeDelegate (NeedData_cb);
				return NeedData_cb_delegate;
			}
		}

		static void OverrideNeedData (Gst.GLib.GType gtype)
		{
			OverrideNeedData (gtype, NeedDataVMCallback);
		}

		static void OverrideNeedData (Gst.GLib.GType gtype, NeedDataNativeDelegate callback)
		{
			GstAppSrcClass class_iface = GetClassStruct (gtype, false);
			class_iface.NeedData = callback;
			OverrideClassStruct (gtype, class_iface);
		}

		[UnmanagedFunctionPointer (GLib.Global.CallingConvention)]
		delegate void NeedDataNativeDelegate (IntPtr inst, uint length);

		static void NeedData_cb (IntPtr inst, uint length)
		{
			try {
				AppSrc __obj = Gst.GLib.Object.GetObject (inst, false) as AppSrc;
				__obj.OnNeedData (length);
			} catch (Exception e) {
				Gst.GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[Gst.GLib.DefaultSignalHandler(Type=typeof(Gst.App.AppSrc), ConnectionMethod="OverrideNeedData")]
		protected virtual void OnNeedData (uint length)
		{
			InternalNeedData (length);
		}

		private void InternalNeedData (uint length)
		{
			NeedDataNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).NeedData;
			if (unmanaged == null) return;

			unmanaged (this.Handle, length);
		}

		static EnoughDataNativeDelegate EnoughData_cb_delegate;
		static EnoughDataNativeDelegate EnoughDataVMCallback {
			get {
				if (EnoughData_cb_delegate == null)
					EnoughData_cb_delegate = new EnoughDataNativeDelegate (EnoughData_cb);
				return EnoughData_cb_delegate;
			}
		}

		static void OverrideEnoughData (Gst.GLib.GType gtype)
		{
			OverrideEnoughData (gtype, EnoughDataVMCallback);
		}

		static void OverrideEnoughData (Gst.GLib.GType gtype, EnoughDataNativeDelegate callback)
		{
			GstAppSrcClass class_iface = GetClassStruct (gtype, false);
			class_iface.EnoughData = callback;
			OverrideClassStruct (gtype, class_iface);
		}

		[UnmanagedFunctionPointer (GLib.Global.CallingConvention)]
		delegate void EnoughDataNativeDelegate (IntPtr inst);

		static void EnoughData_cb (IntPtr inst)
		{
			try {
				AppSrc __obj = Gst.GLib.Object.GetObject (inst, false) as AppSrc;
				__obj.OnEnoughData ();
			} catch (Exception e) {
				Gst.GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[Gst.GLib.DefaultSignalHandler(Type=typeof(Gst.App.AppSrc), ConnectionMethod="OverrideEnoughData")]
		protected virtual void OnEnoughData ()
		{
			InternalEnoughData ();
		}

		private void InternalEnoughData ()
		{
			EnoughDataNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).EnoughData;
			if (unmanaged == null) return;

			unmanaged (this.Handle);
		}

		static SeekDataNativeDelegate SeekData_cb_delegate;
		static SeekDataNativeDelegate SeekDataVMCallback {
			get {
				if (SeekData_cb_delegate == null)
					SeekData_cb_delegate = new SeekDataNativeDelegate (SeekData_cb);
				return SeekData_cb_delegate;
			}
		}

		static void OverrideSeekData (Gst.GLib.GType gtype)
		{
			OverrideSeekData (gtype, SeekDataVMCallback);
		}

		static void OverrideSeekData (Gst.GLib.GType gtype, SeekDataNativeDelegate callback)
		{
			GstAppSrcClass class_iface = GetClassStruct (gtype, false);
			class_iface.SeekData = callback;
			OverrideClassStruct (gtype, class_iface);
		}

		[UnmanagedFunctionPointer (GLib.Global.CallingConvention)]
		delegate bool SeekDataNativeDelegate (IntPtr inst, ulong offset);

		static bool SeekData_cb (IntPtr inst, ulong offset)
		{
			try {
				AppSrc __obj = Gst.GLib.Object.GetObject (inst, false) as AppSrc;
				bool __result = __obj.OnSeekData (offset);
				return __result;
			} catch (Exception e) {
				Gst.GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[Gst.GLib.DefaultSignalHandler(Type=typeof(Gst.App.AppSrc), ConnectionMethod="OverrideSeekData")]
		protected virtual bool OnSeekData (ulong offset)
		{
			return InternalSeekData (offset);
		}

		private bool InternalSeekData (ulong offset)
		{
			SeekDataNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).SeekData;
			if (unmanaged == null) return false;

			bool __result = unmanaged (this.Handle, offset);
			return __result;
		}

		static PushBufferNativeDelegate PushBuffer_cb_delegate;
		static PushBufferNativeDelegate PushBufferVMCallback {
			get {
				if (PushBuffer_cb_delegate == null)
					PushBuffer_cb_delegate = new PushBufferNativeDelegate (PushBuffer_cb);
				return PushBuffer_cb_delegate;
			}
		}

		static void OverridePushBuffer (Gst.GLib.GType gtype)
		{
			OverridePushBuffer (gtype, PushBufferVMCallback);
		}

		static void OverridePushBuffer (Gst.GLib.GType gtype, PushBufferNativeDelegate callback)
		{
			GstAppSrcClass class_iface = GetClassStruct (gtype, false);
			class_iface.PushBuffer = callback;
			OverrideClassStruct (gtype, class_iface);
		}

		[UnmanagedFunctionPointer (GLib.Global.CallingConvention)]
		delegate int PushBufferNativeDelegate (IntPtr inst, IntPtr buffer);

		static int PushBuffer_cb (IntPtr inst, IntPtr buffer)
		{
			try {
				AppSrc __obj = Gst.GLib.Object.GetObject (inst, false) as AppSrc;
				Gst.FlowReturn __result = __obj.OnPushBuffer (Gst.GLib.Object.GetObject(buffer) as Gst.Buffer);
				return (int) __result;
			} catch (Exception e) {
				Gst.GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[Gst.GLib.DefaultSignalHandler(Type=typeof(Gst.App.AppSrc), ConnectionMethod="OverridePushBuffer")]
		protected virtual Gst.FlowReturn OnPushBuffer (Gst.Buffer buffer)
		{
			return InternalPushBuffer (buffer);
		}

		private Gst.FlowReturn InternalPushBuffer (Gst.Buffer buffer)
		{
			PushBufferNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).PushBuffer;
			if (unmanaged == null) return (Gst.FlowReturn) 0;

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

		static EndOfStreamNativeDelegate EndOfStream_cb_delegate;
		static EndOfStreamNativeDelegate EndOfStreamVMCallback {
			get {
				if (EndOfStream_cb_delegate == null)
					EndOfStream_cb_delegate = new EndOfStreamNativeDelegate (EndOfStream_cb);
				return EndOfStream_cb_delegate;
			}
		}

		static void OverrideEndOfStream (Gst.GLib.GType gtype)
		{
			OverrideEndOfStream (gtype, EndOfStreamVMCallback);
		}

		static void OverrideEndOfStream (Gst.GLib.GType gtype, EndOfStreamNativeDelegate callback)
		{
			GstAppSrcClass class_iface = GetClassStruct (gtype, false);
			class_iface.EndOfStream = callback;
			OverrideClassStruct (gtype, class_iface);
		}

		[UnmanagedFunctionPointer (GLib.Global.CallingConvention)]
		delegate int EndOfStreamNativeDelegate (IntPtr inst);

		static int EndOfStream_cb (IntPtr inst)
		{
			try {
				AppSrc __obj = Gst.GLib.Object.GetObject (inst, false) as AppSrc;
				Gst.FlowReturn __result = __obj.OnEndOfStream ();
				return (int) __result;
			} catch (Exception e) {
				Gst.GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[Gst.GLib.DefaultSignalHandler(Type=typeof(Gst.App.AppSrc), ConnectionMethod="OverrideEndOfStream")]
		protected virtual Gst.FlowReturn OnEndOfStream ()
		{
			return InternalEndOfStream ();
		}

		private Gst.FlowReturn InternalEndOfStream ()
		{
			EndOfStreamNativeDelegate unmanaged = GetClassStruct (this.LookupGType ().GetThresholdType (), true).EndOfStream;
			if (unmanaged == null) return (Gst.FlowReturn) 0;

			int __result = unmanaged (this.Handle);
			return (Gst.FlowReturn) __result;
		}

		[StructLayout (LayoutKind.Sequential)]
		struct GstAppSrcClass {
			public NeedDataNativeDelegate NeedData;
			public EnoughDataNativeDelegate EnoughData;
			public SeekDataNativeDelegate SeekData;
			public PushBufferNativeDelegate PushBuffer;
			public EndOfStreamNativeDelegate EndOfStream;
			[MarshalAs (UnmanagedType.ByValArray, SizeConst=0)]
			public IntPtr[] GstReserved;
		}

		static uint class_offset = ((Gst.GLib.GType) typeof (Gst.Base.BaseSrc)).GetClassSize ();
		static Hashtable class_structs;

		static GstAppSrcClass GetClassStruct (Gst.GLib.GType gtype, bool use_cache)
		{
			if (class_structs == null)
				class_structs = new Hashtable ();

			if (use_cache && class_structs.Contains (gtype))
				return (GstAppSrcClass) class_structs [gtype];
			else {
				IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
				GstAppSrcClass class_struct = (GstAppSrcClass) Marshal.PtrToStructure (class_ptr, typeof (GstAppSrcClass));
				if (use_cache)
					class_structs.Add (gtype, class_struct);
				return class_struct;
			}
		}

		static void OverrideClassStruct (Gst.GLib.GType gtype, GstAppSrcClass class_struct)
		{
			IntPtr class_ptr = new IntPtr (gtype.GetClassPtr ().ToInt64 () + class_offset);
			Marshal.StructureToPtr (class_struct, class_ptr, false);
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_latency(IntPtr raw, ulong min, ulong max);

		public void SetLatency(ulong min, ulong max) {
			gst_app_src_set_latency(Handle, min, max);
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern int gst_app_src_end_of_stream(IntPtr raw);

		public Gst.FlowReturn EndOfStream() {
			int raw_ret = gst_app_src_end_of_stream(Handle);
			Gst.FlowReturn ret = (Gst.FlowReturn) raw_ret;
			return ret;
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern int gst_app_src_push_buffer(IntPtr raw, IntPtr buffer);

		public Gst.FlowReturn PushBuffer(Gst.Buffer buffer) {
			int raw_ret = gst_app_src_push_buffer(Handle, buffer == null ? IntPtr.Zero : buffer.Handle);
			Gst.FlowReturn ret = (Gst.FlowReturn) raw_ret;
			return ret;
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_set_callbacks(IntPtr raw, IntPtr callbacks, IntPtr user_data, Gst.GLib.DestroyNotify notify);

		public void SetCallbacks(Gst.App.AppSrcCallbacks callbacks, IntPtr user_data, Gst.GLib.DestroyNotify notify) {
			IntPtr native_callbacks = Gst.GLib.Marshaller.StructureToPtrAlloc (callbacks);
			gst_app_src_set_callbacks(Handle, native_callbacks, user_data, notify);
			callbacks = Gst.App.AppSrcCallbacks.New (native_callbacks);
			Marshal.FreeHGlobal (native_callbacks);
		}

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern IntPtr gst_app_src_get_type();

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

		[DllImport("libgstapp-0.10.dll", CallingConvention = GLib.Global.CallingConvention)]
		static extern void gst_app_src_get_latency(IntPtr raw, out ulong min, out ulong max);

		public void GetLatency(out ulong min, out ulong max) {
			gst_app_src_get_latency(Handle, out min, out max);
		}


		static AppSrc ()
		{
			GtkSharp.GstreamerSharp.ObjectManager.Initialize ();
		}
#endregion
#region Customized extensions
#line 1 "AppSrc.custom"
[DllImport ("libgstreamer-0.10.dll") ]
static extern IntPtr gst_element_factory_make (IntPtr element, IntPtr name);

public AppSrc (string name) : base (IntPtr.Zero) {
  IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
  IntPtr native_element = Gst.GLib.Marshaller.StringToPtrGStrdup ("appsrc");
  Raw = gst_element_factory_make (native_element, native_name);
  Gst.GLib.Marshaller.Free (native_name);
  Gst.GLib.Marshaller.Free (native_element);
  if (Raw == IntPtr.Zero)
    throw new Exception ("Failed to instantiate element \"appsrc\"");
}

public AppSrc () : this ( (string) null) { }

#endregion
	}
}
