Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated for NDK r4 and manually optimized some wrapper functions

  • Loading branch information...
commit 380a88f0f898f0cfda46155958c8f50581b5b448 1 parent 93c1ac7
@pcgod authored
View
2  .gitignore
@@ -1,4 +1,2 @@
bin/*
libs/*
-jni/celt_wrapper/*.java
-jni/celt_wrapper/*.c
View
5 Application.mk
@@ -1,5 +0,0 @@
-APP_PROJECT_PATH := $(call my-dir)
-APP_MODULES := libcelt_interface libcelt libspeex
-
-#APP_OPTIM := debug
-#APP_ABI := amd64
View
2  jni/Android.mk
@@ -43,7 +43,7 @@ include $(CLEAR_VARS)
LOCAL_PATH := $(ROOT)/celt_wrapper
LOCAL_MODULE := libcelt_interface
LOCAL_SRC_FILES := celt_wrap.c
-LOCAL_CFLAGS := -I$(LIBPATH)
+LOCAL_CFLAGS := -I$(LIBPATH) -fvisibility=hidden
LOCAL_STATIC_LIBRARIES := libcelt libspeex
include $(BUILD_SHARED_LIBRARY)
View
1  jni/Application.mk
@@ -0,0 +1 @@
+#APP_OPTIM := debug
View
26 jni/celt_wrapper/SWIGTYPE_p_CELTDecoder.java
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public class SWIGTYPE_p_CELTDecoder {
+ private long swigCPtr;
+
+ protected SWIGTYPE_p_CELTDecoder(long cPtr, boolean futureUse) {
+ swigCPtr = cPtr;
+ }
+
+ protected SWIGTYPE_p_CELTDecoder() {
+ swigCPtr = 0;
+ }
+
+ protected static long getCPtr(SWIGTYPE_p_CELTDecoder obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+}
+
View
26 jni/celt_wrapper/SWIGTYPE_p_CELTEncoder.java
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public class SWIGTYPE_p_CELTEncoder {
+ private long swigCPtr;
+
+ protected SWIGTYPE_p_CELTEncoder(long cPtr, boolean futureUse) {
+ swigCPtr = cPtr;
+ }
+
+ protected SWIGTYPE_p_CELTEncoder() {
+ swigCPtr = 0;
+ }
+
+ protected static long getCPtr(SWIGTYPE_p_CELTEncoder obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+}
+
View
26 jni/celt_wrapper/SWIGTYPE_p_CELTMode.java
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public class SWIGTYPE_p_CELTMode {
+ private long swigCPtr;
+
+ protected SWIGTYPE_p_CELTMode(long cPtr, boolean futureUse) {
+ swigCPtr = cPtr;
+ }
+
+ protected SWIGTYPE_p_CELTMode() {
+ swigCPtr = 0;
+ }
+
+ protected static long getCPtr(SWIGTYPE_p_CELTMode obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+}
+
View
26 jni/celt_wrapper/SWIGTYPE_p_SpeexResamplerState.java
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public class SWIGTYPE_p_SpeexResamplerState {
+ private long swigCPtr;
+
+ protected SWIGTYPE_p_SpeexResamplerState(long cPtr, boolean futureUse) {
+ swigCPtr = cPtr;
+ }
+
+ protected SWIGTYPE_p_SpeexResamplerState() {
+ swigCPtr = 0;
+ }
+
+ protected static long getCPtr(SWIGTYPE_p_SpeexResamplerState obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+}
+
View
344 jni/celt_wrapper/celt.i
@@ -1,344 +0,0 @@
-%module celt
-%{
-/** Contains the state of an encoder. One encoder state is needed
- for each stream. It is initialised once at the beginning of the
- stream. Do *not* re-initialise the state for every frame.
- @brief Encoder state
- */
-typedef struct CELTEncoder CELTEncoder;
-
-/** State of the decoder. One decoder state is needed for each stream.
- It is initialised once at the beginning of the stream. Do *not*
- re-initialise the state for every frame */
-typedef struct CELTDecoder CELTDecoder;
-
-/** The mode contains all the information necessary to create an
- encoder. Both the encoder and decoder need to be initialised
- with exactly the same mode, otherwise the quality will be very
- bad */
-typedef struct CELTMode CELTMode;
-
-extern CELTMode *celt_mode_create(int Fs, int frame_size, int *error);
-extern void celt_mode_destroy(CELTMode *mode);
-
-extern CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error);
-extern void celt_encoder_destroy(CELTEncoder *st);
-extern int celt_encode(CELTEncoder *st, const short *pcm, short *optional_synthesis, unsigned char *compressed, int nbCompressedBytes);
-extern int celt_encoder_ctl(CELTEncoder * st, int request, ...);
-
-extern CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error);
-extern void celt_decoder_destroy(CELTDecoder *st);
-extern int celt_decode(CELTDecoder *st, const unsigned char *data, int len, short *pcm);
-//extern int celt_decoder_ctl(CELTDecoder * st, int request, ...);
-%}
-%include "typemaps.i"
-%include "arrays_java.i"
-
-%javaconst(1);
-
-%apply unsigned char[] { unsigned char * };
-%apply float[] { float * };
-%apply short[] { short * };
-
-%apply int *OUTPUT { int *error };
-%apply int *OUTPUT { int *value };
-
-#define EXPORT extern
-#define celt_int32 int
-#define celt_int16 short
-
-#define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x))
-#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr)))
-
-/* Error codes */
-/** No error */
-#define CELT_OK 0
-/** An (or more) invalid argument (e.g. out of range) */
-#define CELT_BAD_ARG -1
-/** The mode struct passed is invalid */
-#define CELT_INVALID_MODE -2
-/** An internal error was detected */
-#define CELT_INTERNAL_ERROR -3
-/** The data passed (e.g. compressed data to decoder) is corrupted */
-#define CELT_CORRUPTED_DATA -4
-/** Invalid/unsupported request number */
-#define CELT_UNIMPLEMENTED -5
-/** An encoder or decoder structure is invalid or already freed */
-#define CELT_INVALID_STATE -6
-/** Memory allocation has failed */
-#define CELT_ALLOC_FAIL -7
-
-/* Requests */
-#define CELT_GET_MODE_REQUEST 1
-/** Get the CELTMode used by an encoder or decoder */
-#define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x)
-#define CELT_SET_COMPLEXITY_REQUEST 2
-/** Controls the complexity from 0-10 (int) */
-#define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x)
-#define CELT_SET_PREDICTION_REQUEST 4
-/** Controls the use of interframe prediction.
- 0=Independent frames
- 1=Short term interframe prediction allowed
- 2=Long term prediction allowed
- */
-#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, _celt_check_int(x)
-#define CELT_SET_VBR_RATE_REQUEST 6
-/** Set the target VBR rate in bits per second(int); 0=CBR (default) */
-#define CELT_SET_VBR_RATE(x) CELT_SET_VBR_RATE_REQUEST, _celt_check_int(x)
-/** Reset the encoder/decoder memories to zero*/
-#define CELT_RESET_STATE_REQUEST 8
-#define CELT_RESET_STATE CELT_RESET_STATE_REQUEST
-
-/** GET the frame size used in the current mode */
-#define CELT_GET_FRAME_SIZE 1000
-/** GET the lookahead used in the current mode */
-#define CELT_GET_LOOKAHEAD 1001
-/** GET the sample rate used in the current mode */
-#define CELT_GET_SAMPLE_RATE 1003
-
-/** GET the bit-stream version for compatibility check */
-#define CELT_GET_BITSTREAM_VERSION 2000
-
-
-/** Contains the state of an encoder. One encoder state is needed
- for each stream. It is initialised once at the beginning of the
- stream. Do *not* re-initialise the state for every frame.
- @brief Encoder state
- */
-typedef struct CELTEncoder CELTEncoder;
-
-/** State of the decoder. One decoder state is needed for each stream.
- It is initialised once at the beginning of the stream. Do *not*
- re-initialise the state for every frame */
-typedef struct CELTDecoder CELTDecoder;
-
-/** The mode contains all the information necessary to create an
- encoder. Both the encoder and decoder need to be initialised
- with exactly the same mode, otherwise the quality will be very
- bad */
-typedef struct CELTMode CELTMode;
-
-
-/** \defgroup codec Encoding and decoding */
-/* @{ */
-
-/* Mode calls */
-
-/** Creates a new mode struct. This will be passed to an encoder or
- decoder. The mode MUST NOT BE DESTROYED until the encoders and
- decoders that use it are destroyed as well.
- @param Fs Sampling rate (32000 to 96000 Hz)
- @param frame_size Number of samples (per channel) to encode in each
- packet (even values; 64 - 512)
- @param error Returned error code (if NULL, no error will be returned)
- @return A newly created mode
-*/
-%rename(celt_mode_create) wrap_celt_mode_create;
-%inline %{
-CELTMode *wrap_celt_mode_create(int Fs, int frame_size) {
- return celt_mode_create(Fs, frame_size, NULL);
-}
-%}
-%ignore celt_mode_create;
-EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error);
-
-/** Destroys a mode struct. Only call this after all encoders and
- decoders using this mode are destroyed as well.
- @param mode Mode to be destroyed
-*/
-EXPORT void celt_mode_destroy(CELTMode *mode);
-
-/** Query information from a mode */
-EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value);
-
-/* Encoder stuff */
-
-
-/** Creates a new encoder state. Each stream needs its own encoder
- state (can't be shared across simultaneous streams).
- @param mode Contains all the information about the characteristics of
- * the stream (must be the same characteristics as used for the
- * decoder)
- @param channels Number of channels
- @param error Returns an error code
- @return Newly created encoder state.
-*/
-%rename(celt_encoder_create) wrap_celt_encoder_create;
-%inline %{
-CELTEncoder *wrap_celt_encoder_create(const CELTMode *mode, int channels) {
- return celt_encoder_create(mode, channels, NULL);
-}
-%}
-%ignore celt_encoder_create;
-EXPORT CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error);
-
-/** Destroys a an encoder state.
- @param st Encoder state to be destroyed
- */
-EXPORT void celt_encoder_destroy(CELTEncoder *st);
-
-/** Encodes a frame of audio.
- @param st Encoder state
- @param pcm PCM audio in float format, with a normal range of ±1.0.
- * Samples with a range beyond ±1.0 are supported but will
- * be clipped by decoders using the integer API and should
- * only be used if it is known that the far end supports
- * extended dynmaic range. There must be exactly
- * frame_size samples per channel.
- @param optional_synthesis If not NULL, the encoder copies the audio signal that
- * the decoder would decode. It is the same as calling the
- * decoder on the compressed data, just faster.
- * This may alias pcm.
- @param compressed The compressed data is written here. This may not alias pcm or
- * optional_synthesis.
- @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
- * (can change from one frame to another)
- @return Number of bytes written to "compressed". Will be the same as
- * "nbCompressedBytes" unless the stream is VBR and will never be larger.
- * If negative, an error has occurred (see error codes). It is IMPORTANT that
- * the length returned be somehow transmitted to the decoder. Otherwise, no
- * decoding is possible.
-*/
-%ignore celt_encode_float;
-EXPORT int celt_encode_float(CELTEncoder *st, float *pcm, float *optional_synthesis, char *compressed, int nbCompressedBytes);
-
-/** Encodes a frame of audio.
- @param st Encoder state
- @param pcm PCM audio in signed 16-bit format (native endian). There must be
- * exactly frame_size samples per channel.
- @param optional_synthesis If not NULL, the encoder copies the audio signal that
- * the decoder would decode. It is the same as calling the
- * decoder on the compressed data, just faster.
- * This may alias pcm.
- @param compressed The compressed data is written here. This may not alias pcm or
- * optional_synthesis.
- @param nbCompressedBytes Maximum number of bytes to use for compressing the frame
- * (can change from one frame to another)
- @return Number of bytes written to "compressed". Will be the same as
- * "nbCompressedBytes" unless the stream is VBR and will never be larger.
- * If negative, an error has occurred (see error codes). It is IMPORTANT that
- * the length returned be somehow transmitted to the decoder. Otherwise, no
- * decoding is possible.
- */
-%rename(celt_encode) wrap_celt_encode;
-%inline %{
-int wrap_celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCompressedBytes) {
- return celt_encode(st, pcm, NULL, compressed, nbCompressedBytes);
-}
-%}
-%ignore celt_encode;
-EXPORT int celt_encode(CELTEncoder *st, celt_int16 *pcm, celt_int16 *optional_synthesis, unsigned char *compressed, int nbCompressedBytes);
-
-/** Query and set encoder parameters
- @param st Encoder state
- @param request Parameter to change or query
- @param value Pointer to a 32-bit int value
- @return Error code
-*/
-%varargs(int value = 0) celt_encoder_ctl;
-EXPORT int celt_encoder_ctl(CELTEncoder * st, int request, ...);
-
-/* Decoder stuff */
-
-
-/** Creates a new decoder state. Each stream needs its own decoder state (can't
- be shared across simultaneous streams).
- @param mode Contains all the information about the characteristics of the
- stream (must be the same characteristics as used for the encoder)
- @param channels Number of channels
- @param error Returns an error code
- @return Newly created decoder state.
- */
-%rename(celt_decoder_create) wrap_celt_decoder_create;
-%inline %{
-CELTDecoder *wrap_celt_decoder_create(const CELTMode *mode, int channels) {
- return celt_decoder_create(mode, channels, NULL);
-}
-%}
-%ignore celt_decoder_create;
-EXPORT CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error);
-
-/** Destroys a a decoder state.
- @param st Decoder state to be destroyed
- */
-EXPORT void celt_decoder_destroy(CELTDecoder *st);
-
-/** Decodes a frame of audio.
- @param st Decoder state
- @param data Compressed data produced by an encoder
- @param len Number of bytes to read from "data". This MUST be exactly the number
- of bytes returned by the encoder. Using a larger value WILL NOT WORK.
- @param pcm One frame (frame_size samples per channel) of decoded PCM will be
- returned here in float format.
- @return Error code.
- */
-%ignore celt_decode_float;
-EXPORT int celt_decode_float(CELTDecoder *st, unsigned char *data, int len, float *pcm);
-
-/** Decodes a frame of audio.
- @param st Decoder state
- @param data Compressed data produced by an encoder
- @param len Number of bytes to read from "data". This MUST be exactly the number
- of bytes returned by the encoder. Using a larger value WILL NOT WORK.
- @param pcm One frame (frame_size samples per channel) of decoded PCM will be
- returned here in 16-bit PCM format (native endian).
- @return Error code.
- */
-EXPORT int celt_decode(CELTDecoder *st, unsigned char *data, int len, celt_int16 *pcm);
-
-/** Query and set decoder parameters
- @param st Decoder state
- @param request Parameter to change or query
- @param value Pointer to a 32-bit int value
- @return Error code
- */
-%varargs(int value = 0) celt_decoder_ctl;
-%ignore celt_decoder_ctl;
-EXPORT int celt_decoder_ctl(CELTDecoder * st, int request, ...);
-
-
-/** Returns the English string that corresponds to an error code
- * @param error Error code (negative for an error, 0 for success
- * @return Constant string (must NOT be freed)
- */
-%ignore celt_strerror;
-EXPORT const char *celt_strerror(int error);
-
-
-#define spx_uint32_t int
-#define spx_int16_t short
-
-%apply int *INOUT { int *in_len };
-%apply int *INOUT { int *out_len };
-
-%{
-typedef struct SpeexResamplerState SpeexResamplerState;
-extern SpeexResamplerState *speex_resampler_init(int nb_channels,
- int in_rate,
- int out_rate,
- int quality,
- int *err);
-%}
-
-typedef struct SpeexResamplerState SpeexResamplerState;
-
-%rename(speex_resampler_init) wrap_speex_resampler_init;
-%inline %{
-SpeexResamplerState *wrap_speex_resampler_init(unsigned int nb_channels, unsigned int in_rate, unsigned int out_rate, int quality) {
- return speex_resampler_init(nb_channels, in_rate, out_rate, quality, NULL);
-}
-%}
-%ignore speex_resampler_init;
-extern SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
- spx_uint32_t in_rate,
- spx_uint32_t out_rate,
- int quality,
- int *err);
-
-extern void speex_resampler_destroy(SpeexResamplerState *st);
-extern int speex_resampler_process_int(SpeexResamplerState *st,
- spx_uint32_t channel_index,
- const spx_int16_t *in,
- spx_uint32_t *in_len,
- spx_int16_t *out,
- spx_uint32_t *out_len);
View
68 jni/celt_wrapper/celt.java
@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public class celt implements celtConstants {
+ public static SWIGTYPE_p_CELTMode celt_mode_create(int Fs, int frame_size) {
+ long cPtr = celtJNI.celt_mode_create(Fs, frame_size);
+ return (cPtr == 0) ? null : new SWIGTYPE_p_CELTMode(cPtr, false);
+ }
+
+ public static void celt_mode_destroy(SWIGTYPE_p_CELTMode mode) {
+ celtJNI.celt_mode_destroy(SWIGTYPE_p_CELTMode.getCPtr(mode));
+ }
+
+ public static int celt_mode_info(SWIGTYPE_p_CELTMode mode, int request, int[] value) {
+ return celtJNI.celt_mode_info(SWIGTYPE_p_CELTMode.getCPtr(mode), request, value);
+ }
+
+ public static SWIGTYPE_p_CELTEncoder celt_encoder_create(SWIGTYPE_p_CELTMode mode, int channels) {
+ long cPtr = celtJNI.celt_encoder_create(SWIGTYPE_p_CELTMode.getCPtr(mode), channels);
+ return (cPtr == 0) ? null : new SWIGTYPE_p_CELTEncoder(cPtr, false);
+ }
+
+ public static void celt_encoder_destroy(SWIGTYPE_p_CELTEncoder st) {
+ celtJNI.celt_encoder_destroy(SWIGTYPE_p_CELTEncoder.getCPtr(st));
+ }
+
+ public static int celt_encode(SWIGTYPE_p_CELTEncoder st, short[] pcm, short[] compressed, int nbCompressedBytes) {
+ return celtJNI.celt_encode(SWIGTYPE_p_CELTEncoder.getCPtr(st), pcm, compressed, nbCompressedBytes);
+ }
+
+ public static int celt_encoder_ctl(SWIGTYPE_p_CELTEncoder st, int request, int value) {
+ return celtJNI.celt_encoder_ctl(SWIGTYPE_p_CELTEncoder.getCPtr(st), request, value);
+ }
+
+ public static SWIGTYPE_p_CELTDecoder celt_decoder_create(SWIGTYPE_p_CELTMode mode, int channels) {
+ long cPtr = celtJNI.celt_decoder_create(SWIGTYPE_p_CELTMode.getCPtr(mode), channels);
+ return (cPtr == 0) ? null : new SWIGTYPE_p_CELTDecoder(cPtr, false);
+ }
+
+ public static void celt_decoder_destroy(SWIGTYPE_p_CELTDecoder st) {
+ celtJNI.celt_decoder_destroy(SWIGTYPE_p_CELTDecoder.getCPtr(st));
+ }
+
+ public static int celt_decode(SWIGTYPE_p_CELTDecoder st, short[] data, int len, short[] pcm) {
+ return celtJNI.celt_decode(SWIGTYPE_p_CELTDecoder.getCPtr(st), data, len, pcm);
+ }
+
+ public static SWIGTYPE_p_SpeexResamplerState speex_resampler_init(long nb_channels, long in_rate, long out_rate, int quality) {
+ long cPtr = celtJNI.speex_resampler_init(nb_channels, in_rate, out_rate, quality);
+ return (cPtr == 0) ? null : new SWIGTYPE_p_SpeexResamplerState(cPtr, false);
+ }
+
+ public static void speex_resampler_destroy(SWIGTYPE_p_SpeexResamplerState st) {
+ celtJNI.speex_resampler_destroy(SWIGTYPE_p_SpeexResamplerState.getCPtr(st));
+ }
+
+ public static int speex_resampler_process_int(SWIGTYPE_p_SpeexResamplerState st, int channel_index, short[] in, int[] in_len, short[] out, int[] out_len) {
+ return celtJNI.speex_resampler_process_int(SWIGTYPE_p_SpeexResamplerState.getCPtr(st), channel_index, in, in_len, out, out_len);
+ }
+
+}
View
30 jni/celt_wrapper/celtConstants.java
@@ -0,0 +1,30 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+public interface celtConstants {
+ public final static int CELT_OK = 0;
+ public final static int CELT_BAD_ARG = -1;
+ public final static int CELT_INVALID_MODE = -2;
+ public final static int CELT_INTERNAL_ERROR = -3;
+ public final static int CELT_CORRUPTED_DATA = -4;
+ public final static int CELT_UNIMPLEMENTED = -5;
+ public final static int CELT_INVALID_STATE = -6;
+ public final static int CELT_ALLOC_FAIL = -7;
+ public final static int CELT_GET_MODE_REQUEST = 1;
+ public final static int CELT_SET_COMPLEXITY_REQUEST = 2;
+ public final static int CELT_SET_PREDICTION_REQUEST = 4;
+ public final static int CELT_SET_VBR_RATE_REQUEST = 6;
+ public final static int CELT_RESET_STATE_REQUEST = 8;
+ public final static int CELT_RESET_STATE = 8;
+ public final static int CELT_GET_FRAME_SIZE = 1000;
+ public final static int CELT_GET_LOOKAHEAD = 1001;
+ public final static int CELT_GET_SAMPLE_RATE = 1003;
+ public final static int CELT_GET_BITSTREAM_VERSION = 2000;
+}
View
25 jni/celt_wrapper/celtJNI.java
@@ -0,0 +1,25 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pcgod.mumbleclient.jni;
+
+class celtJNI {
+ public final static native long celt_mode_create(int jarg1, int jarg2);
+ public final static native void celt_mode_destroy(long jarg1);
+ public final static native int celt_mode_info(long jarg1, int jarg2, int[] jarg3);
+ public final static native long celt_encoder_create(long jarg1, int jarg2);
+ public final static native void celt_encoder_destroy(long jarg1);
+ public final static native int celt_encode(long jarg1, short[] jarg2, short[] jarg3, int jarg4);
+ public final static native int celt_encoder_ctl(long jarg1, int jarg2, int jarg3);
+ public final static native long celt_decoder_create(long jarg1, int jarg2);
+ public final static native void celt_decoder_destroy(long jarg1);
+ public final static native int celt_decode(long jarg1, short[] jarg2, int jarg3, short[] jarg4);
+ public final static native long speex_resampler_init(long jarg1, long jarg2, long jarg3, int jarg4);
+ public final static native void speex_resampler_destroy(long jarg1);
+ public final static native int speex_resampler_process_int(long jarg1, int jarg2, short[] jarg3, int[] jarg4, short[] jarg5, int[] jarg6);
+}
View
1,038 jni/celt_wrapper/celt_wrap.c
@@ -0,0 +1,1038 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGJAVA
+
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+# pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Fix for jlong on some versions of gcc on Windows */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+ typedef long long __int64;
+#endif
+
+/* Fix for jlong on 64-bit x86 Solaris */
+#if defined(__x86_64)
+# ifdef _LP64
+# undef _LP64
+# endif
+#endif
+
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Support for throwing Java exceptions */
+typedef enum {
+ SWIG_JavaOutOfMemoryError = 1,
+ SWIG_JavaIOException,
+ SWIG_JavaRuntimeException,
+ SWIG_JavaIndexOutOfBoundsException,
+ SWIG_JavaArithmeticException,
+ SWIG_JavaIllegalArgumentException,
+ SWIG_JavaNullPointerException,
+ SWIG_JavaDirectorPureVirtual,
+ SWIG_JavaUnknownError
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+ SWIG_JavaExceptionCodes code;
+ const char *java_exception;
+} SWIG_JavaExceptions_t;
+
+
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+ jclass excep;
+ static const SWIG_JavaExceptions_t java_exceptions[] = {
+ { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+ { SWIG_JavaIOException, "java/io/IOException" },
+ { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+ { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+ { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+ { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+ { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+ { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+ { SWIG_JavaUnknownError, "java/lang/UnknownError" },
+ { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" }
+ };
+ const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+ while (except_ptr->code != code && except_ptr->code)
+ except_ptr++;
+
+ (*jenv)->ExceptionClear(jenv);
+ excep = (*jenv)->FindClass(jenv, except_ptr->java_exception);
+ if (excep)
+ (*jenv)->ThrowNew(jenv, excep, msg);
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
+
+
+/** Contains the state of an encoder. One encoder state is needed
+ for each stream. It is initialised once at the beginning of the
+ stream. Do *not* re-initialise the state for every frame.
+ @brief Encoder state
+ */
+typedef struct CELTEncoder CELTEncoder;
+
+/** State of the decoder. One decoder state is needed for each stream.
+ It is initialised once at the beginning of the stream. Do *not*
+ re-initialise the state for every frame */
+typedef struct CELTDecoder CELTDecoder;
+
+/** The mode contains all the information necessary to create an
+ encoder. Both the encoder and decoder need to be initialised
+ with exactly the same mode, otherwise the quality will be very
+ bad */
+typedef struct CELTMode CELTMode;
+
+extern CELTMode *celt_mode_create(int Fs, int frame_size, int *error);
+extern void celt_mode_destroy(CELTMode *mode);
+
+extern CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error);
+extern void celt_encoder_destroy(CELTEncoder *st);
+extern int celt_encode(CELTEncoder *st, const short *pcm, short *optional_synthesis, unsigned char *compressed, int nbCompressedBytes);
+extern int celt_encoder_ctl(CELTEncoder * st, int request, ...);
+
+extern CELTDecoder *celt_decoder_create(const CELTMode *mode, int channels, int *error);
+extern void celt_decoder_destroy(CELTDecoder *st);
+extern int celt_decode(CELTDecoder *st, const unsigned char *data, int len, short *pcm);
+//extern int celt_decoder_ctl(CELTDecoder * st, int request, ...);
+
+
+
+/* signed char[] support */
+static int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetByteArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (signed char*) calloc(sz, sizeof(signed char));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (signed char)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jbyte)carr[i];
+ (*jenv)->ReleaseByteArrayElements(jenv, input, jarr, 0);
+}
+
+static jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) {
+ jbyte *arr;
+ int i;
+ jbyteArray jresult = (*jenv)->NewByteArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetByteArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jbyte)result[i];
+ (*jenv)->ReleaseByteArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* unsigned char[] support */
+static int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (unsigned char*) calloc(sz, sizeof(unsigned char));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (unsigned char)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jshort)carr[i];
+ (*jenv)->ReleaseShortArrayElements(jenv, input, jarr, 0);
+}
+
+static jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) {
+ jshort *arr;
+ int i;
+ jshortArray jresult = (*jenv)->NewShortArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jshort)result[i];
+ (*jenv)->ReleaseShortArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* short[] support */
+static int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (short*) calloc(sz, sizeof(short));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (short)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jshort)carr[i];
+ (*jenv)->ReleaseShortArrayElements(jenv, input, jarr, 0);
+}
+
+static jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) {
+ jshort *arr;
+ int i;
+ jshortArray jresult = (*jenv)->NewShortArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jshort)result[i];
+ (*jenv)->ReleaseShortArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* unsigned short[] support */
+static int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (unsigned short*) calloc(sz, sizeof(unsigned short));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (unsigned short)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jint)carr[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) {
+ jint *arr;
+ int i;
+ jintArray jresult = (*jenv)->NewIntArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jint)result[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* int[] support */
+static int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (int*) calloc(sz, sizeof(int));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (int)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jint)carr[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) {
+ jint *arr;
+ int i;
+ jintArray jresult = (*jenv)->NewIntArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jint)result[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* unsigned int[] support */
+static int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (unsigned int*) calloc(sz, sizeof(unsigned int));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (unsigned int)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jlong)carr[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) {
+ jlong *arr;
+ int i;
+ jlongArray jresult = (*jenv)->NewLongArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jlong)result[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* long[] support */
+static int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (long*) calloc(sz, sizeof(long));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (long)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jint)carr[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, input, jarr, 0);
+}
+
+static jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) {
+ jint *arr;
+ int i;
+ jintArray jresult = (*jenv)->NewIntArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jint)result[i];
+ (*jenv)->ReleaseIntArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* unsigned long[] support */
+static int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (unsigned long*) calloc(sz, sizeof(unsigned long));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (unsigned long)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jlong)carr[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) {
+ jlong *arr;
+ int i;
+ jlongArray jresult = (*jenv)->NewLongArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jlong)result[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* jlong[] support */
+static int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (jlong*) calloc(sz, sizeof(jlong));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (jlong)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jlong)carr[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, input, jarr, 0);
+}
+
+static jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) {
+ jlong *arr;
+ int i;
+ jlongArray jresult = (*jenv)->NewLongArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jlong)result[i];
+ (*jenv)->ReleaseLongArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* float[] support */
+static int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetFloatArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (float*) calloc(sz, sizeof(float));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (float)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jfloat)carr[i];
+ (*jenv)->ReleaseFloatArrayElements(jenv, input, jarr, 0);
+}
+
+static jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) {
+ jfloat *arr;
+ int i;
+ jfloatArray jresult = (*jenv)->NewFloatArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetFloatArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jfloat)result[i];
+ (*jenv)->ReleaseFloatArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+/* double[] support */
+static int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) {
+ int i;
+ jsize sz;
+ if (!input) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array");
+ return 0;
+ }
+ sz = (*jenv)->GetArrayLength(jenv, input);
+ *jarr = (*jenv)->GetDoubleArrayElements(jenv, input, 0);
+ if (!*jarr)
+ return 0;
+ *carr = (double*) calloc(sz, sizeof(double));
+ if (!*carr) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed");
+ return 0;
+ }
+ for (i=0; i<sz; i++)
+ (*carr)[i] = (double)(*jarr)[i];
+ return 1;
+}
+
+static void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input) {
+ int i;
+ jsize sz = (*jenv)->GetArrayLength(jenv, input);
+ for (i=0; i<sz; i++)
+ jarr[i] = (jdouble)carr[i];
+ (*jenv)->ReleaseDoubleArrayElements(jenv, input, jarr, 0);
+}
+
+static jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) {
+ jdouble *arr;
+ int i;
+ jdoubleArray jresult = (*jenv)->NewDoubleArray(jenv, sz);
+ if (!jresult)
+ return NULL;
+ arr = (*jenv)->GetDoubleArrayElements(jenv, jresult, 0);
+ if (!arr)
+ return NULL;
+ for (i=0; i<sz; i++)
+ arr[i] = (jdouble)result[i];
+ (*jenv)->ReleaseDoubleArrayElements(jenv, jresult, arr, 0);
+ return jresult;
+}
+
+
+static CELTMode *wrap_celt_mode_create(int Fs, int frame_size) {
+ return celt_mode_create(Fs, frame_size, NULL);
+}
+
+
+static CELTEncoder *wrap_celt_encoder_create(const CELTMode *mode, int channels) {
+ return celt_encoder_create(mode, channels, NULL);
+}
+
+
+static int wrap_celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCompressedBytes) {
+ return celt_encode(st, pcm, NULL, compressed, nbCompressedBytes);
+}
+
+
+static CELTDecoder *wrap_celt_decoder_create(const CELTMode *mode, int channels) {
+ return celt_decoder_create(mode, channels, NULL);
+}
+
+
+typedef struct SpeexResamplerState SpeexResamplerState;
+extern SpeexResamplerState *speex_resampler_init(int nb_channels,
+ int in_rate,
+ int out_rate,
+ int quality,
+ int *err);
+
+
+static SpeexResamplerState *wrap_speex_resampler_init(unsigned int nb_channels, unsigned int in_rate, unsigned int out_rate, int quality) {
+ return speex_resampler_init(nb_channels, in_rate, out_rate, quality, NULL);
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT jlong JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1mode_1create(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2) {
+ jlong jresult = 0 ;
+ int arg1 ;
+ int arg2 ;
+ CELTMode *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = (int)jarg1;
+ arg2 = (int)jarg2;
+ result = (CELTMode *)wrap_celt_mode_create(arg1,arg2);
+ *(CELTMode **)&jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1mode_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+ CELTMode *arg1 = (CELTMode *) 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTMode **)&jarg1;
+ celt_mode_destroy(arg1);
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1mode_1info(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jintArray jarg3) {
+ jint jresult = 0 ;
+ CELTMode *arg1 = (CELTMode *) 0 ;
+ int arg2 ;
+ int *arg3 = (int *) 0 ;
+ int temp3 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTMode **)&jarg1;
+ arg2 = (int)jarg2;
+ {
+ if (!jarg3) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return 0;
+ }
+ if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return 0;
+ }
+ arg3 = &temp3;
+ }
+ result = (int)celt_mode_info((struct CELTMode const *)arg1,arg2,arg3);
+ jresult = (jint)result;
+ {
+ jint jvalue = (jint)temp3;
+ (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue);
+ }
+
+ return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1encoder_1create(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
+ jlong jresult = 0 ;
+ CELTMode *arg1 = (CELTMode *) 0 ;
+ int arg2 ;
+ CELTEncoder *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTMode **)&jarg1;
+ arg2 = (int)jarg2;
+ result = (CELTEncoder *)wrap_celt_encoder_create((struct CELTMode const *)arg1,arg2);
+ *(CELTEncoder **)&jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1encoder_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+ CELTEncoder *arg1 = (CELTEncoder *) 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTEncoder **)&jarg1;
+ celt_encoder_destroy(arg1);
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1encode(JNIEnv *jenv, jclass jcls, jlong jarg1, jshortArray jarg2, jshortArray jarg3, jint jarg4) {
+ jint jresult = 0 ;
+ CELTEncoder *arg1 = (CELTEncoder *) 0 ;
+ short *arg2 = (short *) 0 ;
+ unsigned char *arg3 = (unsigned char *) 0 ;
+ int arg4 ;
+ jshort *jarr2 ;
+ jshort *jarr3 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTEncoder **)&jarg1;
+ if (!SWIG_JavaArrayInShort(jenv, &jarr2, &arg2, jarg2)) return 0;
+ if (!SWIG_JavaArrayInUchar(jenv, &jarr3, &arg3, jarg3)) return 0;
+ arg4 = (int)jarg4;
+ result = (int)wrap_celt_encode(arg1,arg2,arg3,arg4);
+ jresult = (jint)result;
+ SWIG_JavaArrayArgoutShort(jenv, jarr2, arg2, jarg2);
+ SWIG_JavaArrayArgoutUchar(jenv, jarr3, arg3, jarg3);
+ free(arg2);
+ free(arg3);
+ return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1encoder_1ctl(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3) {
+ jint jresult = 0 ;
+ CELTEncoder *arg1 = (CELTEncoder *) 0 ;
+ int arg2 ;
+ int arg3 = (int) 0 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTEncoder **)&jarg1;
+ arg2 = (int)jarg2;
+ arg3 = (int)jarg3;
+ result = (int)celt_encoder_ctl(arg1,arg2,arg3);
+ jresult = (jint)result;
+ return jresult;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1decoder_1create(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
+ jlong jresult = 0 ;
+ CELTMode *arg1 = (CELTMode *) 0 ;
+ int arg2 ;
+ CELTDecoder *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTMode **)&jarg1;
+ arg2 = (int)jarg2;
+ result = (CELTDecoder *)wrap_celt_decoder_create((struct CELTMode const *)arg1,arg2);
+ *(CELTDecoder **)&jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1decoder_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+ CELTDecoder *arg1 = (CELTDecoder *) 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(CELTDecoder **)&jarg1;
+ celt_decoder_destroy(arg1);
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_celt_1decode(JNIEnv *jenv, jclass jcls, jlong jarg1, jshortArray jarg2, jint jarg3, jshortArray jarg4) {
+ (void)jcls;
+ int i;
+
+ CELTDecoder *arg1 = *(CELTDecoder **)&jarg1;
+ jshort *jarr2 = (*jenv)->GetShortArrayElements(jenv, jarg2, 0);
+ jshort *jarr4 = (*jenv)->GetShortArrayElements(jenv, jarg4, 0);
+ if (!jarr2 || !jarr4) return 0;
+
+ int arg3 = (int)jarg3;
+ unsigned char *arg2 = (unsigned char *)malloc(arg3);
+ for (i = 0; i < arg3; ++i) {
+ arg2[i] = (unsigned char)jarr2[i];
+ }
+ (*jenv)->ReleaseShortArrayElements(jenv, jarg2, jarr2, 0);
+
+ int result = celt_decode(arg1, arg2, arg3, jarr4);
+
+ (*jenv)->ReleaseShortArrayElements(jenv, jarg4, jarr4, 0);
+ free(arg2);
+
+ return (jint)result;
+}
+
+
+SWIGEXPORT jlong JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_speex_1resampler_1init(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jint jarg4) {
+ jlong jresult = 0 ;
+ unsigned int arg1 ;
+ unsigned int arg2 ;
+ unsigned int arg3 ;
+ int arg4 ;
+ SpeexResamplerState *result = 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = (unsigned int)jarg1;
+ arg2 = (unsigned int)jarg2;
+ arg3 = (unsigned int)jarg3;
+ arg4 = (int)jarg4;
+ result = (SpeexResamplerState *)wrap_speex_resampler_init(arg1,arg2,arg3,arg4);
+ *(SpeexResamplerState **)&jresult = result;
+ return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_speex_1resampler_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+ SpeexResamplerState *arg1 = (SpeexResamplerState *) 0 ;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(SpeexResamplerState **)&jarg1;
+ speex_resampler_destroy(arg1);
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pcgod_mumbleclient_jni_celtJNI_speex_1resampler_1process_1int(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jshortArray jarg3, jintArray jarg4, jshortArray jarg5, jintArray jarg6) {
+ jint jresult = 0 ;
+ SpeexResamplerState *arg1 = (SpeexResamplerState *) 0 ;
+ int arg2 ;
+ short *arg3 = (short *) 0 ;
+ int *arg4 = (int *) 0 ;
+ short *arg5 = (short *) 0 ;
+ int *arg6 = (int *) 0 ;
+ jshort *jarr3 ;
+ jshort *jarr5 ;
+ int result;
+
+ (void)jenv;
+ (void)jcls;
+ arg1 = *(SpeexResamplerState **)&jarg1;
+ arg2 = (int)jarg2;
+ if (!SWIG_JavaArrayInShort(jenv, &jarr3, &arg3, jarg3)) return 0;
+ {
+ if (!jarg4) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return 0;
+ }
+ if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return 0;
+ }
+ arg4 = (int *) (*jenv)->GetIntArrayElements(jenv, jarg4, 0);
+ }
+ if (!SWIG_JavaArrayInShort(jenv, &jarr5, &arg5, jarg5)) return 0;
+ {
+ if (!jarg6) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
+ return 0;
+ }
+ if ((*jenv)->GetArrayLength(jenv, jarg6) == 0) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
+ return 0;
+ }
+ arg6 = (int *) (*jenv)->GetIntArrayElements(jenv, jarg6, 0);
+ }
+ result = (int)speex_resampler_process_int(arg1,arg2,(short const *)arg3,arg4,arg5,arg6);
+ jresult = (jint)result;
+ SWIG_JavaArrayArgoutShort(jenv, jarr3, arg3, jarg3);
+ {
+ (*jenv)->ReleaseIntArrayElements(jenv, jarg4, (jint *)arg4, 0);
+ }
+ SWIG_JavaArrayArgoutShort(jenv, jarr5, arg5, jarg5);
+ {
+ (*jenv)->ReleaseIntArrayElements(jenv, jarg6, (jint *)arg6, 0);
+ }
+ free(arg3);
+
+ free(arg5);
+
+ return jresult;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
View
3  jni/celt_wrapper/regen-wrapper.sh
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-swig -java -package 'org.pcgod.mumbleclient.jni' celt.i
Please sign in to comment.
Something went wrong with that request. Please try again.