Merge "Add primitive SFU support to bridge_softmix."
authorJenkins2 <jenkins2@gerrit.asterisk.org>
Tue, 6 Jun 2017 11:57:24 +0000 (06:57 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Tue, 6 Jun 2017 11:57:24 +0000 (06:57 -0500)
1  2 
main/bridge_channel.c

diff --combined main/bridge_channel.c
@@@ -989,6 -989,11 +989,11 @@@ int ast_bridge_channel_queue_frame(stru
                /* Media frames need to be mapped to an appropriate write stream */
                dup->stream_num = AST_VECTOR_GET(
                        &bridge_channel->stream_map.to_bridge, fr->stream_num);
+               if (dup->stream_num == -1) {
+                       ast_bridge_channel_unlock(bridge_channel);
+                       bridge_frame_free(dup);
+                       return 0;
+               }
        } else {
                dup->stream_num = -1;
        }
@@@ -2101,7 -2106,7 +2106,7 @@@ void bridge_channel_internal_pull(struc
            && (ast_channel_is_leaving_bridge(bridge_channel->chan)
                || bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
                ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
 -              ast_clear_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_OUTGOING);
 +              ast_channel_clear_flag(bridge_channel->chan, AST_FLAG_OUTGOING);
        }
  
        bridge->reconfigured = 1;
@@@ -2339,7 -2344,9 +2344,9 @@@ static void bridge_channel_handle_write
        case AST_FRAME_NULL:
                break;
        default:
-               if (fr->stream_num >= (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
+               if (fr->stream_num > 0 &&
+                               (fr->stream_num >= (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel) ||
+                               AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num) == -1)) {
                        /* Nowhere to write to, so drop it */
                        break;
                }
@@@ -2473,11 -2480,11 +2480,11 @@@ static void bridge_handle_trip(struct a
                         * If a stream topology has changed then the bridge_channel's
                         * media mapping needs to be updated.
                         */
                        if (bridge_channel->bridge->technology->stream_topology_changed) {
                                bridge_channel->bridge->technology->stream_topology_changed(
                                        bridge_channel->bridge, bridge_channel);
+                       } else {
+                               ast_bridge_channel_stream_map(bridge_channel);
                        }
                        break;
                default: