]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_session: Apply intention behind requested formats.
authorJoshua C. Colp <jcolp@sangoma.com>
Mon, 23 Mar 2020 10:49:41 +0000 (07:49 -0300)
committerJoshua Colp <jcolp@sangoma.com>
Thu, 26 Mar 2020 16:54:05 +0000 (11:54 -0500)
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

doc/CHANGES-staging/res_pjsip_session_codecs.md [new file with mode: 0644]
res/res_pjsip_session.c

diff --git a/doc/CHANGES-staging/res_pjsip_session_codecs.md b/doc/CHANGES-staging/res_pjsip_session_codecs.md
new file mode 100644 (file)
index 0000000..847eb41
--- /dev/null
@@ -0,0 +1,8 @@
+Subject: res_pjsip_session
+
+When placing an outgoing call to a PJSIP endpoint the intent
+of any requested formats will now be respected. If only an audio
+format is requested (such as ulaw) but the underlying endpoint
+does not support the format the resulting SDP will still only
+contain an audio stream, and not any additional streams such as
+video.
index 90fb274d388bcad161ce99fd79dabd2ca30c5212..3e2e0680f4f40cda80bafe45fea54e9a25aa4b6d 100644 (file)
@@ -2718,16 +2718,6 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint
                        }
 
                        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) {
                                /*
@@ -2739,6 +2729,17 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint
                                        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);