--- main/translate.c (Asterisk 13.38.1) +++ main/translate.c (working copy) @@ -1501,14 +1501,17 @@ static void check_translation_path( enum ast_media_type type) { - int index, src_index = format2index(src_fmt); + int i; + + if (ast_format_get_type(src_fmt) != type) { + return; + } + /* For a given source format, traverse the list of known formats to determine whether there exists a translation path from the source format to the destination format. */ - for (index = 0; (src_index >= 0) && index < cur_max_index; index++) { - struct ast_codec *codec = index2codec(index); - RAII_VAR(struct ast_format *, fmt, ast_format_create(codec), ao2_cleanup); - - ao2_ref(codec, -1); + for (i = ast_format_cap_count(result) - 1; 0 <= i; i--) { + int index, src_index; + struct ast_format *fmt = ast_format_cap_get_format(result, i); if (ast_format_get_type(fmt) != type) { @@ -1526,4 +1529,13 @@ static void check_translation_path( continue; } + + /* if this is a pass-through format, not in the source, + we cannot transcode. Therefore, remove it from the result */ + src_index = format2index(src_fmt); + index = format2index(fmt); + if (src_index < 0 || index < 0) { + ast_format_cap_remove(result, fmt); + continue; + } /* if we don't have a translation path from the src --- channels/chan_sip.c (Asterisk 13.38.1) +++ channels/chan_sip.c (working copy) @@ -13546,7 +13546,4 @@ static enum sip_result add_sdp(struct si - /* Check if we need audio */ - if (ast_format_cap_has_type(tmpcap, AST_MEDIA_TYPE_AUDIO) - || ast_format_cap_has_type(p->caps, AST_MEDIA_TYPE_AUDIO)) { - needaudio = TRUE; - } + /* Check if we need audio in this call */ + needaudio = ast_format_cap_has_type(tmpcap, AST_MEDIA_TYPE_AUDIO); @@ -13681,3 +13678,2 @@ static enum sip_result add_sdp(struct si - Then our mutually shared capabilities, determined previous in tmpcap - - Then preferences in order from sip.conf device config for this peer/user */ @@ -13725,23 +13721,2 @@ static enum sip_result add_sdp(struct si - /* Finally our remaining audio/video codecs */ - for (x = 0; p->outgoing_call && x < ast_format_cap_count(p->caps); x++) { - tmp_fmt = ast_format_cap_get_format(p->caps, x); - - if (ast_format_cap_iscompatible_format(alreadysent, tmp_fmt) != AST_FORMAT_CMP_NOT_EQUAL) { - ao2_ref(tmp_fmt, -1); - continue; - } - - if (ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_AUDIO) { - add_codec_to_sdp(p, tmp_fmt, &m_audio, &a_audio, debug, &min_audio_packet_size, &max_audio_packet_size); - } else if (needvideo && ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_VIDEO) { - add_vcodec_to_sdp(p, tmp_fmt, &m_video, &a_video, debug, &min_video_packet_size); - } else if (needtext && ast_format_get_type(tmp_fmt) == AST_MEDIA_TYPE_TEXT) { - add_tcodec_to_sdp(p, tmp_fmt, &m_text, &a_text, debug, &min_text_packet_size); - } - - ast_format_cap_append(alreadysent, tmp_fmt, 0); - ao2_ref(tmp_fmt, -1); - } - /* Now add DTMF RFC2833 telephony-event as a codec */