[Asterisk-code-review] chan_sip: Allow [peer] without audio (text+video). (asterisk[16])

Alexander Traud asteriskteam at digium.com
Fri Feb 5 02:57:09 CST 2021


Alexander Traud has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15411 )


Change subject: chan_sip: Allow [peer] without audio (text+video).
......................................................................

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
---
M channels/chan_sip.c
1 file changed, 15 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/11/15411/1

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 7aa5581..2abfb93 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6555,8 +6555,21 @@
 	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 {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15411
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I0fb74faf51ef22a60c10b467df6a4d1c1943b73e
Gerrit-Change-Number: 15411
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210205/ee0bcad4/attachment-0001.html>


More information about the asterisk-code-review mailing list