* #36737: switch back to svn repo, remove assert in sip_transaction.c
diff --git a/jni/pjproject-android/.svn/pristine/33/3356c29f41f86de274e7d76232abbc796a0ca920.svn-base b/jni/pjproject-android/.svn/pristine/33/3356c29f41f86de274e7d76232abbc796a0ca920.svn-base
new file mode 100644
index 0000000..c705c96
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/33/3356c29f41f86de274e7d76232abbc796a0ca920.svn-base
@@ -0,0 +1,275 @@
+# $Id$
+
+## Automatic test module for SIPp.
+##
+## This module will need a test driver for each SIPp scenario:
+## - For simple scenario, i.e: make/receive call (including auth), this
+##   test module can auto-generate a default test driver, i.e: make call
+##   or apply auto answer. Just name the SIPp scenario using "uas" or
+##   "uac" prefix accordingly.
+## - Custom test driver can be defined in a python script file containing
+##   a list of the PJSUA instances and another list for PJSUA expects/
+##   commands. The custom test driver file must use the same filename as
+##   the SIPp XML scenario. See samples of SIPp scenario + its driver
+##   in tests/pjsua/scripts-sipp/ folder for detail.
+##
+##   Here are defined macros that can be used in the custom driver:
+##   - $SIPP_PORT	    : SIPp binding port
+##   - $SIPP_URI	    : SIPp SIP URI
+##   - $PJSUA_PORT[N]	    : binding port of PJSUA instance #N
+##   - $PJSUA_URI[N]	    : SIP URI of PJSUA instance #N
+
+import ctypes
+import time
+import imp
+import sys
+import os
+import re
+import subprocess
+from inc_cfg import *
+import inc_const
+
+# flags that test is running in Unix
+G_INUNIX = False
+if sys.platform.lower().find("win32")!=-1 or sys.platform.lower().find("microsoft")!=-1:
+    G_INUNIX = False
+else:
+    G_INUNIX = True
+
+# /dev/null handle, for redirecting output when SIPP is not in background mode
+FDEVNULL = None
+
+# SIPp executable path and param
+#SIPP_PATH = '"C:\\Program Files (x86)\\Sipp_3.2\\sipp.exe"'
+SIPP_PATH = 'sipp'
+SIPP_PORT    = 6000
+SIPP_PARAM = "-m 1 -i 127.0.0.1 -p " + str(SIPP_PORT)
+SIPP_TIMEOUT = 60
+# On BG mode, SIPp doesn't require special terminal
+# On non-BG mode, on win, it needs env var: "TERMINFO=c:\cygwin\usr\share\terminfo"
+# TODO: on unix with BG mode, waitpid() always fails, need to be fixed
+SIPP_BG_MODE = False
+#SIPP_BG_MODE = not G_INUNIX
+
+# Will be updated based on the test driver file (a .py file whose the same name as SIPp XML file)
+PJSUA_INST_PARAM = []
+PJSUA_EXPECTS = []
+
+# Default PJSUA param if test driver is not available:
+# - no-tcp as SIPp is on UDP only
+# - id, username, and realm: to allow PJSUA sending re-INVITE with auth after receiving 401/407 response
+PJSUA_DEF_PARAM = "--null-audio --max-calls=1 --no-tcp --id=sip:a@localhost --username=a --realm=*"
+
+# Get SIPp scenario (XML file)
+SIPP_SCEN_XML  = ""
+if ARGS[1].endswith('.xml'):
+    SIPP_SCEN_XML  = ARGS[1]
+else:
+    exit(-99)
+
+
+# Functions for resolving macros in the test driver
+def resolve_pjsua_port(mo):
+    return str(PJSUA_INST_PARAM[int(mo.group(1))].sip_port)
+
+def resolve_pjsua_uri(mo):
+    return PJSUA_INST_PARAM[int(mo.group(1))].uri[1:-1]
+
+def resolve_driver_macros(st):
+    st = re.sub("\$SIPP_PORT", str(SIPP_PORT), st)
+    st = re.sub("\$SIPP_URI", "sip:sipp@127.0.0.1:"+str(SIPP_PORT), st)
+    st = re.sub("\$PJSUA_PORT\[(\d+)\]", resolve_pjsua_port, st)
+    st = re.sub("\$PJSUA_URI\[(\d+)\]", resolve_pjsua_uri, st)
+    return st
+
+
+# Init test driver
+if os.access(SIPP_SCEN_XML[:-4]+".py", os.R_OK):
+    # Load test driver file (the corresponding .py file), if any
+    cfg_file = imp.load_source("cfg_file", SIPP_SCEN_XML[:-4]+".py")
+    for ua_idx, ua_param in enumerate(cfg_file.PJSUA):
+	ua_param = resolve_driver_macros(ua_param)
+	PJSUA_INST_PARAM.append(InstanceParam("pjsua"+str(ua_idx), ua_param))
+    PJSUA_EXPECTS = cfg_file.PJSUA_EXPECTS
+else:
+    # Generate default test driver
+    if os.path.basename(SIPP_SCEN_XML)[0:3] == "uas":
+	# auto make call when SIPp is as UAS
+	ua_param = PJSUA_DEF_PARAM + " sip:127.0.0.1:" + str(SIPP_PORT)
+    else:
+	# auto answer when SIPp is as UAC
+	ua_param = PJSUA_DEF_PARAM + " --auto-answer=200" 
+    PJSUA_INST_PARAM.append(InstanceParam("pjsua", ua_param))
+
+
+# Start SIPp process, returning PID
+def start_sipp():
+    global SIPP_BG_MODE
+    sipp_proc = None
+
+    sipp_param = SIPP_PARAM + " -sf " + SIPP_SCEN_XML
+    if SIPP_BG_MODE:
+	sipp_param = sipp_param + " -bg"
+    if SIPP_TIMEOUT:
+	sipp_param = sipp_param + " -timeout "+str(SIPP_TIMEOUT)+"s -timeout_error" + " -deadcall_wait "+str(SIPP_TIMEOUT)+"s"
+
+    # add target param
+    sipp_param = sipp_param + " 127.0.0.1:" + str(PJSUA_INST_PARAM[0].sip_port)
+
+    # run SIPp
+    fullcmd = os.path.normpath(SIPP_PATH) + " " + sipp_param
+    print "Running SIPP: " + fullcmd
+    if SIPP_BG_MODE:
+	sipp_proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=G_INUNIX, universal_newlines=False)
+    else:
+	# redirect output to NULL
+	global FDEVNULL
+	#FDEVNULL  = open(os.devnull, 'w')
+	FDEVNULL  = open("logs/sipp_output.tmp", 'w')
+	sipp_proc = subprocess.Popen(fullcmd, shell=G_INUNIX, stdout=FDEVNULL, stderr=FDEVNULL)
+
+    if not SIPP_BG_MODE:
+	if sipp_proc == None or sipp_proc.poll():
+	    return None
+	return sipp_proc
+
+    else:
+	# get SIPp child process PID
+	pid = 0
+	r = re.compile("PID=\[(\d+)\]", re.I)
+
+	while True:
+	    line = sipp_proc.stdout.readline()
+	    pid_r = r.search(line)
+	    if pid_r:
+		pid = int(pid_r.group(1))
+		break
+	    if not sipp_proc.poll():
+		break
+
+	if pid != 0:
+	    # Win specific: get process handle from PID, as on win32, os.waitpid() takes process handle instead of pid
+	    if (sys.platform == "win32"):
+		SYNCHRONIZE = 0x00100000
+		PROCESS_QUERY_INFORMATION = 0x0400
+		hnd = ctypes.windll.kernel32.OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, False, pid)
+		pid = hnd
+
+	return pid
+
+
+# Wait SIPp process to exit, returning SIPp exit code
+def wait_sipp(sipp):
+    if not SIPP_BG_MODE:
+	global FDEVNULL
+	sipp.wait()
+	FDEVNULL.close()
+	return sipp.returncode
+
+    else:
+	print "Waiting SIPp (PID=" + str(sipp) + ") to exit.."
+	wait_cnt = 0
+	while True:
+	    try:
+		wait_cnt = wait_cnt + 1
+		[pid_, ret_code] = os.waitpid(sipp, 0)
+		if sipp == pid_:
+		    #print "SIPP returned ", ret_code
+		    ret_code = ret_code >> 8
+
+		    # Win specific: Close process handle
+		    if (sys.platform == "win32"):
+			ctypes.windll.kernel32.CloseHandle(sipp)
+		    
+		    return ret_code
+	    except os.error:
+		if wait_cnt <= 5:
+		    print "Retry ("+str(wait_cnt)+") waiting SIPp.."
+		else:
+		    return -99
+
+
+# Execute PJSUA flow
+def exec_pjsua_expects(t, sipp):
+    # Get all PJSUA instances
+    ua = []
+    for ua_idx in range(len(PJSUA_INST_PARAM)):
+	ua.append(t.process[ua_idx])
+
+    ua_err_st = ""
+    while len(PJSUA_EXPECTS):
+	expect = PJSUA_EXPECTS.pop(0)
+	ua_idx = expect[0]
+	expect_st = expect[1]
+	send_cmd = resolve_driver_macros(expect[2])
+	# Handle exception in pjsua flow, to avoid zombie SIPp process
+	try:
+	    if expect_st != "":
+		ua[ua_idx].expect(expect_st, raise_on_error = True)
+	    if send_cmd != "":
+		ua[ua_idx].send(send_cmd)
+	except TestError, e:
+	    ua_err_st = e.desc
+	    break;
+	except:
+	    ua_err_st = "Unknown error"
+	    break;
+
+    # Need to poll here for handling these cases:
+    # - If there is no PJSUA EXPECT scenario, we must keep polling the stdout,
+    #   otherwise PJSUA process may stuck (due to stdout pipe buffer full?).
+    # - last PJSUA_EXPECT contains a pjsua command that needs time to
+    #   finish, for example "v" (re-INVITE), the SIPp XML scenario may expect
+    #   that re-INVITE transaction to be completed and without stdout poll
+    #   PJSUA process may stuck.
+    # Ideally the poll should be done contiunously until SIPp process is
+    # terminated.
+    for ua_idx in range(len(ua)):
+	ua[ua_idx].expect(inc_const.STDOUT_REFRESH, raise_on_error = False)
+
+    return ua_err_st
+
+
+def sipp_err_to_str(err_code):
+    if err_code == 0:
+	return "All calls were successful"
+    elif err_code == 1:
+	return "At least one call failed"
+    elif err_code == 97:
+	return "exit on internal command. Calls may have been processed"
+    elif err_code == 99:
+	return "Normal exit without calls processed"
+    elif err_code == -1:
+	return "Fatal error (timeout)"
+    elif err_code == -2:
+	return "Fatal error binding a socket"
+    else:
+	return "Unknown error"
+
+
+# Test body function
+def TEST_FUNC(t):
+
+    sipp_ret_code = 0
+    ua_err_st = ""
+
+    sipp = start_sipp()
+    if not sipp:
+	raise TestError("Failed starting SIPp")
+
+    ua_err_st = exec_pjsua_expects(t, sipp)
+
+    sipp_ret_code = wait_sipp(sipp)
+
+    if ua_err_st != "":
+	raise TestError(ua_err_st)
+
+    if sipp_ret_code:
+	rc = ctypes.c_byte(sipp_ret_code).value
+        raise TestError("SIPp returned error " + str(rc) + ": " + sipp_err_to_str(rc))
+
+
+# Here where it all comes together
+test = TestParam(SIPP_SCEN_XML[:-4],
+		 PJSUA_INST_PARAM,
+		 TEST_FUNC)
diff --git a/jni/pjproject-android/.svn/pristine/33/3377d5b775a54738e31a4018614648f03e22dc2f.svn-base b/jni/pjproject-android/.svn/pristine/33/3377d5b775a54738e31a4018614648f03e22dc2f.svn-base
new file mode 100644
index 0000000..a7fec50
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/33/3377d5b775a54738e31a4018614648f03e22dc2f.svn-base
@@ -0,0 +1,11 @@
+#ifdef _MSC_VER
+#   pragma warning(disable: 4100)   // unreferenced formal parameter
+#   pragma warning(disable: 4101)   // unreferenced local variable
+#   pragma warning(disable: 4244)   // conversion from 'double ' to 'float '
+#   pragma warning(disable: 4305)   // truncation from 'const double ' to 'float '
+#   pragma warning(disable: 4018)   // signed/unsigned mismatch
+//#   pragma warning(disable: 4701)   // local variable used without initialized
+#endif
+
+#include <string.h>
+#include "../../gsm/inc/config.h"
diff --git a/jni/pjproject-android/.svn/pristine/33/33af35b96c03c9b9976138d69f217f6a6bd4b9b0.svn-base b/jni/pjproject-android/.svn/pristine/33/33af35b96c03c9b9976138d69f217f6a6bd4b9b0.svn-base
new file mode 100644
index 0000000..f6275b8
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/33/33af35b96c03c9b9976138d69f217f6a6bd4b9b0.svn-base
@@ -0,0 +1,297 @@
+/*
+Copyright (c) 2003-2004, Mark Borgerding
+
+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 author nor the names of any 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.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "os_support.h"
+#include "kiss_fftr.h"
+#include "_kiss_fft_guts.h"
+
+struct kiss_fftr_state{
+    kiss_fft_cfg substate;
+    kiss_fft_cpx * tmpbuf;
+    kiss_fft_cpx * super_twiddles;
+#ifdef USE_SIMD    
+    long pad;
+#endif    
+};
+
+kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
+{
+    int i;
+    kiss_fftr_cfg st = NULL;
+    size_t subsize, memneeded;
+
+    if (nfft & 1) {
+        speex_warning("Real FFT optimization must be even.\n");
+        return NULL;
+    }
+    nfft >>= 1;
+
+    kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize);
+    memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2);
+
+    if (lenmem == NULL) {
+        st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
+    } else {
+        if (*lenmem >= memneeded)
+            st = (kiss_fftr_cfg) mem;
+        *lenmem = memneeded;
+    }
+    if (!st)
+        return NULL;
+
+    st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */
+    st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize);
+    st->super_twiddles = st->tmpbuf + nfft;
+    kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
+
+#ifdef FIXED_POINT
+    for (i=0;i<nfft;++i) {
+       spx_word32_t phase = i+(nfft>>1);
+       if (!inverse_fft)
+          phase = -phase;
+       kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft));
+    }
+#else
+    for (i=0;i<nfft;++i) {
+       const double pi=3.14159265358979323846264338327;
+       double phase = pi*(((double)i) /nfft + .5);
+       if (!inverse_fft)
+          phase = -phase;
+       kf_cexp(st->super_twiddles+i, phase );
+    }
+#endif
+    return st;
+}
+
+void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata)
+{
+    /* input buffer timedata is stored row-wise */
+    int k,ncfft;
+    kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
+
+    if ( st->substate->inverse) {
+        speex_fatal("kiss fft usage error: improper alloc\n");
+    }
+
+    ncfft = st->substate->nfft;
+
+    /*perform the parallel fft of two real signals packed in real,imag*/
+    kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
+    /* The real part of the DC element of the frequency spectrum in st->tmpbuf
+     * contains the sum of the even-numbered elements of the input time sequence
+     * The imag part is the sum of the odd-numbered elements
+     *
+     * The sum of tdc.r and tdc.i is the sum of the input time sequence. 
+     *      yielding DC of input time sequence
+     * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... 
+     *      yielding Nyquist bin of input time sequence
+     */
+ 
+    tdc.r = st->tmpbuf[0].r;
+    tdc.i = st->tmpbuf[0].i;
+    C_FIXDIV(tdc,2);
+    CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
+    CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
+    freqdata[0].r = tdc.r + tdc.i;
+    freqdata[ncfft].r = tdc.r - tdc.i;
+#ifdef USE_SIMD    
+    freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0);
+#else
+    freqdata[ncfft].i = freqdata[0].i = 0;
+#endif
+
+    for ( k=1;k <= ncfft/2 ; ++k ) {
+        fpk    = st->tmpbuf[k]; 
+        fpnk.r =   st->tmpbuf[ncfft-k].r;
+        fpnk.i = - st->tmpbuf[ncfft-k].i;
+        C_FIXDIV(fpk,2);
+        C_FIXDIV(fpnk,2);
+
+        C_ADD( f1k, fpk , fpnk );
+        C_SUB( f2k, fpk , fpnk );
+        C_MUL( tw , f2k , st->super_twiddles[k]);
+
+        freqdata[k].r = HALF_OF(f1k.r + tw.r);
+        freqdata[k].i = HALF_OF(f1k.i + tw.i);
+        freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r);
+        freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i);
+    }
+}
+
+void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata, kiss_fft_scalar *timedata)
+{
+    /* input buffer timedata is stored row-wise */
+    int k, ncfft;
+
+    if (st->substate->inverse == 0) {
+        speex_fatal("kiss fft usage error: improper alloc\n");
+    }
+
+    ncfft = st->substate->nfft;
+
+    st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r;
+    st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r;
+    /*C_FIXDIV(st->tmpbuf[0],2);*/
+
+    for (k = 1; k <= ncfft / 2; ++k) {
+        kiss_fft_cpx fk, fnkc, fek, fok, tmp;
+        fk = freqdata[k];
+        fnkc.r = freqdata[ncfft - k].r;
+        fnkc.i = -freqdata[ncfft - k].i;
+        /*C_FIXDIV( fk , 2 );
+        C_FIXDIV( fnkc , 2 );*/
+
+        C_ADD (fek, fk, fnkc);
+        C_SUB (tmp, fk, fnkc);
+        C_MUL (fok, tmp, st->super_twiddles[k]);
+        C_ADD (st->tmpbuf[k],     fek, fok);
+        C_SUB (st->tmpbuf[ncfft - k], fek, fok);
+#ifdef USE_SIMD        
+        st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0);
+#else
+        st->tmpbuf[ncfft - k].i *= -1;
+#endif
+    }
+    kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
+}
+
+void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata)
+{
+   /* input buffer timedata is stored row-wise */
+   int k,ncfft;
+   kiss_fft_cpx f2k,tdc;
+   spx_word32_t f1kr, f1ki, twr, twi;
+
+   if ( st->substate->inverse) {
+      speex_fatal("kiss fft usage error: improper alloc\n");
+   }
+
+   ncfft = st->substate->nfft;
+
+   /*perform the parallel fft of two real signals packed in real,imag*/
+   kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
+    /* The real part of the DC element of the frequency spectrum in st->tmpbuf
+   * contains the sum of the even-numbered elements of the input time sequence
+   * The imag part is the sum of the odd-numbered elements
+   *
+   * The sum of tdc.r and tdc.i is the sum of the input time sequence. 
+   *      yielding DC of input time sequence
+   * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... 
+   *      yielding Nyquist bin of input time sequence
+    */
+ 
+   tdc.r = st->tmpbuf[0].r;
+   tdc.i = st->tmpbuf[0].i;
+   C_FIXDIV(tdc,2);
+   CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
+   CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
+   freqdata[0] = tdc.r + tdc.i;
+   freqdata[2*ncfft-1] = tdc.r - tdc.i;
+
+   for ( k=1;k <= ncfft/2 ; ++k )
+   {
+      /*fpk    = st->tmpbuf[k]; 
+      fpnk.r =   st->tmpbuf[ncfft-k].r;
+      fpnk.i = - st->tmpbuf[ncfft-k].i;
+      C_FIXDIV(fpk,2);
+      C_FIXDIV(fpnk,2);
+
+      C_ADD( f1k, fpk , fpnk );
+      C_SUB( f2k, fpk , fpnk );
+      
+      C_MUL( tw , f2k , st->super_twiddles[k]);
+
+      freqdata[2*k-1] = HALF_OF(f1k.r + tw.r);
+      freqdata[2*k] = HALF_OF(f1k.i + tw.i);
+      freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r);
+      freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i);
+      */
+
+      /*f1k.r = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1);
+      f1k.i = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1);
+      f2k.r = PSHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1);
+      f2k.i = SHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1);
+      
+      C_MUL( tw , f2k , st->super_twiddles[k]);
+
+      freqdata[2*k-1] = HALF_OF(f1k.r + tw.r);
+      freqdata[2*k] = HALF_OF(f1k.i + tw.i);
+      freqdata[2*(ncfft-k)-1] = HALF_OF(f1k.r - tw.r);
+      freqdata[2*(ncfft-k)] = HALF_OF(tw.i - f1k.i);
+   */
+      f2k.r = SHR32(SUB32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),1);
+      f2k.i = PSHR32(ADD32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),1);
+      
+      f1kr = SHL32(ADD32(EXTEND32(st->tmpbuf[k].r), EXTEND32(st->tmpbuf[ncfft-k].r)),13);
+      f1ki = SHL32(SUB32(EXTEND32(st->tmpbuf[k].i), EXTEND32(st->tmpbuf[ncfft-k].i)),13);
+      
+      twr = SHR32(SUB32(MULT16_16(f2k.r,st->super_twiddles[k].r),MULT16_16(f2k.i,st->super_twiddles[k].i)), 1);
+      twi = SHR32(ADD32(MULT16_16(f2k.i,st->super_twiddles[k].r),MULT16_16(f2k.r,st->super_twiddles[k].i)), 1);
+      
+#ifdef FIXED_POINT
+      freqdata[2*k-1] = PSHR32(f1kr + twr, 15);
+      freqdata[2*k] = PSHR32(f1ki + twi, 15);
+      freqdata[2*(ncfft-k)-1] = PSHR32(f1kr - twr, 15);
+      freqdata[2*(ncfft-k)] = PSHR32(twi - f1ki, 15);
+#else
+      freqdata[2*k-1] = .5f*(f1kr + twr);
+      freqdata[2*k] = .5f*(f1ki + twi);
+      freqdata[2*(ncfft-k)-1] = .5f*(f1kr - twr);
+      freqdata[2*(ncfft-k)] = .5f*(twi - f1ki);
+      
+#endif
+   }
+}
+
+void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata,kiss_fft_scalar *timedata)
+{
+   /* input buffer timedata is stored row-wise */
+   int k, ncfft;
+
+   if (st->substate->inverse == 0) {
+      speex_fatal ("kiss fft usage error: improper alloc\n");
+   }
+
+   ncfft = st->substate->nfft;
+
+   st->tmpbuf[0].r = freqdata[0] + freqdata[2*ncfft-1];
+   st->tmpbuf[0].i = freqdata[0] - freqdata[2*ncfft-1];
+   /*C_FIXDIV(st->tmpbuf[0],2);*/
+
+   for (k = 1; k <= ncfft / 2; ++k) {
+      kiss_fft_cpx fk, fnkc, fek, fok, tmp;
+      fk.r = freqdata[2*k-1];
+      fk.i = freqdata[2*k];
+      fnkc.r = freqdata[2*(ncfft - k)-1];
+      fnkc.i = -freqdata[2*(ncfft - k)];
+        /*C_FIXDIV( fk , 2 );
+      C_FIXDIV( fnkc , 2 );*/
+
+      C_ADD (fek, fk, fnkc);
+      C_SUB (tmp, fk, fnkc);
+      C_MUL (fok, tmp, st->super_twiddles[k]);
+      C_ADD (st->tmpbuf[k],     fek, fok);
+      C_SUB (st->tmpbuf[ncfft - k], fek, fok);
+#ifdef USE_SIMD        
+      st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0);
+#else
+      st->tmpbuf[ncfft - k].i *= -1;
+#endif
+   }
+   kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
+}
diff --git a/jni/pjproject-android/.svn/pristine/33/33b5fc091810703c15de4c3d1bd2c19bb2b00bff.svn-base b/jni/pjproject-android/.svn/pristine/33/33b5fc091810703c15de4c3d1bd2c19bb2b00bff.svn-base
new file mode 100644
index 0000000..a2a59ab
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/33/33b5fc091810703c15de4c3d1bd2c19bb2b00bff.svn-base
@@ -0,0 +1,410 @@
+/* $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.h>
+#include <pjlib.h>
+#include <stdio.h>
+
+#define THIS_FILE	"audio_tool.c"
+
+static pj_caching_pool caching_pool;
+static pj_pool_factory *pf;
+static FILE *fhnd;
+static pj_med_mgr_t *mm;
+static pjmedia_codec *codec;
+static pjmedia_codec_param cattr;
+
+
+#define WRITE_ORIGINAL_PCM 0
+#if WRITE_ORIGINAL_PCM
+static FILE *fhnd_pcm;
+#endif
+
+static char talker_sdp[] = 
+    "v=0\r\n"
+    "o=- 0 0 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 4002 RTP/AVP 0\r\n"
+    "a=rtpmap:0 PCMU/8000\r\n"
+    "a=sendonly\r\n";
+static char listener_sdp[] = 
+    "v=0\r\n"
+    "o=- 0 0 IN IP4 127.0.0.1\r\n"
+    "s=-\r\n"
+    "c=IN IP4 127.0.0.1\r\n"
+    "t=0 0\r\n"
+    "m=audio 4000 RTP/AVP 0\r\n"
+    "a=rtpmap:0 PCMU/8000\r\n"
+    "a=recvonly\r\n";
+
+static pj_status_t play_callback(/* in */   void *user_data,
+				 /* in */   pj_uint32_t timestamp,
+				 /* out */  void *frame,
+				 /* out */  unsigned size)
+{
+    char pkt[160];
+    struct pjmedia_frame in, out;
+    int frmsz = cattr.avg_bps / 8 * cattr.ptime / 1000;
+
+    if (fread(pkt, frmsz, 1, fhnd) != 1) {
+	puts("EOF");
+	return -1;
+    } else {
+	in.type = PJMEDIA_FRAME_TYPE_AUDIO;
+	in.buf = pkt;
+	in.size = frmsz;
+	out.buf = frame;
+	if (codec->op->decode (codec, &in, size, &out) != 0)
+	    return -1;
+
+	size = out.size;
+	return 0;
+    }
+}
+
+static pj_status_t rec_callback( /* in */   void *user_data,
+			         /* in */   pj_uint32_t timestamp,
+			         /* in */   const void *frame,
+			         /* in*/    unsigned size)
+{
+    char pkt[160];
+    struct pjmedia_frame in, out;
+    //int frmsz = cattr.avg_bps / 8 * cattr.ptime / 1000;
+
+#if WRITE_ORIGINAL_PCM
+    fwrite(frame, size, 1, fhnd_pcm);
+#endif
+
+    in.type = PJMEDIA_FRAME_TYPE_AUDIO;
+    in.buf = (void*)frame;
+    in.size = size;
+    out.buf = pkt;
+
+    if (codec->op->encode(codec, &in, sizeof(pkt), &out) != 0)
+	return -1;
+
+    if (fwrite(pkt, out.size, 1, fhnd) != 1)
+	return -1;
+    return 0;
+}
+
+static pj_status_t init()
+{
+    pjmedia_codec_mgr *cm;
+    pjmedia_codec_info id;
+    int i;
+
+    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
+    pf = &caching_pool.factory;
+
+    if (pj_snd_init(&caching_pool.factory))
+	return -1;
+
+    PJ_LOG(3,(THIS_FILE, "Dumping audio devices:"));
+    for (i=0; i<pj_snd_get_dev_count(); ++i) {
+	const pj_snd_dev_info *info;
+	info = pj_snd_get_dev_info(i);
+	PJ_LOG(3,(THIS_FILE, "  %d: %s\t(%d in, %d out", 
+			     i, info->name, 
+			     info->input_count, info->output_count));
+    }
+
+    mm = pj_med_mgr_create (&caching_pool.factory);
+    cm = pj_med_mgr_get_codec_mgr (mm);
+
+    id.type = PJMEDIA_TYPE_AUDIO;
+    id.pt = 0;
+    id.encoding_name = pj_str("PCMU");
+    id.sample_rate = 8000;
+
+    codec = pjmedia_codec_mgr_alloc_codec (cm, &id);
+    codec->op->default_attr(codec, &cattr);
+    codec->op->open(codec, &cattr);
+    return 0;
+}
+
+static pj_status_t deinit()
+{
+    pjmedia_codec_mgr *cm;
+    cm = pj_med_mgr_get_codec_mgr (mm);
+    codec->op->close(codec);
+    pjmedia_codec_mgr_dealloc_codec (cm, codec);
+    pj_med_mgr_destroy (mm);
+    pj_caching_pool_destroy(&caching_pool);
+    return 0;
+}
+
+static pj_status_t record_file (const char *filename)
+{
+    pj_snd_stream *stream;
+    pj_snd_stream_info info;
+    int status;
+    char s[10];
+
+    printf("Recording to file %s...\n", filename);
+
+    fhnd = fopen(filename, "wb");
+    if (!fhnd)
+	return -1;
+
+#if WRITE_ORIGINAL_PCM
+    fhnd_pcm = fopen("ORIGINAL.PCM", "wb");
+    if (!fhnd_pcm)
+	return -1;
+#endif
+
+    pj_bzero(&info, sizeof(info));
+    info.bits_per_sample = 16;
+    info.bytes_per_frame = 2;
+    info.frames_per_packet = 160;
+    info.samples_per_frame = 1;
+    info.samples_per_sec = 8000;
+
+    stream = pj_snd_open_recorder(-1, &info, &rec_callback, NULL);
+    if (!stream)
+	return -1;
+
+    status = pj_snd_stream_start(stream);
+    if (status != 0)
+	goto on_error;
+
+    puts("Press <ENTER> to exit recording");
+    fgets(s, sizeof(s), stdin);
+
+    pj_snd_stream_stop(stream);
+    pj_snd_stream_close(stream);
+
+#if WRITE_ORIGINAL_PCM
+    fclose(fhnd_pcm);
+#endif
+    fclose(fhnd);
+    return 0;
+
+on_error:
+    pj_snd_stream_stop(stream);
+    pj_snd_stream_close(stream);
+    return -1;
+}
+
+
+static pj_status_t play_file (const char *filename)
+{
+    pj_snd_stream *stream;
+    pj_snd_stream_info info;
+    int status;
+    char s[10];
+
+    printf("Playing file %s...\n", filename);
+
+    fhnd = fopen(filename, "rb");
+    if (!fhnd)
+	return -1;
+
+    pj_bzero(&info, sizeof(info));
+    info.bits_per_sample = 16;
+    info.bytes_per_frame = 2;
+    info.frames_per_packet = 160;
+    info.samples_per_frame = 1;
+    info.samples_per_sec = 8000;
+
+    stream = pj_snd_open_player(-1, &info, &play_callback, NULL);
+    if (!stream)
+	return -1;
+
+    status = pj_snd_stream_start(stream);
+    if (status != 0)
+	goto on_error;
+
+    puts("Press <ENTER> to exit playing");
+    fgets(s, sizeof(s), stdin);
+
+    pj_snd_stream_stop(stream);
+    pj_snd_stream_close(stream);
+
+    fclose(fhnd);
+    return 0;
+
+on_error:
+    pj_snd_stream_stop(stream);
+    pj_snd_stream_close(stream);
+    return -1;
+}
+
+static int create_ses_by_remote_sdp(int local_port, char *sdp)
+{
+    pj_media_session_t *ses = NULL;
+    pjsdp_session_desc *sdp_ses;
+    pj_media_sock_info skinfo;
+    pj_pool_t *pool;
+    char s[4];
+    const pj_media_stream_info *info[2];
+    int i, count;
+
+    pool = pj_pool_create(pf, "sdp", 1024, 0, NULL);
+    if (!pool) {
+	PJ_LOG(1,(THIS_FILE, "Unable to create pool"));
+	return -1;
+    }
+
+    pj_bzero(&skinfo, sizeof(skinfo));
+    skinfo.rtp_sock = skinfo.rtcp_sock = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, 0);
+    if (skinfo.rtp_sock == PJ_INVALID_SOCKET) {
+	PJ_LOG(1,(THIS_FILE, "Unable to create socket"));
+	goto on_error;
+    }
+
+    pj_sockaddr_init2(&skinfo.rtp_addr_name, "0.0.0.0", local_port);
+    if (pj_sock_bind(skinfo.rtp_sock, (struct pj_sockaddr*)&skinfo.rtp_addr_name, sizeof(pj_sockaddr_in)) != 0) {
+	PJ_LOG(1,(THIS_FILE, "Unable to bind socket"));
+	goto on_error;
+    }
+
+    sdp_ses = pjsdp_parse(sdp, strlen(sdp), pool);
+    if (!sdp_ses) {
+	PJ_LOG(1,(THIS_FILE, "Error parsing SDP"));
+	goto on_error;
+    }
+
+    ses = pj_media_session_create_from_sdp(mm, sdp_ses, &skinfo);
+    if (!ses) {
+	PJ_LOG(1,(THIS_FILE, "Unable to create session from SDP"));
+	goto on_error;
+    }
+
+    if (pj_media_session_activate(ses) != 0) {
+	PJ_LOG(1,(THIS_FILE, "Error activating session"));
+	goto on_error;
+    }
+
+    count = pj_media_session_enum_streams(ses, 2, info);
+    printf("\nDumping streams: \n");
+    for (i=0; i<count; ++i) {
+	const char *dir;
+	char *local_ip;
+
+	switch (info[i]->dir) {
+	case PJMEDIA_DIR_NONE:
+	    dir = "- NONE -"; break;
+	case PJMEDIA_DIR_ENCODING:
+	    dir = "SENDONLY"; break;
+	case PJMEDIA_DIR_DECODING:
+	    dir = "RECVONLY"; break;
+	case PJMEDIA_DIR_ENCODING_DECODING:
+	    dir = "SENDRECV"; break;
+	default:
+	    dir = "?UNKNOWN"; break;
+	}
+
+	local_ip = pj_sockaddr_get_str_addr(&info[i]->sock_info.rtp_addr_name);
+
+	printf("  Stream %d: %.*s %s local=%s:%d remote=%.*s:%d\n",
+	       i, info[i]->type.slen, info[i]->type.ptr,
+	       dir, 
+	       local_ip, pj_sockaddr_get_port(&info[i]->sock_info.rtp_addr_name),
+	       info[i]->rem_addr.slen, info[i]->rem_addr.ptr, info[i]->rem_port);
+    }
+
+    puts("Press <ENTER> to quit");
+    fgets(s, sizeof(s), stdin);
+
+    pj_media_session_destroy(ses);
+    pj_sock_close(skinfo.rtp_sock);
+    pj_pool_release(pool);
+
+    return 0;
+
+on_error:
+    if (ses)
+	pj_media_session_destroy(ses);
+    if (skinfo.rtp_sock != PJ_INVALID_SOCKET)
+	pj_sock_close(skinfo.rtp_sock);
+    if (pool)
+	pj_pool_release(pool);
+    return -1;
+}
+
+#if WRITE_ORIGINAL_PCM
+static pj_status_t convert(const char *src, const char *dst)
+{
+    char pcm[320];
+    char frame[160];
+    struct pjmedia_frame in, out;
+
+    fhnd_pcm = fopen(src, "rb");
+    if (!fhnd_pcm)
+	return -1;
+    fhnd = fopen(dst, "wb");
+    if (!fhnd)
+	return -1;
+
+    while (fread(pcm, 320, 1, fhnd_pcm) == 1) {
+
+	in.type = PJMEDIA_FRAME_TYPE_AUDIO;
+	in.buf = pcm;
+	in.size = 320;
+	out.buf = frame;
+
+	if (codec->op->encode(codec, &in, 160, &out) != 0)
+	    break;
+
+	if (fwrite(frame, out.size, 1, fhnd) != 1)
+	    break;
+
+    }
+
+    fclose(fhnd);
+    fclose(fhnd_pcm);
+    return 0;
+}
+#endif
+
+static void usage(const char *exe)
+{
+    printf("Usage: %s <command> <file>\n", exe);
+    puts("where:");
+    puts("  <command>     play|record|send|recv");
+}
+
+int main(int argc, char *argv[])
+{
+    if (argc < 2) {
+	usage(argv[0]);
+	return 1;
+    }
+
+    pj_init();
+
+    init();
+
+    if (stricmp(argv[1], "record")==0) {
+	record_file("FILE.PCM");
+    } else if (stricmp(argv[1], "play")==0) {
+	play_file("FILE.PCM");
+    } else if (stricmp(argv[1], "send")==0) {
+	create_ses_by_remote_sdp(4002, listener_sdp);
+    } else if (stricmp(argv[1], "recv")==0) {
+	create_ses_by_remote_sdp(4000, talker_sdp);
+    } else {
+	usage(argv[0]);
+    }
+    deinit();
+    return 0;
+}
diff --git a/jni/pjproject-android/.svn/pristine/33/33c715f71fba9eec67cc5dbeccbc4bdc50bb8a7c.svn-base b/jni/pjproject-android/.svn/pristine/33/33c715f71fba9eec67cc5dbeccbc4bdc50bb8a7c.svn-base
new file mode 100644
index 0000000..9b83a9d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/33/33c715f71fba9eec67cc5dbeccbc4bdc50bb8a7c.svn-base
@@ -0,0 +1,54 @@
+#if defined(PJ_BUILD_DLL)
+
+TARGET		pjsip_simple.dll
+TARGETTYPE	dll
+
+UID		0x0 0xA0000008
+
+
+CAPABILITY	None
+LIBRARY		pjsip.lib pjsdp.lib pjlib_util.lib pjlib.lib esock.lib insock.lib charconv.lib euser.lib estlib.lib
+MACRO		PJ_DLL
+MACRO		PJ_EXPORTING
+
+DEFFILE		.\pjsip_simple.def
+
+#else
+
+TARGET 		pjsip_simple.lib
+TARGETTYPE 	lib
+
+#endif
+
+SOURCEPATH	..\pjsip\src\pjsip-simple
+
+MACRO		PJ_M_I386=1
+MACRO		PJ_SYMBIAN=1
+
+// Must compile as C++, otherwise exception would not work
+OPTION          CW -lang c++
+OPTION          ARMCC --cpp --gnu
+OPTION          GCC     -x c++
+OPTION          GCCE    -x c++
+
+// PJSIP-SIMPLE files
+
+SOURCE	errno.c
+SOURCE	evsub.c
+SOURCE	evsub_msg.c
+SOURCE	iscomposing.c
+SOURCE	mwi.c
+SOURCE	pidf.c
+SOURCE	presence.c
+SOURCE	presence_body.c
+SOURCE	publishc.c
+SOURCE	rpid.c
+SOURCE	xpidf.c
+
+SYSTEMINCLUDE	..\pjlib\include 
+SYSTEMINCLUDE	..\pjlib-util\include 
+SYSTEMINCLUDE	..\pjsip\include
+
+SYSTEMINCLUDE	\epoc32\include
+SYSTEMINCLUDE	\epoc32\include\libc
+