]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Fix an issue where an incompatible audio format may be added to SDP.
authorJoshua Colp <jcolp@digium.com>
Wed, 23 Oct 2013 11:11:18 +0000 (11:11 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 23 Oct 2013 11:11:18 +0000 (11:11 +0000)
If preferred codecs included any non-audio format the code would
mistakenly add the audio format, even if it was not a joint capability
with the remote side.

(closes issue ASTERISK-21131)
Reported by: nbougues
Patches:
patch_unsupported_codec_1.8.patch uploaded by nbougues (license 6470)
........

Merged revisions 401497 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@401498 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 5ab91c2954f79c59d34bc71ba1f5c592219f28bc..72e1b11704847b5feded2d5629d80f23185c856a 100644 (file)
@@ -13197,19 +13197,18 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
                */
 
                /* Prefer the audio codec we were requested to use, first, no matter what
-                  Note that p->prefcodec can include video codecs, so mask them out
+                  Note that p->prefcodec can include video codecs, so ignore them
                */
-               if (ast_format_cap_has_joint(tmpcap, p->prefcaps)) {
-                       ast_format_cap_iter_start(p->prefcaps);
-                       while (!(ast_format_cap_iter_next(p->prefcaps, &tmp_fmt))) {
-                               if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_AUDIO) {
-                                       continue;
-                               }
-                               add_codec_to_sdp(p, &tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size);
-                               ast_format_cap_add(alreadysent, &tmp_fmt);
+               ast_format_cap_iter_start(p->prefcaps);
+               while (!(ast_format_cap_iter_next(p->prefcaps, &tmp_fmt))) {
+                       if (AST_FORMAT_GET_TYPE(tmp_fmt.id) != AST_FORMAT_TYPE_AUDIO ||
+                               !ast_format_cap_iscompatible(tmpcap, &tmp_fmt)) {
+                               continue;
                        }
-                       ast_format_cap_iter_end(p->prefcaps);
+                       add_codec_to_sdp(p, &tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size);
+                       ast_format_cap_add(alreadysent, &tmp_fmt);
                }
+               ast_format_cap_iter_end(p->prefcaps);
 
                /* Start by sending our preferred audio/video codecs */
                for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {