From c1a7567d24a08377438837ed26b1f8a886867c10 Mon Sep 17 00:00:00 2001 From: Jason Parker Date: Thu, 18 Jul 2013 16:03:12 +0000 Subject: ARI: Add support for suppressing media streams. Also convert res_mutestream to use the core feature behind this. (closes issue ASTERISK-21618) Review: https://reviewboard.asterisk.org/r/2652/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@394715 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/stasis/control.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'res/stasis') diff --git a/res/stasis/control.c b/res/stasis/control.c index 1fdcb8ded..df57a90a7 100644 --- a/res/stasis/control.c +++ b/res/stasis/control.c @@ -35,6 +35,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/bridging.h" #include "asterisk/bridging_basic.h" #include "asterisk/bridging_features.h" +#include "asterisk/frame.h" #include "asterisk/pbx.h" struct stasis_app_control { @@ -207,6 +208,65 @@ int stasis_app_control_continue(struct stasis_app_control *control, const char * return 0; } +struct stasis_app_control_mute_data { + enum ast_frame_type frametype; + unsigned int direction; +}; + +static void *app_control_mute(struct stasis_app_control *control, + struct ast_channel *chan, void *data) +{ + RAII_VAR(struct stasis_app_control_mute_data *, mute_data, data, ast_free); + SCOPED_CHANNELLOCK(lockvar, chan); + + ast_channel_suppress(control->channel, mute_data->direction, mute_data->frametype); + + return NULL; +} + +int stasis_app_control_mute(struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype) +{ + struct stasis_app_control_mute_data *mute_data; + + if (!(mute_data = ast_calloc(1, sizeof(*mute_data)))) { + return -1; + } + + mute_data->direction = direction; + mute_data->frametype = frametype; + + stasis_app_send_command_async(control, app_control_mute, mute_data); + + return 0; +} + +static void *app_control_unmute(struct stasis_app_control *control, + struct ast_channel *chan, void *data) +{ + RAII_VAR(struct stasis_app_control_mute_data *, mute_data, data, ast_free); + SCOPED_CHANNELLOCK(lockvar, chan); + + ast_channel_unsuppress(control->channel, mute_data->direction, mute_data->frametype); + + return NULL; +} + +int stasis_app_control_unmute(struct stasis_app_control *control, unsigned int direction, enum ast_frame_type frametype) +{ + struct stasis_app_control_mute_data *mute_data; + + if (!(mute_data = ast_calloc(1, sizeof(*mute_data)))) { + return -1; + } + + mute_data->direction = direction; + mute_data->frametype = frametype; + + stasis_app_send_command_async(control, app_control_unmute, mute_data); + + return 0; +} + char *stasis_app_control_get_channel_var(struct stasis_app_control *control, const char *variable) { RAII_VAR(struct ast_str *, tmp, ast_str_create(32), ast_free); -- cgit v1.2.3