Index: rtp.c =================================================================== RCS file: /usr/cvsroot/asterisk/rtp.c,v retrieving revision 1.92.2.14 diff -u -r1.92.2.14 rtp.c --- rtp.c 31 May 2005 12:55:43 -0000 1.92.2.14 +++ rtp.c 2 Jun 2005 05:28:48 -0000 @@ -753,7 +753,7 @@ } /* Looks up an RTP code out of our *static* outbound list */ -int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code) { +int ast_rtp_lookup_code(struct ast_rtp* rtp, const int isAstFormat, const int code) { int pt; @@ -787,7 +787,7 @@ return -1; } -char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code) { +char* ast_rtp_lookup_mime_subtype(const int isAstFormat, const int code) { int i; for (i = 0; i < sizeof mimeTypes/sizeof mimeTypes[0]; ++i) { @@ -798,6 +798,41 @@ } return ""; } + +char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat) +{ + int format; + unsigned len; + char *end = buf; + char *start = buf; + + if (!buf || !size) + return NULL; + + snprintf(end, size, "0x%x (", capability); + + len = strlen(end); + end += len; + size -= len; + start = end; + + for (format = 1; format < AST_RTP_MAX; format <<= 1) { + if (capability & format) { + const char *name = ast_rtp_lookup_mime_subtype(isAstFormat, format); + snprintf(end, size, "%s|", name); + len = strlen(end); + end += len; + size -= len; + } + } + + if (start == end) + snprintf(start, size, "nothing)"); + else if (size > 1) + *(end -1) = ')'; + + return buf; + } static int rtp_socket(void) { Index: channels/chan_sip.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v retrieving revision 1.510.2.66 diff -u -r1.510.2.66 chan_sip.c --- channels/chan_sip.c 31 May 2005 05:30:07 -0000 1.510.2.66 +++ channels/chan_sip.c 2 Jun 2005 05:28:54 -0000 @@ -2784,9 +2784,9 @@ 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)); + ast_rtp_lookup_mime_multiple(s1, slen, noncodeccapability, 0), + ast_rtp_lookup_mime_multiple(s2, slen, peernoncodeccapability, 0), + ast_rtp_lookup_mime_multiple(s3, slen, p->noncodeccapability, 0)); } if (!p->jointcapability) { ast_log(LOG_NOTICE, "No compatible codecs!\n"); Index: include/asterisk/rtp.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/rtp.h,v retrieving revision 1.16 diff -u -r1.16 rtp.h --- include/asterisk/rtp.h 26 Aug 2004 04:56:26 -0000 1.16 +++ include/asterisk/rtp.h 2 Jun 2005 05:28:55 -0000 @@ -97,6 +97,9 @@ // Mapping an Asterisk code into a MIME subtype (string): char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code); +/* Build a string of MIME subtype names from a capability list */ +char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat); + void ast_rtp_setnat(struct ast_rtp *rtp, int nat); int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);