summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-04-10 16:32:28 +0000
committerRichard Mudgett <rmudgett@digium.com>2015-04-10 16:32:28 +0000
commit0b805cb87526fd229e3f2811f95d3ba9b4fd64f0 (patch)
treecaa99f576195a695fb7552e66e043b4ebaaf19d3 /main/channel.c
parent894153b8b1557903c1d512994aecedb326dc0951 (diff)
translate.c: Only select audio codecs to determine the best translation choice.
Given a source capability of h264 and ulaw, a destination capability of h264 and g722 then ast_translator_best_choice() would pick h264 as the best choice even though h264 is a video codec and Asterisk only supports translation of audio codecs. When the audio starts flowing, there are warnings about a codec mismatch when the channel tries to write a frame to the peer. * Made ast_translator_best_choice() only select audio codecs. * Restore a check in channel.c:set_format() lost after v1.8 to prevent trying to set a non-audio codec. This is an intermediate patch for a series of patches aimed at improving translation path choices for ASTERISK-24841. This patch is a complete enough fix for ASTERISK-21777 as the v11 version of ast_translator_best_choice() does the same thing. However, chan_sip.c still somehow tries to call ast_codec_choose() which then calls ast_best_codec() with a capability set that doesn't contain any audio formats for the incoming call. The remaining warning message seems to be a benign transient. ASTERISK-21777 #close Reported by: Nick Ruggles ASTERISK-24380 #close Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/4605/ ........ Merged revisions 434614 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434615 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434616 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main/channel.c b/main/channel.c
index 2d1b6ddd1..70ced0210 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -5268,7 +5268,14 @@ static int set_format(struct ast_channel *chan, struct ast_format_cap *cap_set,
access = &set_format_access_write;
}
- best_set_fmt = ast_format_cap_get_format(cap_set, 0);
+ best_set_fmt = ast_format_cap_get_best_by_type(cap_set, AST_MEDIA_TYPE_AUDIO);
+ if (!best_set_fmt) {
+ /*
+ * Not setting any audio formats?
+ * Assume a call without any sounds (video, text)
+ */
+ return 0;
+ }
/* See if the underlying channel driver is capable of performing transcoding for us */
res = ast_channel_setoption(chan, access->setoption,