[Asterisk-code-review] bridge softmix: Use removed stream spots when renegotiating. (asterisk[master])
Joshua Colp
asteriskteam at digium.com
Sun Jul 16 12:33:39 CDT 2017
Joshua Colp has uploaded this change for review. ( 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(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/29/6029/1
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: newchange
Gerrit-Change-Id: I95cdcfd55cf47e02ea52abb5d94008db3fb68b1d
Gerrit-Change-Number: 6029
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170716/5ed2fe31/attachment-0001.html>
More information about the asterisk-code-review
mailing list