[Asterisk-code-review] res_pjsip_session: Apply intention behind requested formats. (asterisk[16])

Joshua Colp asteriskteam at digium.com
Mon Mar 23 12:06:29 CDT 2020


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13958 )


Change subject: res_pjsip_session: Apply intention behind requested formats.
......................................................................

res_pjsip_session: Apply intention behind requested formats.

When an outgoing channel is created a list of formats may
optionally be provided which is used as a request that the
formats be used if possible. If an endpoint is not configured
for any of the formats we ignore this request and use what is
configured. This has the side effect of also including other
stream types (such as video) that were not present in the
requested formats.

This change makes it so that the intention of the request is
preserved - that is if only an audio format is requested then
even if there is no joint audio format between the request and
the configuration we will still only place an audio stream in
the outgoing call.

ASTERISK-28787

Change-Id: Ia54c0c63e94aca176169b9bae4bb8a8380ea245f
---
M res/res_pjsip_session.c
1 file changed, 11 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/58/13958/1

diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index b9448b9..47d8ef6 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -2716,16 +2716,6 @@
 			}
 
 			ast_format_cap_get_compatible(req_cap, endpoint->media.codecs, joint_cap);
-			if (!ast_format_cap_count(joint_cap)) {
-				ao2_ref(joint_cap, -1);
-				continue;
-			}
-
-			clone_stream = ast_stream_clone(req_stream, NULL);
-			if (!clone_stream) {
-				ao2_ref(joint_cap, -1);
-				continue;
-			}
 
 			if (ast_stream_get_type(req_stream) == AST_MEDIA_TYPE_AUDIO) {
 				/*
@@ -2737,6 +2727,17 @@
 					endpoint->media.codecs, AST_MEDIA_TYPE_AUDIO);
 			}
 
+			if (!ast_format_cap_count(joint_cap)) {
+				ao2_ref(joint_cap, -1);
+				continue;
+			}
+
+			clone_stream = ast_stream_clone(req_stream, NULL);
+			if (!clone_stream) {
+				ao2_ref(joint_cap, -1);
+				continue;
+			}
+
 			ast_stream_set_formats(clone_stream, joint_cap);
 			ao2_ref(joint_cap, -1);
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ia54c0c63e94aca176169b9bae4bb8a8380ea245f
Gerrit-Change-Number: 13958
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200323/73a29e01/attachment.html>


More information about the asterisk-code-review mailing list