/**
 * Copyright (c) 2011, The University of Southampton and the individual contributors.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 *   * 	Redistributions of source code must retain the above copyright notice,
 * 	this list of conditions and the following disclaimer.
 *
 *   *	Redistributions in binary form must reproduce the above copyright notice,
 * 	this list of conditions and the following disclaimer in the documentation
 * 	and/or other materials provided with the distribution.
 *
 *   *	Neither the name of the University of Southampton nor the names of its
 * 	contributors may be used to endorse or promote products derived from this
 * 	software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.openimaj.hardware.kinect.freenect;

import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Iterator;

import java.util.Collections;
import java.util.Iterator;
import org.bridj.BridJ;
import org.bridj.CRuntime;
import org.bridj.Callback;
import org.bridj.FlagSet;
import org.bridj.ValuedEnum;
import org.bridj.Platform;
import org.bridj.Pointer;
import org.bridj.ann.Library;
import org.bridj.ann.Runtime;
/**
 * Wrapper for library <b>freenect</b><br>
 * This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
 * a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
 * For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
 */
@Library("freenect-combined") 
@Runtime(CRuntime.class) 
@SuppressWarnings("all")
public class libfreenectLibrary {
	private static ByteBuffer videoBuffer;
	private static ByteBuffer depthBuffer;
	static {
		Platform.addEmbeddedLibraryResourceRoot("org/openimaj/hardware/kinect/nativelib/");
		BridJ.register();
	}
	public enum freenect_device_flags implements ValuedEnum<freenect_device_flags > {
		FREENECT_DEVICE_MOTOR(0x01),
		FREENECT_DEVICE_CAMERA(0x02),
		FREENECT_DEVICE_AUDIO(0x04);
		freenect_device_flags(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_device_flags > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_device_flags > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_resolution implements ValuedEnum<freenect_resolution > {
		FREENECT_RESOLUTION_LOW(0),
		FREENECT_RESOLUTION_MEDIUM(1),
		FREENECT_RESOLUTION_HIGH(2),
		FREENECT_RESOLUTION_DUMMY(2147483647);
		freenect_resolution(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_resolution > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_resolution > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_video_format implements ValuedEnum<freenect_video_format > {
		FREENECT_VIDEO_RGB(0),
		FREENECT_VIDEO_BAYER(1),
		FREENECT_VIDEO_IR_8BIT(2),
		FREENECT_VIDEO_IR_10BIT(3),
		FREENECT_VIDEO_IR_10BIT_PACKED(4),
		FREENECT_VIDEO_YUV_RGB(5),
		FREENECT_VIDEO_YUV_RAW(6),
		FREENECT_VIDEO_DUMMY(2147483647);
		freenect_video_format(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_video_format > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_video_format > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_depth_format implements ValuedEnum<freenect_depth_format > {
		FREENECT_DEPTH_11BIT(0),
		FREENECT_DEPTH_10BIT(1),
		FREENECT_DEPTH_11BIT_PACKED(2),
		FREENECT_DEPTH_10BIT_PACKED(3),
		FREENECT_DEPTH_REGISTERED(4),
		FREENECT_DEPTH_MM(5),
		FREENECT_DEPTH_DUMMY(2147483647);
		freenect_depth_format(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_depth_format > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_depth_format > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_led_options implements ValuedEnum<freenect_led_options > {
		LED_OFF(0),
		LED_GREEN(1),
		LED_RED(2),
		LED_YELLOW(3),
		LED_BLINK_GREEN(4),
		LED_BLINK_RED_YELLOW(6);
		freenect_led_options(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_led_options > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_led_options > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_tilt_status_code implements ValuedEnum<freenect_tilt_status_code > {
		TILT_STATUS_STOPPED(0x00),
		TILT_STATUS_LIMIT(0x01),
		TILT_STATUS_MOVING(0x04);
		freenect_tilt_status_code(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_tilt_status_code > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_tilt_status_code > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	public enum freenect_loglevel implements ValuedEnum<freenect_loglevel > {
		FREENECT_LOG_FATAL(0),
		FREENECT_LOG_ERROR(1),
		FREENECT_LOG_WARNING(2),
		FREENECT_LOG_NOTICE(3),
		FREENECT_LOG_INFO(4),
		FREENECT_LOG_DEBUG(5),
		FREENECT_LOG_SPEW(6),
		FREENECT_LOG_FLOOD(7);
		freenect_loglevel(long value) {
			this.value = value;
		}
		public final long value;
		public long value() {
			return this.value;
		}
		public Iterator<freenect_loglevel > iterator() {
			return Collections.singleton(this).iterator();
		}
		public static ValuedEnum<freenect_loglevel > fromValue(int value) {
			return FlagSet.fromValue(value, values());
		}
	};
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INTMAX_MAX = (long)9223372036854775807L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT_LEAST64_MIN = (long)(-9223372036854775807L - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT32_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT_FAST64_MIN = (long)(-9223372036854775807L - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int WINT_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int WINT_MAX = (int)2147483647;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST8_MAX = (int)127;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT16_MIN = (int)-32768;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT16_MAX = (int)32767;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_LEAST8_MAX = (int)255;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int WCHAR_MIN = (int)(0x7fffffff - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int WCHAR_MAX = (int)0x7fffffff;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INTPTR_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INTMAX_MIN = (long)(-9223372036854775807L - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INTPTR_MAX = (int)2147483647;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long SIZE_MAX = (long)4294967295L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_FAST8_MAX = (int)255;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST8_MIN = (int)-128;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long UINT_FAST32_MAX = (long)4294967295L;
	public static final int FREENECT_COUNTS_PER_G = (int)819;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST8_MAX = (int)127;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_FAST16_MAX = (int)65535;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int SIG_ATOMIC_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int __WORDSIZE = (int)32;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT8_MAX = (int)255;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long UINTPTR_MAX = (long)4294967295L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT32_MAX = (int)2147483647;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int SIG_ATOMIC_MAX = (int)2147483647;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int PTRDIFF_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST32_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_FAST64_MAX = (int)-1;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST16_MIN = (int)-32768;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int PTRDIFF_MAX = (int)2147483647;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long UINT32_MAX = (long)4294967295L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT16_MAX = (int)65535;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST32_MAX = (int)2147483647;
	public static final int FREENECT_DEPTH_RAW_NO_VALUE = (int)2047;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST16_MIN = (int)-32768;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST8_MIN = (int)-128;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINTMAX_MAX = (int)-1;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_FAST16_MAX = (int)32767;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST16_MAX = (int)32767;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT8_MIN = (int)-128;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_LEAST16_MAX = (int)65535;
	public static final int FREENECT_DEPTH_MM_MAX_VALUE = (int)10000;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long UINT_LEAST32_MAX = (long)4294967295L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT64_MAX = (int)-1;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT8_MAX = (int)127;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST32_MIN = (int)(-2147483647 - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int INT_LEAST32_MAX = (int)2147483647;
	public static final int FREENECT_DEPTH_RAW_MAX_VALUE = (int)2048;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT64_MIN = (long)(-9223372036854775807L - 1);
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT64_MAX = (long)9223372036854775807L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT_FAST64_MAX = (long)9223372036854775807L;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final long INT_LEAST64_MAX = (long)9223372036854775807L;
	public static final int FREENECT_DEPTH_MM_NO_VALUE = (int)0;
	/// <i>native declaration : /usr/include/stdint.h</i>
	public static final int UINT_LEAST64_MAX = (int)-1;
	/**
	 * Typedef for logging callback functions<br>
	 * <i>native declaration : /usr/include/stdint.h</i>
	 */
	public static abstract class freenect_log_cb extends Callback<freenect_log_cb > {
		public abstract void apply(Pointer<libfreenectLibrary.freenect_context > dev, ValuedEnum<libfreenectLibrary.freenect_loglevel > level, Pointer<Byte > msg);
	};
	/**
	 * Typedef for depth image received event callbacks<br>
	 * <i>native declaration : /usr/include/stdint.h</i>
	 */
	public static abstract class freenect_depth_cb extends Callback<freenect_depth_cb > {
		public abstract void apply(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<? > depth, int timestamp);
	};
	/**
	 * Typedef for video image received event callbacks<br>
	 * <i>native declaration : /usr/include/stdint.h</i>
	 */
	public static abstract class freenect_video_cb extends Callback<freenect_video_cb > {
		public abstract void apply(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<? > video, int timestamp);
	};
	public static native int freenect_init(Pointer<Pointer<libfreenectLibrary.freenect_context > > ctx, Pointer<? > usb_ctx);
	public static native int freenect_shutdown(Pointer<libfreenectLibrary.freenect_context > ctx);
	public static native void freenect_set_log_level(Pointer<libfreenectLibrary.freenect_context > ctx, ValuedEnum<libfreenectLibrary.freenect_loglevel > level);
	public static native void freenect_set_log_callback(Pointer<libfreenectLibrary.freenect_context > ctx, Pointer<libfreenectLibrary.freenect_log_cb > cb);
	public static native int freenect_process_events(Pointer<libfreenectLibrary.freenect_context > ctx);
	public static native int freenect_process_events_timeout(Pointer<libfreenectLibrary.freenect_context > ctx, Pointer<libfreenectLibrary.timeval > timeout);
	public static native int freenect_num_devices(Pointer<libfreenectLibrary.freenect_context > ctx);
	public static native int freenect_list_device_attributes(Pointer<libfreenectLibrary.freenect_context > ctx, Pointer<Pointer<freenect_device_attributes > > attribute_list);
	public static native void freenect_free_device_attributes(Pointer<freenect_device_attributes > attribute_list);
	public static native int freenect_supported_subdevices();
	public static native void freenect_select_subdevices(Pointer<libfreenectLibrary.freenect_context > ctx, ValuedEnum<libfreenectLibrary.freenect_device_flags > subdevs);
	public static native int freenect_open_device(Pointer<libfreenectLibrary.freenect_context > ctx, Pointer<Pointer<libfreenectLibrary.freenect_device > > dev, int index);
	public static native int freenect_open_device_by_camera_serial(Pointer<libfreenectLibrary.freenect_context > ctx, Pointer<Pointer<libfreenectLibrary.freenect_device > > dev, Pointer<Byte > camera_serial);
	public static native int freenect_close_device(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native void freenect_set_user(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<? > user);
	public static native Pointer<? > freenect_get_user(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native void freenect_set_depth_callback(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<libfreenectLibrary.freenect_depth_cb > cb);
	public static native void freenect_set_video_callback(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<libfreenectLibrary.freenect_video_cb > cb);
	public static native int freenect_set_depth_buffer(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<? > buf);
	public static native int freenect_set_video_buffer(Pointer<libfreenectLibrary.freenect_device > dev, Pointer<? > buf);
	public static native int freenect_start_depth(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_start_video(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_stop_depth(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_stop_video(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_update_tilt_state(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native Pointer<freenect_raw_tilt_state > freenect_get_tilt_state(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native double freenect_get_tilt_degs(Pointer<freenect_raw_tilt_state > state);
	public static native int freenect_set_tilt_degs(Pointer<libfreenectLibrary.freenect_device > dev, double angle);
	public static native ValuedEnum<libfreenectLibrary.freenect_tilt_status_code > freenect_get_tilt_status(Pointer<freenect_raw_tilt_state > state);
	public static native int freenect_set_led(Pointer<libfreenectLibrary.freenect_device > dev, ValuedEnum<libfreenectLibrary.freenect_led_options > option);
	public static native void freenect_get_mks_accel(Pointer<freenect_raw_tilt_state > state, Pointer<Double > x, Pointer<Double > y, Pointer<Double > z);
	public static native int freenect_get_video_mode_count();
	public static native freenect_frame_mode freenect_get_video_mode(int mode_num);
	public static native freenect_frame_mode freenect_get_current_video_mode(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native freenect_frame_mode freenect_find_video_mode(ValuedEnum<libfreenectLibrary.freenect_resolution > res, ValuedEnum<libfreenectLibrary.freenect_video_format > fmt);
	public static native int freenect_set_video_mode(Pointer<libfreenectLibrary.freenect_device > dev, freenect_frame_mode mode);
	// PROXY ADDED IN OPENIMAJ
	public static native int freenect_set_video_mode_proxy(Pointer<libfreenectLibrary.freenect_device > dev, ValuedEnum<libfreenectLibrary.freenect_resolution > res, ValuedEnum<libfreenectLibrary.freenect_video_format > fmt);
	public static native int freenect_get_depth_mode_count();
	public static native freenect_frame_mode freenect_get_depth_mode(int mode_num);
	public static native freenect_frame_mode freenect_get_current_depth_mode(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native freenect_frame_mode freenect_find_depth_mode(ValuedEnum<libfreenectLibrary.freenect_resolution > res, ValuedEnum<libfreenectLibrary.freenect_depth_format > fmt);
	public static native int freenect_set_depth_mode(Pointer<libfreenectLibrary.freenect_device > dev, freenect_frame_mode mode);
	// PROXY ADDED IN OPENIMAJ
	public static native int freenect_set_depth_mode_proxy(Pointer<libfreenectLibrary.freenect_device > dev, ValuedEnum<libfreenectLibrary.freenect_resolution > res, ValuedEnum<libfreenectLibrary.freenect_depth_format > fmt);
	// TWO UTILITIES ADDED IN OPENIMAJ
	public static native int freenect_get_video_buffer_size(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_get_depth_buffer_size(Pointer<libfreenectLibrary.freenect_device > dev);
	/// Undefined type
	public static interface freenect_device {
		
	};
	/// Undefined type
	public static interface timeval {
		
	};
	/// Undefined type
	public static interface freenect_context {
		
	};

	//libfreenect-registration.h methods
	public static native freenect_registration freenect_copy_registration(Pointer<libfreenectLibrary.freenect_device > dev);
	public static native int freenect_destroy_registration(Pointer<freenect_registration > reg);
	public static native void freenect_camera_to_world(Pointer<libfreenectLibrary.freenect_device > dev, int cx, int cy, int wz, Pointer<Double > wx, Pointer<Double > wy);
}
