Index: /pjproject/trunk/pjlib/include/pj/config.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/config.h	(revision 733)
+++ /pjproject/trunk/pjlib/include/pj/config.h	(revision 734)
@@ -345,8 +345,8 @@
  * flag is set.
  *
- * Default: 1500
+ * Default: 2000
  */
 #ifndef PJ_LOG_MAX_SIZE
-#  define PJ_LOG_MAX_SIZE	    1500
+#  define PJ_LOG_MAX_SIZE	    2000
 #endif
 
Index: /pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c	(revision 733)
+++ /pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c	(revision 734)
@@ -895,4 +895,6 @@
 	     * Reject the offer by setting the port to zero in the answer.
 	     */
+	    pjmedia_sdp_attr *a;
+
 	    /* For simplicity in the construction of the answer, we'll
 	     * just clone the media from the offer. Anyway receiver will
@@ -903,6 +905,9 @@
 	    am->desc.port = 0;
 
-	    /* Match direction */
-	    update_media_direction(pool, om, am);
+	    /* Remove direction attribute, and replace with inactive */
+	    remove_all_media_directions(am);
+
+	    a = pjmedia_sdp_attr_create(pool, "inactive", NULL);
+	    pjmedia_sdp_media_add_attr(am, a);
 
 	} else {
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 733)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c	(revision 734)
@@ -582,5 +582,6 @@
 static pj_status_t acquire_call(const char *title,
 				pjsua_call_id call_id,
-				pjsua_call **p_call)
+				pjsua_call **p_call,
+				pjsip_dialog **p_dlg)
 {
     enum { MAX_RETRY=50 };
@@ -634,4 +635,5 @@
     
     *p_call = call;
+    *p_dlg = call->inv->dlg;
 
     return PJ_SUCCESS;
@@ -646,4 +648,5 @@
     pjsua_call *call;
     pjsua_conf_port_id port_id;
+    pjsip_dialog *dlg;
     pj_status_t status;
 
@@ -651,5 +654,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_get_conf_port()", call_id, &call);
+    status = acquire_call("pjsua_call_get_conf_port()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return PJSUA_INVALID_ID;
@@ -657,5 +660,5 @@
     port_id = call->conf_slot;
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return port_id;
@@ -671,4 +674,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pj_status_t status;
 
@@ -678,5 +682,5 @@
     pj_bzero(info, sizeof(*info));
 
-    status = acquire_call("pjsua_call_get_info()", call_id, &call);
+    status = acquire_call("pjsua_call_get_info()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS) {
 	return status;
@@ -777,5 +781,5 @@
     }
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
@@ -817,4 +821,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pjsip_tx_data *tdata;
     pj_status_t status;
@@ -823,5 +828,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_answer()", call_id, &call);
+    status = acquire_call("pjsua_call_answer()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -835,5 +840,5 @@
 	pjsua_perror(THIS_FILE, "Error creating response", 
 		     status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -848,5 +853,5 @@
 		     status);
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return status;
@@ -864,4 +869,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pj_status_t status;
     pjsip_tx_data *tdata;
@@ -876,5 +882,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_hangup()", call_id, &call);
+    status = acquire_call("pjsua_call_hangup()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -894,5 +900,5 @@
 		     "Failed to create end session message", 
 		     status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -903,5 +909,5 @@
      */
     if (tdata == NULL) {
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return PJ_SUCCESS;
     }
@@ -916,9 +922,9 @@
 		     "Failed to send end session message", 
 		     status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
@@ -934,4 +940,5 @@
     pjmedia_sdp_session *sdp;
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pjsip_tx_data *tdata;
     pj_status_t status;
@@ -940,5 +947,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_set_hold()", call_id, &call);
+    status = acquire_call("pjsua_call_set_hold()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -947,5 +954,5 @@
     if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) {
 	PJ_LOG(3,(THIS_FILE, "Can not hold call that is not confirmed"));
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return PJSIP_ESESSIONSTATE;
     }
@@ -953,5 +960,5 @@
     status = create_inactive_sdp(call, &sdp);
     if (status != PJ_SUCCESS) {
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -961,5 +968,5 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -972,9 +979,9 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
@@ -992,4 +999,5 @@
     pjsip_tx_data *tdata;
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pj_status_t status;
 
@@ -998,5 +1006,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_reinvite()", call_id, &call);
+    status = acquire_call("pjsua_call_reinvite()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1004,5 +1012,5 @@
     if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) {
 	PJ_LOG(3,(THIS_FILE, "Can not re-INVITE call that is not confirmed"));
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return PJSIP_ESESSIONSTATE;
     }
@@ -1016,5 +1024,5 @@
 	pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", 
 		     status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -1024,5 +1032,5 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -1035,9 +1043,9 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
@@ -1055,4 +1063,5 @@
     pjsip_tx_data *tdata;
     pjsua_call *call;
+    pjsip_dialog *dlg;
     struct pjsip_evsub_user xfer_cb;
     pj_status_t status;
@@ -1062,5 +1071,5 @@
 		     PJ_EINVAL);
     
-    status = acquire_call("pjsua_call_xfer()", call_id, &call);
+    status = acquire_call("pjsua_call_xfer()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1074,5 +1083,5 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to create xfer", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -1084,5 +1093,5 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to create REFER request", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -1095,5 +1104,5 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send REFER request", status);
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return status;
     }
@@ -1104,5 +1113,5 @@
      */
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
@@ -1118,4 +1127,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pj_status_t status;
 
@@ -1123,5 +1133,5 @@
 		     PJ_EINVAL);
     
-    status = acquire_call("pjsua_call_dial_dtmf()", call_id, &call);
+    status = acquire_call("pjsua_call_dial_dtmf()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1129,5 +1139,5 @@
     if (!call->session) {
 	PJ_LOG(3,(THIS_FILE, "Media is not established yet!"));
-	pjsip_dlg_dec_lock(call->inv->dlg);
+	pjsip_dlg_dec_lock(dlg);
 	return PJ_EINVALIDOP;
     }
@@ -1135,5 +1145,5 @@
     status = pjmedia_session_dial_dtmf( call->session, 0, digits);
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return status;
@@ -1151,4 +1161,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     const pj_str_t mime_text_plain = pj_str("text/plain");
     pjsip_media_type ctype;
@@ -1161,5 +1172,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_send_im", call_id, &call);
+    status = acquire_call("pjsua_call_send_im()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1215,5 +1226,5 @@
 
 on_return:
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
     return status;
 }
@@ -1228,4 +1239,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pjsip_tx_data *tdata;
     pj_status_t status;
@@ -1234,5 +1246,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_send_typing_ind", call_id, &call);
+    status = acquire_call("pjsua_call_send_typing_ind", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1261,5 +1273,5 @@
 
 on_return:
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
     return status;
 }
@@ -1535,4 +1547,5 @@
 {
     pjsua_call *call;
+    pjsip_dialog *dlg;
     pj_time_val duration, res_delay, con_delay;
     char tmp[128];
@@ -1544,5 +1557,5 @@
 		     PJ_EINVAL);
 
-    status = acquire_call("pjsua_call_dump()", call_id, &call);
+    status = acquire_call("pjsua_call_dump()", call_id, &call, &dlg);
     if (status != PJ_SUCCESS)
 	return status;
@@ -1602,5 +1615,5 @@
 	dump_media_session(indent, p, end-p, call->session);
 
-    pjsip_dlg_dec_lock(call->inv->dlg);
+    pjsip_dlg_dec_lock(dlg);
 
     return PJ_SUCCESS;
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 733)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 734)
@@ -979,15 +979,4 @@
     }
 
-    /* Set route-set */
-    if (!pj_list_empty(&acc->route_set)) {
-	pjsip_dlg_set_route_set(dlg, &acc->route_set);
-    }
-
-    /* Set credentials */
-    if (acc->cred_cnt) {
-	pjsip_auth_clt_set_credentials( &dlg->auth_sess, 
-					acc->cred_cnt, acc->cred);
-    }
-
     status = pjsip_pres_create_uac( dlg, &pres_callback, 
 				    PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub);
@@ -1000,4 +989,15 @@
     }
 
+    /* Set route-set */
+    if (!pj_list_empty(&acc->route_set)) {
+	pjsip_dlg_set_route_set(dlg, &acc->route_set);
+    }
+
+    /* Set credentials */
+    if (acc->cred_cnt) {
+	pjsip_auth_clt_set_credentials( &dlg->auth_sess, 
+					acc->cred_cnt, acc->cred);
+    }
+
     pjsip_evsub_set_mod_data(buddy->sub, pjsua_var.mod.id, buddy);
 
