summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-07-16 17:31:35 +0000
committerJoshua Colp <jcolp@digium.com>2017-07-16 17:31:35 +0000
commitf48695ce5bde836691e1b46350c22f1de21de5d9 (patch)
treeff79a33abb1d35c0bfcc4102bc9c626f2ecb01ce /bridges
parent3fd1d520f73a279b78e3bcfadc3ab7f829ff44c0 (diff)
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
Diffstat (limited to 'bridges')
-rw-r--r--bridges/bridge_softmix.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index ae877eb6e..3801ccbec 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -524,15 +524,32 @@ static int append_all_streams(struct ast_stream_topology *dest,
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;
}