Index: /pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 1738)
+++ /pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c	(revision 1739)
@@ -215,7 +215,15 @@
 	"error while using pfkey"	    /* err_status_pfkey_err     = 24 */
     };
-    return liberr[err];
+    if (err >= 0 && err < PJ_ARRAY_SIZE(liberr)) {
+	return liberr[err];
+    } else {
+	static char msg[32];
+	pj_ansi_snprintf(msg, sizeof(msg), "Unknown libsrtp error %d", err);
+	return msg;
+    }
 #else
-    return NULL;
+    static char msg[32];
+    pj_ansi_snprintf(msg, sizeof(msg), "libsrtp error %d", err);
+    return msg;
 #endif
 }
@@ -229,5 +237,6 @@
 	err = srtp_init();
 	if (err != err_status_ok) { 
-	    PJ_LOG(4, (THIS_FILE, "Failed to init libsrtp."));
+	    PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s", 
+		       get_libsrtp_errstr(err)));
 	    return PJMEDIA_ERRNO_FROM_LIBSRTP(err);
 	}
@@ -381,5 +390,6 @@
 
     if (srtp->session_inited) {
-	PJ_LOG(4, (THIS_FILE, "SRTP could not be re-init'd before deinit'd"));
+	PJ_LOG(4, (srtp->pool->obj_name, 
+		   "Error: unable to start (not initialized)"));
 	return PJ_EINVALIDOP;
     }
@@ -484,16 +494,16 @@
     srtp->session_inited = PJ_TRUE;
 
-    PJ_LOG(5, (THIS_FILE, "TX: %s key=%s", srtp->tx_policy.name.ptr,
-	    octet_string_hex_string(tx->key.ptr, tx->key.slen)));
+    PJ_LOG(5, (srtp->pool->obj_name, "TX: %s key=%s", srtp->tx_policy.name.ptr,
+	       octet_string_hex_string(tx->key.ptr, tx->key.slen)));
     if (srtp->tx_policy.flags) {
-	PJ_LOG(5, (THIS_FILE, "TX: disable%s%s", (cr_tx_idx?"":" enc"),
-						 (au_tx_idx?"":" auth")));
-    }
-
-    PJ_LOG(5, (THIS_FILE, "RX: %s key=%s", srtp->rx_policy.name.ptr,
-	    octet_string_hex_string(rx->key.ptr, rx->key.slen)));
+	PJ_LOG(5,(srtp->pool->obj_name,"TX: disable%s%s", (cr_tx_idx?"":" enc"),
+		  (au_tx_idx?"":" auth")));
+    }
+
+    PJ_LOG(5, (srtp->pool->obj_name, "RX: %s key=%s", srtp->rx_policy.name.ptr,
+	       octet_string_hex_string(rx->key.ptr, rx->key.slen)));
     if (srtp->rx_policy.flags) {
-	PJ_LOG(5, (THIS_FILE, "RX: disable%s%s", (cr_rx_idx?"":" enc"),
-						 (au_rx_idx?"":" auth")));
+	PJ_LOG(5,(srtp->pool->obj_name,"RX: disable%s%s", (cr_rx_idx?"":" enc"),
+		  (au_rx_idx?"":" auth")));
     }
 
@@ -514,9 +524,13 @@
     err = srtp_dealloc(p_srtp->srtp_rx_ctx);
     if (err != err_status_ok) {
-	PJ_LOG(4, (THIS_FILE, "Failed to dealloc RX SRTP context"));
+	PJ_LOG(4, (p_srtp->pool->obj_name, 
+		   "Failed to dealloc RX SRTP context: %s",
+		   get_libsrtp_errstr(err)));
     }
     err = srtp_dealloc(p_srtp->srtp_tx_ctx);
     if (err != err_status_ok) {
-	PJ_LOG(4, (THIS_FILE, "Failed to dealloc TX SRTP context"));
+	PJ_LOG(4, (p_srtp->pool->obj_name, 
+		   "Failed to dealloc TX SRTP context: %s",
+		   get_libsrtp_errstr(err)));
     }
 
@@ -714,6 +728,7 @@
 	srtp->rtp_cb(srtp->user_data, srtp->rx_buffer, len);
     } else {
-	PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTP size=%d, err=%d", 
-		   size, err));
+	PJ_LOG(5,(srtp->pool->obj_name, 
+		  "Failed to unprotect SRTP, pkt size=%d, err=%s", 
+		  size, get_libsrtp_errstr(err)));
     }
 
@@ -747,6 +762,7 @@
 	srtp->rtcp_cb(srtp->user_data, srtp->rx_buffer, len);
     } else {
-	PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTCP size=%d, err=%d",
-		   size, err));
+	PJ_LOG(5,(srtp->pool->obj_name, 
+		  "Failed to unprotect SRTCP, pkt size=%d, err=%s",
+		  size, get_libsrtp_errstr(err)));
     }
     
@@ -793,5 +809,6 @@
 				     crypto_suites[cs_idx].cipher_key_len);
 	    if (err != err_status_ok) {
-		PJ_LOG(5,(THIS_FILE, "Failed generating random key"));
+		PJ_LOG(5,(THIS_FILE, "Failed generating random key: %s",
+			  get_libsrtp_errstr(err)));
 		return PJMEDIA_ERRNO_FROM_LIBSRTP(err);
 	    }
@@ -1244,5 +1261,6 @@
     status = pjmedia_transport_media_stop(srtp->real_tp);
     if (status != PJ_SUCCESS)
-	PJ_LOG(4, (THIS_FILE, "SRTP failed stop underlying media transport."));
+	PJ_LOG(4, (srtp->pool->obj_name, 
+		   "SRTP failed stop underlying media transport."));
 
     return pjmedia_transport_srtp_stop(tp);
