[Asterisk-code-review] res pjsip session: outgoing call did not offer all configure... (asterisk[15])

Kevin Harwell asteriskteam at digium.com
Fri Sep 22 16:35:31 CDT 2017


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/6569


Change subject: res_pjsip_session: outgoing call did not offer all configured codecs
......................................................................

res_pjsip_session: outgoing call did not offer all configured codecs

For some scenarios when an outgoing call was made only a subset of the
configured codecs were offered. If the codecs being offered happened to
not have a codec supported by the phone then the call would fail.

For instance Alice and Bob both are configured in Asterisk for g722 and ulaw(
allow=!all,g722,ulaw). Alice's endpoint however only supports g722 while Bob's
only supports ulaw. When Alice calls Bob, Alice negotiates g722 fine with
Asterisk. But when Asterisk sends the outgoing offer to Bob it only contains
g722 and not both g722 and ulaw, so the call ends.

This patch makes it so all the codecs configured on the endpoint always get sent
and not just a subset.

ASTERISK-27259

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



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/6569/1

diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index c974e48..f873b3e 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -2414,7 +2414,6 @@
 		for (i = 0; i < ast_stream_topology_get_count(req_topology); ++i) {
 			struct ast_stream *req_stream;
 			struct ast_format_cap *req_cap;
-			struct ast_format_cap *joint_cap;
 			struct ast_stream *clone_stream;
 
 			req_stream = ast_stream_topology_get_stream(req_topology, i);
@@ -2423,27 +2422,27 @@
 				continue;
 			}
 
-			req_cap = ast_stream_get_formats(req_stream);
-
-			joint_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
-			if (!joint_cap) {
+			req_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+			if (!req_cap) {
 				continue;
 			}
 
-			ast_format_cap_get_compatible(req_cap, endpoint->media.codecs, joint_cap);
-			if (!ast_format_cap_count(joint_cap)) {
-				ao2_ref(joint_cap, -1);
+			ast_format_cap_append_from_cap(req_cap,
+				endpoint->media.codecs, AST_MEDIA_TYPE_UNKNOWN);
+
+			if (!ast_format_cap_count(req_cap)) {
+				ao2_ref(req_cap, -1);
 				continue;
 			}
 
 			clone_stream = ast_stream_clone(req_stream, NULL);
 			if (!clone_stream) {
-				ao2_ref(joint_cap, -1);
+				ao2_ref(req_cap, -1);
 				continue;
 			}
 
-			ast_stream_set_formats(clone_stream, joint_cap);
-			ao2_ref(joint_cap, -1);
+			ast_stream_set_formats(clone_stream, req_cap);
+			ao2_ref(req_cap, -1);
 
 			if (!session->pending_media_state->topology) {
 				session->pending_media_state->topology = ast_stream_topology_alloc();

-- 
To view, visit https://gerrit.asterisk.org/6569
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffabc373bd94cd1dc700925dcfe406e12918c696
Gerrit-Change-Number: 6569
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170922/22481fab/attachment-0001.html>


More information about the asterisk-code-review mailing list