summaryrefslogtreecommitdiff
path: root/res/stasis/control.c
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2013-07-18 16:03:12 +0000
committerJason Parker <jparker@digium.com>2013-07-18 16:03:12 +0000
commitc1a7567d24a08377438837ed26b1f8a886867c10 (patch)
tree4e137b98205c9c96b590b3707ec81c69df84f96b /res/stasis/control.c
parent3a2a12ca1ad8097482fe621e8b877db682601905 (diff)
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
Diffstat (limited to 'res/stasis/control.c')
-rw-r--r--res/stasis/control.c60
1 files changed, 60 insertions, 0 deletions
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);