[asterisk-commits] bridge simple: Improve renegotiation success rate. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 17 08:49:21 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6760 )

Change subject: bridge_simple: Improve renegotiation success rate.
......................................................................

bridge_simple: Improve renegotiation success rate.

When making channels compatible the bridge_simple module
will renegotiate one to better match the other. Some
endpoints incorrectly terminate the call if this process
fails.

To better handle this scenario the audio streams present
on the new requested topology will include any existing
negotiated formats that happen to exist on the first
valid audio stream. This ensures formats are persent that
are known to be acceptable to the remote endpoint.

ASTERISK-27259

Change-Id: I8fc0cc03e8bcfd0be8302f13b9f32d8268977f43
---
M bridges/bridge_simple.c
1 file changed, 54 insertions(+), 2 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c
index a49bc39..7ee1966 100644
--- a/bridges/bridge_simple.c
+++ b/bridges/bridge_simple.c
@@ -113,6 +113,58 @@
 	.stream_topology_changed = simple_bridge_stream_topology_changed,
 };
 
+static void simple_bridge_request_stream_topology_change(struct ast_channel *chan,
+	struct ast_stream_topology *requested_topology)
+{
+	struct ast_stream_topology *existing_topology = ast_channel_get_stream_topology(chan);
+	struct ast_stream *stream;
+	struct ast_format_cap *audio_formats = NULL;
+	struct ast_stream_topology *new_topology;
+	int i;
+
+	/* We find an existing stream with negotiated audio formats that we can place into
+	 * any audio streams in the new topology to ensure that negotiation succeeds. Some
+	 * endpoints incorrectly terminate the call if SDP negotiation fails.
+	 */
+	for (i = 0; i < ast_stream_topology_get_count(existing_topology); ++i) {
+		stream = ast_stream_topology_get_stream(existing_topology, i);
+
+		if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO ||
+			ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
+			continue;
+		}
+
+		audio_formats = ast_stream_get_formats(stream);
+		break;
+	}
+
+	if (!audio_formats) {
+		ast_channel_request_stream_topology_change(chan, requested_topology, &simple_bridge);
+		return;
+	}
+
+	new_topology = ast_stream_topology_clone(requested_topology);
+	if (!new_topology) {
+		ast_channel_request_stream_topology_change(chan, requested_topology, &simple_bridge);
+		return;
+	}
+
+	for (i = 0; i < ast_stream_topology_get_count(new_topology); ++i) {
+		stream = ast_stream_topology_get_stream(new_topology, i);
+
+		if (ast_stream_get_type(stream) != AST_MEDIA_TYPE_AUDIO ||
+			ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
+			continue;
+		}
+
+		ast_format_cap_append_from_cap(ast_stream_get_formats(stream), audio_formats, AST_MEDIA_TYPE_AUDIO);
+	}
+
+	ast_channel_request_stream_topology_change(chan, new_topology, &simple_bridge);
+
+	ast_stream_topology_free(new_topology);
+}
+
 static void simple_bridge_stream_topology_changed(struct ast_bridge *bridge,
 		struct ast_bridge_channel *bridge_channel)
 {
@@ -135,9 +187,9 @@
 
 	/* Align topologies according to size or first channel to join */
 	if (ast_stream_topology_get_count(t0) < ast_stream_topology_get_count(t1)) {
-		ast_channel_request_stream_topology_change(c0, t1, &simple_bridge);
+		simple_bridge_request_stream_topology_change(c0, t1);
 	} else {
-		ast_channel_request_stream_topology_change(c1, t0, &simple_bridge);
+		simple_bridge_request_stream_topology_change(c1, t0);
 	}
 }
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8fc0cc03e8bcfd0be8302f13b9f32d8268977f43
Gerrit-Change-Number: 6760
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20171017/40b1c7e3/attachment-0001.html>


More information about the asterisk-commits mailing list