From 2bcec10db8d5b78c85a1303179025d314fc6c4ab Mon Sep 17 00:00:00 2001 From: Alexander Traud <pabstraud@compuserve.com> Date: Fri, 5 Feb 2021 09:33:41 +0100 Subject: [PATCH] chan_sip: Allow [peer] without audio (text+video). Two previous commits, 620d9f4 and 6d980de, allow to set up a call without audio, again. That was introduced originally with commit f04d5fb but changed and broke over time. The original commit missed one scenario: A [peer] section in sip.conf, which does not allow audio at all. In that case, chan_sip rejected the call, although even when the requester offered no audio. Now, chan_sip does not check whether there is no audio format but checks whether there is no format in general. In other words, if there is at least one format to offer, the call succeeds. However, to prevent calls with no-audio, chan_sip still rejects calls when both call parties (caller = requester of the call *and* callee = [peer] section in sip.conf) included audio. In such a case, it is expected that the call should have audio. ASTERISK-29280 Change-Id: I0fb74faf51ef22a60c10b467df6a4d1c1943b73e --- channels/chan_sip.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7aa558179b..2abfb9324b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -6555,8 +6555,21 @@ static int sip_call(struct ast_channel *ast, const char *dest, int timeout) ast_rtp_instance_available_formats(p->rtp, p->caps, p->prefcaps, p->jointcaps); p->jointnoncodeccapability = p->noncodeccapability; - /* If there are no audio formats left to offer, punt */ - if (!(ast_format_cap_has_type(p->jointcaps, AST_MEDIA_TYPE_AUDIO))) { + /* If there are no formats left to offer, punt */ + if (ast_format_cap_empty(p->jointcaps)) { + ast_log(LOG_WARNING, "No format found to offer. Cancelling call to %s\n", p->username); + res = -1; + /* If audio was requested (prefcaps) and the [peer] section contains + * audio (caps) the user expects audio. In that case, if jointcaps + * contain no audio, punt. Furthermore, this check allows the [peer] + * section to have no audio. In that case, the user expects no audio + * and we can pass. Finally, this check allows the requester not to + * offer any audio. In that case, the call is expected to have no audio + * and we can pass, as well. + */ + } else if ((ast_format_cap_empty(p->caps) || ast_format_cap_has_type(p->caps, AST_MEDIA_TYPE_AUDIO)) && + (ast_format_cap_empty(p->prefcaps) || ast_format_cap_has_type(p->prefcaps, AST_MEDIA_TYPE_AUDIO)) && + !ast_format_cap_has_type(p->jointcaps, AST_MEDIA_TYPE_AUDIO)) { ast_log(LOG_WARNING, "No audio format found to offer. Cancelling call to %s\n", p->username); res = -1; } else { -- GitLab