diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a9f52051207dc7b73be5b871f607f48a580111fb..0e28fd16348284ec11b20b8d733df3df04feb570 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2413,6 +2413,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 			}
 		}
 	}
+
+	/* RTP addresses and ports for audio and video */
 	sin.sin_family = AF_INET;
 	memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
 	/* Setup audio port number */
@@ -2423,9 +2425,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 	sin.sin_port = htons(vportno);
 	if (p->vrtp && sin.sin_port)
 		ast_rtp_set_peer(p->vrtp, &sin);
-#if 0
-	printf("Peer RTP is at port %s:%d\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
-#endif	
+
+	if (sipdebug)
+		ast_verbose("Peer RTP is at port %s:%d\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+
 	/* Next, scan through each "a=rtpmap:" line, noting each
 	 * specified RTP payload type (with corresponding MIME subtype):
 	 */
@@ -2458,11 +2461,19 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 	p->noncodeccapability = noncodeccapability & (peernoncodeccapability | vpeernoncodeccapability);
 	
 	if (sip_debug_test_pvt(p)) {
-		ast_verbose("Capabilities: us - %d, them - %d/%d, combined - %d\n",
-			    p->capability, peercapability, vpeercapability, p->jointcapability);
-		ast_verbose("Non-codec capabilities: us - %d, them - %d, combined - %d\n",
-			    noncodeccapability, peernoncodeccapability,
-			    p->noncodeccapability);
+		const unsigned slen=80;
+		char s1[slen], s2[slen], s3[slen], s4[slen];
+
+		ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n",
+			ast_getformatname_multiple(s1, slen, p->capability),
+			ast_getformatname_multiple(s2, slen, peercapability),
+			ast_getformatname_multiple(s3, slen, vpeercapability),
+			ast_getformatname_multiple(s4, slen, p->jointcapability));
+
+		ast_verbose("Non-codec capabilities: us - %s, peer - %s, combined - %s\n",
+			ast_getformatname_multiple(s1, slen, noncodeccapability),
+			ast_getformatname_multiple(s2, slen, peernoncodeccapability),
+			ast_getformatname_multiple(s3, slen, p->noncodeccapability));
 	}
 	if (!p->jointcapability) {
 		ast_log(LOG_WARNING, "No compatible codecs!\n");
@@ -2470,7 +2481,11 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
 	}
 	if (p->owner) {
 		if (!(p->owner->nativeformats & p->jointcapability)) {
-			ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %d and not %d\n", p->jointcapability, p->owner->nativeformats);
+			const unsigned slen=80;
+			char s1[slen], s2[slen];
+			ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n", 
+					ast_getformatname_multiple(s1, slen, p->jointcapability),
+					ast_getformatname_multiple(s2, slen, p->owner->nativeformats));
 			p->owner->nativeformats = sip_codec_choose(p->jointcapability);
 			ast_set_read_format(p->owner, p->owner->readformat);
 			ast_set_write_format(p->owner, p->owner->writeformat);
@@ -3075,7 +3090,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
 	while(cur) {
 		if (p->jointcapability & cur->codec) {
 			if (sip_debug_test_pvt(p))
-				ast_verbose("Answering/Requesting with preferred capability %d\n", cur->codec);
+				ast_verbose("Answering with preferred capability 0x%x(%s)\n", cur->codec, ast_getformatname(cur->codec));
 			codec = ast_rtp_lookup_code(p->rtp, 1, cur->codec);
 			if (codec > -1) {
 				snprintf(costr, sizeof(costr), " %d", codec);
@@ -3097,7 +3112,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
 	for (x = 1; x <= (videosupport ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) {
 		if ((p->jointcapability & x) && !(alreadysent & x)) {
 			if (sip_debug_test_pvt(p))
-				ast_verbose("Answering with capability %d\n", x);	
+				ast_verbose("Answering with capability 0x%x(%s)\n", x, ast_getformatname(x));
 			codec = ast_rtp_lookup_code(p->rtp, 1, x);
 			if (codec > -1) {
 				snprintf(costr, sizeof(costr), " %d", codec);
@@ -3116,7 +3131,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p, struct ast_rtp *
 	for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
 		if (p->noncodeccapability & x) {
 			if (sip_debug_test_pvt(p))
-				ast_verbose("Answering with non-codec capability %d\n", x);
+				ast_verbose("Answering with non-codec capability 0x%x(%s)\n", x, ast_getformatname(x));
 			codec = ast_rtp_lookup_code(p->rtp, 0, x);
 			if (codec > -1) {
 				snprintf(costr, sizeof(costr), " %d", codec);
diff --git a/frame.c b/frame.c
index c127ebcdde8af9312fca64977e6b298ee30327fa..1e80f0b0d1a68f4a620db9f6b13c74eaf00acc97 100755
--- a/frame.c
+++ b/frame.c
@@ -424,6 +424,33 @@ char* ast_getformatname(int format)
 	return "UNKN";
 }
 
+char* ast_getformatname_multiple(char *buf, unsigned n, int format) {
+	unsigned u=1;
+	unsigned len;
+	char *b = buf;
+	char *start = buf;
+	if (!n) return buf;
+	snprintf(b,n,"0x%x(",format);
+	len = strlen(b);
+	b += len;
+	n -= len;
+	start = b;
+	while (u) {
+		if (u&format) {
+			snprintf(b,n,"%s|",ast_getformatname(u));
+			len = strlen(b);
+			b += len;
+			n -= len;
+		}
+		u *= 2;
+	}
+	if (start==b)
+		snprintf(start,n,"EMPTY)");
+	else if (n>1)
+		b[-1]=')';
+	return buf;
+}
+
 int ast_getformatbyname(char *name)
 {
 	if (!strcasecmp(name, "g723.1")) 
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 0bec024bbe1f6e3c00c9e24fe2f6b8f033f10d08..3f9964621ab6e4e779b573aec89ddf9d2ad42369 100755
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -319,15 +319,25 @@ int ast_fr_fdwrite(int fd, struct ast_frame *frame);
  */
 int ast_fr_fdhangup(int fd);
 
-//! Get a format from a name
+//! Get the name of a format
 /*!
  * \param format id of format
- * Gets the name of a format.
- * This returns the name of the format in a sttring or UNKN if unknown.
+ * \return A static string containing the name of the format or "UNKN" if unknown.
  */
-//! Get the name of a format
 extern char* ast_getformatname(int format);
 
+//! Get the names of a set of formats
+/*!
+ * \param buf a buffer for the output string
+ * \param n size of buf (bytes)
+ * \param format the format (combined IDs of codecs)
+ * Prints a list of readable codec names corresponding to "format".
+ * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602(GSM|SPEEX|ILBC)"
+ * \return The return value is buf.
+ */
+extern char* ast_getformatname_multiple(char *buf, unsigned n, int format);
+
+
 /*!
  * \param name string of format
  * Gets a format from a name.