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

namespace Gst.RtspServer {

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

#region Autogenerated code
	public partial class RTSPServer : GLib.Object {

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

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

		public RTSPServer () : base (IntPtr.Zero)
		{
			if (GetType () != typeof (RTSPServer)) {
				CreateNativeObject (new string [0], new GLib.Value[0]);
				return;
			}
			Raw = gst_rtsp_server_new();
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_address(IntPtr raw, IntPtr address);

		[GLib.Property ("address")]
		public string Address {
			get  {
				IntPtr raw_ret = gst_rtsp_server_get_address(Handle);
				string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gst_rtsp_server_set_address(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_backlog(IntPtr raw, int backlog);

		[GLib.Property ("backlog")]
		public int Backlog {
			get  {
				int raw_ret = gst_rtsp_server_get_backlog(Handle);
				int ret = raw_ret;
				return ret;
			}
			set  {
				gst_rtsp_server_set_backlog(Handle, value);
			}
		}

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

		[GLib.Property ("bound-port")]
		public int BoundPort {
			get  {
				int raw_ret = gst_rtsp_server_get_bound_port(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern uint gst_rtsp_server_get_content_length_limit(IntPtr raw);

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_content_length_limit(IntPtr raw, uint limit);

		[GLib.Property ("content-length-limit")]
		public uint ContentLengthLimit {
			get  {
				uint raw_ret = gst_rtsp_server_get_content_length_limit(Handle);
				uint ret = raw_ret;
				return ret;
			}
			set  {
				gst_rtsp_server_set_content_length_limit(Handle, value);
			}
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_mount_points(IntPtr raw, IntPtr mounts);

		[GLib.Property ("mount-points")]
		public Gst.RtspServer.RTSPMountPoints MountPoints {
			get  {
				IntPtr raw_ret = gst_rtsp_server_get_mount_points(Handle);
				Gst.RtspServer.RTSPMountPoints ret = GLib.Object.GetObject(raw_ret, true) as Gst.RtspServer.RTSPMountPoints;
				return ret;
			}
			set  {
				gst_rtsp_server_set_mount_points(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_service(IntPtr raw, IntPtr service);

		[GLib.Property ("service")]
		public string Service {
			get  {
				IntPtr raw_ret = gst_rtsp_server_get_service(Handle);
				string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
				return ret;
			}
			set  {
				IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
				gst_rtsp_server_set_service(Handle, native_value);
				GLib.Marshaller.Free (native_value);
			}
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_session_pool(IntPtr raw, IntPtr pool);

		[GLib.Property ("session-pool")]
		public Gst.RtspServer.RTSPSessionPool SessionPool {
			get  {
				IntPtr raw_ret = gst_rtsp_server_get_session_pool(Handle);
				Gst.RtspServer.RTSPSessionPool ret = GLib.Object.GetObject(raw_ret, true) as Gst.RtspServer.RTSPSessionPool;
				return ret;
			}
			set  {
				gst_rtsp_server_set_session_pool(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[GLib.Signal("client-connected")]
		public event Gst.RtspServer.ClientConnectedHandler ClientConnected {
			add {
				this.AddSignalHandler ("client-connected", value, typeof (Gst.RtspServer.ClientConnectedArgs));
			}
			remove {
				this.RemoveSignalHandler ("client-connected", value);
			}
		}

		static ClientConnectedNativeDelegate ClientConnected_cb_delegate;
		static ClientConnectedNativeDelegate ClientConnectedVMCallback {
			get {
				if (ClientConnected_cb_delegate == null)
					ClientConnected_cb_delegate = new ClientConnectedNativeDelegate (ClientConnected_cb);
				return ClientConnected_cb_delegate;
			}
		}

		static void OverrideClientConnected (GLib.GType gtype)
		{
			OverrideClientConnected (gtype, ClientConnectedVMCallback);
		}

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void ClientConnectedNativeDelegate (IntPtr inst, IntPtr _object);

		static void ClientConnected_cb (IntPtr inst, IntPtr _object)
		{
			try {
				RTSPServer __obj = GLib.Object.GetObject (inst, false) as RTSPServer;
				__obj.OnClientConnected (GLib.Object.GetObject(_object) as Gst.RtspServer.RTSPClient);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[GLib.DefaultSignalHandler(Type=typeof(Gst.RtspServer.RTSPServer), ConnectionMethod="OverrideClientConnected")]
		protected virtual void OnClientConnected (Gst.RtspServer.RTSPClient _object)
		{
			InternalClientConnected (_object);
		}

		private void InternalClientConnected (Gst.RtspServer.RTSPClient _object)
		{
			ClientConnectedNativeDelegate unmanaged = null;
			unsafe {
				IntPtr* raw_ptr = (IntPtr*)(((long) this.LookupGType().GetThresholdType().GetClassPtr()) + (long) class_abi.GetFieldOffset("client_connected"));
				unmanaged = (ClientConnectedNativeDelegate) Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(ClientConnectedNativeDelegate));
			}
			if (unmanaged == null) return;

			unmanaged (this.Handle, _object == null ? IntPtr.Zero : _object.Handle);
		}


		// 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("create_client"
							, GLib.Object.class_abi.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // create_client
							, null
							, "client_connected"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("client_connected"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // client_connected
							, "create_client"
							, "_gst_reserved"
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
						new GLib.AbiField("_gst_reserved"
							, -1
							, (uint) Marshal.SizeOf(typeof(IntPtr)) * 20 // _gst_reserved
							, "client_connected"
							, null
							, (uint) Marshal.SizeOf(typeof(IntPtr))
							, 0
							),
					});

				return _class_abi;
			}
		}


		// End of the ABI representation.

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

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_rtsp_server_io_func(IntPtr socket, int condition, IntPtr server);

		public static bool IoFunc(GLib.Socket socket, GLib.IOCondition condition, Gst.RtspServer.RTSPServer server) {
			bool raw_ret = gst_rtsp_server_io_func(socket == null ? IntPtr.Zero : socket.Handle, (int) condition, server == null ? IntPtr.Zero : server.Handle);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern uint gst_rtsp_server_attach(IntPtr raw, IntPtr context);

		public uint Attach(GLib.MainContext context) {
			uint raw_ret = gst_rtsp_server_attach(Handle, context == null ? IntPtr.Zero : context.Handle);
			uint ret = raw_ret;
			return ret;
		}

		public uint Attach() {
			return Attach (null);
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gst_rtsp_server_client_filter(IntPtr raw, Gst.RtspServerSharp.RTSPServerClientFilterFuncNative func, IntPtr user_data);

		public Gst.RtspServer.RTSPClient[] ClientFilter(Gst.RtspServer.RTSPServerClientFilterFunc func) {
			Gst.RtspServerSharp.RTSPServerClientFilterFuncWrapper func_wrapper = new Gst.RtspServerSharp.RTSPServerClientFilterFuncWrapper (func);
			IntPtr raw_ret = gst_rtsp_server_client_filter(Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
			Gst.RtspServer.RTSPClient[] ret = (Gst.RtspServer.RTSPClient[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.List), true, true, typeof(Gst.RtspServer.RTSPClient));
			return ret;
		}

		public Gst.RtspServer.RTSPClient[] ClientFilter() {
			return ClientFilter (null);
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe IntPtr gst_rtsp_server_create_socket(IntPtr raw, IntPtr cancellable, out IntPtr error);

		public unsafe GLib.Socket CreateSocket(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = gst_rtsp_server_create_socket(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.Socket ret = raw_ret == IntPtr.Zero ? null : (GLib.Socket) GLib.Opaque.GetOpaque (raw_ret, typeof (GLib.Socket), true);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		public GLib.Socket CreateSocket() {
			return CreateSocket (null);
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern unsafe IntPtr gst_rtsp_server_create_source(IntPtr raw, IntPtr cancellable, out IntPtr error);

		public unsafe GLib.Source CreateSource(GLib.Cancellable cancellable) {
			IntPtr error = IntPtr.Zero;
			IntPtr raw_ret = gst_rtsp_server_create_source(Handle, cancellable == null ? IntPtr.Zero : cancellable.Handle, out error);
			GLib.Source ret = new GLib.Source(raw_ret);
			if (error != IntPtr.Zero) throw new GLib.GException (error);
			return ret;
		}

		public GLib.Source CreateSource() {
			return CreateSource (null);
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_auth(IntPtr raw, IntPtr auth);

		public Gst.RtspServer.RTSPAuth Auth { 
			get {
				IntPtr raw_ret = gst_rtsp_server_get_auth(Handle);
				Gst.RtspServer.RTSPAuth ret = GLib.Object.GetObject(raw_ret, true) as Gst.RtspServer.RTSPAuth;
				return ret;
			}
			set {
				gst_rtsp_server_set_auth(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

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

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gst_rtsp_server_set_thread_pool(IntPtr raw, IntPtr pool);

		public Gst.RtspServer.RTSPThreadPool ThreadPool { 
			get {
				IntPtr raw_ret = gst_rtsp_server_get_thread_pool(Handle);
				Gst.RtspServer.RTSPThreadPool ret = GLib.Object.GetObject(raw_ret, true) as Gst.RtspServer.RTSPThreadPool;
				return ret;
			}
			set {
				gst_rtsp_server_set_thread_pool(Handle, value == null ? IntPtr.Zero : value.Handle);
			}
		}

		[DllImport("gstrtspserver-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gst_rtsp_server_transfer_connection(IntPtr raw, IntPtr socket, IntPtr ip, int port, IntPtr initial_buffer);

		public bool TransferConnection(GLib.Socket socket, string ip, int port, string initial_buffer) {
			socket.Owned = false;
			IntPtr native_ip = GLib.Marshaller.StringToPtrGStrdup (ip);
			IntPtr native_initial_buffer = GLib.Marshaller.StringToPtrGStrdup (initial_buffer);
			bool raw_ret = gst_rtsp_server_transfer_connection(Handle, socket == null ? IntPtr.Zero : socket.Handle, native_ip, port, native_initial_buffer);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_ip);
			GLib.Marshaller.Free (native_initial_buffer);
			return ret;
		}

		public bool TransferConnection(GLib.Socket socket, string ip, int port) {
			return TransferConnection (socket, ip, port, null);
		}


		static RTSPServer ()
		{
			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"
							, GLib.Object.abi_info.Fields
							, (uint) Marshal.SizeOf(typeof(IntPtr)) // priv
							, null
							, "_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;
			}
		}


		// End of the ABI representation.

#endregion
	}
}