* #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/af/af19e0b30bd0b806e23b3602b71b61969b91454c.svn-base b/jni/pjproject-android/.svn/pristine/af/af19e0b30bd0b806e23b3602b71b61969b91454c.svn-base
new file mode 100644
index 0000000..4f788bb
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af19e0b30bd0b806e23b3602b71b61969b91454c.svn-base
@@ -0,0 +1,35 @@
+/* $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/rand.h>
+#include <pj/os.h>
+#include <pj/compat/rand.h>
+
+PJ_DEF(void) pj_srand(unsigned int seed)
+{
+    PJ_CHECK_STACK();
+    platform_srand(seed);
+}
+
+PJ_DEF(int) pj_rand(void)
+{
+    PJ_CHECK_STACK();
+    return platform_rand();
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/af/af4e8c9c3886739973ccc27d1bb3b3f547392ba3.svn-base b/jni/pjproject-android/.svn/pristine/af/af4e8c9c3886739973ccc27d1bb3b3f547392ba3.svn-base
new file mode 100644
index 0000000..a0c083f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af4e8c9c3886739973ccc27d1bb3b3f547392ba3.svn-base
@@ -0,0 +1,24 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2009-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 
+ */
+
+/*
+ * This file is a C++ wrapper, see ticket #886 for details.
+ */
+
+#include "sip_auth_parser.c"
diff --git a/jni/pjproject-android/.svn/pristine/af/af70e0f54cf36e8518142a15b3d568801f6da0d8.svn-base b/jni/pjproject-android/.svn/pristine/af/af70e0f54cf36e8518142a15b3d568801f6da0d8.svn-base
new file mode 100644
index 0000000..647b078
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af70e0f54cf36e8518142a15b3d568801f6da0d8.svn-base
@@ -0,0 +1,146 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2011-2013 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2011 Dan Arrhenius <dan@keystream.se>
+ *
+ * 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 __PJMEDIA_CODEC_OPENCORE_AMR_H__
+#define __PJMEDIA_CODEC_OPENCORE_AMR_H__
+
+#include <pjmedia-codec/types.h>
+
+/**
+ * @defgroup PJMED_OC_AMR OpenCORE AMR Codec
+ * @ingroup PJMEDIA_CODEC_CODECS
+ * @brief AMRCodec wrapper for OpenCORE AMR codec
+ * @{
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * Bitmask options to be passed during AMR codec factory initialization.
+ */
+enum pjmedia_amr_options
+{
+    PJMEDIA_AMR_NO_NB	    = 1,    /**< Disable narrowband mode.	*/
+    PJMEDIA_AMR_NO_WB	    = 2,    /**< Disable wideband mode.		*/
+};
+
+/**
+ * Settings. Use #pjmedia_codec_opencore_amrnb/wb_set_config() to
+ * activate.
+ */
+typedef struct pjmedia_codec_amr_config
+{
+    /**
+     * Control whether to use octent align.
+     */
+    pj_bool_t octet_align;
+
+    /**
+     * Set the bitrate.
+     */
+    unsigned bitrate;
+
+} pjmedia_codec_amr_config;
+
+typedef pjmedia_codec_amr_config pjmedia_codec_amrnb_config;
+typedef pjmedia_codec_amr_config pjmedia_codec_amrwb_config;
+
+/**
+ * Initialize and register AMR codec factory to pjmedia endpoint.
+ *
+ * @param endpt     The pjmedia endpoint.
+ * @param options   Bitmask of pjmedia_amr_options (default=0).
+ *
+ * @return          PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amr_init(pjmedia_endpt* endpt,
+                                                     unsigned options);
+
+/**
+ * Initialize and register AMR codec factory using default settings to
+ * pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_opencore_amr_init_default(pjmedia_endpt* endpt);
+
+/**
+ * Unregister AMR codec factory from pjmedia endpoint and deinitialize
+ * the OpenCORE codec library.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amr_deinit(void);
+
+/**
+ * Initialize and register AMR-NB codec factory to pjmedia endpoint. Calling
+ * this function will automatically initialize AMR codec factory without
+ * the wideband mode (i.e. it is equivalent to calling
+ * #pjmedia_codec_opencore_amr_init() with PJMEDIA_AMR_NO_WB). Application
+ * should call #pjmedia_codec_opencore_amr_init() instead if wishing to use
+ * both modes.
+ *
+ * @param endpt	The pjmedia endpoint.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_init(pjmedia_endpt* endpt);
+
+/**
+ * Unregister AMR-NB codec factory from pjmedia endpoint and deinitialize
+ * the OpenCORE codec library.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_deinit(void);
+
+
+/**
+ * Set AMR-NB parameters.
+ *
+ * @param cfg	The settings;
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrnb_set_config(
+				const pjmedia_codec_amrnb_config* cfg);
+
+
+/**
+ * Set AMR-WB parameters.
+ *
+ * @param cfg	The settings;
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_set_config(
+                                        const pjmedia_codec_amrwb_config* cfg);
+
+PJ_END_DECL
+
+
+/**
+ * @}
+ */
+
+#endif	/* __PJMEDIA_CODEC_OPENCORE_AMRNB_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/af/af73523c33d540b651f798792e0e1819a4d32b6e.svn-base b/jni/pjproject-android/.svn/pristine/af/af73523c33d540b651f798792e0e1819a4d32b6e.svn-base
new file mode 100644
index 0000000..5d14f35
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af73523c33d540b651f798792e0e1819a4d32b6e.svn-base
@@ -0,0 +1,193 @@
+EXPORTS
+	echo_supp_cancel_echo                    @ 1 NONAME
+	echo_supp_capture                        @ 2 NONAME
+	echo_supp_create                         @ 3 NONAME
+	echo_supp_destroy                        @ 4 NONAME
+	echo_supp_playback                       @ 5 NONAME
+	pjmedia_bidirectional_port_create        @ 6 NONAME
+	pjmedia_calc_avg_signal                  @ 7 NONAME
+	pjmedia_clock_create                     @ 8 NONAME
+	pjmedia_clock_destroy                    @ 9 NONAME
+	pjmedia_clock_start                      @ 10 NONAME
+	pjmedia_clock_stop                       @ 11 NONAME
+	pjmedia_clock_wait                       @ 12 NONAME
+	pjmedia_codec_g711_deinit                @ 13 NONAME
+	pjmedia_codec_g711_init                  @ 14 NONAME
+	pjmedia_codec_info_to_id                 @ 15 NONAME
+	pjmedia_codec_mgr_alloc_codec            @ 16 NONAME
+	pjmedia_codec_mgr_dealloc_codec          @ 17 NONAME
+	pjmedia_codec_mgr_enum_codecs            @ 18 NONAME
+	pjmedia_codec_mgr_find_codecs_by_id      @ 19 NONAME
+	pjmedia_codec_mgr_get_codec_info         @ 20 NONAME
+	pjmedia_codec_mgr_get_default_param      @ 21 NONAME
+	pjmedia_codec_mgr_init                   @ 22 NONAME
+	pjmedia_codec_mgr_register_factory       @ 23 NONAME
+	pjmedia_codec_mgr_set_codec_priority     @ 24 NONAME
+	pjmedia_codec_mgr_unregister_factory     @ 25 NONAME
+	pjmedia_conf_add_passive_port            @ 26 NONAME
+	pjmedia_conf_add_port                    @ 27 NONAME
+	pjmedia_conf_adjust_rx_level             @ 28 NONAME
+	pjmedia_conf_adjust_tx_level             @ 29 NONAME
+	pjmedia_conf_configure_port              @ 30 NONAME
+	pjmedia_conf_connect_port                @ 31 NONAME
+	pjmedia_conf_create                      @ 32 NONAME
+	pjmedia_conf_destroy                     @ 33 NONAME
+	pjmedia_conf_disconnect_port             @ 34 NONAME
+	pjmedia_conf_enum_ports                  @ 35 NONAME
+	pjmedia_conf_get_connect_count           @ 36 NONAME
+	pjmedia_conf_get_master_port             @ 37 NONAME
+	pjmedia_conf_get_port_count              @ 38 NONAME
+	pjmedia_conf_get_port_info               @ 39 NONAME
+	pjmedia_conf_get_ports_info              @ 40 NONAME
+	pjmedia_conf_get_signal_level            @ 41 NONAME
+	pjmedia_conf_remove_port                 @ 42 NONAME
+	pjmedia_conf_set_port0_name              @ 43 NONAME
+	pjmedia_delay_buf_create                 @ 44 NONAME
+	pjmedia_delay_buf_get                    @ 45 NONAME
+	pjmedia_delay_buf_put                    @ 46 NONAME
+	pjmedia_echo_cancel                      @ 47 NONAME
+	pjmedia_echo_capture                     @ 48 NONAME
+	pjmedia_echo_create                      @ 49 NONAME
+	pjmedia_echo_destroy                     @ 50 NONAME
+	pjmedia_echo_playback                    @ 51 NONAME
+	pjmedia_echo_port_create                 @ 52 NONAME
+	pjmedia_endpt_create                     @ 53 NONAME
+	pjmedia_endpt_create_pool                @ 54 NONAME
+	pjmedia_endpt_create_sdp                 @ 55 NONAME
+	pjmedia_endpt_destroy                    @ 56 NONAME
+	pjmedia_endpt_dump                       @ 57 NONAME
+	pjmedia_endpt_get_codec_mgr              @ 58 NONAME
+	pjmedia_endpt_get_ioqueue                @ 59 NONAME
+	pjmedia_endpt_get_thread                 @ 60 NONAME
+	pjmedia_endpt_get_thread_count           @ 61 NONAME
+	pjmedia_ice_create                       @ 62 NONAME
+	pjmedia_ice_destroy                      @ 63 NONAME
+	pjmedia_ice_get_comp                     @ 64 NONAME
+	pjmedia_ice_get_init_status              @ 65 NONAME
+	pjmedia_ice_init_ice                     @ 66 NONAME
+	pjmedia_ice_modify_sdp                   @ 67 NONAME
+	pjmedia_ice_simulate_lost                @ 68 NONAME
+	pjmedia_ice_start_ice                    @ 69 NONAME
+	pjmedia_ice_start_init                   @ 70 NONAME
+	pjmedia_ice_stop_ice                     @ 71 NONAME
+	pjmedia_jbuf_create                      @ 72 NONAME
+	pjmedia_jbuf_destroy                     @ 73 NONAME
+	pjmedia_jbuf_get_frame                   @ 74 NONAME
+	pjmedia_jbuf_get_state                   @ 75 NONAME
+	pjmedia_jbuf_put_frame                   @ 76 NONAME
+	pjmedia_jbuf_reset                       @ 77 NONAME
+	pjmedia_jbuf_set_adaptive                @ 78 NONAME
+	pjmedia_jbuf_set_fixed                   @ 79 NONAME
+	pjmedia_master_port_create               @ 80 NONAME
+	pjmedia_master_port_destroy              @ 81 NONAME
+	pjmedia_master_port_get_dport            @ 82 NONAME
+	pjmedia_master_port_get_uport            @ 83 NONAME
+	pjmedia_master_port_set_dport            @ 84 NONAME
+	pjmedia_master_port_set_uport            @ 85 NONAME
+	pjmedia_master_port_start                @ 86 NONAME
+	pjmedia_master_port_stop                 @ 87 NONAME
+	pjmedia_mem_capture_create               @ 88 NONAME
+	pjmedia_mem_capture_get_size             @ 89 NONAME
+	pjmedia_mem_capture_set_eof_cb           @ 90 NONAME
+	pjmedia_mem_player_create                @ 91 NONAME
+	pjmedia_mem_player_set_eof_cb            @ 92 NONAME
+	pjmedia_null_port_create                 @ 93 NONAME
+	pjmedia_plc_create                       @ 94 NONAME
+	pjmedia_plc_generate                     @ 95 NONAME
+	pjmedia_plc_save                         @ 96 NONAME
+	pjmedia_port_destroy                     @ 97 NONAME
+	pjmedia_port_get_frame                   @ 98 NONAME
+	pjmedia_port_info_init                   @ 99 NONAME
+	pjmedia_port_put_frame                   @ 100 NONAME
+	pjmedia_resample_create                  @ 101 NONAME
+	pjmedia_resample_destroy                 @ 102 NONAME
+	pjmedia_resample_get_input_size          @ 103 NONAME
+	pjmedia_resample_port_create             @ 104 NONAME
+	pjmedia_resample_run                     @ 105 NONAME
+	pjmedia_rtcp_build_rtcp                  @ 106 NONAME
+	pjmedia_rtcp_fini                        @ 107 NONAME
+	pjmedia_rtcp_get_ntp_time                @ 108 NONAME
+	pjmedia_rtcp_init                        @ 109 NONAME
+	pjmedia_rtcp_rx_rtcp                     @ 110 NONAME
+	pjmedia_rtcp_rx_rtp                      @ 111 NONAME
+	pjmedia_rtcp_tx_rtp                      @ 112 NONAME
+	pjmedia_rtp_decode_rtp                   @ 113 NONAME
+	pjmedia_rtp_encode_rtp                   @ 114 NONAME
+	pjmedia_rtp_session_init                 @ 115 NONAME
+	pjmedia_rtp_session_update               @ 116 NONAME
+	pjmedia_session_check_dtmf               @ 117 NONAME
+	pjmedia_session_create                   @ 118 NONAME
+	pjmedia_session_destroy                  @ 119 NONAME
+	pjmedia_session_dial_dtmf                @ 120 NONAME
+	pjmedia_session_enum_streams             @ 121 NONAME
+	pjmedia_session_get_dtmf                 @ 122 NONAME
+	pjmedia_session_get_info                 @ 123 NONAME
+	pjmedia_session_get_port                 @ 124 NONAME
+	pjmedia_session_get_stream_stat          @ 125 NONAME
+	pjmedia_session_info_from_sdp            @ 126 NONAME
+	pjmedia_session_pause                    @ 127 NONAME
+	pjmedia_session_pause_stream             @ 128 NONAME
+	pjmedia_session_resume                   @ 129 NONAME
+	pjmedia_session_resume_stream            @ 130 NONAME
+	pjmedia_session_set_dtmf_callback        @ 131 NONAME
+	pjmedia_silence_det_apply                @ 132 NONAME
+	pjmedia_silence_det_create               @ 133 NONAME
+	pjmedia_silence_det_detect               @ 134 NONAME
+	pjmedia_silence_det_disable              @ 135 NONAME
+	pjmedia_silence_det_set_adaptive         @ 136 NONAME
+	pjmedia_silence_det_set_fixed            @ 137 NONAME
+	pjmedia_silence_det_set_name             @ 138 NONAME
+	pjmedia_silence_det_set_params           @ 139 NONAME
+	pjmedia_snd_port_connect                 @ 140 NONAME
+	pjmedia_snd_port_create                  @ 141 NONAME
+	pjmedia_snd_port_create_player           @ 142 NONAME
+	pjmedia_snd_port_create_rec              @ 143 NONAME
+	pjmedia_snd_port_destroy                 @ 144 NONAME
+	pjmedia_snd_port_disconnect              @ 145 NONAME
+	pjmedia_snd_port_get_ec_tail             @ 146 NONAME
+	pjmedia_snd_port_get_port                @ 147 NONAME
+	pjmedia_snd_port_get_snd_stream          @ 148 NONAME
+	pjmedia_snd_port_set_ec                  @ 149 NONAME
+	pjmedia_splitcomb_create                 @ 150 NONAME
+	pjmedia_splitcomb_create_rev_channel     @ 151 NONAME
+	pjmedia_splitcomb_set_channel            @ 152 NONAME
+	pjmedia_stream_check_dtmf                @ 153 NONAME
+	pjmedia_stream_create                    @ 154 NONAME
+	pjmedia_stream_destroy                   @ 155 NONAME
+	pjmedia_stream_dial_dtmf                 @ 156 NONAME
+	pjmedia_stream_get_dtmf                  @ 157 NONAME
+	pjmedia_stream_get_port                  @ 158 NONAME
+	pjmedia_stream_get_stat                  @ 159 NONAME
+	pjmedia_stream_get_transport             @ 160 NONAME
+	pjmedia_stream_info_from_sdp             @ 161 NONAME
+	pjmedia_stream_pause                     @ 162 NONAME
+	pjmedia_stream_resume                    @ 163 NONAME
+	pjmedia_stream_set_dtmf_callback         @ 164 NONAME
+	pjmedia_stream_start                     @ 165 NONAME
+	pjmedia_strerror                         @ 166 NONAME
+	pjmedia_tonegen_create                   @ 167 NONAME
+	pjmedia_tonegen_create2                  @ 168 NONAME
+	pjmedia_tonegen_get_digit_map            @ 169 NONAME
+	pjmedia_tonegen_is_busy                  @ 170 NONAME
+	pjmedia_tonegen_play                     @ 171 NONAME
+	pjmedia_tonegen_play_digits              @ 172 NONAME
+	pjmedia_tonegen_set_digit_map            @ 173 NONAME
+	pjmedia_tonegen_stop                     @ 174 NONAME
+	pjmedia_transport_udp_attach             @ 175 NONAME
+	pjmedia_transport_udp_close              @ 176 NONAME
+	pjmedia_transport_udp_create             @ 177 NONAME
+	pjmedia_transport_udp_create2            @ 178 NONAME
+	pjmedia_transport_udp_create3            @ 179 NONAME
+	pjmedia_transport_udp_get_info           @ 180 NONAME
+	pjmedia_transport_udp_simulate_lost      @ 181 NONAME
+	pjmedia_wav_player_port_create           @ 182 NONAME
+	pjmedia_wav_player_port_get_pos          @ 183 NONAME
+	pjmedia_wav_player_port_set_pos          @ 184 NONAME
+	pjmedia_wav_player_set_eof_cb            @ 185 NONAME
+	pjmedia_wav_playlist_create              @ 186 NONAME
+	pjmedia_wav_playlist_set_eof_cb          @ 187 NONAME
+	pjmedia_wav_writer_port_create           @ 188 NONAME
+	pjmedia_wav_writer_port_get_pos          @ 189 NONAME
+	pjmedia_wav_writer_port_set_cb           @ 190 NONAME
+	pjmedia_wave_hdr_file_to_host            @ 191 NONAME
+	pjmedia_wave_hdr_host_to_file            @ 192 NONAME
diff --git a/jni/pjproject-android/.svn/pristine/af/af889e6f86ad9ba5e374245a9efb4f69837f97c5.svn-base b/jni/pjproject-android/.svn/pristine/af/af889e6f86ad9ba5e374245a9efb4f69837f97c5.svn-base
new file mode 100644
index 0000000..edfd40f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af889e6f86ad9ba5e374245a9efb4f69837f97c5.svn-base
@@ -0,0 +1,31 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--realm=* --user=username --password=password " + \
+	"--auto-update-nat=0"
+
+# 401 Response, missing realm value
+req1 = sip.RecvfromTransaction("Initial request", 401,
+				include=["REGISTER sip"], 
+				exclude=[],
+				resp_hdr=['WWW-Authenticate: Digest']
+			  	)
+
+# Client should retry, we giving it another 401 with empty realm
+req2 = sip.RecvfromTransaction("REGISTER retry #1 of 2", 407,
+				include=["REGISTER sip"], 
+				exclude=[],
+				resp_hdr=['Proxy-Authenticate: Digest realm=""']
+			  	)
+
+# Client should retry
+req3 = sip.RecvfromTransaction("REGISTER retry #2 of 2", 200,
+				include=[], 
+				exclude=[],
+				expect="registration success"
+			  	)
+
+recvfrom_cfg = sip.RecvfromCfg("Registration with empty realm",
+			       pjsua, [req1, req2, req3])
diff --git a/jni/pjproject-android/.svn/pristine/af/af8f5d7bf29490b56ddf67f94b265c80c804a4b6.svn-base b/jni/pjproject-android/.svn/pristine/af/af8f5d7bf29490b56ddf67f94b265c80c804a4b6.svn-base
new file mode 100644
index 0000000..69a9859
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/af8f5d7bf29490b56ddf67f94b265c80c804a4b6.svn-base
@@ -0,0 +1,114 @@
+# $Id$
+#
+# pjsua Setup script.
+#
+# 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 
+#
+from distutils.core import setup, Extension
+import os
+import sys
+import platform
+
+# find pjsip version
+pj_version=""
+pj_version_major=""
+pj_version_minor=""
+pj_version_rev=""
+pj_version_suffix=""
+f = open('../../../version.mak', 'r')
+for line in f:
+    if line.find("export PJ_VERSION_MAJOR") != -1:
+    	tokens=line.split("=")
+	if len(tokens)>1:
+		pj_version_major= tokens[1].strip()
+    elif line.find("export PJ_VERSION_MINOR") != -1:
+    	tokens=line.split("=")
+	if len(tokens)>1:
+		pj_version_minor= line.split("=")[1].strip()
+    elif line.find("export PJ_VERSION_REV") != -1:
+    	tokens=line.split("=")
+	if len(tokens)>1:
+		pj_version_rev= line.split("=")[1].strip()
+    elif line.find("export PJ_VERSION_SUFFIX") != -1:
+    	tokens=line.split("=")
+	if len(tokens)>1:
+		pj_version_suffix= line.split("=")[1].strip()
+
+f.close()
+if not pj_version_major:
+    print 'Unable to get PJ_VERSION_MAJOR'
+    sys.exit(1)
+
+pj_version = pj_version_major + "." + pj_version_minor
+if pj_version_rev:
+	pj_version += "." + pj_version_rev
+if pj_version_suffix:
+	pj_version += "-" + pj_version_suffix
+
+#print 'PJ_VERSION = "'+ pj_version + '"'
+
+
+# Fill in pj_inc_dirs
+pj_inc_dirs = []
+f = os.popen("make -f helper.mak inc_dir")
+for line in f:
+    pj_inc_dirs.append(line.rstrip("\r\n"))
+f.close()
+
+# Fill in pj_lib_dirs
+pj_lib_dirs = []
+f = os.popen("make -f helper.mak lib_dir")
+for line in f:
+    pj_lib_dirs.append(line.rstrip("\r\n"))
+f.close()
+
+# Fill in pj_libs
+pj_libs = []
+f = os.popen("make -f helper.mak libs")
+for line in f:
+    pj_libs.append(line.rstrip("\r\n"))
+f.close()
+
+# Mac OS X depedencies
+if platform.system() == 'Darwin':
+    extra_link_args = ["-framework", "CoreFoundation", 
+                       "-framework", "AudioToolbox"]
+    version = platform.mac_ver()[0].split(".")    
+    # OS X Lion (10.7.x) or above support
+    if version[0] == '10' and int(version[1]) >= 7:
+        extra_link_args += ["-framework", "AudioUnit"]
+else:
+    extra_link_args = []
+
+
+setup(name="pjsua", 
+      version=pj_version,
+      description='SIP User Agent Library based on PJSIP',
+      url='http://trac.pjsip.org/repos/wiki/Python_SIP_Tutorial',
+      ext_modules = [Extension("_pjsua", 
+                               ["_pjsua.c"], 
+                               define_macros=[('PJ_AUTOCONF', '1'),],
+                               include_dirs=pj_inc_dirs, 
+                               library_dirs=pj_lib_dirs, 
+                               libraries=pj_libs,
+                               extra_link_args=extra_link_args
+                              )
+                    ],
+      py_modules=["pjsua"]
+     )
+
+
diff --git a/jni/pjproject-android/.svn/pristine/af/afb68d56fd4857d40154e6cbd398b57bb14b4fd5.svn-base b/jni/pjproject-android/.svn/pristine/af/afb68d56fd4857d40154e6cbd398b57bb14b4fd5.svn-base
new file mode 100644
index 0000000..d7b3344
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/afb68d56fd4857d40154e6cbd398b57bb14b4fd5.svn-base
@@ -0,0 +1,1680 @@
+/* $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-codec/ipp_codecs.h>
+#include <pjmedia-codec/amr_sdp_match.h>
+#include <pjmedia-codec/g7221_sdp_match.h>
+#include <pjmedia/codec.h>
+#include <pjmedia/errno.h>
+#include <pjmedia/endpoint.h>
+#include <pjmedia/plc.h>
+#include <pjmedia/port.h>
+#include <pjmedia/silencedet.h>
+#include <pj/assert.h>
+#include <pj/log.h>
+#include <pj/math.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+#include <pj/os.h>
+
+
+/*
+ * Only build this file if PJMEDIA_HAS_INTEL_IPP != 0
+ */
+#if defined(PJMEDIA_HAS_INTEL_IPP) && PJMEDIA_HAS_INTEL_IPP != 0
+
+#include <usc.h>
+#include <ippversion.h>
+
+#define THIS_FILE   "ipp_codecs.c"
+
+
+/* Prototypes for IPP codecs factory */
+static pj_status_t ipp_test_alloc( pjmedia_codec_factory *factory, 
+				   const pjmedia_codec_info *id );
+static pj_status_t ipp_default_attr( pjmedia_codec_factory *factory, 
+				     const pjmedia_codec_info *id, 
+				     pjmedia_codec_param *attr );
+static pj_status_t ipp_enum_codecs( pjmedia_codec_factory *factory, 
+				    unsigned *count, 
+				    pjmedia_codec_info codecs[]);
+static pj_status_t ipp_alloc_codec( pjmedia_codec_factory *factory, 
+				    const pjmedia_codec_info *id, 
+				    pjmedia_codec **p_codec);
+static pj_status_t ipp_dealloc_codec( pjmedia_codec_factory *factory, 
+				      pjmedia_codec *codec );
+
+/* Prototypes for IPP codecs implementation. */
+static pj_status_t  ipp_codec_init( pjmedia_codec *codec, 
+				    pj_pool_t *pool );
+static pj_status_t  ipp_codec_open( pjmedia_codec *codec, 
+				    pjmedia_codec_param *attr );
+static pj_status_t  ipp_codec_close( pjmedia_codec *codec );
+static pj_status_t  ipp_codec_modify(pjmedia_codec *codec, 
+				     const pjmedia_codec_param *attr );
+static pj_status_t  ipp_codec_parse( pjmedia_codec *codec,
+				     void *pkt,
+				     pj_size_t pkt_size,
+				     const pj_timestamp *ts,
+				     unsigned *frame_cnt,
+				     pjmedia_frame frames[]);
+static pj_status_t  ipp_codec_encode( pjmedia_codec *codec, 
+				      const struct pjmedia_frame *input,
+				      unsigned output_buf_len, 
+				      struct pjmedia_frame *output);
+static pj_status_t  ipp_codec_decode( pjmedia_codec *codec, 
+				      const struct pjmedia_frame *input,
+				      unsigned output_buf_len, 
+				      struct pjmedia_frame *output);
+static pj_status_t  ipp_codec_recover(pjmedia_codec *codec, 
+				      unsigned output_buf_len, 
+				      struct pjmedia_frame *output);
+
+/* Definition for IPP codecs operations. */
+static pjmedia_codec_op ipp_op = 
+{
+    &ipp_codec_init,
+    &ipp_codec_open,
+    &ipp_codec_close,
+    &ipp_codec_modify,
+    &ipp_codec_parse,
+    &ipp_codec_encode,
+    &ipp_codec_decode,
+    &ipp_codec_recover
+};
+
+/* Definition for IPP codecs factory operations. */
+static pjmedia_codec_factory_op ipp_factory_op =
+{
+    &ipp_test_alloc,
+    &ipp_default_attr,
+    &ipp_enum_codecs,
+    &ipp_alloc_codec,
+    &ipp_dealloc_codec,
+    &pjmedia_codec_ipp_deinit
+};
+
+/* IPP codecs factory */
+static struct ipp_factory {
+    pjmedia_codec_factory    base;
+    pjmedia_endpt	    *endpt;
+    pj_pool_t		    *pool;
+    pj_mutex_t		    *mutex;
+    unsigned		     g7221_pcm_shift;
+} ipp_factory;
+
+/* IPP codecs private data. */
+typedef struct ipp_private {
+    int			 codec_idx;	    /**< Codec index.		    */
+    void		*codec_setting;	    /**< Specific codec setting.    */
+    pj_pool_t		*pool;		    /**< Pool for each instance.    */
+
+    USC_Handle		 enc;		    /**< Encoder state.		    */
+    USC_Handle		 dec;		    /**< Decoder state.		    */
+    USC_CodecInfo	*info;		    /**< Native codec info.	    */
+    pj_uint16_t		 frame_size;	    /**< Bitstream frame size.	    */
+
+    pj_bool_t		 plc_enabled;	    /**< PLC enabled flag.	    */
+    pjmedia_plc		*plc;		    /**< PJMEDIA PLC engine, NULL if 
+						 codec has internal PLC.    */
+
+    pj_bool_t		 vad_enabled;	    /**< VAD enabled flag.	    */
+    pjmedia_silence_det	*vad;		    /**< PJMEDIA VAD engine, NULL if 
+						 codec has internal VAD.    */
+    pj_timestamp	 last_tx;	    /**< Timestamp of last transmit.*/
+
+    unsigned		 g7221_pcm_shift;   /**< G722.1 PCM level adjustment*/
+} ipp_private_t;
+
+
+/* USC codec implementations. */
+extern USC_Fxns USC_G729AFP_Fxns;
+extern USC_Fxns USC_G729I_Fxns;
+extern USC_Fxns USC_G723_Fxns;
+extern USC_Fxns USC_G726_Fxns;
+extern USC_Fxns USC_G728_Fxns;
+extern USC_Fxns USC_G722_Fxns;
+extern USC_Fxns USC_GSMAMR_Fxns;
+extern USC_Fxns USC_AMRWB_Fxns;
+extern USC_Fxns USC_AMRWBE_Fxns;
+
+
+/* CUSTOM CALLBACKS */
+
+/* This callback is useful for translating RTP frame into USC frame, e.g:
+ * reassigning frame attributes, reorder bitstream. Default behaviour of
+ * the translation is just setting the USC frame buffer & its size as 
+ * specified in RTP frame, setting USC frame frametype to 0, setting bitrate
+ * of USC frame to bitrate info of codec_data. Implement this callback when 
+ * the default behaviour is unapplicable.
+ */
+typedef void (*predecode_cb)(ipp_private_t *codec_data,
+			     const pjmedia_frame *rtp_frame,
+			     USC_Bitstream *usc_frame);
+
+/* Parse frames from a packet. Default behaviour of frame parsing is 
+ * just separating frames based on calculating frame length derived 
+ * from bitrate. Implement this callback when the default behaviour is 
+ * unapplicable.
+ */
+typedef pj_status_t (*parse_cb)(ipp_private_t *codec_data, void *pkt, 
+				pj_size_t pkt_size, const pj_timestamp *ts,
+				unsigned *frame_cnt, pjmedia_frame frames[]);
+
+/* Pack frames into a packet. Default behaviour of packing frames is 
+ * just stacking the frames with octet aligned without adding any 
+ * payload header. Implement this callback when the default behaviour is
+ * unapplicable.
+ */
+typedef pj_status_t (*pack_cb)(ipp_private_t *codec_data, void *pkt, 
+			       pj_size_t *pkt_size, pj_size_t max_pkt_size);
+
+
+
+/* Custom callback implementations. */
+static    void predecode_g723( ipp_private_t *codec_data,
+			       const pjmedia_frame *rtp_frame,
+			       USC_Bitstream *usc_frame);
+static pj_status_t parse_g723( ipp_private_t *codec_data, void *pkt, 
+			       pj_size_t pkt_size, const pj_timestamp *ts,
+			       unsigned *frame_cnt, pjmedia_frame frames[]);
+
+static void predecode_g729( ipp_private_t *codec_data,
+			    const pjmedia_frame *rtp_frame,
+			    USC_Bitstream *usc_frame);
+
+static    void predecode_amr( ipp_private_t *codec_data,
+			      const pjmedia_frame *rtp_frame,
+			      USC_Bitstream *usc_frame);
+static pj_status_t parse_amr( ipp_private_t *codec_data, void *pkt, 
+			      pj_size_t pkt_size, const pj_timestamp *ts,
+			      unsigned *frame_cnt, pjmedia_frame frames[]);
+static  pj_status_t pack_amr( ipp_private_t *codec_data, void *pkt, 
+			      pj_size_t *pkt_size, pj_size_t max_pkt_size);
+
+static    void predecode_g7221( ipp_private_t *codec_data,
+				const pjmedia_frame *rtp_frame,
+				USC_Bitstream *usc_frame);
+static  pj_status_t pack_g7221( ipp_private_t *codec_data, void *pkt, 
+			        pj_size_t *pkt_size, pj_size_t max_pkt_size);
+
+/* IPP codec implementation descriptions. */
+static struct ipp_codec {
+    int		     enabled;		/* Is this codec enabled?	    */
+    const char	    *name;		/* Codec name.			    */
+    pj_uint8_t	     pt;		/* Payload type.		    */
+    USC_Fxns	    *fxns;		/* USC callback functions.	    */
+    unsigned	     clock_rate;	/* Codec's clock rate.		    */
+    unsigned	     channel_count;	/* Codec's channel count.	    */
+    unsigned	     samples_per_frame;	/* Codec's samples count.	    */
+
+    unsigned	     def_bitrate;	/* Default bitrate of this codec.   */
+    unsigned	     max_bitrate;	/* Maximum bitrate of this codec.   */
+    pj_uint8_t	     frm_per_pkt;	/* Default num of frames per packet.*/
+    int		     has_native_vad;	/* Codec has internal VAD?	    */
+    int		     has_native_plc;	/* Codec has internal PLC?	    */
+
+    predecode_cb     predecode;		/* Callback to translate RTP frame
+					   into USC frame.		    */
+    parse_cb	     parse;		/* Callback to parse bitstream.	    */
+    pack_cb	     pack;		/* Callback to pack bitstream.	    */
+
+    pjmedia_codec_fmtp dec_fmtp;	/* Decoder's fmtp params.	    */
+}
+
+ipp_codec[] = 
+{
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+    {1, "AMR",	    PJMEDIA_RTP_PT_AMR,       &USC_GSMAMR_Fxns,  8000, 1, 160, 
+		    7400, 12200, 2, 1, 1, 
+		    &predecode_amr, &parse_amr, &pack_amr,
+		    {1, {{{"octet-align", 11}, {"1", 1}}} }
+    },
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB
+    {1, "AMR-WB",   PJMEDIA_RTP_PT_AMRWB,     &USC_AMRWB_Fxns,  16000, 1, 320,
+		    15850, 23850, 2, 1, 1, 
+		    &predecode_amr, &parse_amr, &pack_amr,
+		    {1, {{{"octet-align", 11}, {"1", 1}}} }
+    },
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+#	if defined(PJ_HAS_FLOATING_POINT) && (PJ_HAS_FLOATING_POINT != 0)
+    {1, "G729",	    PJMEDIA_RTP_PT_G729,      &USC_G729AFP_Fxns, 8000, 1,  80,
+		    8000, 11800, 2, 1, 1, 
+		    &predecode_g729, NULL, NULL
+    },
+#	else
+    {1, "G729",	    PJMEDIA_RTP_PT_G729,      &USC_G729I_Fxns,	 8000, 1,  80,
+		    8000, 11800, 2, 1, 1, 
+		    &predecode_g729, NULL, NULL
+    },
+#	endif
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1
+    /* This is actually G.723.1 */
+    {1, "G723",	    PJMEDIA_RTP_PT_G723,      &USC_G723_Fxns,	 8000, 1, 240,  
+		    6300,  6300, 1, 1, 1, 
+		    &predecode_g723, &parse_g723, NULL
+    },
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_G726
+    {0, "G726-16",  PJMEDIA_RTP_PT_G726_16,   &USC_G726_Fxns,	 8000, 1,  80, 
+		    16000, 16000, 2, 0, 0,
+		    NULL, NULL, NULL
+    },
+    {0, "G726-24",  PJMEDIA_RTP_PT_G726_24,   &USC_G726_Fxns,	 8000, 1,  80, 
+		    24000, 24000, 2, 0, 0,
+		    NULL, NULL, NULL
+    },
+    {1, "G726-32",  PJMEDIA_RTP_PT_G726_32,   &USC_G726_Fxns,	 8000, 1,  80, 
+		    32000, 32000, 2, 0, 0,
+		    NULL, NULL, NULL
+    },
+    {0, "G726-40",  PJMEDIA_RTP_PT_G726_40,   &USC_G726_Fxns,	 8000, 1,  80, 
+		    40000, 40000, 2, 0, 0,
+		    NULL, NULL, NULL
+    },
+    /* Old definition of G726-32 */
+    {1, "G721",	    PJMEDIA_RTP_PT_G721,      &USC_G726_Fxns,	 8000, 1,  80, 
+		    32000, 32000, 2, 0, 0,
+		    NULL, NULL, NULL
+    },
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_G728
+    {1, "G728",	    PJMEDIA_RTP_PT_G728,      &USC_G728_Fxns,	 8000, 1,  80, 
+		    16000, 16000, 2, 0, 1,
+		    NULL, NULL, NULL
+    },
+#   endif
+
+#   if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+    {0, "G7221",    PJMEDIA_RTP_PT_G722_1_16, &USC_G722_Fxns,	16000, 1, 320, 
+		    16000, 16000, 1, 0, 1,
+		    predecode_g7221, NULL, pack_g7221,
+		    {1, {{{"bitrate", 7}, {"16000", 5}}} }
+    },
+    {1, "G7221",    PJMEDIA_RTP_PT_G722_1_24, &USC_G722_Fxns,	16000, 1, 320, 
+		    24000, 24000, 1, 0, 1,
+		    predecode_g7221, NULL, pack_g7221,
+		    {1, {{{"bitrate", 7}, {"24000", 5}}} }
+    },
+    {1, "G7221",    PJMEDIA_RTP_PT_G722_1_32, &USC_G722_Fxns,	16000, 1, 320, 
+		    32000, 32000, 1, 0, 1,
+		    predecode_g7221, NULL, pack_g7221,
+		    {1, {{{"bitrate", 7}, {"32000", 5}}} }
+    },
+#   endif
+};
+
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+
+static void predecode_g729( ipp_private_t *codec_data,
+			    const pjmedia_frame *rtp_frame,
+			    USC_Bitstream *usc_frame)
+{
+    switch (rtp_frame->size) {
+    case 2:
+	/* SID */
+	usc_frame->frametype = 1;
+	usc_frame->bitrate = codec_data->info->params.modes.bitrate;
+	break;
+    case 8:  
+	/* G729D */
+	usc_frame->frametype = 2;
+	usc_frame->bitrate = 6400;
+	break;
+    case 10: 
+	/* G729 */
+	usc_frame->frametype = 3;
+	usc_frame->bitrate = 8000;
+	break;
+    case 15: 
+	/* G729E */
+	usc_frame->frametype = 4;
+	usc_frame->bitrate = 11800;
+	break;
+    default: 
+	usc_frame->frametype = 0;
+	usc_frame->bitrate = 0;
+	break;
+    }
+
+    usc_frame->pBuffer = rtp_frame->buf;
+    usc_frame->nbytes = rtp_frame->size;
+}
+
+#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G729 */
+
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1
+
+static    void predecode_g723( ipp_private_t *codec_data,
+			       const pjmedia_frame *rtp_frame,
+			       USC_Bitstream *usc_frame)
+{
+    int i, HDR = 0;
+    pj_uint8_t *f = (pj_uint8_t*)rtp_frame->buf;
+
+    PJ_UNUSED_ARG(codec_data);
+
+    for (i = 0; i < 2; ++i){
+	int tmp;
+	tmp = (f[0] >> (i & 0x7)) & 1;
+	HDR +=  tmp << i ;
+    }
+
+    usc_frame->pBuffer = rtp_frame->buf;
+    usc_frame->nbytes = rtp_frame->size;
+    usc_frame->bitrate = HDR == 0? 6300 : 5300;
+    usc_frame->frametype = 0;
+}
+
+static pj_status_t parse_g723(ipp_private_t *codec_data, void *pkt, 
+			      pj_size_t pkt_size, const pj_timestamp *ts,
+			      unsigned *frame_cnt, pjmedia_frame frames[])
+{
+    unsigned count = 0;
+    pj_uint8_t *f = (pj_uint8_t*)pkt;
+
+    while (pkt_size && count < *frame_cnt) {
+	int framesize, i, j;
+	int HDR = 0;
+
+	for (i = 0; i < 2; ++i){
+	    j = (f[0] >> (i & 0x7)) & 1;
+	    HDR +=  j << i ;
+	}
+
+	if (HDR == 0)
+	    framesize = 24;
+	else if (HDR == 1)
+	    framesize = 20;
+	else if (HDR == 2)
+	    framesize = 4;
+	else if (HDR == 3)
+	    framesize = 1;
+	else {
+	    pj_assert(!"Unknown G723.1 frametype, packet may be corrupted!");
+	    return PJMEDIA_CODEC_EINMODE;
+	}
+
+	frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
+	frames[count].buf = f;
+	frames[count].size = framesize;
+	frames[count].timestamp.u64 = ts->u64 + count * 
+			ipp_codec[codec_data->codec_idx].samples_per_frame;
+
+	f += framesize;
+	pkt_size -= framesize;
+
+	++count;
+    }
+
+    *frame_cnt = count;
+    return PJ_SUCCESS;
+}
+
+#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G723_1 */
+
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR || PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB
+
+#include <pjmedia-codec/amr_helper.h>
+
+typedef struct amr_settings_t {
+    pjmedia_codec_amr_pack_setting enc_setting;
+    pjmedia_codec_amr_pack_setting dec_setting;
+    pj_int8_t enc_mode;
+} amr_settings_t;
+
+
+/* Rearrange AMR bitstream and convert RTP frame into USC frame:
+ * - make the start_bit to be 0
+ * - if it is speech frame, reorder bitstream from sensitivity bits order
+ *   to encoder bits order.
+ * - set the appropriate value of usc_frame.
+ */
+static void predecode_amr( ipp_private_t *codec_data,
+			   const pjmedia_frame *rtp_frame,
+			   USC_Bitstream *usc_frame)
+{
+    pjmedia_frame frame;
+    pjmedia_codec_amr_bit_info *info;
+    pjmedia_codec_amr_pack_setting *setting;
+
+    setting = &((amr_settings_t*)codec_data->codec_setting)->dec_setting;
+
+    frame = *rtp_frame;
+    pjmedia_codec_amr_predecode(rtp_frame, setting, &frame);
+    info = (pjmedia_codec_amr_bit_info*) &frame.bit_info;
+
+    usc_frame->pBuffer = frame.buf;
+    usc_frame->nbytes = frame.size;
+    if (info->mode != -1) {
+	usc_frame->bitrate = setting->amr_nb? 
+			     pjmedia_codec_amrnb_bitrates[info->mode]:
+			     pjmedia_codec_amrwb_bitrates[info->mode];
+    } else {
+	usc_frame->bitrate = 0;
+    }
+
+    if (frame.size > 5) {
+	/* Speech */
+	if (info->good_quality)
+	    usc_frame->frametype = 0;
+	else
+	    usc_frame->frametype = setting->amr_nb ? 5 : 6;
+    } else if (frame.size == 5) {
+	/* SID */
+	if (info->good_quality) {
+	    usc_frame->frametype = info->STI? 2 : 1;
+	} else {
+	    usc_frame->frametype = setting->amr_nb ? 6 : 7;
+	}
+    } else {
+	/* no data */
+	usc_frame->frametype = 3;
+    }
+}
+
+/* Pack AMR payload */
+static pj_status_t pack_amr(ipp_private_t *codec_data, void *pkt, 
+			    pj_size_t *pkt_size, pj_size_t max_pkt_size)
+{
+    enum {MAX_FRAMES_PER_PACKET = PJMEDIA_MAX_FRAME_DURATION_MS / 20};
+
+    pjmedia_frame frames[MAX_FRAMES_PER_PACKET];
+    unsigned nframes = 0;
+    pjmedia_codec_amr_bit_info *info;
+    pj_uint8_t *r; /* Read cursor */
+    pj_uint8_t SID_FT;
+    pjmedia_codec_amr_pack_setting *setting;
+    const pj_uint8_t *framelen_tbl;
+
+    setting = &((amr_settings_t*)codec_data->codec_setting)->enc_setting;
+    framelen_tbl = setting->amr_nb? pjmedia_codec_amrnb_framelen:
+				    pjmedia_codec_amrwb_framelen;
+
+    SID_FT = (pj_uint8_t)(setting->amr_nb? 8 : 9);
+
+    /* Align pkt buf right */
+    r = (pj_uint8_t*)pkt + max_pkt_size - *pkt_size;
+    pj_memmove(r, pkt, *pkt_size);
+
+    /* Get frames */
+    for (;;) {
+	pj_bool_t eof;
+	pj_uint16_t info_;
+
+	info_ = *((pj_uint16_t*)r);
+	eof = ((info_ & 0x40) != 0);
+
+	info = (pjmedia_codec_amr_bit_info*) &frames[nframes].bit_info;
+	pj_bzero(info, sizeof(*info));
+	info->frame_type = (pj_uint8_t)(info_ & 0x0F);
+	info->good_quality = (pj_uint8_t)((info_ & 0x80) == 0);
+	info->mode = (pj_int8_t) ((info_ >> 8) & 0x0F);
+	info->STI = (pj_uint8_t)((info_ >> 5) & 1);
+
+	frames[nframes].buf = r + 2;
+	frames[nframes].size = info->frame_type <= SID_FT ?
+			       framelen_tbl[info->frame_type] : 0;
+
+	r += frames[nframes].size + 2;
+
+	/* Last frame */
+	if (++nframes >= MAX_FRAMES_PER_PACKET || eof)
+	    break;
+    }
+
+    /* Pack */
+    *pkt_size = max_pkt_size;
+    return pjmedia_codec_amr_pack(frames, nframes, setting, pkt, pkt_size);
+}
+
+
+/* Parse AMR payload into frames. */
+static pj_status_t parse_amr(ipp_private_t *codec_data, void *pkt, 
+			     pj_size_t pkt_size, const pj_timestamp *ts,
+			     unsigned *frame_cnt, pjmedia_frame frames[])
+{
+    amr_settings_t* s = (amr_settings_t*)codec_data->codec_setting;
+    pjmedia_codec_amr_pack_setting *setting;
+    pj_status_t status;
+    pj_uint8_t cmr;
+
+    setting = &s->dec_setting;
+
+    status = pjmedia_codec_amr_parse(pkt, pkt_size, ts, setting, frames, 
+				     frame_cnt, &cmr);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    /* Check Change Mode Request. */
+    if (((setting->amr_nb && cmr <= 7) || (!setting->amr_nb && cmr <= 8)) &&
+	s->enc_mode != cmr)
+    {
+	struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+
+	s->enc_mode = cmr;
+	codec_data->info->params.modes.bitrate = s->enc_setting.amr_nb?
+				pjmedia_codec_amrnb_bitrates[s->enc_mode] :
+				pjmedia_codec_amrwb_bitrates[s->enc_mode];
+	ippc->fxns->std.Control(&codec_data->info->params.modes, 
+				codec_data->enc);
+
+	PJ_LOG(4,(THIS_FILE, "AMR%s switched encoding mode to: %d (%dbps)",
+		  (s->enc_setting.amr_nb?"":"-WB"),
+		  s->enc_mode,
+		  codec_data->info->params.modes.bitrate));
+    }
+
+    return PJ_SUCCESS;
+}
+
+#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_AMR */
+
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+
+static void predecode_g7221( ipp_private_t *codec_data,
+			     const pjmedia_frame *rtp_frame,
+			     USC_Bitstream *usc_frame)
+{
+    usc_frame->pBuffer = (char*)rtp_frame->buf;
+    usc_frame->nbytes = rtp_frame->size;
+    usc_frame->frametype = 0;
+    usc_frame->bitrate = codec_data->info->params.modes.bitrate;
+
+#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
+    {
+	pj_uint16_t *p, *p_end;
+
+	p = (pj_uint16_t*)rtp_frame->buf;
+	p_end = p + rtp_frame->size/2;
+	while (p < p_end) {
+	    *p = pj_ntohs(*p);
+	    ++p;
+	}
+    }
+#endif
+}
+
+static pj_status_t pack_g7221( ipp_private_t *codec_data, void *pkt, 
+			       pj_size_t *pkt_size, pj_size_t max_pkt_size)
+{
+    PJ_UNUSED_ARG(codec_data);
+    PJ_UNUSED_ARG(max_pkt_size);
+
+#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
+    {
+	pj_uint16_t *p, *p_end;
+
+	p = (pj_uint16_t*)pkt;
+	p_end = p + *pkt_size/2;
+	while (p < p_end) {
+	    *p = pj_htons(*p);
+	    ++p;
+	}
+    }
+#else
+    PJ_UNUSED_ARG(pkt);
+    PJ_UNUSED_ARG(pkt_size);
+#endif
+
+    return PJ_SUCCESS;
+}
+
+
+#include <pjmedia-codec/g7221.h>
+
+
+PJ_DEF(pj_status_t) pjmedia_codec_g7221_set_pcm_shift(int val)
+{
+    PJ_ASSERT_RETURN(val >= 0, PJ_EINVAL);
+
+    ipp_factory.g7221_pcm_shift = val;
+    return PJ_SUCCESS;
+}
+
+
+#endif /* PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1 */
+
+/*
+ * Initialize and register IPP codec factory to pjmedia endpoint.
+ */
+PJ_DEF(pj_status_t) pjmedia_codec_ipp_init( pjmedia_endpt *endpt )
+{
+    pjmedia_codec_mgr *codec_mgr;
+    pj_str_t codec_name;
+    pj_status_t status;
+
+    if (ipp_factory.pool != NULL) {
+	/* Already initialized. */
+	return PJ_SUCCESS;
+    }
+
+    /* Create IPP codec factory. */
+    ipp_factory.base.op = &ipp_factory_op;
+    ipp_factory.base.factory_data = NULL;
+    ipp_factory.endpt = endpt;
+    ipp_factory.g7221_pcm_shift = PJMEDIA_G7221_DEFAULT_PCM_SHIFT;
+
+    ipp_factory.pool = pjmedia_endpt_create_pool(endpt, "IPP codecs", 4000, 4000);
+    if (!ipp_factory.pool)
+	return PJ_ENOMEM;
+
+    /* Create mutex. */
+    status = pj_mutex_create_simple(ipp_factory.pool, "IPP codecs", 
+				    &ipp_factory.mutex);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Get the codec manager. */
+    codec_mgr = pjmedia_endpt_get_codec_mgr(endpt);
+    if (!codec_mgr) {
+	status = PJ_EINVALIDOP;
+	goto on_error;
+    }
+
+    /* Register format match callback. */
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+    pj_cstr(&codec_name, "G7221");
+    status = pjmedia_sdp_neg_register_fmt_match_cb(
+					&codec_name,
+					&pjmedia_codec_g7221_match_sdp);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+#endif
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+    pj_cstr(&codec_name, "AMR");
+    status = pjmedia_sdp_neg_register_fmt_match_cb(
+					&codec_name,
+					&pjmedia_codec_amr_match_sdp);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+#endif
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMRWB
+    pj_cstr(&codec_name, "AMR-WB");
+    status = pjmedia_sdp_neg_register_fmt_match_cb(
+					&codec_name,
+					&pjmedia_codec_amr_match_sdp);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+#endif
+
+    /* Suppress compile warning */
+    PJ_UNUSED_ARG(codec_name);
+
+    /* Register codec factory to endpoint. */
+    status = pjmedia_codec_mgr_register_factory(codec_mgr, 
+						&ipp_factory.base);
+    if (status != PJ_SUCCESS)
+	goto on_error;
+
+    /* Done. */
+    return PJ_SUCCESS;
+
+on_error:
+    pj_pool_release(ipp_factory.pool);
+    ipp_factory.pool = NULL;
+    return status;
+}
+
+/*
+ * Unregister IPP codecs factory from pjmedia endpoint.
+ */
+PJ_DEF(pj_status_t) pjmedia_codec_ipp_deinit(void)
+{
+    pjmedia_codec_mgr *codec_mgr;
+    pj_status_t status;
+
+    if (ipp_factory.pool == NULL) {
+	/* Already deinitialized */
+	return PJ_SUCCESS;
+    }
+
+    pj_mutex_lock(ipp_factory.mutex);
+
+    /* Get the codec manager. */
+    codec_mgr = pjmedia_endpt_get_codec_mgr(ipp_factory.endpt);
+    if (!codec_mgr) {
+	pj_pool_release(ipp_factory.pool);
+	ipp_factory.pool = NULL;
+	return PJ_EINVALIDOP;
+    }
+
+    /* Unregister IPP codecs factory. */
+    status = pjmedia_codec_mgr_unregister_factory(codec_mgr,
+						  &ipp_factory.base);
+    
+    /* Destroy mutex. */
+    pj_mutex_destroy(ipp_factory.mutex);
+
+    /* Destroy pool. */
+    pj_pool_release(ipp_factory.pool);
+    ipp_factory.pool = NULL;
+
+    return status;
+}
+
+
+/* 
+ * Check if factory can allocate the specified codec. 
+ */
+static pj_status_t ipp_test_alloc( pjmedia_codec_factory *factory, 
+				   const pjmedia_codec_info *info )
+{
+    unsigned i;
+
+    PJ_UNUSED_ARG(factory);
+
+    /* Type MUST be audio. */
+    if (info->type != PJMEDIA_TYPE_AUDIO)
+	return PJMEDIA_CODEC_EUNSUP;
+
+    for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
+	pj_str_t name = pj_str((char*)ipp_codec[i].name);
+	if ((pj_stricmp(&info->encoding_name, &name) == 0) &&
+	    (info->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
+	    (info->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
+	    (ipp_codec[i].enabled))
+	{
+	    return PJ_SUCCESS;
+	}
+    }
+    
+    /* Unsupported, or mode is disabled. */
+    return PJMEDIA_CODEC_EUNSUP;
+}
+
+/*
+ * Generate default attribute.
+ */
+static pj_status_t ipp_default_attr (pjmedia_codec_factory *factory, 
+				      const pjmedia_codec_info *id, 
+				      pjmedia_codec_param *attr )
+{
+    unsigned i;
+
+    PJ_ASSERT_RETURN(factory==&ipp_factory.base, PJ_EINVAL);
+
+    pj_bzero(attr, sizeof(pjmedia_codec_param));
+
+    for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
+	pj_str_t name = pj_str((char*)ipp_codec[i].name);
+	if ((pj_stricmp(&id->encoding_name, &name) == 0) &&
+	    (id->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
+	    (id->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
+	    (id->pt == (unsigned)ipp_codec[i].pt))
+	{
+	    attr->info.pt = (pj_uint8_t)id->pt;
+	    attr->info.channel_cnt = ipp_codec[i].channel_count;
+	    attr->info.clock_rate = ipp_codec[i].clock_rate;
+	    attr->info.avg_bps = ipp_codec[i].def_bitrate;
+	    attr->info.max_bps = ipp_codec[i].max_bitrate;
+	    attr->info.pcm_bits_per_sample = 16;
+	    attr->info.frm_ptime =  (pj_uint16_t)
+				    (ipp_codec[i].samples_per_frame * 1000 / 
+				    ipp_codec[i].channel_count / 
+				    ipp_codec[i].clock_rate);
+	    attr->setting.frm_per_pkt = ipp_codec[i].frm_per_pkt;
+
+	    /* Default flags. */
+	    attr->setting.plc = 1;
+	    attr->setting.penh= 0;
+	    attr->setting.vad = 1;
+	    attr->setting.cng = attr->setting.vad;
+	    attr->setting.dec_fmtp = ipp_codec[i].dec_fmtp;
+
+	    if (attr->setting.vad == 0) {
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+		if (id->pt == PJMEDIA_RTP_PT_G729) {
+		    /* Signal G729 Annex B is being disabled */
+		    attr->setting.dec_fmtp.cnt = 1;
+		    pj_strset2(&attr->setting.dec_fmtp.param[0].name, "annexb");
+		    pj_strset2(&attr->setting.dec_fmtp.param[0].val, "no");
+		}
+#endif
+	    }
+
+	    return PJ_SUCCESS;
+	}
+    }
+
+    return PJMEDIA_CODEC_EUNSUP;
+}
+
+/*
+ * Enum codecs supported by this factory.
+ */
+static pj_status_t ipp_enum_codecs(pjmedia_codec_factory *factory, 
+				    unsigned *count, 
+				    pjmedia_codec_info codecs[])
+{
+    unsigned max;
+    unsigned i;
+
+    PJ_UNUSED_ARG(factory);
+    PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL);
+
+    max = *count;
+    
+    for (i = 0, *count = 0; i < PJ_ARRAY_SIZE(ipp_codec) && *count < max; ++i) 
+    {
+	if (!ipp_codec[i].enabled)
+	    continue;
+
+	pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info));
+	codecs[*count].encoding_name = pj_str((char*)ipp_codec[i].name);
+	codecs[*count].pt = ipp_codec[i].pt;
+	codecs[*count].type = PJMEDIA_TYPE_AUDIO;
+	codecs[*count].clock_rate = ipp_codec[i].clock_rate;
+	codecs[*count].channel_cnt = ipp_codec[i].channel_count;
+
+	++*count;
+    }
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * Allocate a new codec instance.
+ */
+static pj_status_t ipp_alloc_codec( pjmedia_codec_factory *factory, 
+				    const pjmedia_codec_info *id,
+				    pjmedia_codec **p_codec)
+{
+    ipp_private_t *codec_data;
+    pjmedia_codec *codec;
+    int idx;
+    pj_pool_t *pool;
+    unsigned i;
+
+    PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL);
+    PJ_ASSERT_RETURN(factory == &ipp_factory.base, PJ_EINVAL);
+
+    pj_mutex_lock(ipp_factory.mutex);
+
+    /* Find codec's index */
+    idx = -1;
+    for (i = 0; i < PJ_ARRAY_SIZE(ipp_codec); ++i) {
+	pj_str_t name = pj_str((char*)ipp_codec[i].name);
+	if ((pj_stricmp(&id->encoding_name, &name) == 0) &&
+	    (id->clock_rate == (unsigned)ipp_codec[i].clock_rate) &&
+	    (id->channel_cnt == (unsigned)ipp_codec[i].channel_count) &&
+	    (ipp_codec[i].enabled))
+	{
+	    idx = i;
+	    break;
+	}
+    }
+    if (idx == -1) {
+	*p_codec = NULL;
+	return PJMEDIA_CODEC_EFAILED;
+    }
+
+    /* Create pool for codec instance */
+    pool = pjmedia_endpt_create_pool(ipp_factory.endpt, "IPPcodec", 512, 512);
+    codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec);
+    PJ_ASSERT_RETURN(codec != NULL, PJ_ENOMEM);
+    codec->op = &ipp_op;
+    codec->factory = factory;
+    codec->codec_data = PJ_POOL_ZALLOC_T(pool, ipp_private_t);
+    codec_data = (ipp_private_t*) codec->codec_data;
+
+    /* Create PLC if codec has no internal PLC */
+    if (!ipp_codec[idx].has_native_plc) {
+	pj_status_t status;
+	status = pjmedia_plc_create(pool, ipp_codec[idx].clock_rate, 
+				    ipp_codec[idx].samples_per_frame, 0,
+				    &codec_data->plc);
+	if (status != PJ_SUCCESS) {
+	    pj_pool_release(pool);
+	    pj_mutex_unlock(ipp_factory.mutex);
+	    return status;
+	}
+    }
+
+    /* Create silence detector if codec has no internal VAD */
+    if (!ipp_codec[idx].has_native_vad) {
+	pj_status_t status;
+	status = pjmedia_silence_det_create(pool,
+					    ipp_codec[idx].clock_rate,
+					    ipp_codec[idx].samples_per_frame,
+					    &codec_data->vad);
+	if (status != PJ_SUCCESS) {
+	    pj_pool_release(pool);
+	    pj_mutex_unlock(ipp_factory.mutex);
+	    return status;
+	}
+    }
+
+    codec_data->pool = pool;
+    codec_data->codec_idx = idx;
+
+    pj_mutex_unlock(ipp_factory.mutex);
+
+    *p_codec = codec;
+    return PJ_SUCCESS;
+}
+
+/*
+ * Free codec.
+ */
+static pj_status_t ipp_dealloc_codec( pjmedia_codec_factory *factory, 
+				      pjmedia_codec *codec )
+{
+    ipp_private_t *codec_data;
+
+    PJ_ASSERT_RETURN(factory && codec, PJ_EINVAL);
+    PJ_ASSERT_RETURN(factory == &ipp_factory.base, PJ_EINVAL);
+
+    /* Close codec, if it's not closed. */
+    codec_data = (ipp_private_t*) codec->codec_data;
+    if (codec_data->enc != NULL || codec_data->dec != NULL) {
+	ipp_codec_close(codec);
+    }
+
+    pj_pool_release(codec_data->pool);
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * Init codec.
+ */
+static pj_status_t ipp_codec_init( pjmedia_codec *codec, 
+				   pj_pool_t *pool )
+{
+    PJ_UNUSED_ARG(codec);
+    PJ_UNUSED_ARG(pool);
+    return PJ_SUCCESS;
+}
+
+/*
+ * Open codec.
+ */
+static pj_status_t ipp_codec_open( pjmedia_codec *codec, 
+				   pjmedia_codec_param *attr )
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+    int info_size;
+    pj_pool_t *pool;
+    int i, j;
+    USC_MemBank *membanks;
+    int nb_membanks;
+
+    pool = codec_data->pool;
+
+    /* Get the codec info size */
+    if (USC_NoError != ippc->fxns->std.GetInfoSize(&info_size)) {
+	PJ_LOG(1,(THIS_FILE, "Error getting codec info size"));
+	goto on_error;
+    }
+    /* Get the codec info */
+    codec_data->info = pj_pool_zalloc(pool, info_size);
+    if (USC_NoError != ippc->fxns->std.GetInfo((USC_Handle)NULL, 
+					       codec_data->info))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error getting codec info"));
+	goto on_error;
+    }
+
+    /* PREPARING THE ENCODER */
+
+    /* Setting the encoder params */
+    codec_data->info->params.direction = USC_ENCODE;
+    codec_data->info->params.modes.vad = attr->setting.vad && 
+					 ippc->has_native_vad;
+    codec_data->info->params.modes.bitrate = attr->info.avg_bps;
+    codec_data->info->params.law = 0; /* Linear PCM input */
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+    if (ippc->pt == PJMEDIA_RTP_PT_G729) {
+	/* Check if G729 Annex B is signaled to be disabled */
+	for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) {
+	    if (pj_stricmp2(&attr->setting.enc_fmtp.param[i].name, "annexb")==0)
+	    {
+		if (pj_stricmp2(&attr->setting.enc_fmtp.param[i].val, "no")==0)
+		{
+		    attr->setting.vad = 0;
+		    codec_data->info->params.modes.vad = 0;
+		}
+		break;
+	    }
+	}
+    }
+#endif
+
+    /* Get number of memory blocks needed by the encoder */
+    if (USC_NoError != ippc->fxns->std.NumAlloc(&codec_data->info->params,
+					        &nb_membanks))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error getting no of memory blocks of encoder"));
+	goto on_error;
+    }
+
+    /* Allocate memory blocks table */
+    membanks = (USC_MemBank*) pj_pool_zalloc(pool, 
+					     sizeof(USC_MemBank) * nb_membanks);
+    /* Get size of each memory block */
+    if (USC_NoError != ippc->fxns->std.MemAlloc(&codec_data->info->params, 
+					        membanks))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error getting memory blocks size of encoder"));
+	goto on_error;
+    }
+
+    /* Allocate memory for each block */
+    for (i = 0; i < nb_membanks; i++) {
+	membanks[i].pMem = (char*) pj_pool_zalloc(pool, membanks[i].nbytes);
+    }
+
+    /* Create encoder instance */
+    if (USC_NoError != ippc->fxns->std.Init(&codec_data->info->params,
+					    membanks, 
+					    &codec_data->enc))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error initializing encoder"));
+	goto on_error;
+    }
+
+    /* PREPARING THE DECODER */
+
+    /* Setting the decoder params */
+    codec_data->info->params.direction = USC_DECODE;
+
+    /* Not sure if VAD affects decoder, just try to be safe */
+    //codec_data->info->params.modes.vad = ippc->has_native_vad;
+
+    /* Get number of memory blocks needed by the decoder */
+    if (USC_NoError != ippc->fxns->std.NumAlloc(&codec_data->info->params, 
+						 &nb_membanks))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error getting no of memory blocks of decoder"));
+	goto on_error;
+    }
+
+    /* Allocate memory blocks table */
+    membanks = (USC_MemBank*) pj_pool_zalloc(pool, 
+					     sizeof(USC_MemBank) * nb_membanks);
+    /* Get size of each memory block */
+    if (USC_NoError != ippc->fxns->std.MemAlloc(&codec_data->info->params, 
+						membanks))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error getting memory blocks size of decoder"));
+	goto on_error;
+    }
+
+    /* Allocate memory for each block */
+    for (i = 0; i < nb_membanks; i++) {
+	membanks[i].pMem = (char*) pj_pool_zalloc(pool, membanks[i].nbytes);
+    }
+
+    /* Create decoder instance */
+    if (USC_NoError != ippc->fxns->std.Init(&codec_data->info->params, 
+					    membanks, &codec_data->dec))
+    {
+	PJ_LOG(1,(THIS_FILE, "Error initializing decoder"));
+	goto on_error;
+    }
+
+    /* Update codec info */
+    ippc->fxns->std.GetInfo((USC_Handle)codec_data->enc, codec_data->info);
+
+    /* Get bitstream size */
+    i = codec_data->info->params.modes.bitrate * ippc->samples_per_frame;
+    j = ippc->clock_rate << 3;
+    codec_data->frame_size = (pj_uint16_t)(i / j);
+    if (i % j) ++codec_data->frame_size;
+
+    codec_data->vad_enabled = (attr->setting.vad != 0);
+    codec_data->plc_enabled = (attr->setting.plc != 0);
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+    /* Init AMR settings */
+    if (ippc->pt == PJMEDIA_RTP_PT_AMR || ippc->pt == PJMEDIA_RTP_PT_AMRWB) {
+	amr_settings_t *s;
+	pj_uint8_t octet_align = 0;
+	pj_int8_t enc_mode;
+
+	enc_mode = pjmedia_codec_amr_get_mode(
+				codec_data->info->params.modes.bitrate);
+	pj_assert(enc_mode >= 0 && enc_mode <= 8);
+
+	/* Check AMR specific attributes */
+
+	for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) {
+	    /* octet-align, one of the parameters that must have same value 
+	     * in offer & answer (RFC 4867 Section 8.3.1). Just check fmtp
+	     * in the decoder side, since it's value is guaranteed to fulfil 
+	     * above requirement (by SDP negotiator).
+	     */
+	    const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11};
+	    
+	    if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name, 
+			   &STR_FMTP_OCTET_ALIGN) == 0)
+	    {
+		octet_align=(pj_uint8_t)
+			    pj_strtoul(&attr->setting.dec_fmtp.param[i].val);
+		break;
+	    }
+	}
+
+	for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) {
+	    /* mode-set, encoding mode is chosen based on local default mode 
+	     * setting:
+	     * - if local default mode is included in the mode-set, use it
+	     * - otherwise, find the closest mode to local default mode;
+	     *   if there are two closest modes, prefer to use the higher
+	     *   one, e.g: local default mode is 4, the mode-set param
+	     *   contains '2,3,5,6', then 5 will be chosen.
+	     */
+	    const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8};
+	    
+	    if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name, 
+			   &STR_FMTP_MODE_SET) == 0)
+	    {
+		const char *p;
+		pj_size_t l;
+		pj_int8_t diff = 99;
+		
+		p = pj_strbuf(&attr->setting.enc_fmtp.param[i].val);
+		l = pj_strlen(&attr->setting.enc_fmtp.param[i].val);
+
+		while (l--) {
+		    if ((ippc->pt==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') ||
+		        (ippc->pt==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8'))
+		    {
+			pj_int8_t tmp = (pj_int8_t)(*p - '0' - enc_mode);
+
+			if (PJ_ABS(diff) > PJ_ABS(tmp) || 
+			    (PJ_ABS(diff) == PJ_ABS(tmp) && tmp > diff))
+			{
+			    diff = tmp;
+			    if (diff == 0) break;
+			}
+		    }
+		    ++p;
+		}
+
+		if (diff == 99)
+		    goto on_error;
+
+		enc_mode = (pj_int8_t)(enc_mode + diff);
+
+		break;
+	    }
+	}
+
+	/* Initialize AMR specific settings */
+	s = PJ_POOL_ZALLOC_T(pool, amr_settings_t);
+	codec_data->codec_setting = s;
+
+	s->enc_setting.amr_nb = (pj_uint8_t)(ippc->pt == PJMEDIA_RTP_PT_AMR);
+	s->enc_setting.octet_aligned = octet_align;
+	s->enc_setting.reorder = PJ_TRUE;
+	s->enc_setting.cmr = 15;
+
+	s->dec_setting.amr_nb = (pj_uint8_t)(ippc->pt == PJMEDIA_RTP_PT_AMR);
+	s->dec_setting.octet_aligned = octet_align;
+	s->dec_setting.reorder = PJ_TRUE;
+
+	/* Apply encoder mode/bitrate */
+	s->enc_mode = enc_mode;
+	codec_data->info->params.modes.bitrate = s->enc_setting.amr_nb?
+				pjmedia_codec_amrnb_bitrates[s->enc_mode]:
+				pjmedia_codec_amrwb_bitrates[s->enc_mode];
+	ippc->fxns->std.Control(&codec_data->info->params.modes, 
+				codec_data->enc);
+
+	PJ_LOG(4,(THIS_FILE, "AMR%s encoding mode: %d (%dbps)", 
+		  (s->enc_setting.amr_nb?"":"-WB"),
+		  s->enc_mode,
+		  codec_data->info->params.modes.bitrate));
+
+	/* Return back bitrate info to application */
+	attr->info.avg_bps = codec_data->info->params.modes.bitrate;
+    }
+#endif
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+    if (ippc->pt >= PJMEDIA_RTP_PT_G722_1_16 && 
+	ippc->pt <= PJMEDIA_RTP_PT_G7221_RSV2)
+    {
+	codec_data->g7221_pcm_shift = ipp_factory.g7221_pcm_shift;
+    }
+#endif
+
+    return PJ_SUCCESS;
+
+on_error:
+    return PJMEDIA_CODEC_EFAILED;
+}
+
+/*
+ * Close codec.
+ */
+static pj_status_t ipp_codec_close( pjmedia_codec *codec )
+{
+    PJ_UNUSED_ARG(codec);
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Modify codec settings.
+ */
+static pj_status_t  ipp_codec_modify(pjmedia_codec *codec, 
+				     const pjmedia_codec_param *attr )
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+
+    codec_data->vad_enabled = (attr->setting.vad != 0);
+    codec_data->plc_enabled = (attr->setting.plc != 0);
+
+    if (ippc->has_native_vad) {
+	USC_Modes modes;
+
+	modes = codec_data->info->params.modes;
+	modes.vad = codec_data->vad_enabled;
+	ippc->fxns->std.Control(&modes, codec_data->enc);
+    }
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * Get frames in the packet.
+ */
+static pj_status_t  ipp_codec_parse( pjmedia_codec *codec,
+				     void *pkt,
+				     pj_size_t pkt_size,
+				     const pj_timestamp *ts,
+				     unsigned *frame_cnt,
+				     pjmedia_frame frames[])
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+    unsigned count = 0;
+
+    PJ_ASSERT_RETURN(frame_cnt, PJ_EINVAL);
+
+    if (ippc->parse != NULL) {
+	return ippc->parse(codec_data, pkt,  pkt_size, ts, frame_cnt, frames);
+    }
+
+    while (pkt_size >= codec_data->frame_size && count < *frame_cnt) {
+	frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
+	frames[count].buf = pkt;
+	frames[count].size = codec_data->frame_size;
+	frames[count].timestamp.u64 = ts->u64 + count*ippc->samples_per_frame;
+
+	pkt = ((char*)pkt) + codec_data->frame_size;
+	pkt_size -= codec_data->frame_size;
+
+	++count;
+    }
+
+    if (pkt_size && count < *frame_cnt) {
+	frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO;
+	frames[count].buf = pkt;
+	frames[count].size = pkt_size;
+	frames[count].timestamp.u64 = ts->u64 + count*ippc->samples_per_frame;
+	++count;
+    }
+
+    *frame_cnt = count;
+    return PJ_SUCCESS;
+}
+
+/*
+ * Encode frames.
+ */
+static pj_status_t ipp_codec_encode( pjmedia_codec *codec, 
+				     const struct pjmedia_frame *input,
+				     unsigned output_buf_len, 
+				     struct pjmedia_frame *output)
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+    unsigned samples_per_frame;
+    unsigned nsamples;
+    pj_size_t tx = 0;
+    pj_int16_t *pcm_in   = (pj_int16_t*)input->buf;
+    pj_uint8_t  *bits_out = (pj_uint8_t*) output->buf;
+    pj_uint8_t pt;
+
+    /* Invoke external VAD if codec has no internal VAD */
+    if (codec_data->vad && codec_data->vad_enabled) {
+	pj_bool_t is_silence;
+	pj_int32_t silence_duration;
+
+	silence_duration = pj_timestamp_diff32(&codec_data->last_tx, 
+					       &input->timestamp);
+
+	is_silence = pjmedia_silence_det_detect(codec_data->vad, 
+					        (const pj_int16_t*) input->buf,
+						(input->size >> 1),
+						NULL);
+	if (is_silence &&
+	    (PJMEDIA_CODEC_MAX_SILENCE_PERIOD == -1 ||
+	     silence_duration < (PJMEDIA_CODEC_MAX_SILENCE_PERIOD *
+	 			 (int)ippc->clock_rate / 1000)))
+	{
+	    output->type = PJMEDIA_FRAME_TYPE_NONE;
+	    output->buf = NULL;
+	    output->size = 0;
+	    output->timestamp = input->timestamp;
+	    return PJ_SUCCESS;
+	} else {
+	    codec_data->last_tx = input->timestamp;
+	}
+    }
+
+    nsamples = input->size >> 1;
+    samples_per_frame = ippc->samples_per_frame;
+    pt = ippc->pt;
+
+    PJ_ASSERT_RETURN(nsamples % samples_per_frame == 0, 
+		     PJMEDIA_CODEC_EPCMFRMINLEN);
+
+    /* Encode the frames */
+    while (nsamples >= samples_per_frame) {
+	USC_PCMStream in;
+	USC_Bitstream out;
+
+	in.bitrate = codec_data->info->params.modes.bitrate;
+	in.nbytes = samples_per_frame << 1;
+	in.pBuffer = (char*)pcm_in;
+	in.pcmType.bitPerSample = codec_data->info->params.pcmType.bitPerSample;
+	in.pcmType.nChannels = codec_data->info->params.pcmType.nChannels;
+	in.pcmType.sample_frequency = codec_data->info->params.pcmType.sample_frequency;
+
+	out.pBuffer = (char*)bits_out;
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+	/* For AMR: reserve two octets for AMR frame info */
+	if (pt == PJMEDIA_RTP_PT_AMR || pt == PJMEDIA_RTP_PT_AMRWB) {
+	    out.pBuffer += 2;
+	}
+#endif
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+	/* For G722.1: adjust the encoder input signal level */
+	if (pt >= PJMEDIA_RTP_PT_G722_1_16 && 
+	    pt <= PJMEDIA_RTP_PT_G7221_RSV2 &&
+	    codec_data->g7221_pcm_shift)
+	{
+	    unsigned i;
+	    for (i = 0; i < samples_per_frame; ++i)
+		pcm_in[i] >>= codec_data->g7221_pcm_shift;
+	}
+#endif
+
+	if (USC_NoError != ippc->fxns->Encode(codec_data->enc, &in, &out)) {
+	    break;
+	}
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_AMR
+	/* For AMR: put info (frametype, degraded, last frame, mode) in the 
+	 * first two octets for payload packing.
+	 */
+	if (pt == PJMEDIA_RTP_PT_AMR || pt == PJMEDIA_RTP_PT_AMRWB) {
+	    pj_uint16_t *info = (pj_uint16_t*)bits_out;
+
+	    /* Two octets for AMR frame info, 0=LSB:
+	     * bit 0-3	: frame type
+	     * bit 5	: STI flag
+	     * bit 6	: last frame flag
+	     * bit 7	: quality flag
+	     * bit 8-11	: mode
+	     */
+	    out.nbytes += 2;
+	    if (out.frametype == 0 || out.frametype == 4 || 
+		(pt == PJMEDIA_RTP_PT_AMR && out.frametype == 5) ||
+		(pt == PJMEDIA_RTP_PT_AMRWB && out.frametype == 6))
+	    {
+		/* Speech frame type */
+		*info = (char)pjmedia_codec_amr_get_mode(out.bitrate);
+		/* Quality */
+		if (out.frametype == 5 || out.frametype == 6)
+		    *info |= 0x80;
+	    } else if (out.frametype == 1 || out.frametype == 2 || 
+		       (pt == PJMEDIA_RTP_PT_AMR && out.frametype == 6) ||
+		       (pt == PJMEDIA_RTP_PT_AMRWB && out.frametype == 7))
+	    {
+		/* SID frame type */
+		*info = (pj_uint8_t)(pt == PJMEDIA_RTP_PT_AMRWB? 9 : 8);
+		/* Quality */
+		if (out.frametype == 6 || out.frametype == 7)
+		    *info |= 0x80;
+		/* STI */
+		if (out.frametype != 1)
+		    *info |= 0x20;
+	    } else {
+		/* Untransmited */
+		*info = 15;
+		out.nbytes = 2;
+	    }
+
+	    /* Mode */
+	    *info |= (char)pjmedia_codec_amr_get_mode(out.bitrate) << 8;
+
+	    /* Last frame flag */
+	    if (nsamples == samples_per_frame)
+		*info |= 0x40;
+	}
+#endif
+
+	pcm_in += samples_per_frame;
+	nsamples -= samples_per_frame;
+	tx += out.nbytes;
+	bits_out += out.nbytes;
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G729
+	if (pt == PJMEDIA_RTP_PT_G729) {
+	    if (out.frametype == 1) {
+		/* SID */
+		break;
+	    } else if (out.frametype == 0) {
+		/* Untransmitted */
+		tx -= out.nbytes;
+		break;
+	    }
+	}
+#endif
+
+    }
+
+    if (ippc->pack != NULL) {
+	ippc->pack(codec_data, output->buf, &tx, output_buf_len);
+    }
+
+    /* Check if we don't need to transmit the frame (DTX) */
+    if (tx == 0) {
+	output->buf = NULL;
+	output->size = 0;
+	output->timestamp.u64 = input->timestamp.u64;
+	output->type = PJMEDIA_FRAME_TYPE_NONE;
+	return PJ_SUCCESS;
+    }
+
+    output->size = tx;
+    output->type = PJMEDIA_FRAME_TYPE_AUDIO;
+    output->timestamp = input->timestamp;
+
+    return PJ_SUCCESS;
+}
+
+/*
+ * Decode frame.
+ */
+static pj_status_t ipp_codec_decode( pjmedia_codec *codec, 
+				     const struct pjmedia_frame *input,
+				     unsigned output_buf_len, 
+				     struct pjmedia_frame *output)
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+    unsigned samples_per_frame;
+    USC_PCMStream out;
+    USC_Bitstream in;
+    pj_uint8_t pt;
+
+    pt = ippc->pt; 
+    samples_per_frame = ippc->samples_per_frame;
+
+    PJ_ASSERT_RETURN(output_buf_len >= samples_per_frame << 1,
+		     PJMEDIA_CODEC_EPCMTOOSHORT);
+
+    if (input->type == PJMEDIA_FRAME_TYPE_AUDIO) {
+	if (ippc->predecode) {
+	    ippc->predecode(codec_data, input, &in);
+	} else {
+	    /* Most IPP codecs have frametype==0 for speech frame */
+	    in.pBuffer = (char*)input->buf;
+	    in.nbytes = input->size;
+	    in.frametype = 0;
+	    in.bitrate = codec_data->info->params.modes.bitrate;
+	}
+
+	out.pBuffer = output->buf;
+    }
+
+    if (input->type != PJMEDIA_FRAME_TYPE_AUDIO ||
+	USC_NoError != ippc->fxns->Decode(codec_data->dec, &in, &out)) 
+    {
+	pjmedia_zero_samples((pj_int16_t*)output->buf, samples_per_frame);
+	output->size = samples_per_frame << 1;
+	output->timestamp.u64 = input->timestamp.u64;
+	output->type = PJMEDIA_FRAME_TYPE_AUDIO;
+	return PJ_SUCCESS;
+    }
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G726
+    /* For G.726: amplify decoding result (USC G.726 encoder deamplified it) */
+    if (pt == PJMEDIA_RTP_PT_G726_16 || pt == PJMEDIA_RTP_PT_G726_24 ||
+	pt == PJMEDIA_RTP_PT_G726_32 || pt == PJMEDIA_RTP_PT_G726_40 ||
+	pt == PJMEDIA_RTP_PT_G721)
+    {
+	unsigned i;
+	pj_int16_t *s = (pj_int16_t*)output->buf;
+
+	for (i = 0; i < samples_per_frame; ++i)
+	    s[i] <<= 2;
+    }
+#endif
+
+#if PJMEDIA_HAS_INTEL_IPP_CODEC_G722_1
+    /* For G722.1: adjust the decoder output signal level */
+    if (pt >= PJMEDIA_RTP_PT_G722_1_16 && 
+	pt <= PJMEDIA_RTP_PT_G7221_RSV2 &&
+	codec_data->g7221_pcm_shift)
+    {
+	unsigned i;
+	pj_int16_t *s = (pj_int16_t*)output->buf;
+
+	for (i = 0; i < samples_per_frame; ++i)
+	    s[i] <<= codec_data->g7221_pcm_shift;
+    }
+#endif
+
+    output->type = PJMEDIA_FRAME_TYPE_AUDIO;
+    output->size = samples_per_frame << 1;
+    output->timestamp.u64 = input->timestamp.u64;
+
+    /* Invoke external PLC if codec has no internal PLC */
+    if (codec_data->plc && codec_data->plc_enabled)
+	pjmedia_plc_save(codec_data->plc, (pj_int16_t*)output->buf);
+
+    return PJ_SUCCESS;
+}
+
+/* 
+ * Recover lost frame.
+ */
+static pj_status_t  ipp_codec_recover(pjmedia_codec *codec, 
+				      unsigned output_buf_len, 
+				      struct pjmedia_frame *output)
+{
+    ipp_private_t *codec_data = (ipp_private_t*) codec->codec_data;
+    struct ipp_codec *ippc = &ipp_codec[codec_data->codec_idx];
+    unsigned samples_per_frame;
+
+    PJ_UNUSED_ARG(output_buf_len);
+
+    samples_per_frame = ippc->samples_per_frame;
+
+    output->type = PJMEDIA_FRAME_TYPE_AUDIO;
+    output->size = samples_per_frame << 1;
+
+    if (codec_data->plc_enabled) {
+	if (codec_data->plc) {
+	    pjmedia_plc_generate(codec_data->plc, (pj_int16_t*)output->buf);
+	} else {
+	    USC_PCMStream out;
+	    out.pBuffer = output->buf;
+	    ippc->fxns->Decode(codec_data->dec, NULL, &out);
+	}
+    } else {
+	pjmedia_zero_samples((pj_int16_t*)output->buf, samples_per_frame);
+    }
+
+    return PJ_SUCCESS;
+}
+
+
+#if defined(_MSC_VER) && PJMEDIA_AUTO_LINK_IPP_LIBS
+#   pragma comment( lib, "ippcore.lib")
+#   pragma comment( lib, "ipps.lib")
+#   pragma comment( lib, "ippsc.lib")
+#   if defined(IPP_VERSION_MAJOR) && IPP_VERSION_MAJOR<=6
+#	pragma comment( lib, "ippsr.lib")
+#   endif
+//#   pragma comment( lib, "ippcorel.lib")
+//#   pragma comment( lib, "ippsemerged.lib")
+//#   pragma comment( lib, "ippsmerged.lib")
+//#   pragma comment( lib, "ippscemerged.lib")
+//#   pragma comment( lib, "ippscmerged.lib")
+//#   pragma comment( lib, "ippsremerged.lib")
+//#   pragma comment( lib, "ippsrmerged.lib")
+#   if defined(IPP_VERSION_MAJOR) && IPP_VERSION_MAJOR>=6
+#	pragma comment( lib, "speech.lib")
+#   else
+#	pragma comment( lib, "usc.lib")
+#   endif
+#endif
+
+
+#endif	/* PJMEDIA_HAS_INTEL_IPP */
+
diff --git a/jni/pjproject-android/.svn/pristine/af/afbf0cb8a6baf28c3f4913ea7f0ad2a5e311c1d8.svn-base b/jni/pjproject-android/.svn/pristine/af/afbf0cb8a6baf28c3f4913ea7f0ad2a5e311c1d8.svn-base
new file mode 100644
index 0000000..76ff13b
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/afbf0cb8a6baf28c3f4913ea7f0ad2a5e311c1d8.svn-base
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# The unknown media uses static payload type
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=xapplicationx 4000 RTP/AVP 54
+m=audio 5000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=xapplicationx 0 RTP/AVP[\\s\\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Mixed audio and unknown", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/jni/pjproject-android/.svn/pristine/af/afbf2e8a877089a26b8f6b506cce7beed37fe34d.svn-base b/jni/pjproject-android/.svn/pristine/af/afbf2e8a877089a26b8f6b506cce7beed37fe34d.svn-base
new file mode 100644
index 0000000..7c1536b
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/afbf2e8a877089a26b8f6b506cce7beed37fe34d.svn-base
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=AF IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/AVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = [ "Warning: " ]	# better have Warning header
+exclude = []
+sendto_cfg = sip.SendtoCfg("Bad SDP network type", pjsua_args, sdp, 400, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+
diff --git a/jni/pjproject-android/.svn/pristine/af/afc0ffef03803116f7586d87b9d8740b67c90baf.svn-base b/jni/pjproject-android/.svn/pristine/af/afc0ffef03803116f7586d87b9d8740b67c90baf.svn-base
new file mode 100644
index 0000000..230dda6
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/afc0ffef03803116f7586d87b9d8740b67c90baf.svn-base
@@ -0,0 +1,523 @@
+/*
+ * crypto_kernel.c
+ *
+ * header for the cryptographic 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 "alloc.h"
+
+#include "crypto_kernel.h"
+
+/* the debug module for the crypto_kernel */
+
+debug_module_t mod_crypto_kernel = {
+  0,                  /* debugging is off by default */
+  "crypto kernel"     /* printable name for module   */
+};
+
+/*
+ * other debug modules that can be included in the kernel
+ */
+
+extern debug_module_t mod_auth;
+extern debug_module_t mod_cipher;
+extern debug_module_t mod_stat;
+extern debug_module_t mod_alloc;
+
+/* 
+ * cipher types that can be included in the kernel
+ */ 
+
+extern cipher_type_t null_cipher;
+extern cipher_type_t aes_icm;
+extern cipher_type_t aes_cbc;
+
+
+/*
+ * auth func types that can be included in the kernel
+ */
+
+extern auth_type_t null_auth;
+extern auth_type_t hmac;
+
+/* crypto_kernel is a global variable, the only one of its datatype */
+
+crypto_kernel_t
+crypto_kernel = {
+  crypto_kernel_state_insecure,    /* start off in insecure state */
+  NULL,                            /* no cipher types yet         */
+  NULL,                            /* no auth types yet           */
+  NULL                             /* no debug modules yet        */
+};
+
+#define MAX_RNG_TRIALS 25
+
+err_status_t
+crypto_kernel_init() {
+  err_status_t status;  
+
+  /* check the security state */
+  if (crypto_kernel.state == crypto_kernel_state_secure) {
+    
+    /*
+     * we're already in the secure state, but we've been asked to
+     * re-initialize, so we just re-run the self-tests and then return
+     */
+    return crypto_kernel_status(); 
+  }
+
+  /* initialize error reporting system */
+  status = err_reporting_init("crypto");
+  if (status)
+    return status;
+
+  /* load debug modules */
+  status = crypto_kernel_load_debug_module(&mod_crypto_kernel);
+  if (status)
+    return status;
+  status = crypto_kernel_load_debug_module(&mod_auth);
+  if (status)
+    return status;
+  status = crypto_kernel_load_debug_module(&mod_cipher);
+  if (status)
+    return status;
+  status = crypto_kernel_load_debug_module(&mod_stat);
+  if (status)
+    return status;
+  status = crypto_kernel_load_debug_module(&mod_alloc);
+  if (status)
+    return status;
+  
+  /* initialize random number generator */
+  status = rand_source_init();
+  if (status)
+    return status;
+
+  /* run FIPS-140 statistical tests on rand_source */  
+  status = stat_test_rand_source_with_repetition(rand_source_get_octet_string, MAX_RNG_TRIALS);
+  if (status)
+    return status;
+
+  /* initialize pseudorandom number generator */
+  status = ctr_prng_init(rand_source_get_octet_string);
+  if (status)
+    return status;
+
+  /* run FIPS-140 statistical tests on ctr_prng */  
+  status = stat_test_rand_source_with_repetition(ctr_prng_get_octet_string, MAX_RNG_TRIALS);
+  if (status)
+    return status;
+ 
+  /* load cipher types */
+  status = crypto_kernel_load_cipher_type(&null_cipher, NULL_CIPHER);
+  if (status) 
+    return status;
+  status = crypto_kernel_load_cipher_type(&aes_icm, AES_128_ICM);
+  if (status) 
+    return status;
+  status = crypto_kernel_load_cipher_type(&aes_cbc, AES_128_CBC);
+  if (status) 
+    return status;
+
+  /* load auth func types */
+  status = crypto_kernel_load_auth_type(&null_auth, NULL_AUTH);
+  if (status)
+    return status;
+  status = crypto_kernel_load_auth_type(&hmac, HMAC_SHA1);
+  if (status)
+    return status;
+
+  /* change state to secure */
+  crypto_kernel.state = crypto_kernel_state_secure;
+
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_status() {
+  err_status_t status;
+  kernel_cipher_type_t  *ctype = crypto_kernel.cipher_type_list;
+  kernel_auth_type_t    *atype = crypto_kernel.auth_type_list;
+  kernel_debug_module_t *dm    = crypto_kernel.debug_module_list;
+
+  /* run FIPS-140 statistical tests on rand_source */  
+  printf("testing rand_source...");
+  status = stat_test_rand_source_with_repetition(rand_source_get_octet_string, MAX_RNG_TRIALS);
+  if (status) {
+    printf("failed\n");
+    crypto_kernel.state = crypto_kernel_state_insecure;
+    return status;
+  }  
+  printf("passed\n");
+
+  /* for each cipher type, describe and test */
+  while(ctype != NULL) {
+    printf("cipher: %s\n", ctype->cipher_type->description);
+    printf("  instance count: %d\n", ctype->cipher_type->ref_count);
+    printf("  self-test: ");
+    status = cipher_type_self_test(ctype->cipher_type);
+    if (status) {
+      printf("failed with error code %d\n", status);
+      exit(status);
+    }
+    printf("passed\n");
+    ctype = ctype->next;
+  }
+  
+  /* for each auth type, describe and test */
+  while(atype != NULL) {
+    printf("auth func: %s\n", atype->auth_type->description);
+    printf("  instance count: %d\n", atype->auth_type->ref_count);
+    printf("  self-test: ");
+    status = auth_type_self_test(atype->auth_type);
+    if (status) {
+      printf("failed with error code %d\n", status);
+      exit(status);
+    }
+    printf("passed\n");
+    atype = atype->next;
+  }
+
+  /* describe each debug module */
+  printf("debug modules loaded:\n");
+  while (dm != NULL) {
+    printf("  %s ", dm->mod->name);  
+    if (dm->mod->on)
+      printf("(on)\n");
+    else
+      printf("(off)\n");
+    dm = dm->next;
+  }
+
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_list_debug_modules() {
+  kernel_debug_module_t *dm = crypto_kernel.debug_module_list;
+
+  /* describe each debug module */
+  printf("debug modules loaded:\n");
+  while (dm != NULL) {
+    printf("  %s ", dm->mod->name);  
+    if (dm->mod->on)
+      printf("(on)\n");
+    else
+      printf("(off)\n");
+    dm = dm->next;
+  }
+
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_shutdown() {
+  err_status_t status;
+
+  /*
+   * free dynamic memory used in crypto_kernel at present
+   */
+
+  /* walk down cipher type list, freeing memory */
+  while (crypto_kernel.cipher_type_list != NULL) {
+    kernel_cipher_type_t *ctype = crypto_kernel.cipher_type_list;
+    crypto_kernel.cipher_type_list = ctype->next;
+    debug_print(mod_crypto_kernel, 
+		"freeing memory for cipher %s", 
+		ctype->cipher_type->description);
+    crypto_free(ctype);
+  }
+
+  /* walk down authetication module list, freeing memory */
+  while (crypto_kernel.auth_type_list != NULL) {
+     kernel_auth_type_t *atype = crypto_kernel.auth_type_list;
+     crypto_kernel.auth_type_list = atype->next;
+     debug_print(mod_crypto_kernel, 
+		"freeing memory for authentication %s",
+		atype->auth_type->description);
+     crypto_free(atype);
+  }
+
+  /* walk down debug module list, freeing memory */
+  while (crypto_kernel.debug_module_list != NULL) {
+    kernel_debug_module_t *kdm = crypto_kernel.debug_module_list;
+    crypto_kernel.debug_module_list = kdm->next;
+    debug_print(mod_crypto_kernel, 
+		"freeing memory for debug module %s", 
+		kdm->mod->name);
+    crypto_free(kdm);
+  }
+
+  /* de-initialize random number generator */  status = rand_source_deinit();
+  if (status)
+    return status;
+
+  /* return to insecure state */
+  crypto_kernel.state = crypto_kernel_state_insecure;
+  
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_load_cipher_type(cipher_type_t *new_ct, cipher_type_id_t id) {
+  kernel_cipher_type_t *ctype, *new_ctype;
+  err_status_t status;
+
+  /* defensive coding */
+  if (new_ct == NULL)
+    return err_status_bad_param;
+
+  /* check cipher type by running self-test */
+  status = cipher_type_self_test(new_ct);
+  if (status) {
+    return status;
+  }
+
+  /* walk down list, checking if this type is in the list already  */
+  ctype = crypto_kernel.cipher_type_list;
+  while (ctype != NULL) {
+    if ((new_ct == ctype->cipher_type) || (id == ctype->id))
+      return err_status_bad_param;    
+    ctype = ctype->next;
+  }
+
+  /* put new_ct at the head of the list */
+  /* allocate memory */
+  new_ctype = (kernel_cipher_type_t *) crypto_alloc(sizeof(kernel_cipher_type_t));
+  if (new_ctype == NULL)
+    return err_status_alloc_fail;
+    
+  /* set fields */
+  new_ctype->cipher_type = new_ct;
+  new_ctype->id = id;
+  new_ctype->next = crypto_kernel.cipher_type_list;
+
+  /* set head of list to new cipher type */
+  crypto_kernel.cipher_type_list = new_ctype;    
+
+  /* load debug module, if there is one present */
+  if (new_ct->debug != NULL)
+    crypto_kernel_load_debug_module(new_ct->debug);
+  /* we could check for errors here */
+
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_load_auth_type(auth_type_t *new_at, auth_type_id_t id) {
+  kernel_auth_type_t *atype, *new_atype;
+  err_status_t status;
+
+  /* defensive coding */
+  if (new_at == NULL)
+    return err_status_bad_param;
+
+  /* check auth type by running self-test */
+  status = auth_type_self_test(new_at);
+  if (status) {
+    return status;
+  }
+
+  /* walk down list, checking if this type is in the list already  */
+  atype = crypto_kernel.auth_type_list;
+  while (atype != NULL) {
+    if ((new_at == atype->auth_type) || (id == atype->id))
+      return err_status_bad_param;    
+    atype = atype->next;
+  }
+
+  /* put new_at at the head of the list */
+  /* allocate memory */
+  new_atype = (kernel_auth_type_t *)crypto_alloc(sizeof(kernel_auth_type_t));
+  if (new_atype == NULL)
+    return err_status_alloc_fail;
+    
+  /* set fields */
+  new_atype->auth_type = new_at;
+  new_atype->id = id;
+  new_atype->next = crypto_kernel.auth_type_list;
+
+  /* set head of list to new auth type */
+  crypto_kernel.auth_type_list = new_atype;    
+
+  /* load debug module, if there is one present */
+  if (new_at->debug != NULL)
+    crypto_kernel_load_debug_module(new_at->debug);
+  /* we could check for errors here */
+
+  return err_status_ok;
+
+}
+
+
+cipher_type_t *
+crypto_kernel_get_cipher_type(cipher_type_id_t id) {
+  kernel_cipher_type_t *ctype;
+  
+  /* walk down list, looking for id  */
+  ctype = crypto_kernel.cipher_type_list;
+  while (ctype != NULL) {
+    if (id == ctype->id)
+      return ctype->cipher_type; 
+    ctype = ctype->next;
+  } 
+
+  /* haven't found the right one, indicate failure by returning NULL */
+  return NULL;
+}
+
+
+err_status_t
+crypto_kernel_alloc_cipher(cipher_type_id_t id, 
+			      cipher_pointer_t *cp, 
+			      int key_len) {
+  cipher_type_t *ct;
+
+  /* 
+   * if the crypto_kernel is not yet initialized, we refuse to allocate
+   * any ciphers - this is a bit extra-paranoid
+   */
+  if (crypto_kernel.state != crypto_kernel_state_secure)
+    return err_status_init_fail;
+
+  ct = crypto_kernel_get_cipher_type(id);
+  if (!ct)
+    return err_status_fail;
+  
+  return ((ct)->alloc(cp, key_len));
+}
+
+
+
+auth_type_t *
+crypto_kernel_get_auth_type(auth_type_id_t id) {
+  kernel_auth_type_t *atype;
+  
+  /* walk down list, looking for id  */
+  atype = crypto_kernel.auth_type_list;
+  while (atype != NULL) {
+    if (id == atype->id)
+      return atype->auth_type; 
+    atype = atype->next;
+  } 
+
+  /* haven't found the right one, indicate failure by returning NULL */
+  return NULL;
+}
+
+err_status_t
+crypto_kernel_alloc_auth(auth_type_id_t id, 
+			 auth_pointer_t *ap, 
+			 int key_len,
+			 int tag_len) {
+  auth_type_t *at;
+
+  /* 
+   * if the crypto_kernel is not yet initialized, we refuse to allocate
+   * any auth functions - this is a bit extra-paranoid
+   */
+  if (crypto_kernel.state != crypto_kernel_state_secure)
+    return err_status_init_fail;
+
+  at = crypto_kernel_get_auth_type(id);
+  if (!at)
+    return err_status_fail;
+  
+  return ((at)->alloc(ap, key_len, tag_len));
+}
+
+err_status_t
+crypto_kernel_load_debug_module(debug_module_t *new_dm) {
+  kernel_debug_module_t *kdm, *new;
+
+  /* defensive coding */
+  if (new_dm == NULL)
+    return err_status_bad_param;
+
+  /* walk down list, checking if this type is in the list already  */
+  kdm = crypto_kernel.debug_module_list;
+  while (kdm != NULL) {
+    if (strncmp(new_dm->name, kdm->mod->name, 64) == 0)
+      return err_status_bad_param;    
+    kdm = kdm->next;
+  }
+
+  /* put new_dm at the head of the list */
+  /* allocate memory */
+  new = (kernel_debug_module_t *)crypto_alloc(sizeof(kernel_debug_module_t));
+  if (new == NULL)
+    return err_status_alloc_fail;
+    
+  /* set fields */
+  new->mod = new_dm;
+  new->next = crypto_kernel.debug_module_list;
+
+  /* set head of list to new cipher type */
+  crypto_kernel.debug_module_list = new;    
+
+  return err_status_ok;
+}
+
+err_status_t
+crypto_kernel_set_debug_module(char *name, int on) {
+  kernel_debug_module_t *kdm;
+  
+  /* walk down list, checking if this type is in the list already  */
+  kdm = crypto_kernel.debug_module_list;
+  while (kdm != NULL) {
+    if (strncmp(name, kdm->mod->name, 64) == 0) {
+      kdm->mod->on = on;
+      return err_status_ok;
+    }
+    kdm = kdm->next;
+  }
+
+  return err_status_fail;
+}
+
+err_status_t
+crypto_get_random(unsigned char *buffer, unsigned int length) {
+  if (crypto_kernel.state == crypto_kernel_state_secure)
+    return ctr_prng_get_octet_string(buffer, length);
+  else
+    return err_status_fail;
+}
diff --git a/jni/pjproject-android/.svn/pristine/af/affa286fa46d825cdbb852d8cdc3ece2b5ace218.svn-base b/jni/pjproject-android/.svn/pristine/af/affa286fa46d825cdbb852d8cdc3ece2b5ace218.svn-base
new file mode 100644
index 0000000..63dd811
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/af/affa286fa46d825cdbb852d8cdc3ece2b5ace218.svn-base
@@ -0,0 +1,27 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=pjmedia
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 4000 RTP/XAVP 0 101
+a=rtpmap:0 PCMU/8000
+a=sendrecv
+a=rtpmap:101 telephone-event/8000
+a=fmtp:101 0-15
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = []
+exclude = []
+sendto_cfg = sip.SendtoCfg("Unsupported transport type", pjsua_args, sdp, 488, 
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+			   
+