mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-09 22:45:49 +00:00
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/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@405875 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -143,6 +143,42 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_format *forma
|
||||
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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user