? show_codec_names-08122003gork.diff
Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.33
diff -u -r1.33 channel.c
--- channel.c	11 Aug 2003 22:17:46 -0000	1.33
+++ channel.c	12 Aug 2003 19:53:56 -0000
@@ -1100,7 +1100,7 @@
 		if (!(f->subclass & chan->nativeformats)) {
 			/* This frame can't be from the current native formats -- drop it on the
 			   floor */
-			ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %d since our native format has changed to %d\n", chan->name, f->subclass, chan->nativeformats);
+			ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats));
 			ast_frfree(f);
 			f = &null_frame;
 		} else {
@@ -1417,7 +1417,8 @@
 	
 	res = ast_translator_best_choice(&native, &fmt);
 	if (res < 0) {
-		ast_log(LOG_NOTICE, "Unable to find a path from %d to %d\n", fmts, chan->nativeformats);
+		ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
+			ast_getformatname(fmts), ast_getformatname(chan->nativeformats));
 		return -1;
 	}
 	
@@ -1431,7 +1432,7 @@
 	/* Build a translation path from the user write format to the raw writing format */
 	chan->pvt->writetrans = ast_translator_build_path(chan->pvt->rawwriteformat, chan->writeformat);
 	if (option_debug)
-		ast_log(LOG_DEBUG, "Set channel %s to write format %d\n", chan->name, chan->writeformat);
+		ast_log(LOG_DEBUG, "Set channel %s to write format %s\n", chan->name, ast_getformatname(chan->writeformat));
 	return 0;
 }
 
@@ -1446,7 +1447,8 @@
 	/* Find a translation path from the native read format to one of the user's read formats */
 	res = ast_translator_best_choice(&fmt, &native);
 	if (res < 0) {
-		ast_log(LOG_NOTICE, "Unable to find a path from %d to %d\n", chan->nativeformats, fmts);
+		ast_log(LOG_NOTICE, "Unable to find a path from %s to %s\n",
+			ast_getformatname(chan->nativeformats), ast_getformatname(fmts));
 		return -1;
 	}
 	
@@ -1460,7 +1462,8 @@
 	/* Build a translation path from the raw read format to the user reading format */
 	chan->pvt->readtrans = ast_translator_build_path(chan->readformat, chan->pvt->rawreadformat);
 	if (option_debug)
-		ast_log(LOG_DEBUG, "Set channel %s to read format %d\n", chan->name, chan->readformat);
+		ast_log(LOG_DEBUG, "Set channel %s to read format %s\n", 
+			chan->name, ast_getformatname(chan->readformat));
 	return 0;
 }
 
Index: file.c
===================================================================
RCS file: /usr/cvsroot/asterisk/file.c,v
retrieving revision 1.19
diff -u -r1.19 file.c
--- file.c	11 Aug 2003 20:24:14 -0000	1.19
+++ file.c	12 Aug 2003 19:53:57 -0000
@@ -215,7 +215,7 @@
 		if (!fs->trans) 
 			fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass);
 		if (!fs->trans)
-			ast_log(LOG_WARNING, "Unable to translate to format %s, source format %d\n", fs->fmt->name, f->subclass);
+			ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n", fs->fmt->name, ast_getformatname(f->subclass));
 		else {
 			fs->lastwriteformat = f->subclass;
 			res = 0;
@@ -719,7 +719,7 @@
 #endif
 		return 0;
 	}
-	ast_log(LOG_WARNING, "Unable to open %s (format %d): %s\n", filename, chan->nativeformats, strerror(errno));
+	ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname(chan->nativeformats), strerror(errno));
 	return -1;
 }
 
Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.3
diff -u -r1.3 frame.c
--- frame.c	28 Jun 2003 16:40:02 -0000	1.3
+++ frame.c	12 Aug 2003 19:53:57 -0000
@@ -343,6 +343,41 @@
 	return ast_fr_fdwrite(fd, &hangup);
 }
 
+char* ast_getformatname(int format)
+{
+	if (format == AST_FORMAT_G723_1) 
+		return "G723";
+	else if (format == AST_FORMAT_GSM)
+		return "GSM";
+	else if (format == AST_FORMAT_ULAW)
+		return "ULAW";
+	else if (format == AST_FORMAT_ALAW)
+		return "ALAW";
+	else if (format == AST_FORMAT_MP3)
+		return "MP3";
+	else if (format == AST_FORMAT_SLINEAR)
+		return "SLINR";
+	else if (format == AST_FORMAT_LPC10)
+		return "LPC10";
+	else if (format == AST_FORMAT_ADPCM)
+		return "ADPCM";
+	else if (format == AST_FORMAT_G729A)
+		return "G729";
+	else if (format == AST_FORMAT_SPEEX)
+		return "SPEEX";
+	else if (format == AST_FORMAT_ILBC)
+		return "ILBC";
+	else if (format == AST_FORMAT_JPEG)
+		return "JPEG";
+	else if (format == AST_FORMAT_PNG)
+		return "PNG";
+	else if (format == AST_FORMAT_H261)
+		return "H261";
+	else if (format == AST_FORMAT_H263)
+		return "H263";
+	return "UNKN";
+}
+
 int ast_getformatbyname(char *name)
 {
 	if (!strcasecmp(name, "g723.1")) 
@@ -468,7 +503,7 @@
 		break;
 	case AST_FRAME_IMAGE:
 		strcpy(ftype, "Image");
-		snprintf(subclass, sizeof(subclass), "Image format %d\n", f->subclass);
+		snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass));
 		break;
 	case AST_FRAME_HTML:
 		strcpy(ftype, "HTML");
Index: image.c
===================================================================
RCS file: /usr/cvsroot/asterisk/image.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 image.c
--- image.c	12 Feb 2003 13:59:13 -0000	1.1.1.1
+++ image.c	12 Aug 2003 19:53:57 -0000
@@ -175,14 +175,14 @@
 static int show_image_formats(int fd, int argc, char *argv[])
 {
 #define FORMAT "%10s %10s %50s %10s\n"
-#define FORMAT2 "%10s %10s %50s %10d\n"
+#define FORMAT2 "%10s %10s %50s %10s\n"
 	struct ast_imager *i;
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	ast_cli(fd, FORMAT, "Name", "Extensions", "Description", "Format");
 	i = list;
 	while(i) {
-		ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, i->format);
+		ast_cli(fd, FORMAT2, i->name, i->exts, i->desc, ast_getformatname(i->format));
 		i = i->next;
 	};
 	return RESULT_SUCCESS;
Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.21
diff -u -r1.21 rtp.c
--- rtp.c	12 Aug 2003 16:51:44 -0000	1.21
+++ rtp.c	12 Aug 2003 19:53:58 -0000
@@ -456,7 +456,7 @@
 			// assumes that the RTP packet contained one Speex frame
 			break;
 		default:
-			ast_log(LOG_NOTICE, "Unable to calculate samples for format %d\n", rtp->f.subclass);
+			ast_log(LOG_NOTICE, "Unable to calculate samples for format %s\n", ast_getformatname(rtp->f.subclass));
 			break;
 		}
 	} else {
@@ -906,7 +906,7 @@
 			// assumes that the RTP packet contains one Speex frame
 			break;
 		default:
-			ast_log(LOG_WARNING, "Not sure about timestamp format for codec format %d\n", f->subclass);
+			ast_log(LOG_WARNING, "Not sure about timestamp format for codec format %s\n", ast_getformatname(f->subclass));
 		}
 
 		/* Re-calculate last TS */
@@ -974,13 +974,13 @@
 
 	codec = ast_rtp_lookup_code(rtp, 1, subclass);
 	if (codec < 0) {
-		ast_log(LOG_WARNING, "Don't know how to send format %d packets with RTP\n", _f->subclass);
+		ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(_f->subclass));
 		return -1;
 	}
 
 	if (rtp->lasttxformat != subclass) {
 		/* New format, reset the smoother */
-		ast_log(LOG_DEBUG, "Ooh, format changed from %d to %d\n", rtp->lasttxformat, subclass);
+		ast_log(LOG_DEBUG, "Ooh, format changed from %s to %s\n", ast_getformatname(rtp->lasttxformat), ast_getformatname(subclass));
 		rtp->lasttxformat = subclass;
 		if (rtp->smoother)
 			ast_smoother_free(rtp->smoother);
@@ -1041,7 +1041,7 @@
 			ast_rtp_raw_write(rtp, f, codec);
 		break;
 	default:	
-		ast_log(LOG_WARNING, "Not sure about sending format %d packets\n", subclass);
+		ast_log(LOG_WARNING, "Not sure about sending format %s packets\n", ast_getformatname(subclass));
 		// fall through to...
 	case AST_FORMAT_H261:
 	case AST_FORMAT_H263:
Index: translate.c
===================================================================
RCS file: /usr/cvsroot/asterisk/translate.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 translate.c
--- translate.c	16 Mar 2003 22:37:29 -0000	1.1.1.2
+++ translate.c	12 Aug 2003 19:53:58 -0000
@@ -125,7 +125,8 @@
 			}
 		} else {
 			/* We shouldn't have allocated any memory */
-			ast_log(LOG_WARNING, "No translator path from %d to %d\n", source, dest);
+			ast_log(LOG_WARNING, "No translator path from %s to %s\n", 
+				ast_getformatname(source), ast_getformatname(dest));
 			return NULL;
 		}
 	}
@@ -199,7 +200,7 @@
 									tr_matrix[x][z].cost = tr_matrix[x][y].cost + 
 														   tr_matrix[y][z].cost;
 									if (option_debug)
-										ast_log(LOG_DEBUG, "Discovered %d cost path from %d to %d, via %d\n", tr_matrix[x][z].cost, x, z, y);
+										ast_log(LOG_DEBUG, "Discovered %d cost path from %s to %s, via %d\n", tr_matrix[x][z].cost, ast_getformatname(x), ast_getformatname(z), y);
 									changed++;
 								 }
 		
@@ -252,26 +253,29 @@
 
 static int show_translation(int fd, int argc, char *argv[])
 {
-#define SHOW_TRANS 14
+#define SHOW_TRANS 11
 	int x,y;
 	char line[80];
 	if (argc != 2) 
 		return RESULT_SHOWUSAGE;
-	ast_cli(fd, "                        Translation times between formats (in milliseconds)\n");
-	ast_cli(fd, "                                 Destination Format\n");
+	ast_cli(fd, "         Translation times between formats (in milliseconds)\n");
+	ast_cli(fd, "          Source Format (Rows) Destination Format(Columns)\n\n");
 	ast_pthread_mutex_lock(&list_lock);
-	for (x=0;x<SHOW_TRANS; x++) {
-		if (x == 1) 
-			strcpy(line, "  Src  ");
-		else if (x == 2)
-			strcpy(line, "  Fmt  ");
-		else
-			strcpy(line, "       ");
-		for (y=0;y<SHOW_TRANS;y++) {
-			if (tr_matrix[x][y].step)
-				snprintf(line + strlen(line), sizeof(line) - strlen(line), " %4d", tr_matrix[x][y].cost);
+	for (x=-1;x<SHOW_TRANS; x++) {
+		strcpy(line, " ");
+		for (y=-1;y<SHOW_TRANS;y++) {
+			/* Skip MP3 (y = 4) as Destination format */
+			if (y != 4 && x >= 0 && y >= 0 && tr_matrix[x][y].step)
+				snprintf(line + strlen(line), sizeof(line) - strlen(line), " %6d", tr_matrix[x][y].cost);
 			else
-				snprintf(line + strlen(line), sizeof(line) - strlen(line), "  n/a");
+				if ((y != 4) && ((x == -1 && y >= 0) || (y == -1 && x >= 0))) {
+					snprintf(line + strlen(line), sizeof(line) - strlen(line), 
+						" %6s", ast_getformatname(1<<(x+y+1)) );
+				} else if (x != -1 && y != -1 && y != 4) {
+					snprintf(line + strlen(line), sizeof(line) - strlen(line), "      -");
+				} else if (y != 4) {
+					snprintf(line + strlen(line), sizeof(line) - strlen(line), "       ");
+				}
 		}
 		snprintf(line + strlen(line), sizeof(line) - strlen(line), "\n");
 		ast_cli(fd, line);			
@@ -296,12 +300,12 @@
 	t->srcfmt = powerof(t->srcfmt);
 	t->dstfmt = powerof(t->dstfmt);
 	if ((t->srcfmt >= MAX_FORMAT) || (t->dstfmt >= MAX_FORMAT)) {
-		ast_log(LOG_WARNING, "Format %d is larger than MAX_FORMAT\n", t->srcfmt);
+		ast_log(LOG_WARNING, "Format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
 		return -1;
 	}
 	calc_cost(t);
 	if (option_verbose > 1)
-		ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %d to %d, cost %d\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), t->srcfmt, t->dstfmt, t->cost);
+		ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(t->srcfmt), ast_getformatname(t->dstfmt), t->cost);
 	ast_pthread_mutex_lock(&list_lock);
 	if (!added_cli) {
 		ast_cli_register(&show_trans);
Index: apps/app_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_agi.c,v
retrieving revision 1.8
diff -u -r1.8 app_agi.c
--- apps/app_agi.c	14 Jul 2003 16:17:16 -0000	1.8
+++ apps/app_agi.c	12 Aug 2003 19:53:59 -0000
@@ -1435,7 +1435,7 @@
 	res = agi_exec_full(chan, data, 1);
 	if (!res) {
 		if (ast_set_read_format(chan, readformat)) {
-			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %d\n", chan->name, readformat);
+			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(readformat));
 		}
 	}
 	return res;
Index: apps/app_voicemail2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail2.c,v
retrieving revision 1.36
diff -u -r1.36 app_voicemail2.c
--- apps/app_voicemail2.c	9 Aug 2003 23:45:36 -0000	1.36
+++ apps/app_voicemail2.c	12 Aug 2003 19:54:00 -0000
@@ -933,7 +933,7 @@
 	}
 	if (rfmt) {
 		if (ast_set_read_format(chan, rfmt)) {
-			ast_log(LOG_WARNING, "Unable to restore format %d to channel '%s'\n", rfmt, chan->name);
+			ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
 		}
 	}
 	if (outmsg) {
Index: channels/chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.26
diff -u -r1.26 chan_agent.c
--- channels/chan_agent.c	8 Aug 2003 03:01:29 -0000	1.26
+++ channels/chan_agent.c	12 Aug 2003 19:54:01 -0000
@@ -365,7 +365,7 @@
 		res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
 		ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res);
 		if (res)
-			ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(p->chan->nativeformats));
+			ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	} else {
 		// Agent hung-up
 		p->chan = NULL;
@@ -375,7 +375,7 @@
 		ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
 		ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res);
 		if (res)
-			ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(p->chan->nativeformats));
+			ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	}
 	if( !res )
 	{
@@ -1002,8 +1002,8 @@
 								"Channel: %s\r\n",
 								p->agent, chan->name);
 							if (option_verbose > 2)
-								ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged in (format %d/%d)\n", p->agent,
-												chan->readformat, chan->writeformat);
+								ast_verbose(VERBOSE_PREFIX_3 "Agent '%s' logged in (format %s/%s)\n", p->agent,
+												ast_getformatname(chan->readformat), ast_getformatname(chan->writeformat));
 							/* Login this channel and wait for it to
 							   go away */
 							p->chan = chan;
Index: channels/chan_iax.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax.c,v
retrieving revision 1.10
diff -u -r1.10 chan_iax.c
--- channels/chan_iax.c	7 Aug 2003 05:37:15 -0000	1.10
+++ channels/chan_iax.c	12 Aug 2003 19:54:06 -0000
@@ -2256,7 +2256,7 @@
 static int iax_show_channels(int fd, int argc, char *argv[])
 {
 #define FORMAT2 "%-15.15s  %-10.10s  %-11.11s  %-11.11s  %-7.7s  %-6.6s  %s\n"
-#define FORMAT  "%-15.15s  %-10.10s  %5.5d/%5.5d  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %d\n"
+#define FORMAT  "%-15.15s  %-10.10s  %5.5d/%5.5d  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %-6.6s\n"
 	int x;
 	int numchans = 0;
 	if (argc != 3)
@@ -2271,7 +2271,7 @@
 						iaxs[x]->oseqno, iaxs[x]->iseqno, 
 						iaxs[x]->lag,
 						iaxs[x]->jitter,
-						iaxs[x]->voiceformat);
+						ast_getformatname(iaxs[x]->voiceformat) );
 			numchans++;
 		}
 		ast_pthread_mutex_unlock(&iaxsl[x]);
@@ -3727,7 +3727,7 @@
 						iaxs[fr.callno]->peerformat = iax_capability;
 				}
 				if (option_verbose > 2)
-					ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %d)\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->peerformat);
+					ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %s)\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), ast_getformatname(iaxs[fr.callno]->peerformat));
 				if (!(iaxs[fr.callno]->peerformat & iaxs[fr.callno]->capability)) {
 					send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
 					ast_log(LOG_NOTICE, "Rejected call to %s, format 0x%x incompatible with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->capability);
@@ -3861,7 +3861,7 @@
 					/* Select an appropriate format */
 					format = iaxs[fr.callno]->peerformat & iax_capability;
 					if (!format) {
-						ast_log(LOG_DEBUG, "We don't do requested format %d, falling back to peer capability %d\n", iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability);
+						ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr.callno]->peerformat), iaxs[fr.callno]->peercapability);
 						format = iaxs[fr.callno]->peercapability & iax_capability;
 						if (!format) {
 							ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible  with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_capability);
Index: channels/chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.35
diff -u -r1.35 chan_iax2.c
--- channels/chan_iax2.c	9 Aug 2003 19:33:40 -0000	1.35
+++ channels/chan_iax2.c	12 Aug 2003 19:54:09 -0000
@@ -2433,7 +2433,7 @@
 static int iax2_show_channels(int fd, int argc, char *argv[])
 {
 #define FORMAT2 "%-15.15s  %-10.10s  %-11.11s  %-11.11s  %-7.7s  %-6.6s  %s\n"
-#define FORMAT  "%-15.15s  %-10.10s  %5.5d/%5.5d  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %d\n"
+#define FORMAT  "%-15.15s  %-10.10s  %5.5d/%5.5d  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %-6.6s\n"
 	int x;
 	int numchans = 0;
 	if (argc != 3)
@@ -2448,7 +2448,7 @@
 						iaxs[x]->oseqno, iaxs[x]->iseqno, 
 						iaxs[x]->lag,
 						iaxs[x]->jitter,
-						iaxs[x]->voiceformat);
+						ast_getformatname(iaxs[x]->voiceformat) );
 			numchans++;
 		}
 		ast_pthread_mutex_unlock(&iaxsl[x]);
@@ -4105,7 +4105,7 @@
 						iaxs[fr.callno]->peerformat = iax2_capability;
 				}
 				if (option_verbose > 2)
-					ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %d)\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->peerformat);
+					ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %s)\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), ast_getformatname(iaxs[fr.callno]->peerformat));
 				if (!(iaxs[fr.callno]->peerformat & iaxs[fr.callno]->capability)) {
 					memset(&ied0, 0, sizeof(ied0));
 					iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -4243,7 +4243,7 @@
 					/* Select an appropriate format */
 					format = iaxs[fr.callno]->peerformat & iax2_capability;
 					if (!format) {
-						ast_log(LOG_DEBUG, "We don't do requested format %d, falling back to peer capability %d\n", iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability);
+						ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr.callno]->peerformat), iaxs[fr.callno]->peercapability);
 						format = iaxs[fr.callno]->peercapability & iax2_capability;
 						if (!format) {
 							ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible  with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax2_capability);
Index: channels/chan_modem.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_modem.c,v
retrieving revision 1.3
diff -u -r1.3 chan_modem.c
--- channels/chan_modem.c	27 Apr 2003 21:34:27 -0000	1.3
+++ channels/chan_modem.c	12 Aug 2003 19:54:10 -0000
@@ -790,7 +790,7 @@
 					} else
 						ast_log(LOG_WARNING, "Device '%s' is busy\n", p->dev);
 				} else 
-					ast_log(LOG_WARNING, "Asked for a format %d line on %s\n", format, p->dev);
+					ast_log(LOG_WARNING, "Asked for a format %s line on %s\n", ast_getformatname(format), p->dev);
 				break;
 			}
 		}
Index: channels/chan_phone.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_phone.c,v
retrieving revision 1.5
diff -u -r1.5 chan_phone.c
--- channels/chan_phone.c	27 Apr 2003 18:13:11 -0000	1.5
+++ channels/chan_phone.c	12 Aug 2003 19:54:10 -0000
@@ -270,7 +270,7 @@
 			}
 		}
 	} else {
-		ast_log(LOG_WARNING, "Can't do format %d\n", ast->pvt->rawreadformat);
+		ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast->pvt->rawreadformat));
 		return -1;
 	}
 	if (ioctl(p->fd, PHONE_REC_START)) {
Index: channels/chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.141
diff -u -r1.141 chan_sip.c
--- channels/chan_sip.c	12 Aug 2003 16:48:16 -0000	1.141
+++ channels/chan_sip.c	12 Aug 2003 19:54:14 -0000
@@ -1724,7 +1724,7 @@
 					return -1;
 				}
 				if (sipdebug)
-					ast_verbose("Found audio format %d\n", codec);
+					ast_verbose("Found audio format %s\n", ast_getformatname(codec));
 				ast_rtp_set_m_type(p->rtp, codec);
 				codecs += len;
 				/* Skip over any whitespace */
@@ -1742,7 +1742,7 @@
 					return -1;
 				}
 				if (sipdebug)
-					ast_verbose("Found video format %d\n", codec);
+					ast_verbose("Found video format %s\n", ast_getformatname(codec));
 				ast_rtp_set_m_type(p->vrtp, codec);
 				codecs += len;
 				/* Skip over any whitespace */
@@ -3871,7 +3871,7 @@
 static int sip_show_channels(int fd, int argc, char *argv[])
 {
 #define FORMAT2 "%-15.15s  %-10.10s  %-11.11s  %-11.11s  %-7.7s  %-6.6s  %s\n"
-#define FORMAT  "%-15.15s  %-10.10s  %-11.11s  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %d\n"
+#define FORMAT  "%-15.15s  %-10.10s  %-11.11s  %5.5d/%5.5d  %-5.5dms  %-4.4dms  %-6.6s\n"
 	struct sip_pvt *cur;
 	int numchans = 0;
 	if (argc != 3)
@@ -3887,7 +3887,7 @@
 						cur->ocseq, cur->icseq, 
 						0,
 						0,
-						cur->owner ? cur->owner->nativeformats : 0);
+						ast_getformatname(cur->owner ? cur->owner->nativeformats : 0) );
 		numchans++;
 		}
 		cur = cur->next;
@@ -5211,7 +5211,7 @@
 	oldformat = format;
 	format &= capability;
 	if (!format) {
-		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format %d while capability is %d\n", oldformat, capability);
+		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format %s while capability is %s\n", ast_getformatname(oldformat), ast_getformatname(capability));
 		return NULL;
 	}
 	p = sip_alloc(NULL, NULL, 0);
Index: channels/chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.77
diff -u -r1.77 chan_zap.c
--- channels/chan_zap.c	8 Aug 2003 04:20:54 -0000	1.77
+++ channels/chan_zap.c	12 Aug 2003 19:54:18 -0000
@@ -3169,7 +3169,7 @@
 				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to campanded mode.\n", p->channel, index);
 		}
 	} else {
-		ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
+		ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->pvt->rawreadformat));
 		pthread_mutex_unlock(&p->lock);
 		return NULL;
 	}
Index: channels/chan_zap_old.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap_old.c,v
retrieving revision 1.2
diff -u -r1.2 chan_zap_old.c
--- channels/chan_zap_old.c	27 Apr 2003 18:13:11 -0000	1.2
+++ channels/chan_zap_old.c	12 Aug 2003 19:54:22 -0000
@@ -2842,7 +2842,7 @@
 				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to campanded mode.\n", p->channel, index);
 		}
 	} else {
-		ast_log(LOG_WARNING, "Don't know how to read frames in format %d\n", ast->pvt->rawreadformat);
+		ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->pvt->rawreadformat));
 		pthread_mutex_unlock(&p->lock);
 		return NULL;
 	}
Index: include/asterisk/frame.h
===================================================================
RCS file: /usr/cvsroot/asterisk/include/asterisk/frame.h,v
retrieving revision 1.8
diff -u -r1.8 frame.h
--- include/asterisk/frame.h	28 Jun 2003 16:40:02 -0000	1.8
+++ include/asterisk/frame.h	12 Aug 2003 19:54:23 -0000
@@ -309,6 +309,14 @@
 
 //! Get a format from a name
 /*!
+ * \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.
+ */
+//! Get the name of a format
+extern char* ast_getformatname(int format);
+
+/*!
  * \param name string of format
  * Gets a format from a name.
  * This returns the form of the format in binary on success, 0 on error.
Index: res/res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.5
diff -u -r1.5 res_musiconhold.c
--- res/res_musiconhold.c	10 Aug 2003 00:01:48 -0000	1.5
+++ res/res_musiconhold.c	12 Aug 2003 19:54:23 -0000
@@ -395,7 +395,7 @@
 	free(moh);
 	if (chan) {
 		if (oldwfmt && ast_set_write_format(chan, oldwfmt)) 
-			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %d\n", chan->name, oldwfmt);
+			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(oldwfmt));
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "Stopped music on hold on %s\n", chan->name);
 	}
