[asterisk-commits] sgriepentrog: trunk r405876 - in /trunk: ./ include/asterisk/ main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 17 15:33:28 CST 2014
Author: sgriepentrog
Date: Fri Jan 17 15:33:26 2014
New Revision: 405876
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405876
Log:
pjsip: fix support for allow=all
This change adds improvements to support for allow=all in
pjsip.conf so that it functions as intended. Previously,
the allow/disallow socery configuration would set & clear
codecs from the media.codecs and media.prefs list, but if
all was specified the prefs list was not updated. Then a
call would fail when create_outgoing_sdp_stream() created
an SDP with no audio codecs.
A new function ast_codec_pref_append_all() is provided to
add all codecs to the prefs list - only those not already
on the list. This enables the configuration to specify a
codec preference, but still add all codecs, and even then
remove some codecs, as shown in this example:
allow = ulaw, alaw, all, !g729, !g723
Also, the display order of allow in cli output is updated
to match the configuration by using prefs instead of caps
when generating a human readable string.
Finally, a change to create_outgoing_sdp_stream() skips a
codec when it does not have a payload code instead of the
call failing.
(closes issue ASTERISK-23018)
Reported by: xrobau
Review: https://reviewboard.asterisk.org/r/3131/
........
Merged revisions 405875 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/include/asterisk/format_pref.h
trunk/main/format_pref.c
trunk/main/frame.c
trunk/main/sorcery.c
trunk/res/res_pjsip_sdp_rtp.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.
Modified: trunk/include/asterisk/format_pref.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/format_pref.h?view=diff&rev=405876&r1=405875&r2=405876
==============================================================================
--- trunk/include/asterisk/format_pref.h (original)
+++ trunk/include/asterisk/format_pref.h Fri Jan 17 15:33:26 2014
@@ -69,6 +69,9 @@
/*! \brief Remove audio a codec from a preference list */
void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_format *format);
+/*! \brief Append all codecs to a preference list, without disturbing existing order */
+void ast_codec_pref_append_all(struct ast_codec_pref *pref);
+
/*! \brief Append a audio codec to a preference list, removing it first if it was already there
*/
int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format);
Modified: trunk/main/format_pref.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/format_pref.c?view=diff&rev=405876&r1=405875&r2=405876
==============================================================================
--- trunk/main/format_pref.c (original)
+++ trunk/main/format_pref.c Fri Jan 17 15:33:26 2014
@@ -143,6 +143,42 @@
ast_format_list_destroy(f_list);
}
+/*! \brief Append all codecs to a preference list, without distrubing existing order */
+void ast_codec_pref_append_all(struct ast_codec_pref *pref)
+{
+ int x, y, found;
+ size_t f_len = 0;
+ const struct ast_format_list *f_list = ast_format_list_get(&f_len);
+
+ /* leave any existing entries, and don't create duplicates (e.g. allow=ulaw,all) */
+ for (x = 0; x < f_len; x++) {
+ /* x = codec to add */
+ found = 0;
+ for (y = 0; y < f_len; y++) {
+ /* y = scan of existing preferences */
+ if (!pref->order[y]) {
+ break;
+ }
+ if (x + 1 == pref->order[y]) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) {
+ continue;
+ }
+ for (; y < f_len; y++) {
+ /* add x to the end of y */
+ if (!pref->order[y])
+ {
+ pref->order[y] = x + 1;
+ ast_format_copy(&pref->formats[y], &f_list[x].format);
+ break;
+ }
+ }
+ }
+}
+
/*! \brief Append codec to list */
int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format)
{
Modified: trunk/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/frame.c?view=diff&rev=405876&r1=405875&r2=405876
==============================================================================
--- trunk/main/frame.c (original)
+++ trunk/main/frame.c Fri Jan 17 15:33:26 2014
@@ -866,6 +866,8 @@
}
} else if (!iter_allowing) {
memset(pref, 0, sizeof(*pref));
+ } else {
+ ast_codec_pref_append_all(pref);
}
}
}
Modified: trunk/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sorcery.c?view=diff&rev=405876&r1=405875&r2=405876
==============================================================================
--- trunk/main/sorcery.c (original)
+++ trunk/main/sorcery.c Fri Jan 17 15:33:26 2014
@@ -43,6 +43,7 @@
#include "asterisk/taskprocessor.h"
#include "asterisk/threadpool.h"
#include "asterisk/json.h"
+#include "asterisk/format_pref.h"
/* To prevent DEBUG_FD_LEAKS from interfering with things we undef open and close */
#undef open
@@ -222,8 +223,9 @@
static int codec_handler_fn(const void *obj, const intptr_t *args, char **buf)
{
char tmp_buf[256];
- struct ast_format_cap **cap = (struct ast_format_cap **)(obj + args[1]);
- return !(*buf = ast_strdup(ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), *cap)));
+ struct ast_codec_pref *pref = (struct ast_codec_pref *)(obj + args[0]);
+ ast_codec_pref_string(pref, tmp_buf, sizeof(tmp_buf));
+ return !(*buf = ast_strdup(tmp_buf));
}
static sorcery_field_handler sorcery_field_default_handler(enum aco_option_type type)
Modified: trunk/res/res_pjsip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_sdp_rtp.c?view=diff&rev=405876&r1=405875&r2=405876
==============================================================================
--- trunk/res/res_pjsip_sdp_rtp.c (original)
+++ trunk/res/res_pjsip_sdp_rtp.c Fri Jan 17 15:33:26 2014
@@ -936,7 +936,8 @@
}
if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session_media->rtp), 1, &format, 0)) == -1) {
- return -1;
+ ast_log(LOG_WARNING,"Unable to get rtp codec payload code for %s\n",ast_getformatname(&format));
+ continue;
}
if (!(attr = generate_rtpmap_attr(media, pool, rtp_code, 1, &format, 0))) {
More information about the asterisk-commits
mailing list