[asterisk-commits] bridge softmix: Use removed stream spots when renegotiating. (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 19 10:42:52 CDT 2017


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

Change subject: bridge_softmix: Use removed stream spots when renegotiating.
......................................................................

bridge_softmix: Use removed stream spots when renegotiating.

Streams are never truly removed in SDP, they still occupy
a location within the SDP. This location can be reused by
another stream if it so chooses.

This change takes advantage of this such that if a new stream
is needing to be added for a new participant any removed streams
are instead replaced first. This reduces the size of the SDP
and the number of streams.

ASTERISK-27134

Change-Id: I95cdcfd55cf47e02ea52abb5d94008db3fb68b1d
---
M bridges/bridge_softmix.c
1 file changed, 18 insertions(+), 1 deletion(-)

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



diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index ae877eb..3801ccb 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -524,15 +524,32 @@
 	const struct ast_stream_topology *source)
 {
 	int i;
+	int dest_index = 0;
 
 	for (i = 0; i < ast_stream_topology_get_count(source); ++i) {
 		struct ast_stream *clone;
+		int added = 0;
 
 		clone = ast_stream_clone(ast_stream_topology_get_stream(source, i), NULL);
 		if (!clone) {
 			return -1;
 		}
-		if (ast_stream_topology_append_stream(dest, clone) < 0) {
+
+		/* If we can reuse an existing removed stream then do so */
+		while (dest_index < ast_stream_topology_get_count(dest)) {
+			struct ast_stream *stream = ast_stream_topology_get_stream(dest, dest_index);
+
+			dest_index++;
+
+			if (ast_stream_get_state(stream) == AST_STREAM_STATE_REMOVED) {
+				ast_stream_topology_set_stream(dest, dest_index - 1, clone);
+				added = 1;
+				break;
+			}
+		}
+
+		/* If no removed stream exists that we took the place of append the stream */
+		if (!added && ast_stream_topology_append_stream(dest, clone) < 0) {
 			ast_stream_free(clone);
 			return -1;
 		}

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I95cdcfd55cf47e02ea52abb5d94008db3fb68b1d
Gerrit-Change-Number: 6029
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170719/ca761d0e/attachment-0001.html>


More information about the asterisk-commits mailing list