* #36737: switch back to svn repo, remove assert in sip_transaction.c
diff --git a/jni/pjproject-android/.svn/pristine/12/122453b2d30ece9d58b06f2e3626eb61ec927973.svn-base b/jni/pjproject-android/.svn/pristine/12/122453b2d30ece9d58b06f2e3626eb61ec927973.svn-base
new file mode 100644
index 0000000..ca2bd13
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/122453b2d30ece9d58b06f2e3626eb61ec927973.svn-base
@@ -0,0 +1,162 @@
+/* $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 <pj/ioqueue.h>
+#include <pj/os.h>
+#include <pj/log.h>
+#include <pj/list.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+#include <pj/assert.h>
+#include <pj/sock.h>
+
+#define THIS_FILE   "ioqueue"
+
+#define PJ_IOQUEUE_IS_READ_OP(op)   \
+	((op & PJ_IOQUEUE_OP_READ)  || (op & PJ_IOQUEUE_OP_RECV_FROM))
+#define PJ_IOQUEUE_IS_WRITE_OP(op)  \
+	((op & PJ_IOQUEUE_OP_WRITE) || (op & PJ_IOQUEUE_OP_SEND_TO))
+
+
+#if PJ_HAS_TCP
+#  define PJ_IOQUEUE_IS_ACCEPT_OP(op)	(op & PJ_IOQUEUE_OP_ACCEPT)
+#  define PJ_IOQUEUE_IS_CONNECT_OP(op)	(op & PJ_IOQUEUE_OP_CONNECT)
+#else
+#  define PJ_IOQUEUE_IS_ACCEPT_OP(op)	0
+#  define PJ_IOQUEUE_IS_CONNECT_OP(op)	0
+#endif
+
+#if defined(PJ_DEBUG) && PJ_DEBUG != 0
+#  define VALIDATE_FD_SET		1
+#else
+#  define VALIDATE_FD_SET		0
+#endif
+
+struct pj_ioqueue_key_t
+{
+    PJ_DECL_LIST_MEMBER(struct pj_ioqueue_key_t)
+    pj_sock_t		    fd;
+    pj_ioqueue_operation_e  op;
+    void		   *user_data;
+    pj_ioqueue_callback	    cb;
+};
+
+struct pj_ioqueue_t
+{
+};
+
+PJ_DEF(pj_ioqueue_t*) pj_ioqueue_create(pj_pool_t *pool, pj_size_t max_fd)
+{
+    return NULL;
+}
+
+PJ_DEF(pj_status_t) pj_ioqueue_destroy(pj_ioqueue_t *ioque)
+{
+    return 0;
+}
+
+PJ_DEF(pj_ioqueue_key_t*) pj_ioqueue_register( pj_pool_t *pool,
+					       pj_ioqueue_t *ioque,
+					       pj_oshandle_t sock,
+					       void *user_data,
+					       const pj_ioqueue_callback *cb)
+{
+    return NULL;
+}
+
+PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_t *ioque,
+					   pj_ioqueue_key_t *key)
+{
+    return -1;
+}
+
+PJ_DEF(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key )
+{
+    return NULL;
+}
+
+
+PJ_DEF(int) pj_ioqueue_poll( pj_ioqueue_t *ioque, const pj_time_val *timeout)
+{
+    return -1;
+}
+
+PJ_DEF(int) pj_ioqueue_read( pj_ioqueue_t *ioque,
+			     pj_ioqueue_key_t *key,
+			     void *buffer,
+			     pj_size_t buflen)
+{
+    return -1;
+}
+
+PJ_DEF(int) pj_ioqueue_recvfrom( pj_ioqueue_t *ioque,
+				 pj_ioqueue_key_t *key,
+				 void *buffer,
+				 pj_size_t buflen,
+				 pj_sockaddr_t *addr,
+				 int *addrlen)
+{
+    return -1;
+}
+
+PJ_DEF(int) pj_ioqueue_write( pj_ioqueue_t *ioque,
+			      pj_ioqueue_key_t *key,
+			      const void *data,
+			      pj_size_t datalen)
+{
+    return -1;
+}
+
+PJ_DEF(int) pj_ioqueue_sendto( pj_ioqueue_t *ioque,
+			       pj_ioqueue_key_t *key,
+			       const void *data,
+			       pj_size_t datalen,
+			       const pj_sockaddr_t *addr,
+			       int addrlen)
+{
+    return -1;
+}
+
+#if PJ_HAS_TCP
+/*
+ * Initiate overlapped accept() operation.
+ */
+PJ_DEF(int) pj_ioqueue_accept( pj_ioqueue_t *ioqueue,
+			       pj_ioqueue_key_t *key,
+			       pj_sock_t *new_sock,
+			       pj_sockaddr_t *local,
+			       pj_sockaddr_t *remote,
+			       int *addrlen)
+{
+    return -1;
+}
+
+/*
+ * Initiate overlapped connect() operation (well, it's non-blocking actually,
+ * since there's no overlapped version of connect()).
+ */
+PJ_DEF(pj_status_t) pj_ioqueue_connect( pj_ioqueue_t *ioqueue,
+					pj_ioqueue_key_t *key,
+					const pj_sockaddr_t *addr,
+					int addrlen )
+{
+    return -1;
+}
+#endif	/* PJ_HAS_TCP */
+
diff --git a/jni/pjproject-android/.svn/pristine/12/122edfce43ea317de749c707580816a6fd9f673e.svn-base b/jni/pjproject-android/.svn/pristine/12/122edfce43ea317de749c707580816a6fd9f673e.svn-base
new file mode 100644
index 0000000..4f86b55
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/122edfce43ea317de749c707580816a6fd9f673e.svn-base
@@ -0,0 +1,427 @@
+/*
+ * datatypes.h
+ * 
+ * data types for bit vectors and finite fields
+ *
+ * David A. McGrew
+ * Cisco Systems, Inc.
+ */
+
+/*
+ *	
+ * Copyright (c) 2001-2006, Cisco Systems, Inc.
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ *   Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * 
+ *   Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ * 
+ *   Neither the name of the Cisco Systems, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS 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.
+ *
+ */
+
+
+#ifndef _DATATYPES_H
+#define _DATATYPES_H
+
+#include "integers.h"           /* definitions of uint32_t, et cetera   */
+#include "alloc.h"
+
+#include <stdarg.h>
+
+#ifndef SRTP_KERNEL
+# include <stdio.h>
+# include <string.h>
+# include <time.h>
+# ifdef HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+# elif defined HAVE_WINSOCK2_H
+#  include <winsock2.h>
+# endif
+#endif
+
+
+/* if DATATYPES_USE_MACROS is defined, then little functions are macros */
+#define DATATYPES_USE_MACROS  
+
+typedef union {
+  uint8_t  v8[2];
+  uint16_t value;
+} v16_t;
+
+typedef union {
+  uint8_t  v8[4];
+  uint16_t v16[2];
+  uint32_t value;
+} v32_t;
+
+typedef union {
+  uint8_t  v8[8];
+  uint16_t v16[4];
+  uint32_t v32[2];
+  uint64_t value;
+} v64_t;
+
+typedef union {
+  uint8_t  v8[16];
+  uint16_t v16[8];
+  uint32_t v32[4];
+  uint64_t v64[2];
+} v128_t;
+
+
+
+/* some useful and simple math functions */
+
+#define pow_2(X) ( (unsigned int)1 << (X) )   /* 2^X     */
+
+#define pow_minus_one(X) ( (X) ? -1 : 1 )      /* (-1)^X  */
+
+
+/*
+ * octet_get_weight(x) returns the hamming weight (number of bits equal to
+ * one) in the octet x
+ */
+
+int
+octet_get_weight(uint8_t octet);
+
+char *
+octet_bit_string(uint8_t x);
+
+#define MAX_PRINT_STRING_LEN 1024
+
+char *
+octet_string_hex_string(const void *str, int length);
+
+char *
+v128_bit_string(v128_t *x);
+
+char *
+v128_hex_string(v128_t *x);
+
+uint8_t
+nibble_to_hex_char(uint8_t nibble);
+
+char *
+char_to_hex_string(char *x, int num_char);
+
+uint8_t
+hex_string_to_octet(char *s);
+
+/*
+ * hex_string_to_octet_string(raw, hex, len) converts the hexadecimal
+ * string at *hex (of length len octets) to the equivalent raw data
+ * and writes it to *raw.
+ *
+ * if a character in the hex string that is not a hexadeciaml digit
+ * (0123456789abcdefABCDEF) is encountered, the function stops writing
+ * data to *raw
+ *
+ * the number of hex digits copied (which is two times the number of
+ * octets in *raw) is returned
+ */
+
+int
+hex_string_to_octet_string(char *raw, char *hex, int len);
+
+v128_t
+hex_string_to_v128(char *s);
+
+void
+v128_copy_octet_string(v128_t *x, const uint8_t s[16]);
+
+void
+v128_left_shift(v128_t *x, int index);
+
+void
+v128_right_shift(v128_t *x, int index);
+
+/*
+ * the following macros define the data manipulation functions
+ * 
+ * If DATATYPES_USE_MACROS is defined, then these macros are used
+ * directly (and function call overhead is avoided).  Otherwise,
+ * the macros are used through the functions defined in datatypes.c
+ * (and the compiler provides better warnings).
+ */
+
+#define _v128_set_to_zero(x)     \
+(                               \
+  (x)->v32[0] = 0,              \
+  (x)->v32[1] = 0,              \
+  (x)->v32[2] = 0,              \
+  (x)->v32[3] = 0               \
+)
+
+#define _v128_copy(x, y)          \
+(                                \
+  (x)->v32[0] = (y)->v32[0],     \
+  (x)->v32[1] = (y)->v32[1],     \
+  (x)->v32[2] = (y)->v32[2],     \
+  (x)->v32[3] = (y)->v32[3]      \
+)
+
+#define _v128_xor(z, x, y)                       \
+(                                               \
+   (z)->v32[0] = (x)->v32[0] ^ (y)->v32[0],     \
+   (z)->v32[1] = (x)->v32[1] ^ (y)->v32[1],     \
+   (z)->v32[2] = (x)->v32[2] ^ (y)->v32[2],     \
+   (z)->v32[3] = (x)->v32[3] ^ (y)->v32[3]      \
+)
+
+#define _v128_and(z, x, y)                       \
+(                                               \
+   (z)->v32[0] = (x)->v32[0] & (y)->v32[0],     \
+   (z)->v32[1] = (x)->v32[1] & (y)->v32[1],     \
+   (z)->v32[2] = (x)->v32[2] & (y)->v32[2],     \
+   (z)->v32[3] = (x)->v32[3] & (y)->v32[3]      \
+)
+
+#define _v128_or(z, x, y)                        \
+(                                               \
+   (z)->v32[0] = (x)->v32[0] | (y)->v32[0],     \
+   (z)->v32[1] = (x)->v32[1] | (y)->v32[1],     \
+   (z)->v32[2] = (x)->v32[2] | (y)->v32[2],     \
+   (z)->v32[3] = (x)->v32[3] | (y)->v32[3]      \
+)
+
+#define _v128_complement(x)        \
+(                                  \
+   (x)->v32[0] = ~(x)->v32[0],     \
+   (x)->v32[1] = ~(x)->v32[1],     \
+   (x)->v32[2] = ~(x)->v32[2],     \
+   (x)->v32[3] = ~(x)->v32[3]      \
+)
+
+/* ok for NO_64BIT_MATH if it can compare uint64_t's (even as structures) */
+#define _v128_is_eq(x, y)                                        \
+  (((x)->v64[0] == (y)->v64[0]) && ((x)->v64[1] == (y)->v64[1]))
+
+
+#ifdef NO_64BIT_MATH
+#define _v128_xor_eq(z, x)         \
+(                                  \
+   (z)->v32[0] ^= (x)->v32[0],     \
+   (z)->v32[1] ^= (x)->v32[1],     \
+   (z)->v32[2] ^= (x)->v32[2],     \
+   (z)->v32[3] ^= (x)->v32[3]      \
+)
+#else
+#define _v128_xor_eq(z, x)         \
+(                                  \
+   (z)->v64[0] ^= (x)->v64[0],     \
+   (z)->v64[1] ^= (x)->v64[1]      \
+)
+#endif
+
+/* NOTE!  This assumes an odd ordering! */
+/* This will not be compatible directly with math on some processors */
+/* bit 0 is first 32-bit word, low order bit. in little-endian, that's
+   the first byte of the first 32-bit word.  In big-endian, that's
+   the 3rd byte of the first 32-bit word */
+/* The get/set bit code is used by the replay code ONLY, and it doesn't
+   really care which bit is which.  AES does care which bit is which, but
+   doesn't use the 128-bit get/set or 128-bit shifts  */
+
+#define _v128_get_bit(x, bit)                     \
+(                                                 \
+  ((((x)->v32[(bit) >> 5]) >> ((bit) & 31)) & 1)  \
+)
+
+#define _v128_set_bit(x, bit)                                    \
+(                                                                \
+  (((x)->v32[(bit) >> 5]) |= ((uint32_t)1 << ((bit) & 31))) \
+)
+
+#define _v128_clear_bit(x, bit)                                   \
+(                                                                 \
+  (((x)->v32[(bit) >> 5]) &= ~((uint32_t)1 << ((bit) & 31))) \
+)
+
+#define _v128_set_bit_to(x, bit, value)   \
+(                                         \
+   (value) ? _v128_set_bit(x, bit) :      \
+             _v128_clear_bit(x, bit)      \
+)
+
+
+#if 0
+/* nothing uses this */
+#ifdef WORDS_BIGENDIAN
+
+#define _v128_add(z, x, y) {                    \
+  uint64_t tmp;					\
+    						\
+  tmp = x->v32[3] + y->v32[3];                  \
+  z->v32[3] = (uint32_t) tmp;			\
+  						\
+  tmp =  x->v32[2] + y->v32[2] + (tmp >> 32);	\
+  z->v32[2] = (uint32_t) tmp;                   \
+						\
+  tmp =  x->v32[1] + y->v32[1] + (tmp >> 32);	\
+  z->v32[1] = (uint32_t) tmp;			\
+                                                \
+  tmp =  x->v32[0] + y->v32[0] + (tmp >> 32);	\
+  z->v32[0] = (uint32_t) tmp;			\
+}
+
+#else /* assume little endian architecture */
+
+#define _v128_add(z, x, y) {                    \
+  uint64_t tmp;					\
+						\
+  tmp = htonl(x->v32[3]) + htonl(y->v32[3]);	\
+  z->v32[3] = ntohl((uint32_t) tmp);		\
+  						\
+  tmp =  htonl(x->v32[2]) + htonl(y->v32[2])	\
+       + htonl(tmp >> 32);			\
+  z->v32[2] = ntohl((uint32_t) tmp);		\
+                                                \
+  tmp =  htonl(x->v32[1]) + htonl(y->v32[1])	\
+       + htonl(tmp >> 32);			\
+  z->v32[1] = ntohl((uint32_t) tmp);		\
+  						\
+  tmp =  htonl(x->v32[0]) + htonl(y->v32[0])	\
+       + htonl(tmp >> 32);			\
+  z->v32[0] = ntohl((uint32_t) tmp);		\
+}
+#endif /* WORDS_BIGENDIAN */                      
+#endif /* 0 */
+
+
+#ifdef DATATYPES_USE_MACROS  /* little functions are really macros */
+   
+#define v128_set_to_zero(z)       _v128_set_to_zero(z)
+#define v128_copy(z, x)           _v128_copy(z, x)
+#define v128_xor(z, x, y)         _v128_xor(z, x, y)
+#define v128_and(z, x, y)         _v128_and(z, x, y)
+#define v128_or(z, x, y)          _v128_or(z, x, y)
+#define v128_complement(x)        _v128_complement(x) 
+#define v128_is_eq(x, y)          _v128_is_eq(x, y)
+#define v128_xor_eq(x, y)         _v128_xor_eq(x, y)
+#define v128_get_bit(x, i)        _v128_get_bit(x, i)
+#define v128_set_bit(x, i)        _v128_set_bit(x, i)
+#define v128_clear_bit(x, i)      _v128_clear_bit(x, i)
+#define v128_set_bit_to(x, i, y)  _v128_set_bit_to(x, i, y)
+
+#else
+
+void
+v128_set_to_zero(v128_t *x);
+
+int
+v128_is_eq(const v128_t *x, const v128_t *y);
+
+void
+v128_copy(v128_t *x, const v128_t *y);
+
+void
+v128_xor(v128_t *z, v128_t *x, v128_t *y);
+
+void
+v128_and(v128_t *z, v128_t *x, v128_t *y);
+
+void
+v128_or(v128_t *z, v128_t *x, v128_t *y); 
+
+void
+v128_complement(v128_t *x);
+
+int
+v128_get_bit(const v128_t *x, int i);
+
+void
+v128_set_bit(v128_t *x, int i) ;     
+
+void
+v128_clear_bit(v128_t *x, int i);    
+
+void
+v128_set_bit_to(v128_t *x, int i, int y);
+
+#endif /* DATATYPES_USE_MACROS */
+
+/*
+ * octet_string_is_eq(a,b, len) returns 1 if the length len strings a
+ * and b are not equal, returns 0 otherwise
+ */
+
+int
+octet_string_is_eq(uint8_t *a, uint8_t *b, int len);
+
+void
+octet_string_set_to_zero(uint8_t *s, int len);
+
+
+#ifndef SRTP_KERNEL_LINUX
+
+/* 
+ * Convert big endian integers to CPU byte order.
+ */
+#ifdef WORDS_BIGENDIAN
+/* Nothing to do. */
+# define be32_to_cpu(x)	(x)
+# define be64_to_cpu(x)	(x)
+#elif defined(HAVE_BYTESWAP_H)
+/* We have (hopefully) optimized versions in byteswap.h */
+# include <byteswap.h>
+# define be32_to_cpu(x)	bswap_32((x))
+# define be64_to_cpu(x)	bswap_64((x))
+#else
+
+#if defined(__GNUC__) && defined(HAVE_X86)
+/* Fall back. */
+static inline uint32_t be32_to_cpu(uint32_t v) {
+   /* optimized for x86. */
+   asm("bswap %0" : "=r" (v) : "0" (v));
+   return v;
+}
+# else /* HAVE_X86 */
+#  ifdef HAVE_NETINET_IN_H
+#   include <netinet/in.h>
+#  elif defined HAVE_WINSOCK2_H
+#   include <winsock2.h>
+#  endif
+#  define be32_to_cpu(x)	ntohl((x))
+# endif /* HAVE_X86 */
+
+static inline uint64_t be64_to_cpu(uint64_t v) {
+# ifdef NO_64BIT_MATH
+   /* use the make64 functions to do 64-bit math */
+   v = make64(htonl(low32(v)),htonl(high32(v)));
+# else
+   /* use the native 64-bit math */
+   v= (uint64_t)((be32_to_cpu((uint32_t)(v >> 32))) | (((uint64_t)be32_to_cpu((uint32_t)v)) << 32));
+# endif
+   return v;
+}
+
+#endif /* ! SRTP_KERNEL_LINUX */
+
+#endif /* WORDS_BIGENDIAN */
+
+#endif /* _DATATYPES_H */
diff --git a/jni/pjproject-android/.svn/pristine/12/124eae0e21f410ad267ad93da413567e98b3c972.svn-base b/jni/pjproject-android/.svn/pristine/12/124eae0e21f410ad267ad93da413567e98b3c972.svn-base
new file mode 100644
index 0000000..73305d8
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/124eae0e21f410ad267ad93da413567e98b3c972.svn-base
@@ -0,0 +1,742 @@
+/* $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/sound_port.h>
+#include <pjmedia/alaw_ulaw.h>
+#include <pjmedia/delaybuf.h>
+#include <pjmedia/echo.h>
+#include <pjmedia/errno.h>
+#include <pj/assert.h>
+#include <pj/log.h>
+#include <pj/rand.h>
+#include <pj/string.h>	    /* pj_memset() */
+
+#define AEC_TAIL	    128	    /* default AEC length in ms */
+#define AEC_SUSPEND_LIMIT   5	    /* seconds of no activity	*/
+
+#define THIS_FILE	    "sound_port.c"
+
+//#define TEST_OVERFLOW_UNDERFLOW
+
+struct pjmedia_snd_port
+{
+    int			 rec_id;
+    int			 play_id;
+    pj_uint32_t		 aud_caps;
+    pjmedia_aud_param	 aud_param;
+    pjmedia_aud_stream	*aud_stream;
+    pjmedia_dir		 dir;
+    pjmedia_port	*port;
+
+    pjmedia_clock_src    cap_clocksrc,
+                         play_clocksrc;
+
+    unsigned		 clock_rate;
+    unsigned		 channel_count;
+    unsigned		 samples_per_frame;
+    unsigned		 bits_per_sample;
+    unsigned		 options;
+    unsigned		 prm_ec_options;
+
+    /* software ec */
+    pjmedia_echo_state	*ec_state;
+    unsigned		 ec_options;
+    unsigned		 ec_tail_len;
+    pj_bool_t		 ec_suspended;
+    unsigned		 ec_suspend_count;
+    unsigned		 ec_suspend_limit;
+};
+
+/*
+ * The callback called by sound player when it needs more samples to be
+ * played.
+ */
+static pj_status_t play_cb(void *user_data, pjmedia_frame *frame)
+{
+    pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data;
+    pjmedia_port *port;
+    const unsigned required_size = (unsigned)frame->size;
+    pj_status_t status;
+
+    pjmedia_clock_src_update(&snd_port->play_clocksrc, &frame->timestamp);
+
+    port = snd_port->port;
+    if (port == NULL)
+	goto no_frame;
+
+    status = pjmedia_port_get_frame(port, frame);
+    if (status != PJ_SUCCESS)
+	goto no_frame;
+
+    if (frame->type != PJMEDIA_FRAME_TYPE_AUDIO)
+	goto no_frame;
+
+    /* Must supply the required samples */
+    pj_assert(frame->size == required_size);
+
+    if (snd_port->ec_state) {
+	if (snd_port->ec_suspended) {
+	    snd_port->ec_suspended = PJ_FALSE;
+	    //pjmedia_echo_state_reset(snd_port->ec_state);
+	    PJ_LOG(4,(THIS_FILE, "EC activated"));
+	}
+	snd_port->ec_suspend_count = 0;
+	pjmedia_echo_playback(snd_port->ec_state, (pj_int16_t*)frame->buf);
+    }
+
+
+    return PJ_SUCCESS;
+
+no_frame:
+    frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
+    frame->size = required_size;
+    pj_bzero(frame->buf, frame->size);
+
+    if (snd_port->ec_state && !snd_port->ec_suspended) {
+	++snd_port->ec_suspend_count;
+	if (snd_port->ec_suspend_count > snd_port->ec_suspend_limit) {
+	    snd_port->ec_suspended = PJ_TRUE;
+	    PJ_LOG(4,(THIS_FILE, "EC suspended because of inactivity"));
+	}
+	if (snd_port->ec_state) {
+	    /* To maintain correct delay in EC */
+	    pjmedia_echo_playback(snd_port->ec_state, (pj_int16_t*)frame->buf);
+	}
+    }
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * The callback called by sound recorder when it has finished capturing a
+ * frame.
+ */
+static pj_status_t rec_cb(void *user_data, pjmedia_frame *frame)
+{
+    pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data;
+    pjmedia_port *port;
+
+    pjmedia_clock_src_update(&snd_port->cap_clocksrc, &frame->timestamp);
+
+    port = snd_port->port;
+    if (port == NULL)
+	return PJ_SUCCESS;
+
+    /* Cancel echo */
+    if (snd_port->ec_state && !snd_port->ec_suspended) {
+	pjmedia_echo_capture(snd_port->ec_state, (pj_int16_t*) frame->buf, 0);
+    }
+
+    pjmedia_port_put_frame(port, frame);
+
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * The callback called by sound player when it needs more samples to be
+ * played. This version is for non-PCM data.
+ */
+static pj_status_t play_cb_ext(void *user_data, pjmedia_frame *frame)
+{
+    pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data;
+    pjmedia_port *port = snd_port->port;
+
+    if (port == NULL) {
+	frame->type = PJMEDIA_FRAME_TYPE_NONE;
+	return PJ_SUCCESS;
+    }
+
+    pjmedia_port_get_frame(port, frame);
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * The callback called by sound recorder when it has finished capturing a
+ * frame. This version is for non-PCM data.
+ */
+static pj_status_t rec_cb_ext(void *user_data, pjmedia_frame *frame)
+{
+    pjmedia_snd_port *snd_port = (pjmedia_snd_port*) user_data;
+    pjmedia_port *port;
+
+    port = snd_port->port;
+    if (port == NULL)
+	return PJ_SUCCESS;
+
+    pjmedia_port_put_frame(port, frame);
+
+    return PJ_SUCCESS;
+}
+
+/* Initialize with default values (zero) */
+PJ_DEF(void) pjmedia_snd_port_param_default(pjmedia_snd_port_param *prm)
+{
+    pj_bzero(prm, sizeof(*prm));
+}
+
+/*
+ * Start the sound stream.
+ * This may be called even when the sound stream has already been started.
+ */
+static pj_status_t start_sound_device( pj_pool_t *pool,
+				       pjmedia_snd_port *snd_port )
+{
+    pjmedia_aud_rec_cb snd_rec_cb;
+    pjmedia_aud_play_cb snd_play_cb;
+    pjmedia_aud_param param_copy;
+    pj_status_t status;
+
+    /* Check if sound has been started. */
+    if (snd_port->aud_stream != NULL)
+	return PJ_SUCCESS;
+
+    PJ_ASSERT_RETURN(snd_port->dir == PJMEDIA_DIR_CAPTURE ||
+		     snd_port->dir == PJMEDIA_DIR_PLAYBACK ||
+		     snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK,
+		     PJ_EBUG);
+
+    /* Get device caps */
+    if (snd_port->aud_param.dir & PJMEDIA_DIR_CAPTURE) {
+	pjmedia_aud_dev_info dev_info;
+
+	status = pjmedia_aud_dev_get_info(snd_port->aud_param.rec_id, 
+					  &dev_info);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	snd_port->aud_caps = dev_info.caps;
+    } else {
+	snd_port->aud_caps = 0;
+    }
+
+    /* Process EC settings */
+    pj_memcpy(&param_copy, &snd_port->aud_param, sizeof(param_copy));
+    if (param_copy.flags & PJMEDIA_AUD_DEV_CAP_EC) {
+	/* EC is wanted */
+	if ((snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) == 0 &&
+            (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC))
+        {
+	    /* Device supports EC */
+	    /* Nothing to do */
+	} else {
+	    /* Application wants to use software EC or device
+             * doesn't support EC, remove EC settings from
+	     * device parameters
+	     */
+	    param_copy.flags &= ~(PJMEDIA_AUD_DEV_CAP_EC |
+				  PJMEDIA_AUD_DEV_CAP_EC_TAIL);
+	}
+    }
+
+    /* Use different callback if format is not PCM */
+    if (snd_port->aud_param.ext_fmt.id == PJMEDIA_FORMAT_L16) {
+	snd_rec_cb = &rec_cb;
+	snd_play_cb = &play_cb;
+    } else {
+	snd_rec_cb = &rec_cb_ext;
+	snd_play_cb = &play_cb_ext;
+    }
+
+    /* Open the device */
+    status = pjmedia_aud_stream_create(&param_copy,
+				       snd_rec_cb,
+				       snd_play_cb,
+				       snd_port,
+				       &snd_port->aud_stream);
+
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Inactivity limit before EC is suspended. */
+    snd_port->ec_suspend_limit = AEC_SUSPEND_LIMIT *
+				 (snd_port->clock_rate / 
+				  snd_port->samples_per_frame);
+
+    /* Create software EC if parameter specifies EC and
+     * (app specifically requests software EC or device
+     * doesn't support EC). Only do this if the format is PCM!
+     */
+    if ((snd_port->aud_param.flags & PJMEDIA_AUD_DEV_CAP_EC) &&
+	((snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC)==0 ||
+         (snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) != 0) &&
+	param_copy.ext_fmt.id == PJMEDIA_FORMAT_PCM)
+    {
+	if ((snd_port->aud_param.flags & PJMEDIA_AUD_DEV_CAP_EC_TAIL)==0) {
+	    snd_port->aud_param.flags |= PJMEDIA_AUD_DEV_CAP_EC_TAIL;
+	    snd_port->aud_param.ec_tail_ms = AEC_TAIL;
+	    PJ_LOG(4,(THIS_FILE, "AEC tail is set to default %u ms",
+				 snd_port->aud_param.ec_tail_ms));
+	}
+	    
+	status = pjmedia_snd_port_set_ec(snd_port, pool, 
+					 snd_port->aud_param.ec_tail_ms,
+					 snd_port->prm_ec_options);
+	if (status != PJ_SUCCESS) {
+	    pjmedia_aud_stream_destroy(snd_port->aud_stream);
+	    snd_port->aud_stream = NULL;
+	    return status;
+	}
+    }
+
+    /* Start sound stream. */
+    if (!(snd_port->options & PJMEDIA_SND_PORT_NO_AUTO_START)) {
+	status = pjmedia_aud_stream_start(snd_port->aud_stream);
+    }
+    if (status != PJ_SUCCESS) {
+	pjmedia_aud_stream_destroy(snd_port->aud_stream);
+	snd_port->aud_stream = NULL;
+	return status;
+    }
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Stop the sound device.
+ * This may be called even when there's no sound device in the port.
+ */
+static pj_status_t stop_sound_device( pjmedia_snd_port *snd_port )
+{
+    /* Check if we have sound stream device. */
+    if (snd_port->aud_stream) {
+	pjmedia_aud_stream_stop(snd_port->aud_stream);
+	pjmedia_aud_stream_destroy(snd_port->aud_stream);
+	snd_port->aud_stream = NULL;
+    }
+
+    /* Destroy AEC */
+    if (snd_port->ec_state) {
+	pjmedia_echo_destroy(snd_port->ec_state);
+	snd_port->ec_state = NULL;
+    }
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Create bidirectional port.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_create( pj_pool_t *pool,
+					     int rec_id,
+					     int play_id,
+					     unsigned clock_rate,
+					     unsigned channel_count,
+					     unsigned samples_per_frame,
+					     unsigned bits_per_sample,
+					     unsigned options,
+					     pjmedia_snd_port **p_port)
+{
+    pjmedia_snd_port_param param;
+    pj_status_t status;
+
+    pjmedia_snd_port_param_default(&param);
+
+    status = pjmedia_aud_dev_default_param(rec_id, &param.base);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    param.base.dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
+    param.base.rec_id = rec_id;
+    param.base.play_id = play_id;
+    param.base.clock_rate = clock_rate;
+    param.base.channel_count = channel_count;
+    param.base.samples_per_frame = samples_per_frame;
+    param.base.bits_per_sample = bits_per_sample;
+    param.options = options;
+    param.ec_options = 0;
+
+    return pjmedia_snd_port_create2(pool, &param, p_port);
+}
+
+/*
+ * Create sound recorder AEC.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_create_rec( pj_pool_t *pool,
+						 int dev_id,
+						 unsigned clock_rate,
+						 unsigned channel_count,
+						 unsigned samples_per_frame,
+						 unsigned bits_per_sample,
+						 unsigned options,
+						 pjmedia_snd_port **p_port)
+{
+    pjmedia_snd_port_param param;
+    pj_status_t status;
+
+    pjmedia_snd_port_param_default(&param);
+
+    status = pjmedia_aud_dev_default_param(dev_id, &param.base);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    param.base.dir = PJMEDIA_DIR_CAPTURE;
+    param.base.rec_id = dev_id;
+    param.base.clock_rate = clock_rate;
+    param.base.channel_count = channel_count;
+    param.base.samples_per_frame = samples_per_frame;
+    param.base.bits_per_sample = bits_per_sample;
+    param.options = options;
+    param.ec_options = 0;
+
+    return pjmedia_snd_port_create2(pool, &param, p_port);
+}
+
+
+/*
+ * Create sound player port.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_create_player( pj_pool_t *pool,
+						    int dev_id,
+						    unsigned clock_rate,
+						    unsigned channel_count,
+						    unsigned samples_per_frame,
+						    unsigned bits_per_sample,
+						    unsigned options,
+						    pjmedia_snd_port **p_port)
+{
+    pjmedia_snd_port_param param;
+    pj_status_t status;
+
+    pjmedia_snd_port_param_default(&param);
+
+    status = pjmedia_aud_dev_default_param(dev_id, &param.base);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    param.base.dir = PJMEDIA_DIR_PLAYBACK;
+    param.base.play_id = dev_id;
+    param.base.clock_rate = clock_rate;
+    param.base.channel_count = channel_count;
+    param.base.samples_per_frame = samples_per_frame;
+    param.base.bits_per_sample = bits_per_sample;
+    param.options = options;
+    param.ec_options = 0;
+
+    return pjmedia_snd_port_create2(pool, &param, p_port);
+}
+
+
+/*
+ * Create sound port.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_create2(pj_pool_t *pool,
+					     const pjmedia_snd_port_param *prm,
+					     pjmedia_snd_port **p_port)
+{
+    pjmedia_snd_port *snd_port;
+    pj_status_t status;
+    unsigned ptime_usec;
+
+    PJ_ASSERT_RETURN(pool && prm && p_port, PJ_EINVAL);
+
+    snd_port = PJ_POOL_ZALLOC_T(pool, pjmedia_snd_port);
+    PJ_ASSERT_RETURN(snd_port, PJ_ENOMEM);
+
+    snd_port->dir = prm->base.dir;
+    snd_port->rec_id = prm->base.rec_id;
+    snd_port->play_id = prm->base.play_id;
+    snd_port->clock_rate = prm->base.clock_rate;
+    snd_port->channel_count = prm->base.channel_count;
+    snd_port->samples_per_frame = prm->base.samples_per_frame;
+    snd_port->bits_per_sample = prm->base.bits_per_sample;
+    pj_memcpy(&snd_port->aud_param, &prm->base, sizeof(snd_port->aud_param));
+    snd_port->options = prm->options;
+    snd_port->prm_ec_options = prm->ec_options;
+
+    ptime_usec = prm->base.samples_per_frame * 1000 / prm->base.channel_count /
+                 prm->base.clock_rate * 1000;
+    pjmedia_clock_src_init(&snd_port->cap_clocksrc, PJMEDIA_TYPE_AUDIO,
+                           snd_port->clock_rate, ptime_usec);
+    pjmedia_clock_src_init(&snd_port->play_clocksrc, PJMEDIA_TYPE_AUDIO,
+                           snd_port->clock_rate, ptime_usec);
+    
+    /* Start sound device immediately.
+     * If there's no port connected, the sound callback will return
+     * empty signal.
+     */
+    status = start_sound_device( pool, snd_port );
+    if (status != PJ_SUCCESS) {
+	pjmedia_snd_port_destroy(snd_port);
+	return status;
+    }
+
+    *p_port = snd_port;
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Destroy port (also destroys the sound device).
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port)
+{
+    PJ_ASSERT_RETURN(snd_port, PJ_EINVAL);
+
+    return stop_sound_device(snd_port);
+}
+
+
+/*
+ * Retrieve the sound stream associated by this sound device port.
+ */
+PJ_DEF(pjmedia_aud_stream*) pjmedia_snd_port_get_snd_stream(
+						pjmedia_snd_port *snd_port)
+{
+    PJ_ASSERT_RETURN(snd_port, NULL);
+    return snd_port->aud_stream;
+}
+
+
+/*
+ * Change EC settings.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+					     pj_pool_t *pool,
+					     unsigned tail_ms,
+					     unsigned options)
+{
+    pjmedia_aud_param prm;
+    pj_status_t status;
+
+    /* Sound must be opened in full-duplex mode */
+    PJ_ASSERT_RETURN(snd_port && 
+		     snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK,
+		     PJ_EINVALIDOP);
+
+    /* Determine whether we use device or software EC */
+    if ((snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) == 0 &&
+        (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC))
+    {
+	/* We use device EC */
+	pj_bool_t ec_enabled;
+
+	/* Query EC status */
+	status = pjmedia_aud_stream_get_cap(snd_port->aud_stream,
+					    PJMEDIA_AUD_DEV_CAP_EC,
+					    &ec_enabled);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	if (tail_ms != 0) {
+	    /* Change EC setting */
+
+	    if (!ec_enabled) {
+		/* Enable EC first */
+		pj_bool_t value = PJ_TRUE;
+		status = pjmedia_aud_stream_set_cap(snd_port->aud_stream, 
+						    PJMEDIA_AUD_DEV_CAP_EC,
+						    &value);
+		if (status != PJ_SUCCESS)
+		    return status;
+	    }
+
+	    if ((snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC_TAIL)==0) {
+		/* Device does not support setting EC tail */
+		return PJMEDIA_EAUD_INVCAP;
+	    }
+
+	    return pjmedia_aud_stream_set_cap(snd_port->aud_stream,
+					      PJMEDIA_AUD_DEV_CAP_EC_TAIL,
+					      &tail_ms);
+
+	} else if (ec_enabled) {
+	    /* Disable EC */
+	    pj_bool_t value = PJ_FALSE;
+	    return pjmedia_aud_stream_set_cap(snd_port->aud_stream, 
+					      PJMEDIA_AUD_DEV_CAP_EC,
+					      &value);
+	} else {
+	    /* Request to disable EC but EC has been disabled */
+	    /* Do nothing */
+	    return PJ_SUCCESS;
+	}
+
+    } else {
+	/* We use software EC */
+
+	/* Check if there is change in parameters */
+	if (tail_ms==snd_port->ec_tail_len && options==snd_port->ec_options) {
+	    PJ_LOG(5,(THIS_FILE, "pjmedia_snd_port_set_ec() ignored, no "
+				 "change in settings"));
+	    return PJ_SUCCESS;
+	}
+
+	status = pjmedia_aud_stream_get_param(snd_port->aud_stream, &prm);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	/* Audio stream must be in PCM format */
+	PJ_ASSERT_RETURN(prm.ext_fmt.id == PJMEDIA_FORMAT_PCM,
+			 PJ_EINVALIDOP);
+
+	/* Destroy AEC */
+	if (snd_port->ec_state) {
+	    pjmedia_echo_destroy(snd_port->ec_state);
+	    snd_port->ec_state = NULL;
+	}
+
+	if (tail_ms != 0) {
+	    unsigned delay_ms;
+
+	    //No need to add input latency in the latency calculation,
+	    //since actual input latency should be zero.
+	    //delay_ms = (si.rec_latency + si.play_latency) * 1000 /
+	    //	   snd_port->clock_rate;
+	    /* Set EC latency to 3/4 of output latency to reduce the
+	     * possibility of missing/late reference frame.
+	     */
+	    delay_ms = prm.output_latency_ms * 3/4;
+	    status = pjmedia_echo_create2(pool, snd_port->clock_rate, 
+					  snd_port->channel_count,
+					  snd_port->samples_per_frame, 
+					  tail_ms, delay_ms,
+					  options, &snd_port->ec_state);
+	    if (status != PJ_SUCCESS)
+		snd_port->ec_state = NULL;
+	    else
+		snd_port->ec_suspended = PJ_FALSE;
+	} else {
+	    PJ_LOG(4,(THIS_FILE, "Echo canceller is now disabled in the "
+				 "sound port"));
+	    status = PJ_SUCCESS;
+	}
+
+	snd_port->ec_options = options;
+	snd_port->ec_tail_len = tail_ms;
+    }
+
+    return status;
+}
+
+
+/* Get AEC tail length */
+PJ_DEF(pj_status_t) pjmedia_snd_port_get_ec_tail( pjmedia_snd_port *snd_port,
+						  unsigned *p_length)
+{
+    PJ_ASSERT_RETURN(snd_port && p_length, PJ_EINVAL);
+
+    /* Determine whether we use device or software EC */
+    if (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC) {
+	/* We use device EC */
+	pj_bool_t ec_enabled;
+	pj_status_t status;
+
+	/* Query EC status */
+	status = pjmedia_aud_stream_get_cap(snd_port->aud_stream,
+					    PJMEDIA_AUD_DEV_CAP_EC,
+					    &ec_enabled);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	if (!ec_enabled) {
+	    *p_length = 0;
+	} else if (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC_TAIL) {
+	    /* Get device EC tail */
+	    status = pjmedia_aud_stream_get_cap(snd_port->aud_stream,
+						PJMEDIA_AUD_DEV_CAP_EC_TAIL,
+						p_length);
+	    if (status != PJ_SUCCESS)
+		return status;
+	} else {
+	    /* Just use default */
+	    *p_length = AEC_TAIL;
+	}
+
+    } else {
+	/* We use software EC */
+	*p_length =  snd_port->ec_state ? snd_port->ec_tail_len : 0;
+    }
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Get clock source.
+ */
+PJ_DEF(pjmedia_clock_src *)
+pjmedia_snd_port_get_clock_src( pjmedia_snd_port *snd_port,
+                                pjmedia_dir dir )
+{
+    return (dir == PJMEDIA_DIR_CAPTURE? &snd_port->cap_clocksrc:
+            &snd_port->play_clocksrc);
+}
+
+
+/*
+ * Connect a port.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_connect( pjmedia_snd_port *snd_port,
+					      pjmedia_port *port)
+{
+    pjmedia_audio_format_detail *afd;
+
+    PJ_ASSERT_RETURN(snd_port && port, PJ_EINVAL);
+
+    afd = pjmedia_format_get_audio_format_detail(&port->info.fmt, PJ_TRUE);
+
+    /* Check that port has the same configuration as the sound device
+     * port.
+     */
+    if (afd->clock_rate != snd_port->clock_rate)
+	return PJMEDIA_ENCCLOCKRATE;
+
+    if (PJMEDIA_AFD_SPF(afd) != snd_port->samples_per_frame)
+	return PJMEDIA_ENCSAMPLESPFRAME;
+
+    if (afd->channel_count != snd_port->channel_count)
+	return PJMEDIA_ENCCHANNEL;
+
+    if (afd->bits_per_sample != snd_port->bits_per_sample)
+	return PJMEDIA_ENCBITS;
+
+    /* Port is okay. */
+    snd_port->port = port;
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Get the connected port.
+ */
+PJ_DEF(pjmedia_port*) pjmedia_snd_port_get_port(pjmedia_snd_port *snd_port)
+{
+    PJ_ASSERT_RETURN(snd_port, NULL);
+    return snd_port->port;
+}
+
+
+/*
+ * Disconnect port.
+ */
+PJ_DEF(pj_status_t) pjmedia_snd_port_disconnect(pjmedia_snd_port *snd_port)
+{
+    PJ_ASSERT_RETURN(snd_port, PJ_EINVAL);
+
+    snd_port->port = NULL;
+
+    return PJ_SUCCESS;
+}
+
+
diff --git a/jni/pjproject-android/.svn/pristine/12/126a5998bc946b7a3ef629bceb6e1ffe1bdcdddb.svn-base b/jni/pjproject-android/.svn/pristine/12/126a5998bc946b7a3ef629bceb6e1ffe1bdcdddb.svn-base
new file mode 100644
index 0000000..6565c2b
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/126a5998bc946b7a3ef629bceb6e1ffe1bdcdddb.svn-base
@@ -0,0 +1,175 @@
+
+   /******************************************************************
+
+       iLBC Speech Coder ANSI-C Source Code
+
+       filter.c
+
+       Copyright (C) The Internet Society (2004).
+       All Rights Reserved.
+
+   ******************************************************************/
+
+   #include "iLBC_define.h"
+
+   /*----------------------------------------------------------------*
+    *  all-pole filter
+    *---------------------------------------------------------------*/
+
+   void AllPoleFilter(
+       float *InOut,   /* (i/o) on entrance InOut[-orderCoef] to
+                              InOut[-1] contain the state of the
+                              filter (delayed samples). InOut[0] to
+                              InOut[lengthInOut-1] contain the filter
+                              input, on en exit InOut[-orderCoef] to
+                              InOut[-1] is unchanged and InOut[0] to
+                              InOut[lengthInOut-1] contain filtered
+                              samples */
+       float *Coef,/* (i) filter coefficients, Coef[0] is assumed
+                              to be 1.0 */
+       int lengthInOut,/* (i) number of input/output samples */
+       int orderCoef   /* (i) number of filter coefficients */
+   ){
+       int n,k;
+
+       for(n=0;n<lengthInOut;n++){
+           for(k=1;k<=orderCoef;k++){
+               *InOut -= Coef[k]*InOut[-k];
+
+
+
+
+
+           }
+           InOut++;
+       }
+   }
+
+   /*----------------------------------------------------------------*
+    *  all-zero filter
+    *---------------------------------------------------------------*/
+
+   void AllZeroFilter(
+       float *In,      /* (i) In[0] to In[lengthInOut-1] contain
+                              filter input samples */
+       float *Coef,/* (i) filter coefficients (Coef[0] is assumed
+                              to be 1.0) */
+       int lengthInOut,/* (i) number of input/output samples */
+       int orderCoef,  /* (i) number of filter coefficients */
+       float *Out      /* (i/o) on entrance Out[-orderCoef] to Out[-1]
+                              contain the filter state, on exit Out[0]
+                              to Out[lengthInOut-1] contain filtered
+                              samples */
+   ){
+       int n,k;
+
+       for(n=0;n<lengthInOut;n++){
+           *Out = Coef[0]*In[0];
+           for(k=1;k<=orderCoef;k++){
+               *Out += Coef[k]*In[-k];
+           }
+           Out++;
+           In++;
+       }
+   }
+
+   /*----------------------------------------------------------------*
+    *  pole-zero filter
+    *---------------------------------------------------------------*/
+
+   void ZeroPoleFilter(
+       float *In,      /* (i) In[0] to In[lengthInOut-1] contain
+                              filter input samples In[-orderCoef] to
+                              In[-1] contain state of all-zero
+                              section */
+       float *ZeroCoef,/* (i) filter coefficients for all-zero
+                              section (ZeroCoef[0] is assumed to
+                              be 1.0) */
+       float *PoleCoef,/* (i) filter coefficients for all-pole section
+                              (ZeroCoef[0] is assumed to be 1.0) */
+       int lengthInOut,/* (i) number of input/output samples */
+
+
+
+
+
+       int orderCoef,  /* (i) number of filter coefficients */
+       float *Out      /* (i/o) on entrance Out[-orderCoef] to Out[-1]
+                              contain state of all-pole section. On
+                              exit Out[0] to Out[lengthInOut-1]
+                              contain filtered samples */
+   ){
+       AllZeroFilter(In,ZeroCoef,lengthInOut,orderCoef,Out);
+       AllPoleFilter(Out,PoleCoef,lengthInOut,orderCoef);
+   }
+
+   /*----------------------------------------------------------------*
+    * downsample (LP filter and decimation)
+    *---------------------------------------------------------------*/
+
+   void DownSample (
+       float  *In,     /* (i) input samples */
+       float  *Coef,   /* (i) filter coefficients */
+       int lengthIn,   /* (i) number of input samples */
+       float  *state,  /* (i) filter state */
+       float  *Out     /* (o) downsampled output */
+   ){
+       float   o;
+       float *Out_ptr = Out;
+       float *Coef_ptr, *In_ptr;
+       float *state_ptr;
+       int i, j, stop;
+
+       /* LP filter and decimate at the same time */
+
+       for (i = DELAY_DS; i < lengthIn; i+=FACTOR_DS)
+       {
+           Coef_ptr = &Coef[0];
+           In_ptr = &In[i];
+           state_ptr = &state[FILTERORDER_DS-2];
+
+           o = (float)0.0;
+
+           stop = (i < FILTERORDER_DS) ? i + 1 : FILTERORDER_DS;
+
+           for (j = 0; j < stop; j++)
+           {
+               o += *Coef_ptr++ * (*In_ptr--);
+           }
+           for (j = i + 1; j < FILTERORDER_DS; j++)
+           {
+               o += *Coef_ptr++ * (*state_ptr--);
+           }
+
+
+
+
+
+
+           *Out_ptr++ = o;
+       }
+
+       /* Get the last part (use zeros as input for the future) */
+
+       for (i=(lengthIn+FACTOR_DS); i<(lengthIn+DELAY_DS);
+               i+=FACTOR_DS) {
+
+           o=(float)0.0;
+
+           if (i<lengthIn) {
+               Coef_ptr = &Coef[0];
+               In_ptr = &In[i];
+               for (j=0; j<FILTERORDER_DS; j++) {
+                       o += *Coef_ptr++ * (*Out_ptr--);
+               }
+           } else {
+               Coef_ptr = &Coef[i-lengthIn];
+               In_ptr = &In[lengthIn-1];
+               for (j=0; j<FILTERORDER_DS-(i-lengthIn); j++) {
+                       o += *Coef_ptr++ * (*In_ptr--);
+               }
+           }
+           *Out_ptr++ = o;
+       }
+   }
+
diff --git a/jni/pjproject-android/.svn/pristine/12/1288204ea50a4bd717652b2939e5fa3168bc013a.svn-base b/jni/pjproject-android/.svn/pristine/12/1288204ea50a4bd717652b2939e5fa3168bc013a.svn-base
new file mode 100644
index 0000000..6d82aad
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/1288204ea50a4bd717652b2939e5fa3168bc013a.svn-base
@@ -0,0 +1,142 @@
+/* $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 
+ */
+#ifndef __PJSIP_PRINT_H__
+#define __PJSIP_PRINT_H__
+
+#define copy_advance_check(buf,str)   \
+	do { \
+	    if ((str).slen >= (endbuf-buf)) return -1;	\
+	    pj_memcpy(buf, (str).ptr, (str).slen); \
+	    buf += (str).slen; \
+	} while (0)
+
+#define copy_advance_pair_check(buf,str1,len1,str2)   \
+	do { \
+	    if (str2.slen) { \
+		printed = len1+(int)str2.slen; \
+		if (printed >= (endbuf-buf)) return -1;	\
+		pj_memcpy(buf,str1,len1); \
+		pj_memcpy(buf+len1, str2.ptr, str2.slen); \
+		buf += printed; \
+	    } \
+	} while (0)
+
+#define copy_advance_pair_quote_check(buf,str1,len1,str2,quotebegin,quoteend) \
+	do { \
+	    if (str2.slen) { \
+		printed = len1+str2.slen+2; \
+		if (printed >= (endbuf-buf)) return -1;	\
+		pj_memcpy(buf,str1,len1); \
+		*(buf+len1)=quotebegin; \
+		pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
+		*(buf+printed-1) = quoteend; \
+		buf += printed; \
+	    } \
+	} while (0)
+
+#define copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend) \
+	do { \
+		printed = len1+(int)str2.slen+2; \
+		if (printed >= (endbuf-buf)) return -1;	\
+		pj_memcpy(buf,str1,len1); \
+		*(buf+len1)=quotebegin; \
+		pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
+		*(buf+printed-1) = quoteend; \
+		buf += printed; \
+	} while (0)
+
+#define copy_advance_pair_escape(buf,str1,len1,str2,unres)	\
+	do { \
+	  if (str2.slen) { \
+	    if (len1+str2.slen >= (endbuf-buf)) return -1; \
+	    pj_memcpy(buf,str1,len1); \
+	    printed=(int)pj_strncpy2_escape(buf+len1,&str2,(endbuf-buf-len1), \
+					    &unres);\
+	    if (printed < 0) return -1; \
+	    buf += (printed+len1); \
+	  } \
+	} while (0)
+
+
+#define copy_advance_no_check(buf,str)   \
+	do { \
+	    pj_memcpy(buf, (str).ptr, (str).slen); \
+	    buf += (str).slen; \
+	} while (0)
+
+#define copy_advance_escape(buf,str,unres)    \
+	do { \
+	    printed = \
+		(int)pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
+	    if (printed < 0) return -1; \
+	    buf += printed; \
+	} while (0)
+
+#define copy_advance_pair_no_check(buf,str1,len1,str2)   \
+	if (str2.slen) { \
+	    pj_memcpy(buf,str1,len1); \
+	    pj_memcpy(buf+len1, str2.ptr, str2.slen); \
+	    buf += len1+str2.slen; \
+	}
+
+#define copy_advance 		copy_advance_check
+#define copy_advance_pair 	copy_advance_pair_check
+
+#define copy_advance_pair_quote_cond(buf,str1,len1,str2,quotebegin,quoteend) \
+	do {	\
+	  if (str2.slen && *str2.ptr!=quotebegin) \
+	    copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \
+	  else \
+	    copy_advance_pair(buf,str1,len1,str2); \
+	} while (0)
+
+/*
+ * Internal type declarations.
+ */
+typedef void* (*pjsip_hdr_clone_fptr)(pj_pool_t *, const void*);
+typedef int   (*pjsip_hdr_print_fptr)(void *hdr, char *buf, pj_size_t len);
+
+typedef struct pjsip_hdr_name_info_t
+{
+    char	*name;
+    unsigned	 name_len;
+    char	*sname;
+} pjsip_hdr_name_info_t;
+
+extern const pjsip_hdr_name_info_t pjsip_hdr_names[];
+
+PJ_INLINE(void) init_hdr(void *hptr, pjsip_hdr_e htype, void *vptr)
+{
+    pjsip_hdr *hdr = (pjsip_hdr*) hptr;
+    hdr->type = htype;
+    hdr->name.ptr = pjsip_hdr_names[htype].name;
+    hdr->name.slen = pjsip_hdr_names[htype].name_len;
+    if (pjsip_hdr_names[htype].sname) {
+	hdr->sname.ptr = pjsip_hdr_names[htype].sname;
+	hdr->sname.slen = 1;
+    } else {
+	hdr->sname = hdr->name;
+    }
+    hdr->vptr = (pjsip_hdr_vptr*) vptr;
+    pj_list_init(hdr);
+}
+
+#endif	/* __PJSIP_PRINT_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/12/12b69675e824de7ce8eb7a986dd29f126082d718.svn-base b/jni/pjproject-android/.svn/pristine/12/12b69675e824de7ce8eb7a986dd29f126082d718.svn-base
new file mode 100644
index 0000000..91bf8a9
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12b69675e824de7ce8eb7a986dd29f126082d718.svn-base
@@ -0,0 +1,950 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/long_term.c,v 1.6 1996/07/02 12:33:19 jutta Exp $ */
+
+#include "config.h"
+#include <stdio.h>
+#include <assert.h>
+
+#include "private.h"
+
+#include "gsm.h"
+#include "proto.h"
+
+/*
+ *  4.2.11 .. 4.2.12 LONG TERM PREDICTOR (LTP) SECTION
+ */
+
+
+/*
+ * This module computes the LTP gain (bc) and the LTP lag (Nc)
+ * for the long term analysis filter.   This is done by calculating a
+ * maximum of the cross-correlation function between the current
+ * sub-segment short term residual signal d[0..39] (output of
+ * the short term analysis filter; for simplification the index
+ * of this array begins at 0 and ends at 39 for each sub-segment of the
+ * RPE-LTP analysis) and the previous reconstructed short term
+ * residual signal dp[ -120 .. -1 ].  A dynamic scaling must be
+ * performed to avoid overflow.
+ */
+
+ /* The next procedure exists in six versions.  First two integer
+  * version (if USE_FLOAT_MUL is not defined); then four floating
+  * point versions, twice with proper scaling (USE_FLOAT_MUL defined),
+  * once without (USE_FLOAT_MUL and FAST defined, and fast run-time
+  * option used).  Every pair has first a Cut version (see the -C
+  * option to toast or the LTP_CUT option to gsm_option()), then the
+  * uncut one.  (For a detailed explanation of why this is altogether
+  * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered
+  * Harmful''.)
+  */
+
+#ifndef  USE_FLOAT_MUL
+
+#ifdef	LTP_CUT
+
+static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out),
+
+	struct gsm_state * st,
+
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	word		Nc, bc;
+	word		wt[40];
+
+	longword	L_result;
+	longword	L_max, L_power;
+	word		R, S, dmax, scal, best_k;
+	word		ltp_cut;
+
+	register word	temp, wt_k;
+
+	/*  Search of the optimum scaling of d[0..39].
+	 */
+	dmax = 0;
+	for (k = 0; k <= 39; k++) {
+		temp = d[k];
+		temp = GSM_ABS( temp );
+		if (temp > dmax) {
+			dmax = temp;
+			best_k = k;
+		}
+	}
+	temp = 0;
+	if (dmax == 0) scal = 0;
+	else {
+		assert(dmax > 0);
+		temp = gsm_norm( (longword)dmax << 16 );
+	}
+	if (temp > 6) scal = 0;
+	else scal = 6 - temp;
+	assert(scal >= 0);
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+	wt_k  = SASR(d[best_k], scal);
+
+	for (lambda = 40; lambda <= 120; lambda++) {
+		L_result = (longword)wt_k * dp[best_k - lambda];
+		if (L_result > L_max) {
+			Nc    = lambda;
+			L_max = L_result;
+		}
+	}
+	*Nc_out = Nc;
+	L_max <<= 1;
+
+	/*  Rescaling of L_max
+	 */
+	assert(scal <= 100 && scal >= -100);
+	L_max = L_max >> (6 - scal);	/* sub(6, scal) */
+
+	assert( Nc <= 120 && Nc >= 40);
+
+	/*   Compute the power of the reconstructed short term residual
+	 *   signal dp[..]
+	 */
+	L_power = 0;
+	for (k = 0; k <= 39; k++) {
+
+		register longword L_temp;
+
+		L_temp   = SASR( dp[k - Nc], 3 );
+		L_power += L_temp * L_temp;
+	}
+	L_power <<= 1;	/* from L_MULT */
+
+	/*  Normalization of L_max and L_power
+	 */
+
+	if (L_max <= 0)  {
+		*bc_out = 0;
+		return;
+	}
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	temp = gsm_norm( L_power );
+
+	R = SASR( L_max   << temp, 16 );
+	S = SASR( L_power << temp, 16 );
+
+	/*  Coding of the LTP gain
+	 */
+
+	/*  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break;
+	*bc_out = bc;
+}
+
+#endif 	/* LTP_CUT */
+
+static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out),
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	word		Nc, bc;
+	word		wt[40];
+
+	longword	L_max, L_power;
+	word		R, S, dmax, scal;
+	register word	temp;
+
+	/*  Search of the optimum scaling of d[0..39].
+	 */
+	dmax = 0;
+
+	for (k = 0; k <= 39; k++) {
+		temp = d[k];
+		temp = GSM_ABS( temp );
+		if (temp > dmax) dmax = temp;
+	}
+
+	temp = 0;
+	if (dmax == 0) scal = 0;
+	else {
+		assert(dmax > 0);
+		temp = gsm_norm( (longword)dmax << 16 );
+	}
+
+	if (temp > 6) scal = 0;
+	else scal = 6 - temp;
+
+	assert(scal >= 0);
+
+	/*  Initialization of a working array wt
+	 */
+
+	for (k = 0; k <= 39; k++) wt[k] = SASR( d[k], scal );
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+
+	for (lambda = 40; lambda <= 120; lambda++) {
+
+# undef STEP
+#		define STEP(k) 	(longword)wt[k] * dp[k - lambda]
+
+		register longword L_result;
+
+		L_result  = STEP(0)  ; L_result += STEP(1) ;
+		L_result += STEP(2)  ; L_result += STEP(3) ;
+		L_result += STEP(4)  ; L_result += STEP(5)  ;
+		L_result += STEP(6)  ; L_result += STEP(7)  ;
+		L_result += STEP(8)  ; L_result += STEP(9)  ;
+		L_result += STEP(10) ; L_result += STEP(11) ;
+		L_result += STEP(12) ; L_result += STEP(13) ;
+		L_result += STEP(14) ; L_result += STEP(15) ;
+		L_result += STEP(16) ; L_result += STEP(17) ;
+		L_result += STEP(18) ; L_result += STEP(19) ;
+		L_result += STEP(20) ; L_result += STEP(21) ;
+		L_result += STEP(22) ; L_result += STEP(23) ;
+		L_result += STEP(24) ; L_result += STEP(25) ;
+		L_result += STEP(26) ; L_result += STEP(27) ;
+		L_result += STEP(28) ; L_result += STEP(29) ;
+		L_result += STEP(30) ; L_result += STEP(31) ;
+		L_result += STEP(32) ; L_result += STEP(33) ;
+		L_result += STEP(34) ; L_result += STEP(35) ;
+		L_result += STEP(36) ; L_result += STEP(37) ;
+		L_result += STEP(38) ; L_result += STEP(39) ;
+
+		if (L_result > L_max) {
+
+			Nc    = lambda;
+			L_max = L_result;
+		}
+	}
+
+	*Nc_out = Nc;
+
+	L_max <<= 1;
+
+	/*  Rescaling of L_max
+	 */
+	assert(scal <= 100 && scal >=  -100);
+	L_max = L_max >> (6 - scal);	/* sub(6, scal) */
+
+	assert( Nc <= 120 && Nc >= 40);
+
+	/*   Compute the power of the reconstructed short term residual
+	 *   signal dp[..]
+	 */
+	L_power = 0;
+	for (k = 0; k <= 39; k++) {
+
+		register longword L_temp;
+
+		L_temp   = SASR( dp[k - Nc], 3 );
+		L_power += L_temp * L_temp;
+	}
+	L_power <<= 1;	/* from L_MULT */
+
+	/*  Normalization of L_max and L_power
+	 */
+
+	if (L_max <= 0)  {
+		*bc_out = 0;
+		return;
+	}
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	temp = gsm_norm( L_power );
+
+	R = SASR( L_max   << temp, 16 );
+	S = SASR( L_power << temp, 16 );
+
+	/*  Coding of the LTP gain
+	 */
+
+	/*  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break;
+	*bc_out = bc;
+}
+
+#else	/* USE_FLOAT_MUL */
+
+#ifdef	LTP_CUT
+
+static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out),
+	struct gsm_state * st,		/*              IN 	*/
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	word		Nc, bc;
+	word		ltp_cut;
+
+	float		wt_float[40];
+	float		dp_float_base[120], * dp_float = dp_float_base + 120;
+
+	longword	L_max, L_power;
+	word		R, S, dmax, scal;
+	register word	temp;
+
+	/*  Search of the optimum scaling of d[0..39].
+	 */
+	dmax = 0;
+
+	for (k = 0; k <= 39; k++) {
+		temp = d[k];
+		temp = GSM_ABS( temp );
+		if (temp > dmax) dmax = temp;
+	}
+
+	temp = 0;
+	if (dmax == 0) scal = 0;
+	else {
+		assert(dmax > 0);
+		temp = gsm_norm( (longword)dmax << 16 );
+	}
+
+	if (temp > 6) scal = 0;
+	else scal = 6 - temp;
+
+	assert(scal >= 0);
+	ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100; 
+
+
+	/*  Initialization of a working array wt
+	 */
+
+	for (k = 0; k < 40; k++) {
+		register word w = SASR( d[k], scal );
+		if (w < 0 ? w > -ltp_cut : w < ltp_cut) {
+			wt_float[k] = 0.0;
+		}
+		else {
+			wt_float[k] =  w;
+		}
+	}
+	for (k = -120; k <  0; k++) dp_float[k] =  dp[k];
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+
+	for (lambda = 40; lambda <= 120; lambda += 9) {
+
+		/*  Calculate L_result for l = lambda .. lambda + 9.
+		 */
+		register float *lp = dp_float - lambda;
+
+		register float	W;
+		register float	a = lp[-8], b = lp[-7], c = lp[-6],
+				d = lp[-5], e = lp[-4], f = lp[-3],
+				g = lp[-2], h = lp[-1];
+		register float  E; 
+		register float  S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0,
+				S5 = 0, S6 = 0, S7 = 0, S8 = 0;
+
+#		undef STEP
+#		define	STEP(K, a, b, c, d, e, f, g, h) \
+			if ((W = wt_float[K]) != 0.0) {	\
+			E = W * a; S8 += E;		\
+			E = W * b; S7 += E;		\
+			E = W * c; S6 += E;		\
+			E = W * d; S5 += E;		\
+			E = W * e; S4 += E;		\
+			E = W * f; S3 += E;		\
+			E = W * g; S2 += E;		\
+			E = W * h; S1 += E;		\
+			a  = lp[K];			\
+			E = W * a; S0 += E; } else (a = lp[K])
+
+#		define	STEP_A(K)	STEP(K, a, b, c, d, e, f, g, h)
+#		define	STEP_B(K)	STEP(K, b, c, d, e, f, g, h, a)
+#		define	STEP_C(K)	STEP(K, c, d, e, f, g, h, a, b)
+#		define	STEP_D(K)	STEP(K, d, e, f, g, h, a, b, c)
+#		define	STEP_E(K)	STEP(K, e, f, g, h, a, b, c, d)
+#		define	STEP_F(K)	STEP(K, f, g, h, a, b, c, d, e)
+#		define	STEP_G(K)	STEP(K, g, h, a, b, c, d, e, f)
+#		define	STEP_H(K)	STEP(K, h, a, b, c, d, e, f, g)
+
+		STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3);
+		STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7);
+
+		STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11);
+		STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15);
+
+		STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19);
+		STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23);
+
+		STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27);
+		STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31);
+
+		STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
+		STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
+
+		if (S0 > L_max) { L_max = S0; Nc = lambda;     }
+		if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
+		if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
+		if (S3 > L_max) { L_max = S3; Nc = lambda + 3; }
+		if (S4 > L_max) { L_max = S4; Nc = lambda + 4; }
+		if (S5 > L_max) { L_max = S5; Nc = lambda + 5; }
+		if (S6 > L_max) { L_max = S6; Nc = lambda + 6; }
+		if (S7 > L_max) { L_max = S7; Nc = lambda + 7; }
+		if (S8 > L_max) { L_max = S8; Nc = lambda + 8; }
+
+	}
+	*Nc_out = Nc;
+
+	L_max <<= 1;
+
+	/*  Rescaling of L_max
+	 */
+	assert(scal <= 100 && scal >=  -100);
+	L_max = L_max >> (6 - scal);	/* sub(6, scal) */
+
+	assert( Nc <= 120 && Nc >= 40);
+
+	/*   Compute the power of the reconstructed short term residual
+	 *   signal dp[..]
+	 */
+	L_power = 0;
+	for (k = 0; k <= 39; k++) {
+
+		register longword L_temp;
+
+		L_temp   = SASR( dp[k - Nc], 3 );
+		L_power += L_temp * L_temp;
+	}
+	L_power <<= 1;	/* from L_MULT */
+
+	/*  Normalization of L_max and L_power
+	 */
+
+	if (L_max <= 0)  {
+		*bc_out = 0;
+		return;
+	}
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	temp = gsm_norm( L_power );
+
+	R = SASR( L_max   << temp, 16 );
+	S = SASR( L_power << temp, 16 );
+
+	/*  Coding of the LTP gain
+	 */
+
+	/*  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break;
+	*bc_out = bc;
+}
+
+#endif /* LTP_CUT */
+
+static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out),
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	word		Nc, bc;
+
+	float		wt_float[40];
+	float		dp_float_base[120], * dp_float = dp_float_base + 120;
+
+	longword	L_max, L_power;
+	word		R, S, dmax, scal;
+	register word	temp;
+
+	/*  Search of the optimum scaling of d[0..39].
+	 */
+	dmax = 0;
+
+	for (k = 0; k <= 39; k++) {
+		temp = d[k];
+		temp = GSM_ABS( temp );
+		if (temp > dmax) dmax = temp;
+	}
+
+	temp = 0;
+	if (dmax == 0) scal = 0;
+	else {
+		assert(dmax > 0);
+		temp = gsm_norm( (longword)dmax << 16 );
+	}
+
+	if (temp > 6) scal = 0;
+	else scal = 6 - temp;
+
+	assert(scal >= 0);
+
+	/*  Initialization of a working array wt
+	 */
+
+	for (k =    0; k < 40; k++) wt_float[k] =  SASR( d[k], scal );
+	for (k = -120; k <  0; k++) dp_float[k] =  dp[k];
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+
+	for (lambda = 40; lambda <= 120; lambda += 9) {
+
+		/*  Calculate L_result for l = lambda .. lambda + 9.
+		 */
+		register float *lp = dp_float - lambda;
+
+		register float	W;
+		register float	a = lp[-8], b = lp[-7], c = lp[-6],
+				d = lp[-5], e = lp[-4], f = lp[-3],
+				g = lp[-2], h = lp[-1];
+		register float  E; 
+		register float  S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0,
+				S5 = 0, S6 = 0, S7 = 0, S8 = 0;
+
+#		undef STEP
+#		define	STEP(K, a, b, c, d, e, f, g, h) \
+			W = wt_float[K];		\
+			E = W * a; S8 += E;		\
+			E = W * b; S7 += E;		\
+			E = W * c; S6 += E;		\
+			E = W * d; S5 += E;		\
+			E = W * e; S4 += E;		\
+			E = W * f; S3 += E;		\
+			E = W * g; S2 += E;		\
+			E = W * h; S1 += E;		\
+			a  = lp[K];			\
+			E = W * a; S0 += E
+
+#		define	STEP_A(K)	STEP(K, a, b, c, d, e, f, g, h)
+#		define	STEP_B(K)	STEP(K, b, c, d, e, f, g, h, a)
+#		define	STEP_C(K)	STEP(K, c, d, e, f, g, h, a, b)
+#		define	STEP_D(K)	STEP(K, d, e, f, g, h, a, b, c)
+#		define	STEP_E(K)	STEP(K, e, f, g, h, a, b, c, d)
+#		define	STEP_F(K)	STEP(K, f, g, h, a, b, c, d, e)
+#		define	STEP_G(K)	STEP(K, g, h, a, b, c, d, e, f)
+#		define	STEP_H(K)	STEP(K, h, a, b, c, d, e, f, g)
+
+		STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3);
+		STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7);
+
+		STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11);
+		STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15);
+
+		STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19);
+		STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23);
+
+		STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27);
+		STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31);
+
+		STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
+		STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
+
+		if (S0 > L_max) { L_max = S0; Nc = lambda;     }
+		if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
+		if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
+		if (S3 > L_max) { L_max = S3; Nc = lambda + 3; }
+		if (S4 > L_max) { L_max = S4; Nc = lambda + 4; }
+		if (S5 > L_max) { L_max = S5; Nc = lambda + 5; }
+		if (S6 > L_max) { L_max = S6; Nc = lambda + 6; }
+		if (S7 > L_max) { L_max = S7; Nc = lambda + 7; }
+		if (S8 > L_max) { L_max = S8; Nc = lambda + 8; }
+	}
+	*Nc_out = Nc;
+
+	L_max <<= 1;
+
+	/*  Rescaling of L_max
+	 */
+	assert(scal <= 100 && scal >=  -100);
+	L_max = L_max >> (6 - scal);	/* sub(6, scal) */
+
+	assert( Nc <= 120 && Nc >= 40);
+
+	/*   Compute the power of the reconstructed short term residual
+	 *   signal dp[..]
+	 */
+	L_power = 0;
+	for (k = 0; k <= 39; k++) {
+
+		register longword L_temp;
+
+		L_temp   = SASR( dp[k - Nc], 3 );
+		L_power += L_temp * L_temp;
+	}
+	L_power <<= 1;	/* from L_MULT */
+
+	/*  Normalization of L_max and L_power
+	 */
+
+	if (L_max <= 0)  {
+		*bc_out = 0;
+		return;
+	}
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	temp = gsm_norm( L_power );
+
+	R = SASR( L_max   << temp, 16 );
+	S = SASR( L_power << temp, 16 );
+
+	/*  Coding of the LTP gain
+	 */
+
+	/*  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break;
+	*bc_out = bc;
+}
+
+#ifdef	FAST
+#ifdef	LTP_CUT
+
+static void Cut_Fast_Calculation_of_the_LTP_parameters P5((st,
+							d,dp,bc_out,Nc_out),
+	struct gsm_state * st,		/*              IN	*/
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	register float	wt_float;
+	word		Nc, bc;
+	word		wt_max, best_k, ltp_cut;
+
+	float		dp_float_base[120], * dp_float = dp_float_base + 120;
+
+	register float	L_result, L_max, L_power;
+
+	wt_max = 0;
+
+	for (k = 0; k < 40; ++k) {
+		if      ( d[k] > wt_max) wt_max =  d[best_k = k];
+		else if (-d[k] > wt_max) wt_max = -d[best_k = k];
+	}
+
+	assert(wt_max >= 0);
+	wt_float = (float)wt_max;
+
+	for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k];
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+
+	for (lambda = 40; lambda <= 120; lambda++) {
+		L_result = wt_float * dp_float[best_k - lambda];
+		if (L_result > L_max) {
+			Nc    = lambda;
+			L_max = L_result;
+		}
+	}
+
+	*Nc_out = Nc;
+	if (L_max <= 0.)  {
+		*bc_out = 0;
+		return;
+	}
+
+	/*  Compute the power of the reconstructed short term residual
+	 *  signal dp[..]
+	 */
+	dp_float -= Nc;
+	L_power = 0;
+	for (k = 0; k < 40; ++k) {
+		register float f = dp_float[k];
+		L_power += f * f;
+	}
+
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	/*  Coding of the LTP gain
+	 *  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	lambda = L_max / L_power * 32768.;
+	for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break;
+	*bc_out = bc;
+}
+
+#endif /* LTP_CUT */
+
+static void Fast_Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out),
+	register word	* d,		/* [0..39]	IN	*/
+	register word	* dp,		/* [-120..-1]	IN	*/
+	word		* bc_out,	/* 		OUT	*/
+	word		* Nc_out	/* 		OUT	*/
+)
+{
+	register int  	k, lambda;
+	word		Nc, bc;
+
+	float		wt_float[40];
+	float		dp_float_base[120], * dp_float = dp_float_base + 120;
+
+	register float	L_max, L_power;
+
+	for (k = 0; k < 40; ++k) wt_float[k] = (float)d[k];
+	for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k];
+
+	/* Search for the maximum cross-correlation and coding of the LTP lag
+	 */
+	L_max = 0;
+	Nc    = 40;	/* index for the maximum cross-correlation */
+
+	for (lambda = 40; lambda <= 120; lambda += 9) {
+
+		/*  Calculate L_result for l = lambda .. lambda + 9.
+		 */
+		register float *lp = dp_float - lambda;
+
+		register float	W;
+		register float	a = lp[-8], b = lp[-7], c = lp[-6],
+				d = lp[-5], e = lp[-4], f = lp[-3],
+				g = lp[-2], h = lp[-1];
+		register float  E; 
+		register float  S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0,
+				S5 = 0, S6 = 0, S7 = 0, S8 = 0;
+
+#		undef STEP
+#		define	STEP(K, a, b, c, d, e, f, g, h) \
+			W = wt_float[K];		\
+			E = W * a; S8 += E;		\
+			E = W * b; S7 += E;		\
+			E = W * c; S6 += E;		\
+			E = W * d; S5 += E;		\
+			E = W * e; S4 += E;		\
+			E = W * f; S3 += E;		\
+			E = W * g; S2 += E;		\
+			E = W * h; S1 += E;		\
+			a  = lp[K];			\
+			E = W * a; S0 += E
+
+#		define	STEP_A(K)	STEP(K, a, b, c, d, e, f, g, h)
+#		define	STEP_B(K)	STEP(K, b, c, d, e, f, g, h, a)
+#		define	STEP_C(K)	STEP(K, c, d, e, f, g, h, a, b)
+#		define	STEP_D(K)	STEP(K, d, e, f, g, h, a, b, c)
+#		define	STEP_E(K)	STEP(K, e, f, g, h, a, b, c, d)
+#		define	STEP_F(K)	STEP(K, f, g, h, a, b, c, d, e)
+#		define	STEP_G(K)	STEP(K, g, h, a, b, c, d, e, f)
+#		define	STEP_H(K)	STEP(K, h, a, b, c, d, e, f, g)
+
+		STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3);
+		STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7);
+
+		STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11);
+		STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15);
+
+		STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19);
+		STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23);
+
+		STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27);
+		STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31);
+
+		STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35);
+		STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39);
+
+		if (S0 > L_max) { L_max = S0; Nc = lambda;     }
+		if (S1 > L_max) { L_max = S1; Nc = lambda + 1; }
+		if (S2 > L_max) { L_max = S2; Nc = lambda + 2; }
+		if (S3 > L_max) { L_max = S3; Nc = lambda + 3; }
+		if (S4 > L_max) { L_max = S4; Nc = lambda + 4; }
+		if (S5 > L_max) { L_max = S5; Nc = lambda + 5; }
+		if (S6 > L_max) { L_max = S6; Nc = lambda + 6; }
+		if (S7 > L_max) { L_max = S7; Nc = lambda + 7; }
+		if (S8 > L_max) { L_max = S8; Nc = lambda + 8; }
+	}
+	*Nc_out = Nc;
+
+	if (L_max <= 0.)  {
+		*bc_out = 0;
+		return;
+	}
+
+	/*  Compute the power of the reconstructed short term residual
+	 *  signal dp[..]
+	 */
+	dp_float -= Nc;
+	L_power = 0;
+	for (k = 0; k < 40; ++k) {
+		register float f = dp_float[k];
+		L_power += f * f;
+	}
+
+	if (L_max >= L_power) {
+		*bc_out = 3;
+		return;
+	}
+
+	/*  Coding of the LTP gain
+	 *  Table 4.3a must be used to obtain the level DLB[i] for the
+	 *  quantization of the LTP gain b to get the coded version bc.
+	 */
+	lambda = L_max / L_power * 32768.;
+	for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break;
+	*bc_out = bc;
+}
+
+#endif	/* FAST 	 */
+#endif	/* USE_FLOAT_MUL */
+
+
+/* 4.2.12 */
+
+static void Long_term_analysis_filtering P6((bc,Nc,dp,d,dpp,e),
+	word		bc,	/* 					IN  */
+	word		Nc,	/* 					IN  */
+	register word	* dp,	/* previous d	[-120..-1]		IN  */
+	register word	* d,	/* d		[0..39]			IN  */
+	register word	* dpp,	/* estimate	[0..39]			OUT */
+	register word	* e	/* long term res. signal [0..39]	OUT */
+)
+/*
+ *  In this part, we have to decode the bc parameter to compute
+ *  the samples of the estimate dpp[0..39].  The decoding of bc needs the
+ *  use of table 4.3b.  The long term residual signal e[0..39]
+ *  is then calculated to be fed to the RPE encoding section.
+ */
+{
+	register int      k;
+	register longword ltmp;
+
+#	undef STEP
+#	define STEP(BP)					\
+	for (k = 0; k <= 39; k++) {			\
+		dpp[k]  = GSM_MULT_R( BP, dp[k - Nc]);	\
+		e[k]	= GSM_SUB( d[k], dpp[k] );	\
+	}
+
+	switch (bc) {
+	case 0:	STEP(  3277 ); break;
+	case 1:	STEP( 11469 ); break;
+	case 2: STEP( 21299 ); break;
+	case 3: STEP( 32767 ); break; 
+	}
+}
+
+void Gsm_Long_Term_Predictor P7((S,d,dp,e,dpp,Nc,bc), 	/* 4x for 160 samples */
+
+	struct gsm_state	* S,
+
+	word	* d,	/* [0..39]   residual signal	IN	*/
+	word	* dp,	/* [-120..-1] d'		IN	*/
+
+	word	* e,	/* [0..39] 			OUT	*/
+	word	* dpp,	/* [0..39] 			OUT	*/
+	word	* Nc,	/* correlation lag		OUT	*/
+	word	* bc	/* gain factor			OUT	*/
+)
+{
+	assert( d  ); assert( dp ); assert( e  );
+	assert( dpp); assert( Nc ); assert( bc );
+
+#if defined(FAST) && defined(USE_FLOAT_MUL)
+	if (S->fast) 
+#if   defined (LTP_CUT)
+		if (S->ltp_cut)
+			Cut_Fast_Calculation_of_the_LTP_parameters(S,
+				d, dp, bc, Nc);
+		else
+#endif /* LTP_CUT */
+			Fast_Calculation_of_the_LTP_parameters(d, dp, bc, Nc );
+	else 
+#endif /* FAST & USE_FLOAT_MUL */
+#ifdef LTP_CUT
+		if (S->ltp_cut)
+			Cut_Calculation_of_the_LTP_parameters(S, d, dp, bc, Nc);
+		else
+#endif
+			Calculation_of_the_LTP_parameters(d, dp, bc, Nc);
+
+	Long_term_analysis_filtering( *bc, *Nc, dp, d, dpp, e );
+}
+
+/* 4.3.2 */
+void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp),
+	struct gsm_state	* S,
+
+	word			Ncr,
+	word			bcr,
+	register word		* erp,	   /* [0..39]		  	 IN */
+	register word		* drp	   /* [-120..-1] IN, [-120..40] OUT */
+)
+/*
+ *  This procedure uses the bcr and Ncr parameter to realize the
+ *  long term synthesis filtering.  The decoding of bcr needs
+ *  table 4.3b.
+ */
+{
+	register longword	ltmp;	/* for ADD */
+	register int 		k;
+	word			brp, drpp, Nr;
+
+	/*  Check the limits of Nr.
+	 */
+	Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr;
+	S->nrp = Nr;
+	assert(Nr >= 40 && Nr <= 120);
+
+	/*  Decoding of the LTP gain bcr
+	 */
+	brp = gsm_QLB[ bcr ];
+
+	/*  Computation of the reconstructed short term residual 
+	 *  signal drp[0..39]
+	 */
+	assert(brp != MIN_WORD);
+
+	for (k = 0; k <= 39; k++) {
+		drpp   = GSM_MULT_R( brp, drp[ k - Nr ] );
+		drp[k] = GSM_ADD( erp[k], drpp );
+	}
+
+	/*
+	 *  Update of the reconstructed short term residual signal
+	 *  drp[ -1..-120 ]
+	 */
+
+	for (k = 0; k <= 119; k++) drp[ -120 + k ] = drp[ -80 + k ];
+}
diff --git a/jni/pjproject-android/.svn/pristine/12/12bb460d5d99dacd78b04c98187933febbd3600e.svn-base b/jni/pjproject-android/.svn/pristine/12/12bb460d5d99dacd78b04c98187933febbd3600e.svn-base
new file mode 100644
index 0000000..3a73018
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12bb460d5d99dacd78b04c98187933febbd3600e.svn-base
@@ -0,0 +1,55 @@
+#if defined(PJ_BUILD_DLL)

+

+TARGET		pjsua_lib.dll

+TARGETTYPE	dll

+

+UID		0x0 0xA000000B 

+

+

+CAPABILITY	None

+LIBRARY		pjsip_ua.lib pjsip_simple.lib pjsip.lib pjmedia.lib null_audio.lib pjsdp.lib pjnath.lib pjlib_util.lib pjlib.lib esock.lib insock.lib charconv.lib euser.lib estlib.lib

+MACRO		PJ_DLL

+MACRO		PJ_EXPORTING

+

+DEFFILE		.\pjsua_lib.def

+

+#else

+

+TARGET 		pjsua_lib.lib

+TARGETTYPE 	lib

+

+#endif

+

+SOURCEPATH	..\pjsip\src\pjsua-lib

+

+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++

+

+// PJLIB-UTIL files

+

+SOURCE	pjsua_acc.c

+SOURCE	pjsua_aud.c

+SOURCE	pjsua_call.c

+SOURCE	pjsua_core.c

+SOURCE	pjsua_dump.c

+SOURCE	pjsua_im.c

+SOURCE	pjsua_media.c

+SOURCE	pjsua_pres.c

+SOURCE	pjsua_vid.c

+

+SYSTEMINCLUDE	..\pjlib\include 

+SYSTEMINCLUDE	..\pjlib-util\include

+SYSTEMINCLUDE	..\pjnath\include

+SYSTEMINCLUDE	..\pjmedia\include

+SYSTEMINCLUDE	..\pjsip\include

+

+SYSTEMINCLUDE	\epoc32\include

+SYSTEMINCLUDE	\epoc32\include\libc

+

+

diff --git a/jni/pjproject-android/.svn/pristine/12/12bfe1f3053c33433ffad7c00794bb2ba868f8b1.svn-base b/jni/pjproject-android/.svn/pristine/12/12bfe1f3053c33433ffad7c00794bb2ba868f8b1.svn-base
new file mode 100644
index 0000000..2c66d51
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12bfe1f3053c33433ffad7c00794bb2ba868f8b1.svn-base
@@ -0,0 +1,98 @@
+/* Copyright (C) 2002 Jean-Marc Valin 
+   File: exc_5_64_table.c
+   Codebook for excitation in narrowband CELP mode (9600 bps)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION 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.
+*/
+
+
+const signed char exc_5_64_table[320]={
+1,5,-15,49,-66,
+-48,-4,50,-44,7,
+37,16,-18,25,-26,
+-26,-15,19,19,-27,
+-47,28,57,5,-17,
+-32,-41,68,21,-2,
+64,56,8,-16,-13,
+-26,-9,-16,11,6,
+-39,25,-19,22,-31,
+20,-45,55,-43,10,
+-16,47,-40,40,-20,
+-51,3,-17,-14,-15,
+-24,53,-20,-46,46,
+27,-68,32,3,-18,
+-5,9,-31,16,-9,
+-10,-1,-23,48,95,
+47,25,-41,-32,-3,
+15,-25,-55,36,41,
+-27,20,5,13,14,
+-22,5,2,-23,18,
+46,-15,17,-18,-34,
+-5,-8,27,-55,73,
+16,2,-1,-17,40,
+-78,33,0,2,19,
+4,53,-16,-15,-16,
+-28,-3,-13,49,8,
+-7,-29,27,-13,32,
+20,32,-61,16,14,
+41,44,40,24,20,
+7,4,48,-60,-77,
+17,-6,-48,65,-15,
+32,-30,-71,-10,-3,
+-6,10,-2,-7,-29,
+-56,67,-30,7,-5,
+86,-6,-10,0,5,
+-31,60,34,-38,-3,
+24,10,-2,30,23,
+24,-41,12,70,-43,
+15,-17,6,13,16,
+-13,8,30,-15,-8,
+5,23,-34,-98,-4,
+-13,13,-48,-31,70,
+12,31,25,24,-24,
+26,-7,33,-16,8,
+5,-11,-14,-8,-65,
+13,10,-2,-9,0,
+-3,-68,5,35,7,
+0,-31,-1,-17,-9,
+-9,16,-37,-18,-1,
+69,-48,-28,22,-21,
+-11,5,49,55,23,
+-86,-36,16,2,13,
+63,-51,30,-11,13,
+24,-18,-6,14,-19,
+1,41,9,-5,27,
+-36,-44,-34,-37,-21,
+-26,31,-39,15,43,
+5,-8,29,20,-8,
+-20,-52,-28,-1,13,
+26,-34,-10,-9,27,
+-8,8,27,-66,4,
+12,-22,49,10,-77,
+32,-18,3,-38,12,
+-3,-1,2,2,0};
diff --git a/jni/pjproject-android/.svn/pristine/12/12d94e19f6f21d98f89c07181c6213af02d9070e.svn-base b/jni/pjproject-android/.svn/pristine/12/12d94e19f6f21d98f89c07181c6213af02d9070e.svn-base
new file mode 100644
index 0000000..4ccd6cc
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12d94e19f6f21d98f89c07181c6213af02d9070e.svn-base
@@ -0,0 +1,463 @@
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
diff --git a/jni/pjproject-android/.svn/pristine/12/12ec8c76e85660b9b4311611a7576de86c565320.svn-base b/jni/pjproject-android/.svn/pristine/12/12ec8c76e85660b9b4311611a7576de86c565320.svn-base
new file mode 100644
index 0000000..658d091
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12ec8c76e85660b9b4311611a7576de86c565320.svn-base
@@ -0,0 +1,877 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * 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-videodev/videodev_imp.h>
+#include <pj/assert.h>
+#include <pj/errno.h>
+#include <pj/log.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+
+
+#define THIS_FILE   "videodev.c"
+
+#define DEFINE_CAP(name, info)	{name, info}
+
+/* Capability names */
+static struct cap_info
+{
+    const char *name;
+    const char *info;
+} cap_infos[] = 
+{
+    DEFINE_CAP("format",        "Video format"),
+    DEFINE_CAP("scale",         "Input dimension"),
+    DEFINE_CAP("window",        "Window handle"),
+    DEFINE_CAP("resize",        "Renderer resize"),
+    DEFINE_CAP("position",      "Renderer position"),
+    DEFINE_CAP("hide",          "Renderer hide"),
+    DEFINE_CAP("preview",       "Input preview"),
+    DEFINE_CAP("orientation",   "Video orientation"),
+    DEFINE_CAP("switch",        "Switch device"),
+    DEFINE_CAP("wndflags",      "Window flags")
+};
+
+
+/*
+ * The device index seen by application and driver is different. 
+ *
+ * At application level, device index is index to global list of device.
+ * At driver level, device index is index to device list on that particular
+ * factory only.
+ */
+#define MAKE_DEV_ID(f_id, index)   (((f_id & 0xFFFF) << 16) | (index & 0xFFFF))
+#define GET_INDEX(dev_id)	   ((dev_id) & 0xFFFF)
+#define GET_FID(dev_id)		   ((dev_id) >> 16)
+#define DEFAULT_DEV_ID		    0
+
+
+/* extern functions to create factories */
+#if PJMEDIA_VIDEO_DEV_HAS_NULL_VIDEO
+pjmedia_vid_dev_factory* pjmedia_null_video_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_DSHOW
+pjmedia_vid_dev_factory* pjmedia_dshow_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_CBAR_SRC
+pjmedia_vid_dev_factory* pjmedia_cbar_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_SDL
+pjmedia_vid_dev_factory* pjmedia_sdl_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_FFMPEG
+pjmedia_vid_dev_factory* pjmedia_ffmpeg_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_V4L2
+pjmedia_vid_dev_factory* pjmedia_v4l2_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_QT
+pjmedia_vid_dev_factory* pjmedia_qt_factory(pj_pool_factory *pf);
+#endif
+
+#if PJMEDIA_VIDEO_DEV_HAS_IOS
+pjmedia_vid_dev_factory* pjmedia_ios_factory(pj_pool_factory *pf);
+#endif
+
+#define MAX_DRIVERS	16
+#define MAX_DEVS	64
+
+
+/* driver structure */
+struct driver
+{
+    /* Creation function */
+    pjmedia_vid_dev_factory_create_func_ptr create;
+    /* Factory instance */
+    pjmedia_vid_dev_factory *f;
+    char		     name[32];	    /* Driver name		    */
+    unsigned		     dev_cnt;	    /* Number of devices	    */
+    unsigned		     start_idx;	    /* Start index in global list   */
+    int			     cap_dev_idx;   /* Default capture device.	    */
+    int			     rend_dev_idx;  /* Default render device	    */
+};
+
+/* The video device subsystem */
+static struct vid_subsys
+{
+    unsigned	     init_count;	/* How many times init() is called  */
+    pj_pool_factory *pf;		/* The pool factory.		    */
+
+    unsigned	     drv_cnt;		/* Number of drivers.		    */
+    struct driver    drv[MAX_DRIVERS];	/* Array of drivers.		    */
+
+    unsigned	     dev_cnt;		/* Total number of devices.	    */
+    pj_uint32_t	     dev_list[MAX_DEVS];/* Array of device IDs.		    */
+
+} vid_subsys;
+
+/* API: get capability name/info */
+PJ_DEF(const char*) pjmedia_vid_dev_cap_name(pjmedia_vid_dev_cap cap,
+					     const char **p_desc)
+{
+    const char *desc;
+    unsigned i;
+
+    if (p_desc==NULL) p_desc = &desc;
+
+    for (i=0; i<PJ_ARRAY_SIZE(cap_infos); ++i) {
+	if ((1 << i)==cap)
+	    break;
+    }
+
+    if (i==PJ_ARRAY_SIZE(cap_infos)) {
+	*p_desc = "??";
+	return "??";
+    }
+
+    *p_desc = cap_infos[i].info;
+    return cap_infos[i].name;
+}
+
+static pj_status_t get_cap_pointer(const pjmedia_vid_dev_param *param,
+				   pjmedia_vid_dev_cap cap,
+				   void **ptr,
+				   unsigned *size)
+{
+#define FIELD_INFO(name)    *ptr = (void*)&param->name; \
+			    *size = sizeof(param->name)
+
+    switch (cap) {
+    case PJMEDIA_VID_DEV_CAP_FORMAT:
+	FIELD_INFO(fmt);
+	break;
+    case PJMEDIA_VID_DEV_CAP_INPUT_SCALE:
+	FIELD_INFO(disp_size);
+	break;
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW:
+	FIELD_INFO(window);
+	break;
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE:
+	FIELD_INFO(disp_size);
+	break;
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION:
+	FIELD_INFO(window_pos);
+	break;
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE:
+	FIELD_INFO(window_hide);
+	break;
+    case PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW:
+	FIELD_INFO(native_preview);
+	break;
+    case PJMEDIA_VID_DEV_CAP_ORIENTATION:
+	FIELD_INFO(orient);
+	break;
+    /* The PJMEDIA_VID_DEV_CAP_SWITCH does not have an entry in the
+     * param (it doesn't make sense to open a stream and tell it
+     * to switch immediately).
+     */
+    case PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS:
+	FIELD_INFO(window_flags);
+	break;
+    default:
+	return PJMEDIA_EVID_INVCAP;
+    }
+
+#undef FIELD_INFO
+
+    return PJ_SUCCESS;
+}
+
+/* API: set cap value to param */
+PJ_DEF(pj_status_t)
+pjmedia_vid_dev_param_set_cap( pjmedia_vid_dev_param *param,
+			       pjmedia_vid_dev_cap cap,
+			       const void *pval)
+{
+    void *cap_ptr;
+    unsigned cap_size;
+    pj_status_t status;
+
+    status = get_cap_pointer(param, cap, &cap_ptr, &cap_size);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    pj_memcpy(cap_ptr, pval, cap_size);
+    param->flags |= cap;
+
+    return PJ_SUCCESS;
+}
+
+/* API: get cap value from param */
+PJ_DEF(pj_status_t)
+pjmedia_vid_dev_param_get_cap( const pjmedia_vid_dev_param *param,
+			       pjmedia_vid_dev_cap cap,
+			       void *pval)
+{
+    void *cap_ptr;
+    unsigned cap_size;
+    pj_status_t status;
+
+    status = get_cap_pointer(param, cap, &cap_ptr, &cap_size);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    if ((param->flags & cap) == 0) {
+	pj_bzero(cap_ptr, cap_size);
+	return PJMEDIA_EVID_INVCAP;
+    }
+
+    pj_memcpy(pval, cap_ptr, cap_size);
+    return PJ_SUCCESS;
+}
+
+/* Internal: init driver */
+static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh)
+{
+    struct driver *drv = &vid_subsys.drv[drv_idx];
+    pjmedia_vid_dev_factory *f;
+    unsigned i, dev_cnt;
+    pj_status_t status;
+
+    if (!refresh) {
+        /* Create the factory */
+        f = (*drv->create)(vid_subsys.pf);
+        if (!f)
+            return PJ_EUNKNOWN;
+
+        /* Call factory->init() */
+        status = f->op->init(f);
+        if (status != PJ_SUCCESS) {
+            f->op->destroy(f);
+            return status;
+        }
+    } else {
+	f = drv->f;
+    }
+
+    /* Get number of devices */
+    dev_cnt = f->op->get_dev_count(f);
+    if (dev_cnt + vid_subsys.dev_cnt > MAX_DEVS) {
+	PJ_LOG(4,(THIS_FILE, "%d device(s) cannot be registered because"
+			      " there are too many devices",
+			      vid_subsys.dev_cnt + dev_cnt - MAX_DEVS));
+	dev_cnt = MAX_DEVS - vid_subsys.dev_cnt;
+    }
+
+    /* enabling this will cause pjsua-lib initialization to fail when there
+     * is no video device installed in the system, even when pjsua has been
+     * run with --null-video
+     *
+    if (dev_cnt == 0) {
+	f->op->destroy(f);
+	return PJMEDIA_EVID_NODEV;
+    }
+    */
+
+    /* Fill in default devices */
+    drv->rend_dev_idx = drv->cap_dev_idx = -1;
+    for (i=0; i<dev_cnt; ++i) {
+	pjmedia_vid_dev_info info;
+
+	status = f->op->get_dev_info(f, i, &info);
+	if (status != PJ_SUCCESS) {
+	    f->op->destroy(f);
+	    return status;
+	}
+
+	if (drv->name[0]=='\0') {
+	    /* Set driver name */
+	    pj_ansi_strncpy(drv->name, info.driver, sizeof(drv->name));
+	    drv->name[sizeof(drv->name)-1] = '\0';
+	}
+
+	if (drv->rend_dev_idx < 0 && (info.dir & PJMEDIA_DIR_RENDER)) {
+	    /* Set default render device */
+	    drv->rend_dev_idx = i;
+	}
+	if (drv->cap_dev_idx < 0 && (info.dir & PJMEDIA_DIR_CAPTURE)) {
+	    /* Set default capture device */
+	    drv->cap_dev_idx = i;
+	}
+
+        if (drv->rend_dev_idx >= 0 && drv->cap_dev_idx >= 0) {
+	    /* Done. */
+	    break;
+	}
+    }
+
+    /* Register the factory */
+    drv->f = f;
+    drv->f->sys.drv_idx = drv_idx;
+    drv->start_idx = vid_subsys.dev_cnt;
+    drv->dev_cnt = dev_cnt;
+
+    /* Register devices to global list */
+    for (i=0; i<dev_cnt; ++i) {
+	vid_subsys.dev_list[vid_subsys.dev_cnt++] = MAKE_DEV_ID(drv_idx, i);
+    }
+
+    return PJ_SUCCESS;
+}
+
+/* Internal: deinit driver */
+static void deinit_driver(unsigned drv_idx)
+{
+    struct driver *drv = &vid_subsys.drv[drv_idx];
+
+    if (drv->f) {
+	drv->f->op->destroy(drv->f);
+	drv->f = NULL;
+    }
+
+    drv->dev_cnt = 0;
+    drv->rend_dev_idx = drv->cap_dev_idx = -1;
+}
+
+/* API: Initialize the video device subsystem. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_subsys_init(pj_pool_factory *pf)
+{
+    unsigned i;
+    pj_status_t status = PJ_SUCCESS;
+
+    /* Allow init() to be called multiple times as long as there is matching
+     * number of shutdown().
+     */
+    if (vid_subsys.init_count++ != 0) {
+	return PJ_SUCCESS;
+    }
+
+    /* Register error subsystem */
+    pj_register_strerror(PJMEDIA_VIDEODEV_ERRNO_START, 
+			 PJ_ERRNO_SPACE_SIZE, 
+			 &pjmedia_videodev_strerror);
+
+    /* Init */
+    vid_subsys.pf = pf;
+    vid_subsys.drv_cnt = 0;
+    vid_subsys.dev_cnt = 0;
+
+    /* Register creation functions */
+#if PJMEDIA_VIDEO_DEV_HAS_V4L2
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_v4l2_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_QT
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_qt_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_IOS
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_ios_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_DSHOW
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_dshow_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_FFMPEG
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_ffmpeg_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_CBAR_SRC
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_cbar_factory;
+#endif
+#if PJMEDIA_VIDEO_DEV_HAS_SDL
+    vid_subsys.drv[vid_subsys.drv_cnt++].create = &pjmedia_sdl_factory;
+#endif
+
+    /* Initialize each factory and build the device ID list */
+    for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	status = init_driver(i, PJ_FALSE);
+	if (status != PJ_SUCCESS) {
+	    deinit_driver(i);
+	    continue;
+	}
+    }
+
+    return vid_subsys.dev_cnt ? PJ_SUCCESS : status;
+}
+
+/* API: register a video device factory to the video device subsystem. */
+PJ_DEF(pj_status_t)
+pjmedia_vid_register_factory(pjmedia_vid_dev_factory_create_func_ptr adf,
+                             pjmedia_vid_dev_factory *factory)
+{
+    pj_bool_t refresh = PJ_FALSE;
+    pj_status_t status;
+
+    if (vid_subsys.init_count == 0)
+	return PJMEDIA_EVID_INIT;
+
+    vid_subsys.drv[vid_subsys.drv_cnt].create = adf;
+    vid_subsys.drv[vid_subsys.drv_cnt].f = factory;
+
+    if (factory) {
+        /* Call factory->init() */
+        status = factory->op->init(factory);
+        if (status != PJ_SUCCESS) {
+            factory->op->destroy(factory);
+            return status;
+        }
+        refresh = PJ_TRUE;
+    }
+
+    status = init_driver(vid_subsys.drv_cnt, refresh);
+    if (status == PJ_SUCCESS) {
+	vid_subsys.drv_cnt++;
+    } else {
+	deinit_driver(vid_subsys.drv_cnt);
+    }
+
+    return status;
+}
+
+/* API: unregister a video device factory from the video device subsystem. */
+PJ_DEF(pj_status_t)
+pjmedia_vid_unregister_factory(pjmedia_vid_dev_factory_create_func_ptr adf,
+                               pjmedia_vid_dev_factory *factory)
+{
+    unsigned i, j;
+
+    if (vid_subsys.init_count == 0)
+	return PJMEDIA_EVID_INIT;
+
+    for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	struct driver *drv = &vid_subsys.drv[i];
+
+	if ((factory && drv->f==factory) || (adf && drv->create == adf)) {
+	    for (j = drv->start_idx; j < drv->start_idx + drv->dev_cnt; j++)
+	    {
+		vid_subsys.dev_list[j] = (pj_uint32_t)PJMEDIA_VID_INVALID_DEV;
+	    }
+
+	    deinit_driver(i);
+	    pj_bzero(drv, sizeof(*drv));
+	    return PJ_SUCCESS;
+	}
+    }
+
+    return PJMEDIA_EVID_ERR;
+}
+
+/* API: get the pool factory registered to the video device subsystem. */
+PJ_DEF(pj_pool_factory*) pjmedia_vid_dev_subsys_get_pool_factory(void)
+{
+    return vid_subsys.pf;
+}
+
+/* API: Shutdown the video device subsystem. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_subsys_shutdown(void)
+{
+    unsigned i;
+
+    /* Allow shutdown() to be called multiple times as long as there is
+     * matching number of init().
+     */
+    if (vid_subsys.init_count == 0) {
+	return PJ_SUCCESS;
+    }
+    --vid_subsys.init_count;
+
+    if (vid_subsys.init_count == 0) {
+        for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	    deinit_driver(i);
+        }
+
+        vid_subsys.pf = NULL;
+    }
+    return PJ_SUCCESS;
+}
+
+/* API: Refresh the list of video devices installed in the system. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_refresh(void)
+{
+    unsigned i;
+    
+    vid_subsys.dev_cnt = 0;
+    for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	struct driver *drv = &vid_subsys.drv[i];
+	
+	if (drv->f && drv->f->op->refresh) {
+	    pj_status_t status = drv->f->op->refresh(drv->f);
+	    if (status != PJ_SUCCESS) {
+		PJ_PERROR(4, (THIS_FILE, status, "Unable to refresh device "
+						 "list for %s", drv->name));
+	    }
+	}
+	init_driver(i, PJ_TRUE);
+    }
+    return PJ_SUCCESS;
+}
+
+/* API: Get the number of video devices installed in the system. */
+PJ_DEF(unsigned) pjmedia_vid_dev_count(void)
+{
+    return vid_subsys.dev_cnt;
+}
+
+/* Internal: convert local index to global device index */
+static pj_status_t make_global_index(unsigned drv_idx, 
+				     pjmedia_vid_dev_index *id)
+{
+    if (*id < 0) {
+	return PJ_SUCCESS;
+    }
+
+    /* Check that factory still exists */
+    PJ_ASSERT_RETURN(vid_subsys.drv[drv_idx].f, PJ_EBUG);
+
+    /* Check that device index is valid */
+    PJ_ASSERT_RETURN(*id>=0 && *id<(int)vid_subsys.drv[drv_idx].dev_cnt, 
+		     PJ_EBUG);
+
+    *id += vid_subsys.drv[drv_idx].start_idx;
+    return PJ_SUCCESS;
+}
+
+/* Internal: lookup device id */
+static pj_status_t lookup_dev(pjmedia_vid_dev_index id,
+			      pjmedia_vid_dev_factory **p_f,
+			      unsigned *p_local_index)
+{
+    int f_id, index;
+
+    if (id < 0) {
+	unsigned i;
+
+	if (id <= PJMEDIA_VID_INVALID_DEV)
+	    return PJMEDIA_EVID_INVDEV;
+
+	for (i=0; i<vid_subsys.drv_cnt; ++i) {
+	    struct driver *drv = &vid_subsys.drv[i];
+	    if (id==PJMEDIA_VID_DEFAULT_CAPTURE_DEV && 
+		drv->cap_dev_idx >= 0) 
+	    {
+		id = drv->cap_dev_idx;
+		make_global_index(i, &id);
+		break;
+	    } else if (id==PJMEDIA_VID_DEFAULT_RENDER_DEV && 
+		drv->rend_dev_idx >= 0) 
+	    {
+		id = drv->rend_dev_idx;
+		make_global_index(i, &id);
+		break;
+	    }
+	}
+
+	if (id < 0) {
+	    return PJMEDIA_EVID_NODEFDEV;
+	}
+    }
+
+    f_id = GET_FID(vid_subsys.dev_list[id]);
+    index = GET_INDEX(vid_subsys.dev_list[id]);
+
+    if (f_id < 0 || f_id >= (int)vid_subsys.drv_cnt)
+	return PJMEDIA_EVID_INVDEV;
+
+    if (index < 0 || index >= (int)vid_subsys.drv[f_id].dev_cnt)
+	return PJMEDIA_EVID_INVDEV;
+
+    *p_f = vid_subsys.drv[f_id].f;
+    *p_local_index = (unsigned)index;
+
+    return PJ_SUCCESS;
+
+}
+
+/* API: lookup device id */
+PJ_DEF(pj_status_t)
+pjmedia_vid_dev_get_local_index(pjmedia_vid_dev_index id,
+                                pjmedia_vid_dev_factory **p_f,
+                                unsigned *p_local_index)
+{
+    return lookup_dev(id, p_f, p_local_index);
+}
+
+/* API: from factory and local index, get global index */
+PJ_DEF(pj_status_t)
+pjmedia_vid_dev_get_global_index(const pjmedia_vid_dev_factory *f,
+                                 unsigned local_idx,
+                                 pjmedia_vid_dev_index *pid)
+{
+    PJ_ASSERT_RETURN(f->sys.drv_idx >= 0 && f->sys.drv_idx < MAX_DRIVERS,
+                     PJ_EINVALIDOP);
+    *pid = local_idx;
+    return make_global_index(f->sys.drv_idx, pid);
+}
+
+/* API: Get device information. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_get_info(pjmedia_vid_dev_index id,
+					     pjmedia_vid_dev_info *info)
+{
+    pjmedia_vid_dev_factory *f;
+    unsigned index;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(info, PJ_EINVAL);
+    PJ_ASSERT_RETURN(vid_subsys.pf, PJMEDIA_EVID_INIT);
+
+    if (id <= PJMEDIA_VID_INVALID_DEV)
+	return PJMEDIA_EVID_INVDEV;
+
+    status = lookup_dev(id, &f, &index);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    status = f->op->get_dev_info(f, index, info);
+
+    /* Make sure device ID is the real ID (not PJMEDIA_VID_DEFAULT_*_DEV) */
+    info->id = index;
+    make_global_index(f->sys.drv_idx, &info->id);
+
+    return status;
+}
+
+/* API: find device */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_lookup( const char *drv_name,
+					    const char *dev_name,
+					    pjmedia_vid_dev_index *id)
+{
+    pjmedia_vid_dev_factory *f = NULL;
+    unsigned drv_idx, dev_idx;
+
+    PJ_ASSERT_RETURN(drv_name && dev_name && id, PJ_EINVAL);
+    PJ_ASSERT_RETURN(vid_subsys.pf, PJMEDIA_EVID_INIT);
+
+    for (drv_idx=0; drv_idx<vid_subsys.drv_cnt; ++drv_idx) {
+	if (!pj_ansi_stricmp(drv_name, vid_subsys.drv[drv_idx].name))
+	{
+	    f = vid_subsys.drv[drv_idx].f;
+	    break;
+	}
+    }
+
+    if (!f)
+	return PJ_ENOTFOUND;
+
+    for (dev_idx=0; dev_idx<vid_subsys.drv[drv_idx].dev_cnt; ++dev_idx)
+    {
+	pjmedia_vid_dev_info info;
+	pj_status_t status;
+
+	status = f->op->get_dev_info(f, dev_idx, &info);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	if (!pj_ansi_stricmp(dev_name, info.name))
+	    break;
+    }
+
+    if (dev_idx==vid_subsys.drv[drv_idx].dev_cnt)
+	return PJ_ENOTFOUND;
+
+    *id = dev_idx;
+    make_global_index(drv_idx, id);
+
+    return PJ_SUCCESS;
+}
+
+/* API: Initialize the video device parameters with default values for the
+ * specified device.
+ */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_default_param(pj_pool_t *pool,
+                                                  pjmedia_vid_dev_index id,
+						  pjmedia_vid_dev_param *param)
+{
+    pjmedia_vid_dev_factory *f;
+    unsigned index;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(param, PJ_EINVAL);
+    PJ_ASSERT_RETURN(vid_subsys.pf, PJMEDIA_EVID_INIT);
+
+    if (id <= PJMEDIA_VID_INVALID_DEV)
+	return PJMEDIA_EVID_INVDEV;
+
+    status = lookup_dev(id, &f, &index);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    status = f->op->default_param(pool, f, index, param);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Normalize device IDs */
+    make_global_index(f->sys.drv_idx, &param->cap_id);
+    make_global_index(f->sys.drv_idx, &param->rend_id);
+
+    return PJ_SUCCESS;
+}
+
+/* API: Open video stream object using the specified parameters. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_create(
+					pjmedia_vid_dev_param *prm,
+					const pjmedia_vid_dev_cb *cb,
+					void *user_data,
+					pjmedia_vid_dev_stream **p_vid_strm)
+{
+    pjmedia_vid_dev_factory *cap_f=NULL, *rend_f=NULL, *f=NULL;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(prm && prm->dir && p_vid_strm, PJ_EINVAL);
+    PJ_ASSERT_RETURN(vid_subsys.pf, PJMEDIA_EVID_INIT);
+    PJ_ASSERT_RETURN(prm->dir==PJMEDIA_DIR_CAPTURE ||
+		     prm->dir==PJMEDIA_DIR_RENDER ||
+		     prm->dir==PJMEDIA_DIR_CAPTURE_RENDER,
+		     PJ_EINVAL);
+
+    /* Normalize cap_id */
+    if (prm->dir & PJMEDIA_DIR_CAPTURE) {
+	unsigned index;
+
+	if (prm->cap_id < 0)
+	    prm->cap_id = PJMEDIA_VID_DEFAULT_CAPTURE_DEV;
+
+	status = lookup_dev(prm->cap_id, &cap_f, &index);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	prm->cap_id = index;
+	f = cap_f;
+    }
+
+    /* Normalize rend_id */
+    if (prm->dir & PJMEDIA_DIR_RENDER) {
+	unsigned index;
+
+	if (prm->rend_id < 0)
+	    prm->rend_id = PJMEDIA_VID_DEFAULT_RENDER_DEV;
+
+	status = lookup_dev(prm->rend_id, &rend_f, &index);
+	if (status != PJ_SUCCESS)
+	    return status;
+
+	prm->rend_id = index;
+	f = rend_f;
+    }
+
+    PJ_ASSERT_RETURN(f != NULL, PJ_EBUG);
+
+    /* For now, cap_id and rend_id must belong to the same factory */
+    PJ_ASSERT_RETURN((prm->dir != PJMEDIA_DIR_CAPTURE_RENDER) ||
+		     (cap_f == rend_f),
+		     PJMEDIA_EVID_INVDEV);
+
+    /* Create the stream */
+    status = f->op->create_stream(f, prm, cb,
+				  user_data, p_vid_strm);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Assign factory id to the stream */
+    (*p_vid_strm)->sys.drv_idx = f->sys.drv_idx;
+    return PJ_SUCCESS;
+}
+
+/* API: Get the running parameters for the specified video stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_get_param(
+					    pjmedia_vid_dev_stream *strm,
+					    pjmedia_vid_dev_param *param)
+{
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(strm && param, PJ_EINVAL);
+    PJ_ASSERT_RETURN(vid_subsys.pf, PJMEDIA_EVID_INIT);
+
+    status = strm->op->get_param(strm, param);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Normalize device id's */
+    make_global_index(strm->sys.drv_idx, &param->cap_id);
+    make_global_index(strm->sys.drv_idx, &param->rend_id);
+
+    return PJ_SUCCESS;
+}
+
+/* API: Get the value of a specific capability of the video stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_get_cap(
+					    pjmedia_vid_dev_stream *strm,
+					    pjmedia_vid_dev_cap cap,
+					    void *value)
+{
+    return strm->op->get_cap(strm, cap, value);
+}
+
+/* API: Set the value of a specific capability of the video stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_set_cap(
+					    pjmedia_vid_dev_stream *strm,
+					    pjmedia_vid_dev_cap cap,
+					    const void *value)
+{
+    return strm->op->set_cap(strm, cap, value);
+}
+
+/* API: Start the stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_start(pjmedia_vid_dev_stream *strm)
+{
+    pj_status_t status;
+
+    if (pjmedia_vid_dev_stream_is_running(strm))
+	return PJ_SUCCESS;
+
+    status = strm->op->start(strm);
+    if (status == PJ_SUCCESS)
+	strm->sys.is_running = PJ_TRUE;
+    return status;
+}
+
+/* API: has it been started? */
+PJ_DEF(pj_bool_t)
+pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm)
+{
+    return strm->sys.is_running;
+}
+
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_get_frame(
+					    pjmedia_vid_dev_stream *strm,
+					    pjmedia_frame *frame)
+{
+    pj_assert(strm->op->get_frame);
+    return strm->op->get_frame(strm, frame);
+}
+
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_put_frame(
+					    pjmedia_vid_dev_stream *strm,
+                                            const pjmedia_frame *frame)
+{
+    pj_assert(strm->op->put_frame);
+    return strm->op->put_frame(strm, frame);
+}
+
+/* API: Stop the stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_stop(pjmedia_vid_dev_stream *strm)
+{
+    strm->sys.is_running = PJ_FALSE;
+    return strm->op->stop(strm);
+}
+
+/* API: Destroy the stream. */
+PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_destroy(
+						pjmedia_vid_dev_stream *strm)
+{
+    strm->sys.is_running = PJ_FALSE;
+    return strm->op->destroy(strm);
+}
+
+
+#endif /* PJMEDIA_HAS_VIDEO */
diff --git a/jni/pjproject-android/.svn/pristine/12/12eeccaa48b155d35df6889b1276b7999997ee4a.svn-base b/jni/pjproject-android/.svn/pristine/12/12eeccaa48b155d35df6889b1276b7999997ee4a.svn-base
new file mode 100644
index 0000000..caff77e
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/12/12eeccaa48b155d35df6889b1276b7999997ee4a.svn-base
@@ -0,0 +1,27 @@
+
+   /******************************************************************
+
+       iLBC Speech Coder ANSI-C Source Code
+
+       lsf.h
+
+       Copyright (C) The Internet Society (2004).
+       All Rights Reserved.
+
+   ******************************************************************/
+
+   #ifndef __iLBC_LSF_H
+   #define __iLBC_LSF_H
+
+   void a2lsf(
+       float *freq,/* (o) lsf coefficients */
+       float *a    /* (i) lpc coefficients */
+   );
+
+   void lsf2a(
+       float *a_coef,  /* (o) lpc coefficients */
+       float *freq     /* (i) lsf coefficients */
+   );
+
+   #endif
+