--- main/channel.c (Asterisk 13.38.0) +++ main/channel.c (working copy) @@ -5787,2 +5787,7 @@ static int set_format(struct ast_channel + cap_native = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); + if (!cap_native) { + return -1; + } + /* See if the underlying channel driver is capable of performing transcoding for us */ @@ -5794,7 +5799,3 @@ static int set_format(struct ast_channel - ast_channel_lock(chan); - cap_native = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); - if (!cap_native - || ast_format_cap_append(cap_native, best_set_fmt, 0)) { - ast_channel_unlock(chan); + if (ast_format_cap_append(cap_native, best_set_fmt, 0)) { ao2_cleanup(cap_native); @@ -5802,2 +5803,3 @@ static int set_format(struct ast_channel } + ast_channel_lock(chan); ast_channel_nativeformats_set(chan, cap_native); @@ -5830,5 +5832,10 @@ static int set_format(struct ast_channel - cap_native = ast_channel_nativeformats(chan); + if (ast_format_cap_append_from_cap(cap_native, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_AUDIO)) { + ast_channel_unlock(chan); + ao2_cleanup(cap_native); + return -1; + } if (ast_format_cap_empty(cap_native)) { ast_channel_unlock(chan); + ao2_cleanup(cap_native); ast_log(LOG_ERROR, "Unable to set format because channel %s supports no formats\n", @@ -5852,2 +5859,3 @@ static int set_format(struct ast_channel ast_channel_unlock(chan); + ao2_cleanup(cap_native); ast_format_cap_get_names(cap_set, &codec_set); @@ -5866,2 +5874,3 @@ static int set_format(struct ast_channel ast_channel_unlock(chan); + ao2_cleanup(cap_native); return 0; @@ -5915,2 +5924,4 @@ static int set_format(struct ast_channel + ao2_cleanup(cap_native); + return res; --- channels/chan_sip.c (Asterisk 13.38.0) +++ channels/chan_sip.c (working copy) @@ -11159,11 +11159,11 @@ static int process_sdp(struct sip_pvt *p ast_format_cap_get_names(ast_channel_nativeformats(p->owner), &cap_buf)); } caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); if (caps) { - tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0); + tmp_fmt = ast_format_cap_get_best_by_type(p->jointcaps, AST_MEDIA_TYPE_AUDIO); framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt); ast_format_cap_append(caps, tmp_fmt, framing); ast_format_cap_append_from_cap(caps, vpeercapability, AST_MEDIA_TYPE_VIDEO); ast_format_cap_append_from_cap(caps, tpeercapability, AST_MEDIA_TYPE_TEXT); ast_channel_nativeformats_set(p->owner, caps);