diff --git a/apps/app_agi.c b/apps/app_agi.c index 3e332afc52..ce4f450647 100755 --- a/apps/app_agi.c +++ b/apps/app_agi.c @@ -1435,7 +1435,7 @@ static int eagi_exec(struct ast_channel *chan, void *data) 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; diff --git a/apps/app_voicemail2.c b/apps/app_voicemail2.c index 0104149b6a..8d984554d9 100755 --- a/apps/app_voicemail2.c +++ b/apps/app_voicemail2.c @@ -933,7 +933,7 @@ static int play_and_record(struct ast_channel *chan, char *playfile, char *recor } 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) { diff --git a/channel.c b/channel.c index a97f0e8450..85215f703a 100755 --- a/channel.c +++ b/channel.c @@ -1083,7 +1083,7 @@ struct ast_frame *ast_read(struct ast_channel *chan) 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 { @@ -1403,7 +1403,8 @@ int ast_set_write_format(struct ast_channel *chan, int fmts) 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; } @@ -1417,7 +1418,7 @@ int ast_set_write_format(struct ast_channel *chan, int fmts) /* 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; } @@ -1432,7 +1433,8 @@ int ast_set_read_format(struct ast_channel *chan, int fmts) /* 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; } @@ -1446,7 +1448,8 @@ int ast_set_read_format(struct ast_channel *chan, int fmts) /* 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; } diff --git a/channels/chan_agent.c b/channels/chan_agent.c index ccc5e56e0b..aeb867784a 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -398,7 +398,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout) 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; @@ -408,7 +408,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout) 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 ) { @@ -1046,8 +1046,8 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) "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; diff --git a/channels/chan_iax.c b/channels/chan_iax.c index 1d1c354bbf..93f7172e9e 100755 --- a/channels/chan_iax.c +++ b/channels/chan_iax.c @@ -2256,7 +2256,7 @@ static int iax_show_registry(int fd, int argc, char *argv[]) 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 @@ static int iax_show_channels(int fd, int argc, char *argv[]) iaxs[x]->oseqno, iaxs[x]->iseqno, iaxs[x]->lag, iaxs[x]->jitter, - iaxs[x]->voiceformat); + ast_getformatname(iaxs[x]->voiceformat) ); numchans++; } ast_mutex_unlock(&iaxsl[x]); @@ -3550,7 +3550,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata) if (f.frametype == AST_FRAME_VOICE) { if (f.subclass != iaxs[fr.callno]->voiceformat) { iaxs[fr.callno]->voiceformat = f.subclass; - ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass); + ast_log(LOG_DEBUG, "Ooh, voice format changed to %s\n", ast_getformatname(f.subclass)); if (iaxs[fr.callno]->owner) { int orignative; ast_mutex_lock(&iaxs[fr.callno]->owner->lock); @@ -3727,7 +3727,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata) 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); @@ -3737,7 +3737,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata) /* Switch us to use a compatible format */ iaxs[fr.callno]->owner->nativeformats = iaxs[fr.callno]->peerformat; if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Format for call is %d\n", iaxs[fr.callno]->owner->nativeformats); + ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_getformatname(iaxs[fr.callno]->owner->nativeformats)); /* Setup read/write formats properly. */ if (iaxs[fr.callno]->owner->writeformat) ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat); @@ -3861,7 +3861,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata) /* 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); @@ -4224,7 +4224,7 @@ static struct ast_channel *iax_request(char *type, int format, void *data) fmt = format; res = ast_translator_best_choice(&fmt, &native); if (res < 0) { - ast_log(LOG_WARNING, "Unable to create translator path for %d to %d on %s\n", c->nativeformats, fmt, c->name); + ast_log(LOG_WARNING, "Unable to create translator path for %s to %s on %s\n", ast_getformatname(c->nativeformats), ast_getformatname(fmt), c->name); ast_hangup(c); return NULL; } diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 840b964903..ff42b4ddf1 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -2433,7 +2433,7 @@ static int iax2_show_registry(int fd, int argc, char *argv[]) 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 @@ static int iax2_show_channels(int fd, int argc, char *argv[]) iaxs[x]->oseqno, iaxs[x]->iseqno, iaxs[x]->lag, iaxs[x]->jitter, - iaxs[x]->voiceformat); + ast_getformatname(iaxs[x]->voiceformat) ); numchans++; } ast_mutex_unlock(&iaxsl[x]); @@ -4105,7 +4105,7 @@ retryowner: 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"); @@ -4117,7 +4117,7 @@ retryowner: /* Switch us to use a compatible format */ iaxs[fr.callno]->owner->nativeformats = iaxs[fr.callno]->peerformat; if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Format for call is %d\n", iaxs[fr.callno]->owner->nativeformats); + ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_getformatname(iaxs[fr.callno]->owner->nativeformats)); /* Setup read/write formats properly. */ if (iaxs[fr.callno]->owner->writeformat) ast_set_write_format(iaxs[fr.callno]->owner, iaxs[fr.callno]->owner->writeformat); @@ -4243,7 +4243,7 @@ retryowner: /* 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); @@ -4652,7 +4652,7 @@ static struct ast_channel *iax2_request(char *type, int format, void *data) fmt = format; res = ast_translator_best_choice(&fmt, &native); if (res < 0) { - ast_log(LOG_WARNING, "Unable to create translator path for %d to %d on %s\n", c->nativeformats, fmt, c->name); + ast_log(LOG_WARNING, "Unable to create translator path for %s to %s on %s\n", ast_getformatname(c->nativeformats), ast_getformatname(fmt), c->name); ast_hangup(c); return NULL; } diff --git a/channels/chan_modem.c b/channels/chan_modem.c index b62002679a..de8237ff82 100755 --- a/channels/chan_modem.c +++ b/channels/chan_modem.c @@ -790,7 +790,7 @@ static struct ast_channel *modem_request(char *type, int format, void *data) } 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; } } diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 5ae642a1f6..2c99261193 100755 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -270,7 +270,7 @@ static int phone_setup(struct ast_channel *ast) } } } 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)) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ba8cafa83d..343d9fd435 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1724,7 +1724,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) 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 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req) 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 */ @@ -3883,7 +3883,7 @@ static int sip_show_registry(int fd, int argc, char *argv[]) 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) @@ -3899,7 +3899,7 @@ static int sip_show_channels(int fd, int argc, char *argv[]) cur->ocseq, cur->icseq, 0, 0, - cur->owner ? cur->owner->nativeformats : 0); + ast_getformatname(cur->owner ? cur->owner->nativeformats : 0) ); numchans++; } cur = cur->next; @@ -5223,7 +5223,7 @@ static struct ast_channel *sip_request(char *type, int format, void *data) 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); diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 7c5680ea3b..6b6a048252 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -3180,7 +3180,7 @@ struct ast_frame *zt_read(struct ast_channel *ast) 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)); ast_mutex_unlock(&p->lock); return NULL; } diff --git a/channels/chan_zap_old.c b/channels/chan_zap_old.c index c81b6e5c6e..402b1b3c54 100755 --- a/channels/chan_zap_old.c +++ b/channels/chan_zap_old.c @@ -2842,7 +2842,7 @@ struct ast_frame *zt_read(struct ast_channel *ast) 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)); ast_mutex_unlock(&p->lock); return NULL; } diff --git a/file.c b/file.c index bad5f814e5..dde3d2673e 100755 --- a/file.c +++ b/file.c @@ -215,7 +215,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f) 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 @@ int ast_streamfile(struct ast_channel *chan, char *filename, char *preflang) #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; } diff --git a/frame.c b/frame.c index 6143671e7c..2e53f8d1e5 100755 --- a/frame.c +++ b/frame.c @@ -343,6 +343,41 @@ int ast_fr_fdhangup(int fd) 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 "G729A"; + 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 @@ void ast_frame_dump(char *name, struct ast_frame *f, char *prefix) 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"); diff --git a/image.c b/image.c index 1b07b77b25..c46396c791 100755 --- a/image.c +++ b/image.c @@ -175,14 +175,14 @@ int ast_send_image(struct ast_channel *chan, char *filename) 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; diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index 37e681024a..bd1bb2a728 100755 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -308,6 +308,14 @@ int ast_fr_fdwrite(int fd, struct ast_frame *frame); int ast_fr_fdhangup(int fd); //! 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. diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 9ef8e55a39..487d6a2525 100755 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -395,7 +395,7 @@ static void moh_release(struct ast_channel *chan, void *data) 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); } diff --git a/rtp.c b/rtp.c index 484a4f6945..03606b0245 100755 --- a/rtp.c +++ b/rtp.c @@ -477,7 +477,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) // 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 { @@ -927,7 +927,7 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec // 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 */ @@ -995,13 +995,13 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f) 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); @@ -1062,7 +1062,7 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f) 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: diff --git a/translate.c b/translate.c index 01c52309be..0a31d8b714 100755 --- a/translate.c +++ b/translate.c @@ -125,7 +125,8 @@ struct ast_trans_pvt *ast_translator_build_path(int dest, int source) } } 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 @@ static void rebuild_matrix(void) 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 void calc_cost(struct ast_translator *t) 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_mutex_lock(&list_lock); - for (x=0;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 @@ int ast_register_translator(struct ast_translator *t) 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_mutex_lock(&list_lock); if (!added_cli) { ast_cli_register(&show_trans);