Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 3758)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 3763)
@@ -28,25 +28,9 @@
 PJ_BEGIN_DECL
 
-/** 
- * Media transport state.
- */
-typedef enum pjsua_med_tp_st
-{
-    /** Not initialized */
-    PJSUA_MED_TP_IDLE,
-
-    /** Initialized (media_create() has been called) */
-    PJSUA_MED_TP_INIT,
-
-    /** Running (media_start() has been called) */
-    PJSUA_MED_TP_RUNNING,
-
-    /** Disabled (transport is initialized, but media is being disabled) */
-    PJSUA_MED_TP_DISABLED
-
-} pjsua_med_tp_st;
-
 /** Forward decl of pjsua call */
 typedef struct pjsua_call pjsua_call;
+
+/** Forward decl of pjsua call media */
+typedef struct pjsua_call_media pjsua_call_media;
 
 
@@ -93,5 +77,5 @@
     pj_status_t		 tp_ready;  /**< Media transport status.	    */
     pjmedia_transport	*tp_orig;   /**< Original media transport	    */
-    pj_bool_t		 tp_auto_del; /**< May delete media transport   */
+    pj_bool_t		 tp_auto_del; /**< May delete media transport       */
     pjsua_med_tp_st	 tp_st;     /**< Media transport state		    */
     pj_sockaddr		 rtp_addr;  /**< Current RTP source address
@@ -100,6 +84,14 @@
     pjmedia_srtp_use	 rem_srtp_use; /**< Remote's SRTP usage policy.	    */
 
-    pjmedia_event_subscription esub_rend;/**< Subscribe renderer events.     */
+    pjmedia_event_subscription esub_rend;/**< Subscribe renderer events.    */
     pjmedia_event_subscription esub_cap;/**< Subscribe capture events.      */
+
+    pjsua_med_tp_state_cb      med_init_cb;/**< Media transport
+                                                initialization callback.    */
+
+    /** Media transport creation callback. */
+    pj_status_t (*med_create_cb)(pjsua_call_media *call_med,
+                                 pj_status_t status, int security_level,
+                                 int *sip_err_code);
 } pjsua_call_media;
 
@@ -133,4 +125,7 @@
     pjsua_call_media     media[PJSUA_MAX_CALL_MEDIA]; /**< Array of media   */
     int			 audio_idx; /**< First active audio media.	    */
+    pj_mutex_t          *med_ch_mutex;/**< Media channel callback's mutex.  */
+    pjsua_med_tp_state_cb   med_ch_cb;/**< Media channel callback.	    */
+    pjsua_med_tp_state_info med_ch_info;/**< Media channel info.            */
 
     pjsip_evsub		*xfer_sub;  /**< Xfer server subscription, if this
@@ -148,4 +143,15 @@
 					  contains multiple codecs.	    */
 
+    struct {
+        pjsip_dialog        *dlg;    /**< Call dialog.                      */
+        pjmedia_sdp_session *rem_sdp;/**< Remote SDP.                       */
+        union {
+            struct {
+                unsigned         options; /**< Outgoing call options.       */
+                pjsua_msg_data  *msg_data;/**< Headers for outgoing INVITE. */
+            } out_call;
+        } call_var;
+    } async_call;                      /**< Temporary storage for async
+                                            outgoing/incoming call.         */
 };
 
@@ -509,5 +515,7 @@
 				     pj_pool_t *tmp_pool,
 				     const pjmedia_sdp_session *rem_sdp,
-				     int *sip_err_code);
+				     int *sip_err_code,
+                                     pj_bool_t async,
+                                     pjsua_med_tp_state_cb cb);
 pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, 
 					   pj_pool_t *pool,
@@ -524,5 +532,7 @@
 				  const pjsua_transport_config *tcfg,
 				  int security_level,
-				  int *sip_err_code);
+				  int *sip_err_code,
+                                  pj_bool_t async,
+                                  pjsua_med_tp_state_cb cb);
 pj_status_t video_channel_update(pjsua_call_media *call_med,
                                  pj_pool_t *tmp_pool,
@@ -530,4 +540,5 @@
 			         const pjmedia_sdp_session *remote_sdp);
 void stop_video_stream(pjsua_call_media *call_med);
+void set_media_tp_state(pjsua_call_media *call_med, pjsua_med_tp_st tp_st);
 
 
