diff options
Diffstat (limited to 'res/ari/resource_bridges.c')
-rw-r--r-- | res/ari/resource_bridges.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c index f5ae1c003..f243086c9 100644 --- a/res/ari/resource_bridges.c +++ b/res/ari/resource_bridges.c @@ -35,6 +35,7 @@ #include "asterisk/stasis.h" #include "asterisk/stasis_bridges.h" #include "asterisk/stasis_app.h" +#include "asterisk/stasis_app_impl.h" #include "asterisk/stasis_app_playback.h" #include "asterisk/stasis_app_recording.h" #include "asterisk/stasis_channels.h" @@ -1003,3 +1004,68 @@ void ast_ari_bridges_create_with_id(struct ast_variable *headers, ast_ari_response_ok(response, ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer())); } + +static int bridge_set_video_source_cb(struct stasis_app_control *control, + struct ast_channel *chan, void *data) +{ + struct ast_bridge *bridge = data; + + ast_bridge_lock(bridge); + ast_bridge_set_single_src_video_mode(bridge, chan); + ast_bridge_unlock(bridge); + + return 0; +} + +void ast_ari_bridges_set_video_source(struct ast_variable *headers, + struct ast_ari_bridges_set_video_source_args *args, struct ast_ari_response *response) +{ + struct ast_bridge *bridge; + struct stasis_app_control *control; + + bridge = find_bridge(response, args->bridge_id); + if (!bridge) { + return; + } + + control = find_channel_control(response, args->channel_id); + if (!control) { + ao2_ref(bridge, -1); + return; + } + + if (stasis_app_get_bridge(control) != bridge) { + ast_ari_response_error(response, 422, + "Unprocessable Entity", + "Channel not in this bridge"); + ao2_ref(bridge, -1); + ao2_ref(control, -1); + return; + } + + stasis_app_send_command(control, bridge_set_video_source_cb, + ao2_bump(bridge), __ao2_cleanup); + + ao2_ref(bridge, -1); + ao2_ref(control, -1); + + ast_ari_response_no_content(response); +} + +void ast_ari_bridges_clear_video_source(struct ast_variable *headers, + struct ast_ari_bridges_clear_video_source_args *args, struct ast_ari_response *response) +{ + struct ast_bridge *bridge; + + bridge = find_bridge(response, args->bridge_id); + if (!bridge) { + return; + } + + ast_bridge_lock(bridge); + ast_bridge_set_talker_src_video_mode(bridge); + ast_bridge_unlock(bridge); + + ao2_ref(bridge, -1); + ast_ari_response_no_content(response); +} |