* #39226: Switch back to pjsip rev 4710

Rev 4716 introduces errors when building for android (miltiple definitions)
diff --git a/jni/pjproject-android/.svn/pristine/fe/fe6386ce2f6ef6ba549dd57390a7cc3cd970b630.svn-base b/jni/pjproject-android/.svn/pristine/fe/fe6386ce2f6ef6ba549dd57390a7cc3cd970b630.svn-base
new file mode 100644
index 0000000..4e002bc
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fe6386ce2f6ef6ba549dd57390a7cc3cd970b630.svn-base
@@ -0,0 +1,231 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJSIP_SIP_EVENT_H__
+#define __PJSIP_SIP_EVENT_H__
+
+/**
+ * @file sip_event.h
+ * @brief SIP Event
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJSIP_EVENT Event
+ * @ingroup PJSIP_CORE_CORE
+ * @brief Representation of events as they are distributed among modules.
+ * @{
+ */
+#include <pj/types.h>
+#include <pj/timer.h>
+
+
+/** 
+ * Event IDs.
+ */
+typedef enum pjsip_event_id_e
+{
+    /** Unidentified event. */
+    PJSIP_EVENT_UNKNOWN,
+
+    /** Timer event, normally only used internally in transaction. */
+    PJSIP_EVENT_TIMER,
+
+    /** Message transmission event. */
+    PJSIP_EVENT_TX_MSG,
+
+    /** Message received event. */
+    PJSIP_EVENT_RX_MSG,
+
+    /** Transport error event. */
+    PJSIP_EVENT_TRANSPORT_ERROR,
+
+    /** Transaction state changed event. */
+    PJSIP_EVENT_TSX_STATE,
+
+    /** Indicates that the event was triggered by user action. */
+    PJSIP_EVENT_USER
+
+} pjsip_event_id_e;
+
+
+/**
+ * This structure describe event descriptor to fully identify a SIP event.
+ *
+ * Events are the only way for a lower layer object to inform something
+ * to higher layer objects. Normally this is achieved by means of callback,
+ * i.e. the higher layer objects register a callback to handle the event on
+ * the lower layer objects.
+ *
+ * This event descriptor is used for example by transactions, to inform
+ * endpoint about events, and by transports, to inform endpoint about
+ * unexpected transport error.
+ */
+struct pjsip_event
+{
+    /** This is necessary so that we can put events as a list. */
+    PJ_DECL_LIST_MEMBER(struct pjsip_event);
+
+    /** The event type, can be any value of \b pjsip_event_id_e.
+     */
+    pjsip_event_id_e type;
+
+    /**
+     * The event body as union, which fields depends on the event type.
+     * By convention, the first member of each struct in the union must be
+     * the pointer which is relevant to the event.
+     */
+    union
+    {
+        /** Timer event. */
+        struct
+        {
+            pj_timer_entry *entry;      /**< The timer entry.           */
+        } timer;
+
+        /** Transaction state has changed event. */
+        struct
+        {
+            union
+            {
+                pjsip_rx_data   *rdata; /**< The incoming message.      */
+                pjsip_tx_data   *tdata; /**< The outgoing message.      */
+                pj_timer_entry  *timer; /**< The timer.                 */
+                pj_status_t      status;/**< Transport error status.    */
+                void            *data;  /**< Generic data.              */
+            } src;
+            pjsip_transaction   *tsx;   /**< The transaction.           */
+	    int			 prev_state; /**< Previous state.	*/
+            pjsip_event_id_e     type;  /**< Type of event source:      
+                                         *      - PJSIP_EVENT_TX_MSG
+                                         *      - PJSIP_EVENT_RX_MSG,
+                                         *      - PJSIP_EVENT_TRANSPORT_ERROR
+                                         *      - PJSIP_EVENT_TIMER
+                                         *      - PJSIP_EVENT_USER
+                                         */
+        } tsx_state;
+
+        /** Message transmission event. */
+        struct
+        {
+            pjsip_tx_data       *tdata; /**< The transmit data buffer.  */
+
+        } tx_msg;
+
+        /** Transmission error event. */
+        struct
+        {
+            pjsip_tx_data       *tdata; /**< The transmit data.         */
+            pjsip_transaction   *tsx;   /**< The transaction.           */
+        } tx_error;
+
+        /** Message arrival event. */
+        struct
+        {
+            pjsip_rx_data       *rdata; /**< The receive data buffer.   */
+        } rx_msg;
+
+        /** User event. */
+        struct
+        {
+            void                *user1; /**< User data 1.               */
+            void                *user2; /**< User data 2.               */
+            void                *user3; /**< User data 3.               */
+            void                *user4; /**< User data 4.               */
+        } user;
+
+    } body;
+};
+
+/**
+ * Init timer event.
+ */
+#define PJSIP_EVENT_INIT_TIMER(event,pentry)            \
+        do { \
+            (event).type = PJSIP_EVENT_TIMER;           \
+            (event).body.timer.entry = pentry;          \
+        } while (0)
+
+/**
+ * Init tsx state event.
+ */
+#define PJSIP_EVENT_INIT_TSX_STATE(event,ptsx,ptype,pdata,prev)   \
+        do { \
+            (event).type = PJSIP_EVENT_TSX_STATE;           \
+            (event).body.tsx_state.tsx = ptsx;		    \
+            (event).body.tsx_state.type = ptype;            \
+            (event).body.tsx_state.src.data = pdata;        \
+	    (event).body.tsx_state.prev_state = prev;	    \
+        } while (0)
+
+/**
+ * Init tx msg event.
+ */
+#define PJSIP_EVENT_INIT_TX_MSG(event,ptdata)	\
+        do { \
+            (event).type = PJSIP_EVENT_TX_MSG;          \
+            (event).body.tx_msg.tdata = ptdata;		\
+        } while (0)
+
+/**
+ * Init rx msg event.
+ */
+#define PJSIP_EVENT_INIT_RX_MSG(event,prdata)	\
+        do { \
+            (event).type = PJSIP_EVENT_RX_MSG;		\
+            (event).body.rx_msg.rdata = prdata;		\
+        } while (0)
+
+/**
+ * Init transport error event.
+ */
+#define PJSIP_EVENT_INIT_TRANSPORT_ERROR(event,ptsx,ptdata)   \
+        do { \
+            (event).type = PJSIP_EVENT_TRANSPORT_ERROR; \
+            (event).body.tx_error.tsx = ptsx;		\
+            (event).body.tx_error.tdata = ptdata;	\
+        } while (0)
+
+/**
+ * Init user event.
+ */
+#define PJSIP_EVENT_INIT_USER(event,u1,u2,u3,u4)    \
+        do { \
+            (event).type = PJSIP_EVENT_USER;        \
+            (event).body.user.user1 = (void*)u1;     \
+            (event).body.user.user2 = (void*)u2;     \
+            (event).body.user.user3 = (void*)u3;     \
+            (event).body.user.user4 = (void*)u4;     \
+        } while (0)
+
+/**
+ * Get the event string from the event ID.
+ * @param e the event ID.
+ * @note defined in sip_util.c
+ */
+PJ_DECL(const char *) pjsip_event_str(pjsip_event_id_e e);
+
+/**
+ * @}
+ */
+
+PJ_END_DECL
+
+#endif	/* __PJSIP_SIP_EVENT_H__ */
diff --git a/jni/pjproject-android/.svn/pristine/fe/fe7034b9fede8aba0a71bc67aebe1d36a6259e14.svn-base b/jni/pjproject-android/.svn/pristine/fe/fe7034b9fede8aba0a71bc67aebe1d36a6259e14.svn-base
new file mode 100644
index 0000000..7bbd488
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fe7034b9fede8aba0a71bc67aebe1d36a6259e14.svn-base
@@ -0,0 +1,45 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJ_COMPAT_ERRNO_H__
+#define __PJ_COMPAT_ERRNO_H__
+
+#if defined(PJ_WIN32) && PJ_WIN32 != 0 || \
+    defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE != 0 || \
+    defined(PJ_WIN64) && PJ_WIN64 != 0
+
+    typedef unsigned long pj_os_err_type;
+#   define pj_get_native_os_error()	    GetLastError()
+#   define pj_get_native_netos_error()	    WSAGetLastError()
+
+#elif defined(PJ_HAS_ERRNO_VAR) && PJ_HAS_ERRNO_VAR!= 0
+
+    typedef int pj_os_err_type;
+#   define pj_get_native_os_error()	    (errno)
+#   define pj_get_native_netos_error()	    (errno)
+
+#else
+
+#   error "Please define how to get errno for this platform here!"
+
+#endif
+
+
+#endif	/* __PJ_COMPAT_ERRNO_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/fe/fe7aa82c187b7e0add339cd7af954dd8746f28b9.svn-base b/jni/pjproject-android/.svn/pristine/fe/fe7aa82c187b7e0add339cd7af954dd8746f28b9.svn-base
new file mode 100644
index 0000000..48d6883
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fe7aa82c187b7e0add339cd7af954dd8746f28b9.svn-base
@@ -0,0 +1,52 @@
+.\"
+.\" Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+.\" Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+.\" details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+.\"
+.PU
+.TH GSM_PRINT 3 
+.SH NAME
+gsm_print \(em GSM\ 06.10 supplementary function for debugging
+.SH SYNOPSIS
+#include "gsm.h"
+#include <stdio.h>
+
+int gsm_print(f, g, frame);
+.br
+FILE * f;
+.br
+gsm    g;
+.br
+gsm_frame frame;
+.SH "DESCRIPTION"
+Gsm is an implementation of the final draft GSM 06.10
+standard for full-rate speech transcoding, a lossy
+speech compression algorithm.
+The compressed form involves 76 variables with different numbers
+of significant bits packed into 33 bytes.
+.PP
+If you are interested in investigating the details of this
+coding scheme, gsm_print() can be used to dump the contents
+of individual gsm_frames to a file pointer provided by
+the application.
+.PP
+.SH "RETURN VALUE"
+gsm_print() returns -1 if the frame is invalid, else 0.
+.SH EXAMPLE
+A single frame looks like this:
+.br
+.nf
+LARc:   29  32  20  11  08  05  06  07
+#1:     Nc 0040    bc 0    Mc 1    xmaxc 60
+        06 04 00 03 03 06 04 02 02 04 05 04 01
+#2:     Nc 0045    bc 1    Mc 1    xmaxc 48
+        03 07 01 03 04 04 07 01 03 02 04 05 03
+#3:     Nc 0091    bc 1    Mc 1    xmaxc 46
+        00 03 03 07 01 06 02 04 05 03 03 02 04
+#4:     Nc 0120    bc 0    Mc 1    xmaxc 47
+        07 03 06 00 03 03 06 05 00 03 02 07 04
+.nf
+.SH BUGS
+Please direct bug reports to jutta@cs.tu-berlin.de and cabo@cs.tu-berlin.de.
+.SH "SEE ALSO"
+gsm(3), gsm_explode(3) 
diff --git a/jni/pjproject-android/.svn/pristine/fe/fe94ea27f7d38558b392180b7819797dafe4a730.svn-base b/jni/pjproject-android/.svn/pristine/fe/fe94ea27f7d38558b392180b7819797dafe4a730.svn-base
new file mode 100644
index 0000000..208d418
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fe94ea27f7d38558b392180b7819797dafe4a730.svn-base
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------

+// File: SeekPT.h

+//

+// Desc: DirectShow base classes.

+//

+// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.

+//------------------------------------------------------------------------------

+

+

+#ifndef __seekpt_h__

+#define __seekpt_h__

+

+

+class CSeekingPassThru : public ISeekingPassThru, public CUnknown

+{

+public:

+    static CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);

+    CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);

+    ~CSeekingPassThru();

+

+    DECLARE_IUNKNOWN;

+    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);

+

+    STDMETHODIMP Init(BOOL bSupportRendering, IPin *pPin);

+

+private:

+    CPosPassThru              *m_pPosPassThru;

+};

+

+#endif

diff --git a/jni/pjproject-android/.svn/pristine/fe/feb24d9b42f3937cef0d731b03b528d8daa94222.svn-base b/jni/pjproject-android/.svn/pristine/fe/feb24d9b42f3937cef0d731b03b528d8daa94222.svn-base
new file mode 100644
index 0000000..2cc9ea5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/feb24d9b42f3937cef0d731b03b528d8daa94222.svn-base
@@ -0,0 +1,107 @@
+/* Copyright (C) 2005 Analog Devices */
+/**
+   @file vq_bfin.h
+   @author Jean-Marc Valin 
+   @brief Blackfin-optimized vq routine
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_VQ_NBEST
+void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
+{
+   if (N==1)
+   {
+      best_dist[0] = 2147483647;
+      {
+         spx_word32_t dist;
+         __asm__ __volatile__
+               (
+            "LC0 = %8;\n\t"
+            "R2 = 0;\n\t"
+            "I0 = %6;\n\t"
+            "B0 = %6;\n\t"
+            "L0 = %9;\n\t"
+            "LOOP entries_loop%= LC0;\n\t"
+            "LOOP_BEGIN entries_loop%=;\n\t"
+               "%0 = [%4++];\n\t"
+               "%0 >>= 1;\n\t"
+               "A0 = %0;\n\t"
+               "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
+               "LOOP vq_loop%= LC1 = %5;\n\t"
+               "LOOP_BEGIN vq_loop%=;\n\t"
+                  "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
+               "LOOP_END vq_loop%=;\n\t"
+               "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
+               "cc = %0 < %2;\n\t"
+               "if cc %2 = %0;\n\t"
+               "if cc %3 = R2;\n\t"
+               "R2 += 1;\n\t"
+            "LOOP_END entries_loop%=;\n\t"
+            : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E)
+            : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0])
+            : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory"
+               );
+      }
+   } else {
+   int i,k,used;
+   used = 0;
+   for (i=0;i<entries;i++)
+   {
+      spx_word32_t dist;
+      __asm__
+            (
+            "%0 >>= 1;\n\t"
+            "A0 = %0;\n\t"
+            "I0 = %3;\n\t"
+            "L0 = 0;\n\t"
+            "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
+            "LOOP vq_loop%= LC0 = %2;\n\t"
+            "LOOP_BEGIN vq_loop%=;\n\t"
+               "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
+            "LOOP_END vq_loop%=;\n\t"
+            "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
+         : "=D" (dist), "=a" (codebook)
+         : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i])
+         : "R0", "R1", "I0", "L0", "A0"
+            );
+      if (i<N || dist<best_dist[N-1])
+      {
+         for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
+         {
+            best_dist[k]=best_dist[k-1];
+            nbest[k] = nbest[k-1];
+         }
+         best_dist[k]=dist;
+         nbest[k]=i;
+         used++;
+      }
+   }
+   }
+}
diff --git a/jni/pjproject-android/.svn/pristine/fe/fed393a714025a0ff5295e18325f384c5daba6a9.svn-base b/jni/pjproject-android/.svn/pristine/fe/fed393a714025a0ff5295e18325f384c5daba6a9.svn-base
new file mode 100644
index 0000000..68c50b9
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fed393a714025a0ff5295e18325f384c5daba6a9.svn-base
@@ -0,0 +1,1030 @@
+/* $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 
+ */
+
+
+/**
+ * simpleua.c
+ *
+ * This is a very simple SIP user agent complete with media. The user
+ * agent should do a proper SDP negotiation and start RTP media once
+ * SDP negotiation has completed.
+ *
+ * This program does not register to SIP server.
+ *
+ * Capabilities to be demonstrated here:
+ *  - Basic call
+ *  - Should support IPv6 (not tested)
+ *  - UDP transport at port 5060 (hard coded)
+ *  - RTP socket at port 4000 (hard coded)
+ *  - proper SDP negotiation
+ *  - PCMA/PCMU codec only.
+ *  - Audio/media to sound device.
+ *
+ *
+ * Usage:
+ *  - To make outgoing call, start simpleua with the URL of remote
+ *    destination to contact.
+ *    E.g.:
+ *	 simpleua sip:user@remote
+ *
+ *  - Incoming calls will automatically be answered with 180, then 200.
+ *
+ * This program does not disconnect call.
+ *
+ * This program will quit once it has completed a single call.
+ */
+
+/* Include all headers. */
+#include <pjsip.h>
+#include <pjmedia.h>
+#include <pjmedia-codec.h>
+#include <pjsip_ua.h>
+#include <pjsip_simple.h>
+#include <pjlib-util.h>
+#include <pjlib.h>
+
+/* For logging purpose. */
+#define THIS_FILE   "simpleua.c"
+
+#include "util.h"
+
+
+/* Settings */
+#define AF		pj_AF_INET() /* Change to pj_AF_INET6() for IPv6.
+				      * PJ_HAS_IPV6 must be enabled and
+				      * your system must support IPv6.  */
+#if 0
+#define SIP_PORT	5080	     /* Listening SIP port		*/
+#define RTP_PORT	5000	     /* RTP port			*/
+#else
+#define SIP_PORT	5060	     /* Listening SIP port		*/
+#define RTP_PORT	4000	     /* RTP port			*/
+#endif
+
+#define MAX_MEDIA_CNT	2	     /* Media count, set to 1 for audio
+				      * only or 2 for audio and video	*/
+
+/*
+ * Static variables.
+ */
+
+static pj_bool_t	     g_complete;    /* Quit flag.		*/
+static pjsip_endpoint	    *g_endpt;	    /* SIP endpoint.		*/
+static pj_caching_pool	     cp;	    /* Global pool factory.	*/
+
+static pjmedia_endpt	    *g_med_endpt;   /* Media endpoint.		*/
+
+static pjmedia_transport_info g_med_tpinfo[MAX_MEDIA_CNT]; 
+					    /* Socket info for media	*/
+static pjmedia_transport    *g_med_transport[MAX_MEDIA_CNT];
+					    /* Media stream transport	*/
+static pjmedia_sock_info     g_sock_info[MAX_MEDIA_CNT];  
+					    /* Socket info array	*/
+
+/* Call variables: */
+static pjsip_inv_session    *g_inv;	    /* Current invite session.	*/
+static pjmedia_stream       *g_med_stream;  /* Call's audio stream.	*/
+static pjmedia_snd_port	    *g_snd_port;    /* Sound device.		*/
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+static pjmedia_vid_stream   *g_med_vstream; /* Call's video stream.	*/
+static pjmedia_vid_port	    *g_vid_capturer;/* Call's video capturer.	*/
+static pjmedia_vid_port	    *g_vid_renderer;/* Call's video renderer.	*/
+#endif	/* PJMEDIA_HAS_VIDEO */
+
+/*
+ * Prototypes:
+ */
+
+/* Callback to be called when SDP negotiation is done in the call: */
+static void call_on_media_update( pjsip_inv_session *inv,
+				  pj_status_t status);
+
+/* Callback to be called when invite session's state has changed: */
+static void call_on_state_changed( pjsip_inv_session *inv, 
+				   pjsip_event *e);
+
+/* Callback to be called when dialog has forked: */
+static void call_on_forked(pjsip_inv_session *inv, pjsip_event *e);
+
+/* Callback to be called to handle incoming requests outside dialogs: */
+static pj_bool_t on_rx_request( pjsip_rx_data *rdata );
+
+
+
+
+/* This is a PJSIP module to be registered by application to handle
+ * incoming requests outside any dialogs/transactions. The main purpose
+ * here is to handle incoming INVITE request message, where we will
+ * create a dialog and INVITE session for it.
+ */
+static pjsip_module mod_simpleua =
+{
+    NULL, NULL,			    /* prev, next.		*/
+    { "mod-simpleua", 12 },	    /* Name.			*/
+    -1,				    /* Id			*/
+    PJSIP_MOD_PRIORITY_APPLICATION, /* Priority			*/
+    NULL,			    /* load()			*/
+    NULL,			    /* start()			*/
+    NULL,			    /* stop()			*/
+    NULL,			    /* unload()			*/
+    &on_rx_request,		    /* on_rx_request()		*/
+    NULL,			    /* on_rx_response()		*/
+    NULL,			    /* on_tx_request.		*/
+    NULL,			    /* on_tx_response()		*/
+    NULL,			    /* on_tsx_state()		*/
+};
+
+
+/* Notification on incoming messages */
+static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata)
+{
+    PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s %s:%d:\n"
+			 "%.*s\n"
+			 "--end msg--",
+			 rdata->msg_info.len,
+			 pjsip_rx_data_get_info(rdata),
+			 rdata->tp_info.transport->type_name,
+			 rdata->pkt_info.src_name,
+			 rdata->pkt_info.src_port,
+			 (int)rdata->msg_info.len,
+			 rdata->msg_info.msg_buf));
+    
+    /* Always return false, otherwise messages will not get processed! */
+    return PJ_FALSE;
+}
+
+/* Notification on outgoing messages */
+static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
+{
+    
+    /* Important note:
+     *	tp_info field is only valid after outgoing messages has passed
+     *	transport layer. So don't try to access tp_info when the module
+     *	has lower priority than transport layer.
+     */
+
+    PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s %s:%d:\n"
+			 "%.*s\n"
+			 "--end msg--",
+			 (tdata->buf.cur - tdata->buf.start),
+			 pjsip_tx_data_get_info(tdata),
+			 tdata->tp_info.transport->type_name,
+			 tdata->tp_info.dst_name,
+			 tdata->tp_info.dst_port,
+			 (int)(tdata->buf.cur - tdata->buf.start),
+			 tdata->buf.start));
+
+    /* Always return success, otherwise message will not get sent! */
+    return PJ_SUCCESS;
+}
+
+/* The module instance. */
+static pjsip_module msg_logger = 
+{
+    NULL, NULL,				/* prev, next.		*/
+    { "mod-msg-log", 13 },		/* Name.		*/
+    -1,					/* Id			*/
+    PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority	        */
+    NULL,				/* load()		*/
+    NULL,				/* start()		*/
+    NULL,				/* stop()		*/
+    NULL,				/* unload()		*/
+    &logging_on_rx_msg,			/* on_rx_request()	*/
+    &logging_on_rx_msg,			/* on_rx_response()	*/
+    &logging_on_tx_msg,			/* on_tx_request.	*/
+    &logging_on_tx_msg,			/* on_tx_response()	*/
+    NULL,				/* on_tsx_state()	*/
+
+};
+
+
+/*
+ * main()
+ *
+ * If called with argument, treat argument as SIP URL to be called.
+ * Otherwise wait for incoming calls.
+ */
+int main(int argc, char *argv[])
+{
+    pj_pool_t *pool = NULL;
+    pj_status_t status;
+    unsigned i;
+
+    /* Must init PJLIB first: */
+    status = pj_init();
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+    pj_log_set_level(5);
+
+    /* Then init PJLIB-UTIL: */
+    status = pjlib_util_init();
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+    /* Must create a pool factory before we can allocate any memory. */
+    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+
+
+    /* Create global endpoint: */
+    {
+	const pj_str_t *hostname;
+	const char *endpt_name;
+
+	/* Endpoint MUST be assigned a globally unique name.
+	 * The name will be used as the hostname in Warning header.
+	 */
+
+	/* For this implementation, we'll use hostname for simplicity */
+	hostname = pj_gethostname();
+	endpt_name = hostname->ptr;
+
+	/* Create the endpoint: */
+
+	status = pjsip_endpt_create(&cp.factory, endpt_name, 
+				    &g_endpt);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    }
+
+
+    /* 
+     * Add UDP transport, with hard-coded port 
+     * Alternatively, application can use pjsip_udp_transport_attach() to
+     * start UDP transport, if it already has an UDP socket (e.g. after it
+     * resolves the address with STUN).
+     */
+    {
+	pj_sockaddr addr;
+
+	pj_sockaddr_init(AF, &addr, NULL, (pj_uint16_t)SIP_PORT);
+	
+	if (AF == pj_AF_INET()) {
+	    status = pjsip_udp_transport_start( g_endpt, &addr.ipv4, NULL, 
+						1, NULL);
+	} else if (AF == pj_AF_INET6()) {
+	    status = pjsip_udp_transport_start6(g_endpt, &addr.ipv6, NULL,
+						1, NULL);
+	} else {
+	    status = PJ_EAFNOTSUP;
+	}
+
+	if (status != PJ_SUCCESS) {
+	    app_perror(THIS_FILE, "Unable to start UDP transport", status);
+	    return 1;
+	}
+    }
+
+
+    /* 
+     * Init transaction layer.
+     * This will create/initialize transaction hash tables etc.
+     */
+    status = pjsip_tsx_layer_init_module(g_endpt);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+    /* 
+     * Initialize UA layer module.
+     * This will create/initialize dialog hash tables etc.
+     */
+    status = pjsip_ua_init_module( g_endpt, NULL );
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+    /* 
+     * Init invite session module.
+     * The invite session module initialization takes additional argument,
+     * i.e. a structure containing callbacks to be called on specific
+     * occurence of events.
+     *
+     * The on_state_changed and on_new_session callbacks are mandatory.
+     * Application must supply the callback function.
+     *
+     * We use on_media_update() callback in this application to start
+     * media transmission.
+     */
+    {
+	pjsip_inv_callback inv_cb;
+
+	/* Init the callback for INVITE session: */
+	pj_bzero(&inv_cb, sizeof(inv_cb));
+	inv_cb.on_state_changed = &call_on_state_changed;
+	inv_cb.on_new_session = &call_on_forked;
+	inv_cb.on_media_update = &call_on_media_update;
+
+	/* Initialize invite session module:  */
+	status = pjsip_inv_usage_init(g_endpt, &inv_cb);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    }
+
+    /* Initialize 100rel support */
+    status = pjsip_100rel_init_module(g_endpt);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
+
+    /*
+     * Register our module to receive incoming requests.
+     */
+    status = pjsip_endpt_register_module( g_endpt, &mod_simpleua);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+    /*
+     * Register message logger module.
+     */
+    status = pjsip_endpt_register_module( g_endpt, &msg_logger);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+    /* 
+     * Initialize media endpoint.
+     * This will implicitly initialize PJMEDIA too.
+     */
+#if PJ_HAS_THREADS
+    status = pjmedia_endpt_create(&cp.factory, NULL, 1, &g_med_endpt);
+#else
+    status = pjmedia_endpt_create(&cp.factory, 
+				  pjsip_endpt_get_ioqueue(g_endpt), 
+				  0, &g_med_endpt);
+#endif
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+    /* 
+     * Add PCMA/PCMU codec to the media endpoint. 
+     */
+#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0
+    status = pjmedia_codec_g711_init(g_med_endpt);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+#endif
+
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+    /* Init video subsystem */
+    pool = pjmedia_endpt_create_pool(g_med_endpt, "Video subsystem", 512, 512);
+    status = pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    status = pjmedia_converter_mgr_create(pool, NULL);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    status = pjmedia_vid_codec_mgr_create(pool, NULL);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+    status = pjmedia_vid_dev_subsys_init(&cp.factory);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+#  if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
+    /* Init ffmpeg video codecs */
+    status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+#  endif  /* PJMEDIA_HAS_FFMPEG_VID_CODEC */
+
+#endif	/* PJMEDIA_HAS_VIDEO */
+    
+    /* 
+     * Create media transport used to send/receive RTP/RTCP socket.
+     * One media transport is needed for each call. Application may
+     * opt to re-use the same media transport for subsequent calls.
+     */
+    for (i = 0; i < PJ_ARRAY_SIZE(g_med_transport); ++i) {
+	status = pjmedia_transport_udp_create3(g_med_endpt, AF, NULL, NULL, 
+					       RTP_PORT + i*2, 0, 
+					       &g_med_transport[i]);
+	if (status != PJ_SUCCESS) {
+	    app_perror(THIS_FILE, "Unable to create media transport", status);
+	    return 1;
+	}
+
+	/* 
+	 * Get socket info (address, port) of the media transport. We will
+	 * need this info to create SDP (i.e. the address and port info in
+	 * the SDP).
+	 */
+	pjmedia_transport_info_init(&g_med_tpinfo[i]);
+	pjmedia_transport_get_info(g_med_transport[i], &g_med_tpinfo[i]);
+
+	pj_memcpy(&g_sock_info[i], &g_med_tpinfo[i].sock_info,
+		  sizeof(pjmedia_sock_info));
+    }
+
+    /*
+     * If URL is specified, then make call immediately.
+     */
+    if (argc > 1) {
+	pj_sockaddr hostaddr;
+	char hostip[PJ_INET6_ADDRSTRLEN+2];
+	char temp[80];
+	pj_str_t dst_uri = pj_str(argv[1]);
+	pj_str_t local_uri;
+	pjsip_dialog *dlg;
+	pjmedia_sdp_session *local_sdp;
+	pjsip_tx_data *tdata;
+
+	if (pj_gethostip(AF, &hostaddr) != PJ_SUCCESS) {
+	    app_perror(THIS_FILE, "Unable to retrieve local host IP", status);
+	    return 1;
+	}
+	pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
+
+	pj_ansi_sprintf(temp, "<sip:simpleuac@%s:%d>", 
+			hostip, SIP_PORT);
+	local_uri = pj_str(temp);
+
+	/* Create UAC dialog */
+	status = pjsip_dlg_create_uac( pjsip_ua_instance(), 
+				       &local_uri,  /* local URI */
+				       &local_uri,  /* local Contact */
+				       &dst_uri,    /* remote URI */
+				       &dst_uri,    /* remote target */
+				       &dlg);	    /* dialog */
+	if (status != PJ_SUCCESS) {
+	    app_perror(THIS_FILE, "Unable to create UAC dialog", status);
+	    return 1;
+	}
+
+	/* If we expect the outgoing INVITE to be challenged, then we should
+	 * put the credentials in the dialog here, with something like this:
+	 *
+	    {
+		pjsip_cred_info	cred[1];
+
+		cred[0].realm	  = pj_str("sip.server.realm");
+		cred[0].scheme    = pj_str("digest");
+		cred[0].username  = pj_str("theuser");
+		cred[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
+		cred[0].data      = pj_str("thepassword");
+
+		pjsip_auth_clt_set_credentials( &dlg->auth_sess, 1, cred);
+	    }
+	 *
+	 */
+
+
+	/* Get the SDP body to be put in the outgoing INVITE, by asking
+	 * media endpoint to create one for us.
+	 */
+	status = pjmedia_endpt_create_sdp( g_med_endpt,	    /* the media endpt	*/
+					   dlg->pool,	    /* pool.		*/
+					   MAX_MEDIA_CNT,   /* # of streams	*/
+					   g_sock_info,     /* RTP sock info	*/
+					   &local_sdp);	    /* the SDP result	*/
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+
+	/* Create the INVITE session, and pass the SDP returned earlier
+	 * as the session's initial capability.
+	 */
+	status = pjsip_inv_create_uac( dlg, local_sdp, 0, &g_inv);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+	/* If we want the initial INVITE to travel to specific SIP proxies,
+	 * then we should put the initial dialog's route set here. The final
+	 * route set will be updated once a dialog has been established.
+	 * To set the dialog's initial route set, we do it with something
+	 * like this:
+	 *
+	    {
+		pjsip_route_hdr route_set;
+		pjsip_route_hdr *route;
+		const pj_str_t hname = { "Route", 5 };
+		char *uri = "sip:proxy.server;lr";
+
+		pj_list_init(&route_set);
+
+		route = pjsip_parse_hdr( dlg->pool, &hname, 
+					 uri, strlen(uri),
+					 NULL);
+		PJ_ASSERT_RETURN(route != NULL, 1);
+		pj_list_push_back(&route_set, route);
+
+		pjsip_dlg_set_route_set(dlg, &route_set);
+	    }
+	 *
+	 * Note that Route URI SHOULD have an ";lr" parameter!
+	 */
+
+	/* Create initial INVITE request.
+	 * This INVITE request will contain a perfectly good request and 
+	 * an SDP body as well.
+	 */
+	status = pjsip_inv_invite(g_inv, &tdata);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+
+	/* Send initial INVITE request. 
+	 * From now on, the invite session's state will be reported to us
+	 * via the invite session callbacks.
+	 */
+	status = pjsip_inv_send_msg(g_inv, tdata);
+	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+    } else {
+
+	/* No URL to make call to */
+
+	PJ_LOG(3,(THIS_FILE, "Ready to accept incoming calls..."));
+    }
+
+
+    /* Loop until one call is completed */
+    for (;!g_complete;) {
+	pj_time_val timeout = {0, 10};
+	pjsip_endpt_handle_events(g_endpt, &timeout);
+    }
+
+    /* On exit, dump current memory usage: */
+    dump_pool_usage(THIS_FILE, &cp);
+
+    /* Destroy audio ports. Destroy the audio port first
+     * before the stream since the audio port has threads
+     * that get/put frames to the stream.
+     */
+    if (g_snd_port)
+	pjmedia_snd_port_destroy(g_snd_port);
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+    /* Destroy video ports */
+    if (g_vid_capturer)
+	pjmedia_vid_port_destroy(g_vid_capturer);
+    if (g_vid_renderer)
+	pjmedia_vid_port_destroy(g_vid_renderer);
+#endif
+
+    /* Destroy streams */
+    if (g_med_stream)
+	pjmedia_stream_destroy(g_med_stream);
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+    if (g_med_vstream)
+	pjmedia_vid_stream_destroy(g_med_vstream);
+
+    /* Deinit ffmpeg codec */
+#   if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
+    pjmedia_codec_ffmpeg_vid_deinit();
+#   endif
+
+#endif
+
+    /* Destroy media transports */
+    for (i = 0; i < MAX_MEDIA_CNT; ++i) {
+	if (g_med_transport[i])
+	    pjmedia_transport_close(g_med_transport[i]);
+    }
+
+    /* Deinit pjmedia endpoint */
+    if (g_med_endpt)
+	pjmedia_endpt_destroy(g_med_endpt);
+
+    /* Deinit pjsip endpoint */
+    if (g_endpt)
+	pjsip_endpt_destroy(g_endpt);
+
+    /* Release pool */
+    if (pool)
+	pj_pool_release(pool);
+
+    return 0;
+}
+
+
+
+/*
+ * Callback when INVITE session state has changed.
+ * This callback is registered when the invite session module is initialized.
+ * We mostly want to know when the invite session has been disconnected,
+ * so that we can quit the application.
+ */
+static void call_on_state_changed( pjsip_inv_session *inv, 
+				   pjsip_event *e)
+{
+    PJ_UNUSED_ARG(e);
+
+    if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
+
+	PJ_LOG(3,(THIS_FILE, "Call DISCONNECTED [reason=%d (%s)]", 
+		  inv->cause,
+		  pjsip_get_status_text(inv->cause)->ptr));
+
+	PJ_LOG(3,(THIS_FILE, "One call completed, application quitting..."));
+	g_complete = 1;
+
+    } else {
+
+	PJ_LOG(3,(THIS_FILE, "Call state changed to %s", 
+		  pjsip_inv_state_name(inv->state)));
+
+    }
+}
+
+
+/* This callback is called when dialog has forked. */
+static void call_on_forked(pjsip_inv_session *inv, pjsip_event *e)
+{
+    /* To be done... */
+    PJ_UNUSED_ARG(inv);
+    PJ_UNUSED_ARG(e);
+}
+
+
+/*
+ * Callback when incoming requests outside any transactions and any
+ * dialogs are received. We're only interested to hande incoming INVITE
+ * request, and we'll reject any other requests with 500 response.
+ */
+static pj_bool_t on_rx_request( pjsip_rx_data *rdata )
+{
+    pj_sockaddr hostaddr;
+    char temp[80], hostip[PJ_INET6_ADDRSTRLEN];
+    pj_str_t local_uri;
+    pjsip_dialog *dlg;
+    pjmedia_sdp_session *local_sdp;
+    pjsip_tx_data *tdata;
+    unsigned options = 0;
+    pj_status_t status;
+
+
+    /* 
+     * Respond (statelessly) any non-INVITE requests with 500 
+     */
+    if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD) {
+
+	if (rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) {
+	    pj_str_t reason = pj_str("Simple UA unable to handle "
+				     "this request");
+
+	    pjsip_endpt_respond_stateless( g_endpt, rdata, 
+					   500, &reason,
+					   NULL, NULL);
+	}
+	return PJ_TRUE;
+    }
+
+
+    /*
+     * Reject INVITE if we already have an INVITE session in progress.
+     */
+    if (g_inv) {
+
+	pj_str_t reason = pj_str("Another call is in progress");
+
+	pjsip_endpt_respond_stateless( g_endpt, rdata, 
+				       500, &reason,
+				       NULL, NULL);
+	return PJ_TRUE;
+
+    }
+
+    /* Verify that we can handle the request. */
+    status = pjsip_inv_verify_request(rdata, &options, NULL, NULL,
+				      g_endpt, NULL);
+    if (status != PJ_SUCCESS) {
+
+	pj_str_t reason = pj_str("Sorry Simple UA can not handle this INVITE");
+
+	pjsip_endpt_respond_stateless( g_endpt, rdata, 
+				       500, &reason,
+				       NULL, NULL);
+	return PJ_TRUE;
+    } 
+
+    /*
+     * Generate Contact URI
+     */
+    if (pj_gethostip(AF, &hostaddr) != PJ_SUCCESS) {
+	app_perror(THIS_FILE, "Unable to retrieve local host IP", status);
+	return PJ_TRUE;
+    }
+    pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);
+
+    pj_ansi_sprintf(temp, "<sip:simpleuas@%s:%d>", 
+		    hostip, SIP_PORT);
+    local_uri = pj_str(temp);
+
+    /*
+     * Create UAS dialog.
+     */
+    status = pjsip_dlg_create_uas( pjsip_ua_instance(), 
+				   rdata,
+				   &local_uri, /* contact */
+				   &dlg);
+    if (status != PJ_SUCCESS) {
+	pjsip_endpt_respond_stateless(g_endpt, rdata, 500, NULL,
+				      NULL, NULL);
+	return PJ_TRUE;
+    }
+
+    /* 
+     * Get media capability from media endpoint: 
+     */
+
+    status = pjmedia_endpt_create_sdp( g_med_endpt, rdata->tp_info.pool,
+				       MAX_MEDIA_CNT, g_sock_info, &local_sdp);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+
+    /* 
+     * Create invite session, and pass both the UAS dialog and the SDP
+     * capability to the session.
+     */
+    status = pjsip_inv_create_uas( dlg, rdata, local_sdp, 0, &g_inv);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+
+    /*
+     * Initially send 180 response.
+     *
+     * The very first response to an INVITE must be created with
+     * pjsip_inv_initial_answer(). Subsequent responses to the same
+     * transaction MUST use pjsip_inv_answer().
+     */
+    status = pjsip_inv_initial_answer(g_inv, rdata, 
+				      180, 
+				      NULL, NULL, &tdata);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+
+    /* Send the 180 response. */  
+    status = pjsip_inv_send_msg(g_inv, tdata); 
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+
+    /*
+     * Now create 200 response.
+     */
+    status = pjsip_inv_answer( g_inv, 
+			       200, NULL,	/* st_code and st_text */
+			       NULL,		/* SDP already specified */
+			       &tdata);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+    /*
+     * Send the 200 response.
+     */
+    status = pjsip_inv_send_msg(g_inv, tdata);
+    PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE);
+
+
+    /* Done. 
+     * When the call is disconnected, it will be reported via the callback.
+     */
+
+    return PJ_TRUE;
+}
+
+ 
+
+/*
+ * Callback when SDP negotiation has completed.
+ * We are interested with this callback because we want to start media
+ * as soon as SDP negotiation is completed.
+ */
+static void call_on_media_update( pjsip_inv_session *inv,
+				  pj_status_t status)
+{
+    pjmedia_stream_info stream_info;
+    const pjmedia_sdp_session *local_sdp;
+    const pjmedia_sdp_session *remote_sdp;
+    pjmedia_port *media_port;
+
+    if (status != PJ_SUCCESS) {
+
+	app_perror(THIS_FILE, "SDP negotiation has failed", status);
+
+	/* Here we should disconnect call if we're not in the middle 
+	 * of initializing an UAS dialog and if this is not a re-INVITE.
+	 */
+	return;
+    }
+
+    /* Get local and remote SDP.
+     * We need both SDPs to create a media session.
+     */
+    status = pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp);
+
+    status = pjmedia_sdp_neg_get_active_remote(inv->neg, &remote_sdp);
+
+
+    /* Create stream info based on the media audio SDP. */
+    status = pjmedia_stream_info_from_sdp(&stream_info, inv->dlg->pool,
+					  g_med_endpt,
+					  local_sdp, remote_sdp, 0);
+    if (status != PJ_SUCCESS) {
+	app_perror(THIS_FILE,"Unable to create audio stream info",status);
+	return;
+    }
+
+    /* If required, we can also change some settings in the stream info,
+     * (such as jitter buffer settings, codec settings, etc) before we
+     * create the stream.
+     */
+
+    /* Create new audio media stream, passing the stream info, and also the
+     * media socket that we created earlier.
+     */
+    status = pjmedia_stream_create(g_med_endpt, inv->dlg->pool, &stream_info,
+				   g_med_transport[0], NULL, &g_med_stream);
+    if (status != PJ_SUCCESS) {
+	app_perror( THIS_FILE, "Unable to create audio stream", status);
+	return;
+    }
+
+    /* Start the audio stream */
+    status = pjmedia_stream_start(g_med_stream);
+    if (status != PJ_SUCCESS) {
+	app_perror( THIS_FILE, "Unable to start audio stream", status);
+	return;
+    }
+
+    /* Get the media port interface of the audio stream. 
+     * Media port interface is basicly a struct containing get_frame() and
+     * put_frame() function. With this media port interface, we can attach
+     * the port interface to conference bridge, or directly to a sound
+     * player/recorder device.
+     */
+    pjmedia_stream_get_port(g_med_stream, &media_port);
+
+    /* Create sound port */
+    pjmedia_snd_port_create(inv->pool,
+                            PJMEDIA_AUD_DEFAULT_CAPTURE_DEV,
+                            PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV,
+                            PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate	    */
+                            PJMEDIA_PIA_CCNT(&media_port->info),/* channel count    */
+                            PJMEDIA_PIA_SPF(&media_port->info), /* samples per frame*/
+                            PJMEDIA_PIA_BITS(&media_port->info),/* bits per sample  */
+                            0,
+                            &g_snd_port);
+
+    if (status != PJ_SUCCESS) {
+	app_perror( THIS_FILE, "Unable to create sound port", status);
+	PJ_LOG(3,(THIS_FILE, "%d %d %d %d",
+		    PJMEDIA_PIA_SRATE(&media_port->info),/* clock rate	    */
+		    PJMEDIA_PIA_CCNT(&media_port->info),/* channel count    */
+		    PJMEDIA_PIA_SPF(&media_port->info), /* samples per frame*/
+		    PJMEDIA_PIA_BITS(&media_port->info) /* bits per sample  */
+	    ));
+	return;
+    }
+
+    status = pjmedia_snd_port_connect(g_snd_port, media_port);
+
+
+    /* Get the media port interface of the second stream in the session,
+     * which is video stream. With this media port interface, we can attach
+     * the port directly to a renderer/capture video device.
+     */
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+    if (local_sdp->media_count > 1) {
+	pjmedia_vid_stream_info vstream_info;
+	pjmedia_vid_port_param vport_param;
+
+	pjmedia_vid_port_param_default(&vport_param);
+
+	/* Create stream info based on the media video SDP. */
+	status = pjmedia_vid_stream_info_from_sdp(&vstream_info,
+						  inv->dlg->pool, g_med_endpt,
+						  local_sdp, remote_sdp, 1);
+	if (status != PJ_SUCCESS) {
+	    app_perror(THIS_FILE,"Unable to create video stream info",status);
+	    return;
+	}
+
+	/* If required, we can also change some settings in the stream info,
+	 * (such as jitter buffer settings, codec settings, etc) before we
+	 * create the video stream.
+	 */
+
+	/* Create new video media stream, passing the stream info, and also the
+	 * media socket that we created earlier.
+	 */
+	status = pjmedia_vid_stream_create(g_med_endpt, NULL, &vstream_info,
+	                                   g_med_transport[1], NULL,
+	                                   &g_med_vstream);
+	if (status != PJ_SUCCESS) {
+	    app_perror( THIS_FILE, "Unable to create video stream", status);
+	    return;
+	}
+
+	/* Start the video stream */
+	status = pjmedia_vid_stream_start(g_med_vstream);
+	if (status != PJ_SUCCESS) {
+	    app_perror( THIS_FILE, "Unable to start video stream", status);
+	    return;
+	}
+
+	if (vstream_info.dir & PJMEDIA_DIR_DECODING) {
+	    status = pjmedia_vid_dev_default_param(
+				inv->pool, PJMEDIA_VID_DEFAULT_RENDER_DEV,
+				&vport_param.vidparam);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to get default param of video "
+			   "renderer device", status);
+		return;
+	    }
+
+	    /* Get video stream port for decoding direction */
+	    pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_DECODING,
+					&media_port);
+
+	    /* Set format */
+	    pjmedia_format_copy(&vport_param.vidparam.fmt,
+				&media_port->info.fmt);
+	    vport_param.vidparam.dir = PJMEDIA_DIR_RENDER;
+	    vport_param.active = PJ_TRUE;
+
+	    /* Create renderer */
+	    status = pjmedia_vid_port_create(inv->pool, &vport_param, 
+					     &g_vid_renderer);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to create video renderer device",
+			   status);
+		return;
+	    }
+
+	    /* Connect renderer to media_port */
+	    status = pjmedia_vid_port_connect(g_vid_renderer, media_port, 
+					      PJ_FALSE);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to connect renderer to stream",
+			   status);
+		return;
+	    }
+	}
+
+	/* Create capturer */
+	if (vstream_info.dir & PJMEDIA_DIR_ENCODING) {
+	    status = pjmedia_vid_dev_default_param(
+				inv->pool, PJMEDIA_VID_DEFAULT_CAPTURE_DEV,
+				&vport_param.vidparam);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to get default param of video "
+			   "capture device", status);
+		return;
+	    }
+
+	    /* Get video stream port for decoding direction */
+	    pjmedia_vid_stream_get_port(g_med_vstream, PJMEDIA_DIR_ENCODING,
+					&media_port);
+
+	    /* Get capturer format from stream info */
+	    pjmedia_format_copy(&vport_param.vidparam.fmt, 
+	                        &media_port->info.fmt);
+	    vport_param.vidparam.dir = PJMEDIA_DIR_CAPTURE;
+	    vport_param.active = PJ_TRUE;
+
+	    /* Create capturer */
+	    status = pjmedia_vid_port_create(inv->pool, &vport_param, 
+					     &g_vid_capturer);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to create video capture device",
+			   status);
+		return;
+	    }
+
+	    /* Connect capturer to media_port */
+	    status = pjmedia_vid_port_connect(g_vid_capturer, media_port, 
+					      PJ_FALSE);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to connect capturer to stream",
+			   status);
+		return;
+	    }
+	}
+
+	/* Start streaming */
+	if (g_vid_renderer) {
+	    status = pjmedia_vid_port_start(g_vid_renderer);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to start video renderer",
+			   status);
+		return;
+	    }
+	}
+	if (g_vid_capturer) {
+	    status = pjmedia_vid_port_start(g_vid_capturer);
+	    if (status != PJ_SUCCESS) {
+		app_perror(THIS_FILE, "Unable to start video capturer",
+			   status);
+		return;
+	    }
+	}
+    }
+#endif	/* PJMEDIA_HAS_VIDEO */
+
+    /* Done with media. */
+}
+
+
diff --git a/jni/pjproject-android/.svn/pristine/fe/fed51d259919f26e4a16fe197797dfb3c5eccf1d.svn-base b/jni/pjproject-android/.svn/pristine/fe/fed51d259919f26e4a16fe197797dfb3c5eccf1d.svn-base
new file mode 100644
index 0000000..855ca80
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/fe/fed51d259919f26e4a16fe197797dfb3c5eccf1d.svn-base
@@ -0,0 +1 @@
+#include "../../../portaudio/src/common/pa_types.h"