* #27232: jni: added pjproject checkout as regular git content
We will remove it once the next release of pjsip (with Android support)
comes out and is merged into SFLphone.
diff --git a/jni/pjproject-android/.svn/pristine/b0/b00f5c46322d930af8d9259a5d938c0cda67fa7f.svn-base b/jni/pjproject-android/.svn/pristine/b0/b00f5c46322d930af8d9259a5d938c0cda67fa7f.svn-base
new file mode 100644
index 0000000..6c59943
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/b0/b00f5c46322d930af8d9259a5d938c0cda67fa7f.svn-base
@@ -0,0 +1,83 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjlib.h>
+#include <pjlib-util.h>
+
+/*
+ * md5.h
+ */
+PJ_EXPORT_SYMBOL(md5_init)
+PJ_EXPORT_SYMBOL(md5_append)
+PJ_EXPORT_SYMBOL(md5_finish)
+
+/*
+ * scanner.h
+ */
+PJ_EXPORT_SYMBOL(pj_cs_init)
+PJ_EXPORT_SYMBOL(pj_cs_set)
+PJ_EXPORT_SYMBOL(pj_cs_add_range)
+PJ_EXPORT_SYMBOL(pj_cs_add_alpha)
+PJ_EXPORT_SYMBOL(pj_cs_add_num)
+PJ_EXPORT_SYMBOL(pj_cs_add_str)
+PJ_EXPORT_SYMBOL(pj_cs_del_range)
+PJ_EXPORT_SYMBOL(pj_cs_del_str)
+PJ_EXPORT_SYMBOL(pj_cs_invert)
+PJ_EXPORT_SYMBOL(pj_scan_init)
+PJ_EXPORT_SYMBOL(pj_scan_fini)
+PJ_EXPORT_SYMBOL(pj_scan_peek)
+PJ_EXPORT_SYMBOL(pj_scan_peek_n)
+PJ_EXPORT_SYMBOL(pj_scan_peek_until)
+PJ_EXPORT_SYMBOL(pj_scan_get)
+PJ_EXPORT_SYMBOL(pj_scan_get_quote)
+PJ_EXPORT_SYMBOL(pj_scan_get_n)
+PJ_EXPORT_SYMBOL(pj_scan_get_char)
+PJ_EXPORT_SYMBOL(pj_scan_get_newline)
+PJ_EXPORT_SYMBOL(pj_scan_get_until)
+PJ_EXPORT_SYMBOL(pj_scan_get_until_ch)
+PJ_EXPORT_SYMBOL(pj_scan_get_until_chr)
+PJ_EXPORT_SYMBOL(pj_scan_advance_n)
+PJ_EXPORT_SYMBOL(pj_scan_strcmp)
+PJ_EXPORT_SYMBOL(pj_scan_stricmp)
+PJ_EXPORT_SYMBOL(pj_scan_skip_whitespace)
+PJ_EXPORT_SYMBOL(pj_scan_save_state)
+PJ_EXPORT_SYMBOL(pj_scan_restore_state)
+
+/*
+ * stun.h
+ */
+PJ_EXPORT_SYMBOL(pj_stun_create_bind_req)
+PJ_EXPORT_SYMBOL(pj_stun_parse_msg)
+PJ_EXPORT_SYMBOL(pj_stun_msg_find_attr)
+PJ_EXPORT_SYMBOL(pj_stun_get_mapped_addr)
+PJ_EXPORT_SYMBOL(pj_stun_get_err_msg)
+
+/*
+ * xml.h
+ */
+PJ_EXPORT_SYMBOL(pj_xml_parse)
+PJ_EXPORT_SYMBOL(pj_xml_print)
+PJ_EXPORT_SYMBOL(pj_xml_add_node)
+PJ_EXPORT_SYMBOL(pj_xml_add_attr)
+PJ_EXPORT_SYMBOL(pj_xml_find_node)
+PJ_EXPORT_SYMBOL(pj_xml_find_next_node)
+PJ_EXPORT_SYMBOL(pj_xml_find_attr)
+PJ_EXPORT_SYMBOL(pj_xml_find)
+
+
diff --git a/jni/pjproject-android/.svn/pristine/b0/b026ccea0d47d450204f116cab6a25c766cfa3bf.svn-base b/jni/pjproject-android/.svn/pristine/b0/b026ccea0d47d450204f116cab6a25c766cfa3bf.svn-base
new file mode 100644
index 0000000..7904594
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/b0/b026ccea0d47d450204f116cab6a25c766cfa3bf.svn-base
@@ -0,0 +1,106 @@
+
+# PJMEDIA features exclusion
+export CFLAGS +=
+
+# Define the desired sound device backend
+# Valid values are:
+# - pa_unix: PortAudio on Unix (OSS or ALSA)
+# - pa_darwinos: PortAudio on MacOSX (CoreAudio)
+# - pa_old_darwinos: PortAudio on MacOSX (old CoreAudio, for OSX 10.2)
+# - pa_win32: PortAudio on Win32 (WMME)
+# - ds: Win32 DirectSound (dsound.c)
+# - null: Null sound device (nullsound.c)
+AC_PJMEDIA_SND=pa_old_darwinos
+
+# For Unix, specify if ALSA should be supported
+AC_PA_USE_ALSA=0
+
+#
+# Codecs
+#
+AC_NO_G711_CODEC=0
+AC_NO_L16_CODEC=0
+AC_NO_GSM_CODEC=0
+AC_NO_SPEEX_CODEC=0
+AC_NO_ILBC_CODEC=0
+AC_NO_G722_CODEC=0
+AC_NO_G7221_CODEC=0
+
+export CODEC_OBJS=
+
+ifeq ($(AC_NO_G711_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G711_CODEC=0
+else
+export CODEC_OBJS +=
+endif
+
+ifeq ($(AC_NO_L16_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_L16_CODEC=0
+else
+export CODEC_OBJS += l16.o
+endif
+
+ifeq ($(AC_NO_GSM_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_GSM_CODEC=0
+else
+export CODEC_OBJS += gsm.o
+endif
+
+ifeq ($(AC_NO_SPEEX_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_SPEEX_CODEC=0
+else
+export CFLAGS += -I$(THIRD_PARTY)/build/speex -I$(THIRD_PARTY)/speex/include
+export CODEC_OBJS += speex_codec.o
+
+#ifeq (@ac_no_speex_aec@,1)
+ifeq (0,1)
+export PJMEDIA_OBJS += echo_speex.o
+endif
+
+endif
+
+ifeq ($(AC_NO_ILBC_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_ILBC_CODEC=0
+else
+export CODEC_OBJS += ilbc.o
+endif
+
+ifeq ($(AC_NO_G722_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G722_CODEC=0
+else
+export CODEC_OBJS += g722.o g722/g722_enc.o g722/g722_dec.o
+endif
+
+ifeq ($(AC_NO_G7221_CODEC),1)
+export CFLAGS += -DPJMEDIA_HAS_G7221_CODEC=0
+else
+export CODEC_OBJS += g7221.o
+export G7221_CFLAGS += -I$(THIRD_PARTY)
+endif
+
+
+#
+# PortAudio
+#
+ifneq ($(findstring pa,$(AC_PJMEDIA_SND)),)
+export CFLAGS += -I$(THIRD_PARTY)/build/portaudio -I$(THIRD_PARTY)/portaudio/include -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
+export SOUND_OBJS = pasound.o
+endif
+
+#
+# Win32 DirectSound
+#
+ifeq ($(AC_PJMEDIA_SND),ds)
+export SOUND_OBJS = dsound.o
+export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_WIN32_DIRECT_SOUND
+endif
+
+#
+# Last resort, null sound device
+#
+ifeq ($(AC_PJMEDIA_SND),null)
+export SOUND_OBJS = nullsound.o
+export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_NULL_SOUND
+endif
+
+
diff --git a/jni/pjproject-android/.svn/pristine/b0/b045db9dae2b8df306557b539e0687b0bb2d6062.svn-base b/jni/pjproject-android/.svn/pristine/b0/b045db9dae2b8df306557b539e0687b0bb2d6062.svn-base
new file mode 100644
index 0000000..480c834
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/b0/b045db9dae2b8df306557b539e0687b0bb2d6062.svn-base
@@ -0,0 +1,217 @@
+
+ /******************************************************************
+
+ iLBC Speech Coder ANSI-C Source Code
+
+ iLBC_define.h
+
+ Copyright (C) The Internet Society (2004).
+ All Rights Reserved.
+
+ ******************************************************************/
+ #include <string.h>
+
+ #ifndef __iLBC_ILBCDEFINE_H
+ #define __iLBC_ILBCDEFINE_H
+
+ /* general codec settings */
+
+ #define FS (float)8000.0
+ #define BLOCKL_20MS 160
+ #define BLOCKL_30MS 240
+ #define BLOCKL_MAX 240
+ #define NSUB_20MS 4
+ #define NSUB_30MS 6
+ #define NSUB_MAX 6
+ #define NASUB_20MS 2
+
+
+
+
+
+ #define NASUB_30MS 4
+ #define NASUB_MAX 4
+ #define SUBL 40
+ #define STATE_LEN 80
+ #define STATE_SHORT_LEN_30MS 58
+ #define STATE_SHORT_LEN_20MS 57
+
+ /* LPC settings */
+
+ #define LPC_FILTERORDER 10
+ #define LPC_CHIRP_SYNTDENUM (float)0.9025
+ #define LPC_CHIRP_WEIGHTDENUM (float)0.4222
+ #define LPC_LOOKBACK 60
+ #define LPC_N_20MS 1
+ #define LPC_N_30MS 2
+ #define LPC_N_MAX 2
+ #define LPC_ASYMDIFF 20
+ #define LPC_BW (float)60.0
+ #define LPC_WN (float)1.0001
+ #define LSF_NSPLIT 3
+ #define LSF_NUMBER_OF_STEPS 4
+ #define LPC_HALFORDER (LPC_FILTERORDER/2)
+
+ /* cb settings */
+
+ #define CB_NSTAGES 3
+ #define CB_EXPAND 2
+ #define CB_MEML 147
+ #define CB_FILTERLEN 2*4
+ #define CB_HALFFILTERLEN 4
+ #define CB_RESRANGE 34
+ #define CB_MAXGAIN (float)1.3
+
+ /* enhancer */
+
+ #define ENH_BLOCKL 80 /* block length */
+ #define ENH_BLOCKL_HALF (ENH_BLOCKL/2)
+ #define ENH_HL 3 /* 2*ENH_HL+1 is number blocks
+ in said second sequence */
+ #define ENH_SLOP 2 /* max difference estimated and
+ correct pitch period */
+ #define ENH_PLOCSL 20 /* pitch-estimates and pitch-
+ locations buffer length */
+ #define ENH_OVERHANG 2
+ #define ENH_UPS0 4 /* upsampling rate */
+ #define ENH_FL0 3 /* 2*FLO+1 is the length of
+ each filter */
+ #define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0)
+
+
+
+
+
+ #define ENH_CORRDIM (2*ENH_SLOP+1)
+ #define ENH_NBLOCKS (BLOCKL_MAX/ENH_BLOCKL)
+ #define ENH_NBLOCKS_EXTRA 5
+ #define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS +
+ ENH_NBLOCKS_EXTRA */
+ #define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL
+ #define ENH_ALPHA0 (float)0.05
+
+ /* Down sampling */
+
+ #define FILTERORDER_DS 7
+ #define DELAY_DS 3
+ #define FACTOR_DS 2
+
+ /* bit stream defs */
+
+ #define NO_OF_BYTES_20MS 38
+ #define NO_OF_BYTES_30MS 50
+ #define NO_OF_WORDS_20MS 19
+ #define NO_OF_WORDS_30MS 25
+ #define STATE_BITS 3
+ #define BYTE_LEN 8
+ #define ULP_CLASSES 3
+
+ /* help parameters */
+
+ #define FLOAT_MAX (float)1.0e37
+ #define EPS (float)2.220446049250313e-016
+ #define PI (float)3.14159265358979323846
+ #define MIN_SAMPLE -32768
+ #define MAX_SAMPLE 32767
+ #define TWO_PI (float)6.283185307
+ #define PI2 (float)0.159154943
+
+ /* type definition encoder instance */
+ typedef struct iLBC_ULP_Inst_t_ {
+ int lsf_bits[6][ULP_CLASSES+2];
+ int start_bits[ULP_CLASSES+2];
+ int startfirst_bits[ULP_CLASSES+2];
+ int scale_bits[ULP_CLASSES+2];
+ int state_bits[ULP_CLASSES+2];
+ int extra_cb_index[CB_NSTAGES][ULP_CLASSES+2];
+ int extra_cb_gain[CB_NSTAGES][ULP_CLASSES+2];
+ int cb_index[NSUB_MAX][CB_NSTAGES][ULP_CLASSES+2];
+ int cb_gain[NSUB_MAX][CB_NSTAGES][ULP_CLASSES+2];
+ } iLBC_ULP_Inst_t;
+
+ /* type definition encoder instance */
+
+
+
+
+
+ typedef struct iLBC_Enc_Inst_t_ {
+
+ /* flag for frame size mode */
+ int mode;
+
+ /* basic parameters for different frame sizes */
+ int blockl;
+ int nsub;
+ int nasub;
+ int no_of_bytes, no_of_words;
+ int lpc_n;
+ int state_short_len;
+ const iLBC_ULP_Inst_t *ULP_inst;
+
+ /* analysis filter state */
+ float anaMem[LPC_FILTERORDER];
+
+ /* old lsf parameters for interpolation */
+ float lsfold[LPC_FILTERORDER];
+ float lsfdeqold[LPC_FILTERORDER];
+
+ /* signal buffer for LP analysis */
+ float lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX];
+
+ /* state of input HP filter */
+ float hpimem[4];
+
+ } iLBC_Enc_Inst_t;
+
+ /* type definition decoder instance */
+ typedef struct iLBC_Dec_Inst_t_ {
+
+ /* flag for frame size mode */
+ int mode;
+
+ /* basic parameters for different frame sizes */
+ int blockl;
+ int nsub;
+ int nasub;
+ int no_of_bytes, no_of_words;
+ int lpc_n;
+ int state_short_len;
+ const iLBC_ULP_Inst_t *ULP_inst;
+
+ /* synthesis filter state */
+ float syntMem[LPC_FILTERORDER];
+
+ /* old LSF for interpolation */
+
+
+
+
+
+ float lsfdeqold[LPC_FILTERORDER];
+
+ /* pitch lag estimated in enhancer and used in PLC */
+ int last_lag;
+
+ /* PLC state information */
+ int prevLag, consPLICount, prevPLI, prev_enh_pl;
+ float prevLpc[LPC_FILTERORDER+1];
+ float prevResidual[NSUB_MAX*SUBL];
+ float per;
+ unsigned long seed;
+
+ /* previous synthesis filter parameters */
+ float old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX];
+
+ /* state of output HP filter */
+ float hpomem[4];
+
+ /* enhancer state information */
+ int use_enhancer;
+ float enh_buf[ENH_BUFL];
+ float enh_period[ENH_NBLOCKS_TOT];
+
+ } iLBC_Dec_Inst_t;
+
+ #endif
+
diff --git a/jni/pjproject-android/.svn/pristine/b0/b052df1285be7554fb21057c712822a4c252617a.svn-base b/jni/pjproject-android/.svn/pristine/b0/b052df1285be7554fb21057c712822a4c252617a.svn-base
new file mode 100644
index 0000000..cfa9403
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/b0/b052df1285be7554fb21057c712822a4c252617a.svn-base
@@ -0,0 +1,41 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# In this test we simulate broken server, where it wants to
+# change the nonce, but it fails to set stale to true. In this
+# case, we should expect pjsip to retry the authentication until
+# PJSIP_MAX_STALE_COUNT is exceeded as it should have detected
+# that that nonce has changed
+
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+ "--realm=python --user=username --password=password " + \
+ "--auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Initial request", 401,
+ include=["REGISTER sip"],
+ exclude=["Authorization"],
+ resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"1\""]
+ )
+
+req2 = sip.RecvfromTransaction("First retry", 401,
+ include=["REGISTER sip", "Authorization", "nonce=\"1\""],
+ exclude=["Authorization:[\\s\\S]+Authorization:"],
+ resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"2\""]
+ )
+
+req3 = sip.RecvfromTransaction("Second retry retry", 401,
+ include=["REGISTER sip", "Authorization", "nonce=\"2\""],
+ exclude=["Authorization:[\\s\\S]+Authorization:"],
+ resp_hdr=["WWW-Authenticate: Digest realm=\"python\", nonce=\"3\""]
+ )
+
+req4 = sip.RecvfromTransaction("Third retry", 200,
+ include=["REGISTER sip", "Authorization", "nonce=\"3\""],
+ exclude=["Authorization:[\\s\\S]+Authorization:"],
+ expect="registration success"
+ )
+
+recvfrom_cfg = sip.RecvfromCfg("Successful auth server changes nonce but with stale=false",
+ pjsua, [req1, req2, req3, req4])
diff --git a/jni/pjproject-android/.svn/pristine/b0/b0b813683f31feb12d8515760b675d3bb649d94e.svn-base b/jni/pjproject-android/.svn/pristine/b0/b0b813683f31feb12d8515760b675d3bb649d94e.svn-base
new file mode 100644
index 0000000..6d1f1a0
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/b0/b0b813683f31feb12d8515760b675d3bb649d94e.svn-base
@@ -0,0 +1,207 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjmedia/resample.h>
+#include <pjmedia/errno.h>
+#include <pj/assert.h>
+#include <pj/log.h>
+#include <pj/pool.h>
+
+/*
+ * HOW TO ACTIVATE LIBSAMPLERATE (a.k.a SRC/Secret Rabbit Code) AS
+ * PJMEDIA'S SAMPLE RATE CONVERSION BACKEND
+ *
+ * See README.txt in third_party/samplerate directory.
+ */
+
+
+#if PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_LIBSAMPLERATE
+
+#include "../../third_party/libsamplerate/src/samplerate.h"
+
+#define THIS_FILE "resample_libsamplerate.c"
+
+#if defined(_MSC_VER)
+# ifdef _DEBUG
+# pragma comment( lib, "../../third_party/lib/libsamplerate-i386-win32-vc-debug.lib")
+# else
+# pragma comment( lib, "../../third_party/lib/libsamplerate-i386-win32-vc-release.lib")
+# endif
+#endif
+
+
+struct pjmedia_resample
+{
+ SRC_STATE *state;
+ unsigned in_samples;
+ unsigned out_samples;
+ float *frame_in, *frame_out;
+ unsigned in_extra, out_extra;
+ double ratio;
+};
+
+
+PJ_DEF(pj_status_t) pjmedia_resample_create( pj_pool_t *pool,
+ pj_bool_t high_quality,
+ pj_bool_t large_filter,
+ unsigned channel_count,
+ unsigned rate_in,
+ unsigned rate_out,
+ unsigned samples_per_frame,
+ pjmedia_resample **p_resample)
+{
+ pjmedia_resample *resample;
+ int type, err;
+
+ PJ_ASSERT_RETURN(pool && p_resample && rate_in &&
+ rate_out && samples_per_frame, PJ_EINVAL);
+
+ resample = PJ_POOL_ZALLOC_T(pool, pjmedia_resample);
+ PJ_ASSERT_RETURN(resample, PJ_ENOMEM);
+
+ /* Select conversion type */
+ if (high_quality) {
+ type = large_filter ? SRC_SINC_BEST_QUALITY : SRC_SINC_MEDIUM_QUALITY;
+ } else {
+ type = large_filter ? SRC_SINC_FASTEST : SRC_LINEAR;
+ }
+
+ /* Create converter */
+ resample->state = src_new(type, channel_count, &err);
+ if (resample->state == NULL) {
+ PJ_LOG(4,(THIS_FILE, "Error creating resample: %s",
+ src_strerror(err)));
+ return PJMEDIA_ERROR;
+ }
+
+ /* Calculate ratio */
+ resample->ratio = rate_out * 1.0 / rate_in;
+
+ /* Calculate number of samples for input and output */
+ resample->in_samples = samples_per_frame;
+ resample->out_samples = rate_out / (rate_in / samples_per_frame);
+
+ resample->frame_in = (float*)
+ pj_pool_calloc(pool,
+ resample->in_samples + 8,
+ sizeof(float));
+
+ resample->frame_out = (float*)
+ pj_pool_calloc(pool,
+ resample->out_samples + 8,
+ sizeof(float));
+
+ /* Set the converter ratio */
+ err = src_set_ratio(resample->state, resample->ratio);
+ if (err != 0) {
+ PJ_LOG(4,(THIS_FILE, "Error creating resample: %s",
+ src_strerror(err)));
+ return PJMEDIA_ERROR;
+ }
+
+ /* Done */
+
+ PJ_LOG(5,(THIS_FILE,
+ "Resample using libsamplerate %s, type=%s (%s), "
+ "ch=%d, in/out rate=%d/%d",
+ src_get_version(),
+ src_get_name(type), src_get_description(type),
+ channel_count, rate_in, rate_out));
+
+ *p_resample = resample;
+
+ return PJ_SUCCESS;
+}
+
+
+PJ_DEF(void) pjmedia_resample_run( pjmedia_resample *resample,
+ const pj_int16_t *input,
+ pj_int16_t *output )
+{
+ SRC_DATA src_data;
+
+ /* Convert samples to float */
+ src_short_to_float_array(input, resample->frame_in,
+ resample->in_samples);
+
+ if (resample->in_extra) {
+ unsigned i;
+
+ for (i=0; i<resample->in_extra; ++i)
+ resample->frame_in[resample->in_samples+i] =
+ resample->frame_in[resample->in_samples-1];
+ }
+
+ /* Prepare SRC_DATA */
+ pj_bzero(&src_data, sizeof(src_data));
+ src_data.data_in = resample->frame_in;
+ src_data.data_out = resample->frame_out;
+ src_data.input_frames = resample->in_samples + resample->in_extra;
+ src_data.output_frames = resample->out_samples + resample->out_extra;
+ src_data.src_ratio = resample->ratio;
+
+ /* Process! */
+ src_process(resample->state, &src_data);
+
+ /* Convert output back to short */
+ src_float_to_short_array(resample->frame_out, output,
+ src_data.output_frames_gen);
+
+ /* Replay last sample if conversion couldn't fill up the whole
+ * frame. This could happen for example with 22050 to 16000 conversion.
+ */
+ if (src_data.output_frames_gen < (int)resample->out_samples) {
+ unsigned i;
+
+ if (resample->in_extra < 4)
+ resample->in_extra++;
+
+ for (i=src_data.output_frames_gen;
+ i<resample->out_samples; ++i)
+ {
+ output[i] = output[src_data.output_frames_gen-1];
+ }
+ }
+}
+
+
+PJ_DEF(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample)
+{
+ PJ_ASSERT_RETURN(resample != NULL, 0);
+ return resample->in_samples;
+}
+
+
+PJ_DEF(void) pjmedia_resample_destroy(pjmedia_resample *resample)
+{
+ PJ_ASSERT_ON_FAIL(resample, return);
+ if (resample->state) {
+ src_delete(resample->state);
+ resample->state = NULL;
+
+ PJ_LOG(5,(THIS_FILE, "Resample destroyed"));
+ }
+}
+
+#else /* PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_LIBSAMPLERATE */
+
+int pjmedia_libsamplerate_excluded;
+
+#endif /* PJMEDIA_RESAMPLE_IMP==PJMEDIA_RESAMPLE_LIBSAMPLERATE */
+