--- ../asterisk-1.6.1.0/channels/chan_sip.c 2009-04-20 21:08:26.000000000 +0400 +++ asterisk-1.6.1.0/channels/chan_sip.c 2009-06-23 00:45:01.000000000 +0400 @@ -8769,12 +8769,17 @@ Note that p->prefcodec can include video codecs, so mask them out */ if (capability & p->prefcodec) { - int codec = p->prefcodec & AST_FORMAT_AUDIO_MASK; - - add_codec_to_sdp(p, codec, SDP_SAMPLE_RATE(codec), - &m_audio, &a_audio, - debug, &min_audio_packet_size); - alreadysent |= codec; + int mask; + for (mask = 1; mask < AST_FORMAT_AUDIO_MASK; mask <<= 1) { + int codec = p->prefcodec & mask; + if (codec) { + add_codec_to_sdp(p, codec, SDP_SAMPLE_RATE(codec), + &m_audio, &a_audio, + debug, &min_audio_packet_size); + alreadysent |= codec; + break; + } + } } /* Start by sending our preferred audio/video codecs */