Fixed bug in event subscription when it is challenged/authenticated

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@424 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/src/pj/config.c b/pjlib/src/pj/config.c
index 3d1ea61..3e8480e 100644
--- a/pjlib/src/pj/config.c
+++ b/pjlib/src/pj/config.c
@@ -21,7 +21,7 @@
 #include <pj/ioqueue.h>
 
 static const char *id = "config.c";
-const char *PJ_VERSION = "0.5.5";
+const char *PJ_VERSION = "0.5.5.1";
 
 PJ_DEF(void) pj_dump_config(void)
 {
diff --git a/pjmedia/src/pjmedia/endpoint.c b/pjmedia/src/pjmedia/endpoint.c
index 0685c3d..e403178 100644
--- a/pjmedia/src/pjmedia/endpoint.c
+++ b/pjmedia/src/pjmedia/endpoint.c
@@ -432,12 +432,13 @@
 #if PJ_LOG_MAX_LEVEL >= 3
     unsigned i, count;
     pjmedia_codec_info codec_info[32];
+    unsigned prio[32];
 
     PJ_LOG(3,(THIS_FILE, "Dumping PJMEDIA capabilities:"));
 
     count = PJ_ARRAY_SIZE(codec_info);
     if (pjmedia_codec_mgr_enum_codecs(&endpt->codec_mgr, 
-				      &count, codec_info, NULL) != PJ_SUCCESS)
+				      &count, codec_info, prio) != PJ_SUCCESS)
     {
 	PJ_LOG(3,(THIS_FILE, " -error: failed to enum codecs"));
 	return PJ_SUCCESS;
@@ -466,7 +467,7 @@
 	}
 
 	PJ_LOG(3,(THIS_FILE, 
-		  "   %s codec #%2d: pt=%d (%.*s @%dKHz/%d, %sbps, ptime=%d ms, vad=%d, cng=%d)", 
+		  "   %s codec #%2d: pt=%d (%.*s @%dKHz/%d, %sbps, %dms%s%s%s%s%s)",
 		  type, i, codec_info[i].pt,
 		  (int)codec_info[i].encoding_name.slen,
 		  codec_info[i].encoding_name.ptr,
@@ -474,8 +475,11 @@
 		  codec_info[i].channel_cnt,
 		  good_number(bps, param.avg_bps), 
 		  param.ptime,
-		  param.vad,
-		  param.cng));
+		  (param.vad ? " vad" : ""),
+		  (param.cng ? " cng" : ""),
+		  (param.concl ? " plc" : ""),
+		  (param.penh ? " penh" : ""),
+		  (prio[i]==PJMEDIA_CODEC_PRIO_DISABLED?" disabled":"")));
     }
 #endif
 
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index 9a9b852..7b13d54 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -1355,10 +1355,6 @@
 
 	sub->pending_sub = tsx;
 
-    } else if (tsx == sub->pending_sub &&
-	       tsx->state >= PJSIP_TSX_STATE_COMPLETED)
-    {
-	sub->pending_sub = NULL;
     }
 
     return sub;
@@ -1468,6 +1464,10 @@
 	    return;
 	}
 
+	/* Clear pending subscription */
+	if (tsx == sub->pending_sub)
+	    sub->pending_sub = NULL;
+
 	/* Handle authentication. */
 	if (tsx->status_code==401 || tsx->status_code==407) {
 	    pjsip_tx_data *tdata;
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 034262a..3530932 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -683,19 +683,9 @@
 #endif	/* PJMEDIA_HAS_L16_CODEC */
 
 
-    /* If user specifies the exact codec to be used, then disable all codecs
-     * and only enable those specific codecs.
+    /* Enable those codecs that user put with "--add-codec", and move
+     * the priority to top
      */
-    if (pjsua.codec_cnt != 0) {
-	codec_id = pj_str("");
-	pjmedia_codec_mgr_set_codec_priority( 
-	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
-	    &codec_id, 
-	    PJMEDIA_CODEC_PRIO_DISABLED);
-    }
-
-	
-
     for (i=0; i<pjsua.codec_cnt; ++i) {
 	pjmedia_codec_mgr_set_codec_priority( 
 	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index f0774d5..b77871f 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -323,6 +323,9 @@
 	return;
     }
 
+    pjsip_auth_clt_set_credentials( &dlg->auth_sess, pjsua.cred_count,
+				    pjsua.cred_info);
+
     status = pjsip_pres_create_uac( dlg, &pres_callback, 
 				    &pjsua.buddies[index].sub);
     if (status != PJ_SUCCESS) {