* #27232: jni: added pjproject checkout as regular git content

We will remove it once the next release of pjsip (with Android support)
comes out and is merged into SFLphone.
diff --git a/jni/pjproject-android/.svn/pristine/18/181f4cf69afd8581a6d53ed10fe36f4833263e3f.svn-base b/jni/pjproject-android/.svn/pristine/18/181f4cf69afd8581a6d53ed10fe36f4833263e3f.svn-base
new file mode 100644
index 0000000..d1cc04f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/181f4cf69afd8581a6d53ed10fe36f4833263e3f.svn-base
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<!-- 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             -->
+<!--                                                                    -->
+<!--                                                                    -->
+
+<!-- Note:
+     For this test to work, PJSUA-LIB needs to add video line, with
+     this patch:
+
+     pjsua_media.c:1253, after call to pjmedia_endpt_create_sdp():
+
+    if (1) {
+	pjmedia_sdp_media *m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
+	m->desc.media = pj_str("video");
+	m->desc.port = 3000;
+	m->desc.transport = pj_str("RTP/AVP");
+	m->desc.fmt_count = 1;
+	m->desc.fmt[0] = pj_str("0");
+	sdp->media[sdp->media_count++] = m;
+    }
+
+-->
+     
+
+<scenario name="UAC with bad ACK">
+  <!-- UAC with bad ACK causes assertion with pjsip 1.4			-->
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=Tester 234 123 IN IP4 89.208.145.194
+      s=Tester
+      c=IN IP4 89.208.145.194
+      t=0 0
+      m=audio 17424 RTP/AVP 111 0 18 101
+      a=rtpmap:111 SPEEX/16000
+      a=rtpmap:0 PCMU/8000
+      a=rtpmap:18 G729/8000
+      a=rtpmap:101 telephone-event/8000
+      a=sendrecv
+      a=rtcp:17425
+      m=video 11128 RTP/AVP 34 103 104
+      a=rtpmap:34 H263/90000
+      a=rtpmap:103 H263-1998/90000
+      a=rtpmap:104 H264/90000
+      a=sendrecv
+      a=rtcp:11129
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
+  <!-- are saved and used for following messages sent. Useful to test   -->
+  <!-- against stateful SIP proxies/B2BUAs.                             -->
+  <recv response="200" rtd="true">
+  </recv>
+
+  <!-- Packet lost can be simulated in any send/recv message by         -->
+  <!-- by adding the 'lost = "10"'. Value can be [1-100] percent.       -->
+  <send>
+    <![CDATA[
+
+      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <!-- This delay can be customized by the -d command-line option       -->
+  <!-- or by adding a 'milliseconds = "value"' option here.             -->
+  <pause milliseconds="2000"/>
+
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 INVITE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=Tester 234 124 IN IP4 89.208.145.194
+      s=Tester
+      c=IN IP4 89.208.145.194
+      t=0 0
+      m=audio 17424 RTP/AVP 111 0 18 101
+      a=rtpmap:111 SPEEX/16000
+      a=rtpmap:0 PCMU/8000
+      a=rtpmap:18 G729/8000
+      a=rtpmap:101 telephone-event/8000
+      a=sendrecv
+      a=rtcp:17425
+      m=video 0 RTP/AVP 34 103 104
+      a=sendrecv
+
+
+    ]]>
+  </send>
+
+  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
+  <!-- are saved and used for following messages sent. Useful to test   -->
+  <!-- against stateful SIP proxies/B2BUAs.                             -->
+  <recv response="200" rtd="true">
+  </recv>
+
+  <!-- Packet lost can be simulated in any send/recv message by         -->
+  <!-- by adding the 'lost = "10"'. Value can be [1-100] percent.       -->
+  <send>
+    <![CDATA[
+
+      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 ACK
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+
+  <pause milliseconds="2000"/>
+
+
+  <!-- The 'crlf' option inserts a blank line in the statistics report. -->
+  <send retrans="500">
+    <![CDATA[
+
+      BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 3 BYE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="200" crlf="true">
+  </recv>
+
+
+  <!-- definition of the response time repartition table (unit is ms)   -->
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <!-- definition of the call length repartition table (unit is ms)     -->
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/jni/pjproject-android/.svn/pristine/18/183baa97f45396f175325debff11484910f79dc6.svn-base b/jni/pjproject-android/.svn/pristine/18/183baa97f45396f175325debff11484910f79dc6.svn-base
new file mode 100644
index 0000000..18ffd3c
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/183baa97f45396f175325debff11484910f79dc6.svn-base
@@ -0,0 +1,164 @@
+/* $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/plc.h>
+#include <pjmedia/errno.h>
+#include <pjmedia/wsola.h>
+#include <pj/assert.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+
+
+static void* plc_wsola_create(pj_pool_t*, unsigned c, unsigned f);
+static void  plc_wsola_save(void*, pj_int16_t*);
+static void  plc_wsola_generate(void*, pj_int16_t*);
+
+/**
+ * This struct is used internally to represent a PLC backend.
+ */
+struct plc_alg
+{
+    void* (*plc_create)(pj_pool_t*, unsigned c, unsigned f);
+    void  (*plc_save)(void*, pj_int16_t*);
+    void  (*plc_generate)(void*, pj_int16_t*);
+};
+
+
+static struct plc_alg plc_wsola =
+{
+    &plc_wsola_create,
+    &plc_wsola_save,
+    &plc_wsola_generate
+};
+
+
+struct pjmedia_plc
+{
+    void	    *obj;
+    struct plc_alg  *op;
+};
+
+
+/*
+ * Create PLC session. This function will select the PLC algorithm to
+ * use based on the arguments.
+ */
+PJ_DEF(pj_status_t) pjmedia_plc_create( pj_pool_t *pool,
+					unsigned clock_rate,
+					unsigned samples_per_frame,
+					unsigned options,
+					pjmedia_plc **p_plc)
+{
+    pjmedia_plc *plc;
+
+    PJ_ASSERT_RETURN(pool && clock_rate && samples_per_frame && p_plc,
+		     PJ_EINVAL);
+    PJ_ASSERT_RETURN(options == 0, PJ_EINVAL);
+
+    PJ_UNUSED_ARG(options);
+
+    plc = PJ_POOL_ZALLOC_T(pool, pjmedia_plc);
+
+    plc->op = &plc_wsola;
+    plc->obj = plc->op->plc_create(pool, clock_rate, samples_per_frame);
+
+    *p_plc = plc;
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Save a good frame to PLC.
+ */
+PJ_DEF(pj_status_t) pjmedia_plc_save( pjmedia_plc *plc,
+				      pj_int16_t *frame )
+{
+    PJ_ASSERT_RETURN(plc && frame, PJ_EINVAL);
+ 
+    plc->op->plc_save(plc->obj, frame);
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Generate a replacement for lost frame.
+ */
+PJ_DEF(pj_status_t) pjmedia_plc_generate( pjmedia_plc *plc,
+					  pj_int16_t *frame )
+{
+    PJ_ASSERT_RETURN(plc && frame, PJ_EINVAL);
+    
+    plc->op->plc_generate(plc->obj, frame);
+    return PJ_SUCCESS;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+/*
+ * Packet loss concealment based on WSOLA
+ */
+struct wsola_plc
+{
+    pjmedia_wsola   *wsola;
+    pj_bool_t	     prev_lost;
+};
+
+
+static void* plc_wsola_create(pj_pool_t *pool, unsigned clock_rate, 
+			      unsigned samples_per_frame)
+{
+    struct wsola_plc *o;
+    unsigned flag;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(clock_rate);
+
+    o = PJ_POOL_ZALLOC_T(pool, struct wsola_plc);
+    o->prev_lost = PJ_FALSE;
+
+    flag = PJMEDIA_WSOLA_NO_DISCARD;
+    if (PJMEDIA_WSOLA_PLC_NO_FADING)
+	flag |= PJMEDIA_WSOLA_NO_FADING;
+
+    status = pjmedia_wsola_create(pool, clock_rate, samples_per_frame, 1,
+				  flag, &o->wsola);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return o;
+}
+
+static void plc_wsola_save(void *plc, pj_int16_t *frame)
+{
+    struct wsola_plc *o = (struct wsola_plc*) plc;
+
+    pjmedia_wsola_save(o->wsola, frame, o->prev_lost);
+    o->prev_lost = PJ_FALSE;
+}
+
+static void plc_wsola_generate(void *plc, pj_int16_t *frame)
+{
+    struct wsola_plc *o = (struct wsola_plc*) plc;
+    
+    pjmedia_wsola_generate(o->wsola, frame);
+    o->prev_lost = PJ_TRUE;
+}
+
+
diff --git a/jni/pjproject-android/.svn/pristine/18/186d2ad7e40db8371edf39be7534bcc8e1b63ea8.svn-base b/jni/pjproject-android/.svn/pristine/18/186d2ad7e40db8371edf39be7534bcc8e1b63ea8.svn-base
new file mode 100644
index 0000000..38eda08
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/186d2ad7e40db8371edf39be7534bcc8e1b63ea8.svn-base
@@ -0,0 +1,39 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 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_SIP_AUTOCONF_H__
+#define __PJSIP_SIP_AUTOCONF_H__
+
+/**
+ * @file sip_autoconf.h
+ * @brief Describes operating system specifics (automatically detected by
+ *        autoconf)
+ */
+
+/*
+ * Enable/disable TLS transport, as configured by autoconf.
+ * But only do this if user doesn't explicitly configure in pj/config_site.h.
+ */
+/* Since 1.5, the default setting will follow PJ_HAS_SSL_SOCK setting. */
+//#ifndef PJSIP_HAS_TLS_TRANSPORT
+//#undef PJSIP_HAS_TLS_TRANSPORT
+//#endif
+
+#endif	/* __PJSIP_SIP_AUTOCONF_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/18/187a5c4b3ca776174671fe9b97e6fa20900b1603.svn-base b/jni/pjproject-android/.svn/pristine/18/187a5c4b3ca776174671fe9b97e6fa20900b1603.svn-base
new file mode 100644
index 0000000..8ef8a5f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/187a5c4b3ca776174671fe9b97e6fa20900b1603.svn-base
@@ -0,0 +1,126 @@
+/*
+ * kernel_driver.c
+ *
+ * a test driver for the crypto_kernel
+ *
+ * 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.
+ *
+ */
+
+
+#include <stdio.h>           /* for printf() */
+#include <unistd.h>          /* for getopt() */
+#include "crypto_kernel.h"
+
+void
+usage(char *prog_name) {
+  printf("usage: %s [ -v ][ -d debug_module ]*\n", prog_name);
+  exit(255);
+}
+
+int
+main (int argc, char *argv[]) {
+  extern char *optarg;
+  int q;
+  int do_validation      = 0;
+  err_status_t status;
+
+  if (argc == 1)
+    usage(argv[0]);
+
+  /* initialize kernel - we need to do this before anything else */ 
+  status = crypto_kernel_init();
+  if (status) {
+    printf("error: crypto_kernel init failed\n");
+    exit(1);
+  }
+  printf("crypto_kernel successfully initalized\n");
+
+  /* process input arguments */
+  while (1) {
+    q = getopt(argc, argv, "vd:");
+    if (q == -1) 
+      break;
+    switch (q) {
+    case 'v':
+      do_validation = 1;
+      break;
+    case 'd':
+      status = crypto_kernel_set_debug_module(optarg, 1);
+      if (status) {
+	printf("error: set debug module (%s) failed\n", optarg);
+	exit(1);
+      }
+      break;
+    default:
+      usage(argv[0]);
+    }    
+  }
+
+  if (do_validation) {
+    printf("checking crypto_kernel status...\n");
+    status = crypto_kernel_status();
+    if (status) {
+      printf("failed\n");
+      exit(1);
+    }
+    printf("crypto_kernel passed self-tests\n");
+  }
+
+  status = crypto_kernel_shutdown();
+  if (status) {
+    printf("error: crypto_kernel shutdown failed\n");
+    exit(1);
+  }
+  printf("crypto_kernel successfully shut down\n");
+  
+  return 0;
+}
+
+/*
+ * crypto_kernel_cipher_test() is a test of the cipher interface
+ * of the crypto_kernel
+ */
+
+err_status_t
+crypto_kernel_cipher_test(void) {
+
+  /* not implemented yet! */
+
+  return err_status_ok;
+}
diff --git a/jni/pjproject-android/.svn/pristine/18/188383f865f24de0596b6db8be8e3ad47a9303a3.svn-base b/jni/pjproject-android/.svn/pristine/18/188383f865f24de0596b6db8be8e3ad47a9303a3.svn-base
new file mode 100644
index 0000000..d5b1879
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/188383f865f24de0596b6db8be8e3ad47a9303a3.svn-base
@@ -0,0 +1,116 @@
+/* $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 "test.h"
+#include <pj/log.h>
+#include <pj/os.h>
+
+#if INCLUDE_OS_TEST
+static int endianness_test32(void)
+{
+    union t
+    {
+	pj_uint32_t u32;
+	pj_uint16_t u16[2];
+	pj_uint8_t u8[4];
+    } t;
+
+    PJ_LOG(3,("", " Testing endianness.."));
+
+    t.u32 = 0x11223344;
+
+#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN
+    PJ_LOG(3,("", "   Library is set to little endian"));
+
+#  if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN
+#    error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set!
+#  endif
+
+    if ((t.u16[0] & 0xFFFF) != 0x3344 ||
+	(t.u16[1] & 0xFFFF) != 0x1122)
+    {
+	PJ_LOG(3,("", "   Error: wrong 16bit values 0x%x and 0x%x",
+		      (t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF)));
+	return 10;
+    }
+
+    if ((t.u8[0] & 0xFF) != 0x44 ||
+	(t.u8[1] & 0xFF) != 0x33 ||
+	(t.u8[2] & 0xFF) != 0x22 ||
+	(t.u8[3] & 0xFF) != 0x11)
+    {
+	PJ_LOG(3,("", "   Error: wrong 8bit values"));
+	return 12;
+    }
+
+#elif defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN
+    PJ_LOG(3,("", "   Library is set to big endian"));
+
+    if ((t.u16[0] & 0xFFFF) != 0x1122 ||
+	(t.u16[1] & 0xFFFF) != 0x3344)
+    {
+	PJ_LOG(3,("", "   Error: wrong 16bit values 0x%x and 0x%x",
+		      (t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF)));
+	return 20;
+    }
+
+    if ((t.u8[0] & 0xFF) != 0x11 ||
+	(t.u8[1] & 0xFF) != 0x22 ||
+	(t.u8[2] & 0xFF) != 0x33 ||
+	(t.u8[3] & 0xFF) != 0x44)
+    {
+	PJ_LOG(3,("", "   Error: wrong 8bit values"));
+	return 22;
+    }
+
+#  if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN
+#    error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set!
+#  endif
+
+
+#else
+#    error Error: Endianness is not set properly!
+#endif
+
+    return 0;
+}
+
+int os_test(void)
+{
+    const pj_sys_info *si;
+    int rc = 0;
+
+    PJ_LOG(3,("", " Sys info:"));
+    si = pj_get_sys_info();
+    PJ_LOG(3,("", "   machine:  %s", si->machine.ptr));
+    PJ_LOG(3,("", "   os_name:  %s", si->os_name.ptr));
+    PJ_LOG(3,("", "   os_ver:   0x%x", si->os_ver));
+    PJ_LOG(3,("", "   sdk_name: %s", si->sdk_name.ptr));
+    PJ_LOG(3,("", "   sdk_ver:  0x%x", si->sdk_ver));
+    PJ_LOG(3,("", "   info:     %s", si->info.ptr));
+
+    rc = endianness_test32();
+
+    return rc;
+}
+
+#else
+int dummy_os_var;
+#endif
+
diff --git a/jni/pjproject-android/.svn/pristine/18/18b80243e0b616b3acd84c47a8f7dcb99fb5b24b.svn-base b/jni/pjproject-android/.svn/pristine/18/18b80243e0b616b3acd84c47a8f7dcb99fb5b24b.svn-base
new file mode 100644
index 0000000..796ed47
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/18/18b80243e0b616b3acd84c47a8f7dcb99fb5b24b.svn-base
@@ -0,0 +1,490 @@
+/* $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 "turn.h"
+#include <pj/compat/socket.h>
+
+#if PJ_HAS_TCP
+
+struct accept_op
+{
+    pj_ioqueue_op_key_t	op_key;
+    pj_sock_t		sock;
+    pj_sockaddr		src_addr;
+    int			src_addr_len;
+};
+
+struct tcp_listener
+{
+    pj_turn_listener	     base;
+    pj_ioqueue_key_t	    *key;
+    unsigned		     accept_cnt;
+    struct accept_op	    *accept_op;	/* Array of accept_op's	*/
+};
+
+
+static void lis_on_accept_complete(pj_ioqueue_key_t *key, 
+				   pj_ioqueue_op_key_t *op_key, 
+				   pj_sock_t sock, 
+				   pj_status_t status);
+static pj_status_t lis_destroy(pj_turn_listener *listener);
+static void transport_create(pj_sock_t sock, pj_turn_listener *lis,
+			     pj_sockaddr_t *src_addr, int src_addr_len);
+
+static void show_err(const char *sender, const char *title, 
+		     pj_status_t status)
+{
+    char errmsg[PJ_ERR_MSG_SIZE];
+
+    pj_strerror(status, errmsg, sizeof(errmsg));
+    PJ_LOG(4,(sender, "%s: %s", title, errmsg));
+}
+
+
+/*
+ * Create a new listener on the specified port.
+ */
+PJ_DEF(pj_status_t) pj_turn_listener_create_tcp(pj_turn_srv *srv,
+					        int af,
+					        const pj_str_t *bound_addr,
+					        unsigned port,
+						unsigned concurrency_cnt,
+						unsigned flags,
+						pj_turn_listener **p_listener)
+{
+    pj_pool_t *pool;
+    struct tcp_listener *tcp_lis;
+    pj_ioqueue_callback ioqueue_cb;
+    unsigned i;
+    pj_status_t status;
+
+    /* Create structure */
+    pool = pj_pool_create(srv->core.pf, "tcpl%p", 1000, 1000, NULL);
+    tcp_lis = PJ_POOL_ZALLOC_T(pool, struct tcp_listener);
+    tcp_lis->base.pool = pool;
+    tcp_lis->base.obj_name = pool->obj_name;
+    tcp_lis->base.server = srv;
+    tcp_lis->base.tp_type = PJ_TURN_TP_TCP;
+    tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    //tcp_lis->base.sendto = &tcp_sendto;
+    tcp_lis->base.destroy = &lis_destroy;
+    tcp_lis->accept_cnt = concurrency_cnt;
+    tcp_lis->base.flags = flags;
+
+    /* Create socket */
+    status = pj_sock_socket(af, pj_SOCK_STREAM(), 0, &tcp_lis->base.sock);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Init bind address */
+    status = pj_sockaddr_init(af, &tcp_lis->base.addr, bound_addr, 
+			      (pj_uint16_t)port);
+    if (status != PJ_SUCCESS) 
+	goto on_error;
+    
+    /* Create info */
+    pj_ansi_strcpy(tcp_lis->base.info, "TCP:");
+    pj_sockaddr_print(&tcp_lis->base.addr, tcp_lis->base.info+4, 
+		      sizeof(tcp_lis->base.info)-4, 3);
+
+    /* Bind socket */
+    status = pj_sock_bind(tcp_lis->base.sock, &tcp_lis->base.addr, 
+			  pj_sockaddr_get_len(&tcp_lis->base.addr));
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Listen() */
+    status = pj_sock_listen(tcp_lis->base.sock, 5);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Register to ioqueue */
+    pj_bzero(&ioqueue_cb, sizeof(ioqueue_cb));
+    ioqueue_cb.on_accept_complete = &lis_on_accept_complete;
+    status = pj_ioqueue_register_sock(pool, srv->core.ioqueue, tcp_lis->base.sock,
+				      tcp_lis, &ioqueue_cb, &tcp_lis->key);
+
+    /* Create op keys */
+    tcp_lis->accept_op = (struct accept_op*)pj_pool_calloc(pool, concurrency_cnt,
+						    sizeof(struct accept_op));
+
+    /* Create each accept_op and kick off read operation */
+    for (i=0; i<concurrency_cnt; ++i) {
+	lis_on_accept_complete(tcp_lis->key, &tcp_lis->accept_op[i].op_key, 
+			       PJ_INVALID_SOCKET, PJ_EPENDING);
+    }
+
+    /* Done */
+    PJ_LOG(4,(tcp_lis->base.obj_name, "Listener %s created", 
+	   tcp_lis->base.info));
+
+    *p_listener = &tcp_lis->base;
+    return PJ_SUCCESS;
+
+
+on_error:
+    lis_destroy(&tcp_lis->base);
+    return status;
+}
+
+
+/*
+ * Destroy listener.
+ */
+static pj_status_t lis_destroy(pj_turn_listener *listener)
+{
+    struct tcp_listener *tcp_lis = (struct tcp_listener *)listener;
+    unsigned i;
+
+    if (tcp_lis->key) {
+	pj_ioqueue_unregister(tcp_lis->key);
+	tcp_lis->key = NULL;
+	tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    } else if (tcp_lis->base.sock != PJ_INVALID_SOCKET) {
+	pj_sock_close(tcp_lis->base.sock);
+	tcp_lis->base.sock = PJ_INVALID_SOCKET;
+    }
+
+    for (i=0; i<tcp_lis->accept_cnt; ++i) {
+	/* Nothing to do */
+    }
+
+    if (tcp_lis->base.pool) {
+	pj_pool_t *pool = tcp_lis->base.pool;
+
+	PJ_LOG(4,(tcp_lis->base.obj_name, "Listener %s destroyed", 
+		  tcp_lis->base.info));
+
+	tcp_lis->base.pool = NULL;
+	pj_pool_release(pool);
+    }
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Callback on new TCP connection.
+ */
+static void lis_on_accept_complete(pj_ioqueue_key_t *key, 
+				   pj_ioqueue_op_key_t *op_key, 
+				   pj_sock_t sock, 
+				   pj_status_t status)
+{
+    struct tcp_listener *tcp_lis;
+    struct accept_op *accept_op = (struct accept_op*) op_key;
+
+    tcp_lis = (struct tcp_listener*) pj_ioqueue_get_user_data(key);
+
+    PJ_UNUSED_ARG(sock);
+
+    do {
+	/* Report new connection. */
+	if (status == PJ_SUCCESS) {
+	    char addr[PJ_INET6_ADDRSTRLEN+8];
+	    PJ_LOG(5,(tcp_lis->base.obj_name, "Incoming TCP from %s",
+		      pj_sockaddr_print(&accept_op->src_addr, addr,
+					sizeof(addr), 3)));
+	    transport_create(accept_op->sock, &tcp_lis->base,
+			     &accept_op->src_addr, accept_op->src_addr_len);
+	} else if (status != PJ_EPENDING) {
+	    show_err(tcp_lis->base.obj_name, "accept()", status);
+	}
+
+	/* Prepare next accept() */
+	accept_op->src_addr_len = sizeof(accept_op->src_addr);
+	status = pj_ioqueue_accept(key, op_key, &accept_op->sock,
+				   NULL,
+				   &accept_op->src_addr,
+				   &accept_op->src_addr_len);
+
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
+}
+
+
+/****************************************************************************/
+/*
+ * Transport
+ */
+enum
+{
+    TIMER_NONE,
+    TIMER_DESTROY
+};
+
+/* The delay in seconds to be applied before TCP transport is destroyed when 
+ * no allocation is referencing it. This also means the initial time to wait
+ * after the initial TCP connection establishment to receive a valid STUN
+ * message in the transport.
+ */
+#define SHUTDOWN_DELAY  10
+
+struct recv_op
+{
+    pj_ioqueue_op_key_t	op_key;
+    pj_turn_pkt		pkt;
+};
+
+struct tcp_transport
+{
+    pj_turn_transport	 base;
+    pj_pool_t		*pool;
+    pj_timer_entry	 timer;
+
+    pj_turn_allocation	*alloc;
+    int			 ref_cnt;
+
+    pj_sock_t		 sock;
+    pj_ioqueue_key_t	*key;
+    struct recv_op	 recv_op;
+    pj_ioqueue_op_key_t	 send_op;
+};
+
+
+static void tcp_on_read_complete(pj_ioqueue_key_t *key, 
+				 pj_ioqueue_op_key_t *op_key, 
+				 pj_ssize_t bytes_read);
+
+static pj_status_t tcp_sendto(pj_turn_transport *tp,
+			      const void *packet,
+			      pj_size_t size,
+			      unsigned flag,
+			      const pj_sockaddr_t *addr,
+			      int addr_len);
+static void tcp_destroy(struct tcp_transport *tcp);
+static void tcp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
+static void tcp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc);
+static void timer_callback(pj_timer_heap_t *timer_heap,
+			   pj_timer_entry *entry);
+
+static void transport_create(pj_sock_t sock, pj_turn_listener *lis,
+			     pj_sockaddr_t *src_addr, int src_addr_len)
+{
+    pj_pool_t *pool;
+    struct tcp_transport *tcp;
+    pj_ioqueue_callback cb;
+    pj_status_t status;
+
+    pool = pj_pool_create(lis->server->core.pf, "tcp%p", 1000, 1000, NULL);
+
+    tcp = PJ_POOL_ZALLOC_T(pool, struct tcp_transport);
+    tcp->base.obj_name = pool->obj_name;
+    tcp->base.listener = lis;
+    tcp->base.info = lis->info;
+    tcp->base.sendto = &tcp_sendto;
+    tcp->base.add_ref = &tcp_add_ref;
+    tcp->base.dec_ref = &tcp_dec_ref;
+    tcp->pool = pool;
+    tcp->sock = sock;
+
+    pj_timer_entry_init(&tcp->timer, TIMER_NONE, tcp, &timer_callback);
+
+    /* Register to ioqueue */
+    pj_bzero(&cb, sizeof(cb));
+    cb.on_read_complete = &tcp_on_read_complete;
+    status = pj_ioqueue_register_sock(pool, lis->server->core.ioqueue, sock,
+				      tcp, &cb, &tcp->key);
+    if (status != PJ_SUCCESS) {
+	tcp_destroy(tcp);
+	return;
+    }
+
+    /* Init pkt */
+    tcp->recv_op.pkt.pool = pj_pool_create(lis->server->core.pf, "tcpkt%p", 
+					   1000, 1000, NULL);
+    tcp->recv_op.pkt.transport = &tcp->base;
+    tcp->recv_op.pkt.src.tp_type = PJ_TURN_TP_TCP;
+    tcp->recv_op.pkt.src_addr_len = src_addr_len;
+    pj_memcpy(&tcp->recv_op.pkt.src.clt_addr, src_addr, src_addr_len);
+
+    tcp_on_read_complete(tcp->key, &tcp->recv_op.op_key, -PJ_EPENDING);
+    /* Should not access transport from now, it may have been destroyed */
+}
+
+
+static void tcp_destroy(struct tcp_transport *tcp)
+{
+    if (tcp->key) {
+	pj_ioqueue_unregister(tcp->key);
+	tcp->key = NULL;
+	tcp->sock = 0;
+    } else if (tcp->sock) {
+	pj_sock_close(tcp->sock);
+	tcp->sock = 0;
+    }
+
+    if (tcp->pool) {
+	pj_pool_release(tcp->pool);
+    }
+}
+
+
+static void timer_callback(pj_timer_heap_t *timer_heap,
+			   pj_timer_entry *entry)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) entry->user_data;
+
+    PJ_UNUSED_ARG(timer_heap);
+
+    tcp_destroy(tcp);
+}
+
+
+static void tcp_on_read_complete(pj_ioqueue_key_t *key, 
+				 pj_ioqueue_op_key_t *op_key, 
+				 pj_ssize_t bytes_read)
+{
+    struct tcp_transport *tcp;
+    struct recv_op *recv_op = (struct recv_op*) op_key;
+    pj_status_t status;
+
+    tcp = (struct tcp_transport*) pj_ioqueue_get_user_data(key);
+
+    do {
+	/* Report to server or allocation, if we have allocation */
+	if (bytes_read > 0) {
+
+	    recv_op->pkt.len = bytes_read;
+	    pj_gettimeofday(&recv_op->pkt.rx_time);
+
+	    tcp_add_ref(&tcp->base, NULL);
+
+	    if (tcp->alloc) {
+		pj_turn_allocation_on_rx_client_pkt(tcp->alloc, &recv_op->pkt);
+	    } else {
+		pj_turn_srv_on_rx_pkt(tcp->base.listener->server, &recv_op->pkt);
+	    }
+
+	    pj_assert(tcp->ref_cnt > 0);
+	    tcp_dec_ref(&tcp->base, NULL);
+
+	} else if (bytes_read != -PJ_EPENDING) {
+	    /* TCP connection closed/error. Notify client and then destroy 
+	     * ourselves.
+	     * Note: the -PJ_EPENDING is the value passed during init.
+	     */
+	    ++tcp->ref_cnt;
+
+	    if (tcp->alloc) {
+		if (bytes_read != 0) {
+		    show_err(tcp->base.obj_name, "TCP socket error", 
+			     -bytes_read);
+		} else {
+		    PJ_LOG(5,(tcp->base.obj_name, "TCP socket closed"));
+		}
+		pj_turn_allocation_on_transport_closed(tcp->alloc, &tcp->base);
+		tcp->alloc = NULL;
+	    }
+
+	    pj_assert(tcp->ref_cnt > 0);
+	    if (--tcp->ref_cnt == 0) {
+		tcp_destroy(tcp);
+		return;
+	    }
+	}
+
+	/* Reset pool */
+	pj_pool_reset(recv_op->pkt.pool);
+
+	/* If packet is full discard it */
+	if (recv_op->pkt.len == sizeof(recv_op->pkt.pkt)) {
+	    PJ_LOG(4,(tcp->base.obj_name, "Buffer discarded"));
+	    recv_op->pkt.len = 0;
+	}
+
+	/* Read next packet */
+	bytes_read = sizeof(recv_op->pkt.pkt) - recv_op->pkt.len;
+	status = pj_ioqueue_recv(tcp->key, op_key,
+				 recv_op->pkt.pkt + recv_op->pkt.len, 
+				 &bytes_read, 0);
+
+	if (status != PJ_EPENDING && status != PJ_SUCCESS)
+	    bytes_read = -status;
+
+    } while (status != PJ_EPENDING && status != PJ_ECANCELLED &&
+	     status != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL));
+
+}
+
+
+static pj_status_t tcp_sendto(pj_turn_transport *tp,
+			      const void *packet,
+			      pj_size_t size,
+			      unsigned flag,
+			      const pj_sockaddr_t *addr,
+			      int addr_len)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+    pj_ssize_t length = size;
+
+    PJ_UNUSED_ARG(addr);
+    PJ_UNUSED_ARG(addr_len);
+
+    return pj_ioqueue_send(tcp->key, &tcp->send_op, packet, &length, flag);
+}
+
+
+static void tcp_add_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+
+    ++tcp->ref_cnt;
+
+    if (tcp->alloc == NULL && alloc) {
+	tcp->alloc = alloc;
+    }
+
+    /* Cancel shutdown timer if it's running */
+    if (tcp->timer.id != TIMER_NONE) {
+	pj_timer_heap_cancel(tcp->base.listener->server->core.timer_heap,
+			     &tcp->timer);
+	tcp->timer.id = TIMER_NONE;
+    }
+}
+
+
+static void tcp_dec_ref(pj_turn_transport *tp,
+			pj_turn_allocation *alloc)
+{
+    struct tcp_transport *tcp = (struct tcp_transport*) tp;
+
+    --tcp->ref_cnt;
+
+    if (alloc && alloc == tcp->alloc) {
+	tcp->alloc = NULL;
+    }
+
+    if (tcp->ref_cnt == 0 && tcp->timer.id == TIMER_NONE) {
+	pj_time_val delay = { SHUTDOWN_DELAY, 0 };
+	tcp->timer.id = TIMER_DESTROY;
+	pj_timer_heap_schedule(tcp->base.listener->server->core.timer_heap,
+			       &tcp->timer, &delay);
+    }
+}
+
+#else	/* PJ_HAS_TCP */
+
+/* To avoid empty translation unit warning */
+int listener_tcp_dummy = 0;
+
+#endif	/* PJ_HAS_TCP */
+