summaryrefslogtreecommitdiff
path: root/res/stasis
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-11-21 15:56:34 +0000
committerDavid M. Lee <dlee@digium.com>2013-11-21 15:56:34 +0000
commitd1ad4a95f8967cc407d828af258c772aa69ab6e3 (patch)
tree9dfcb189d4df7d2de758537463a09224722a5519 /res/stasis
parent71612fb0077b3d22895342fdd12beae4862b53ca (diff)
ari: Add silence generator controls
This patch adds the ability to start a silence generator on a channel via ARI. This generator will play silence on the channel (avoiding audio timeouts on the peer) until it is stopped, or some other media operation is started (like playing media, starting music on hold, etc.). (closes issue ASTERISK-22514) Review: https://reviewboard.asterisk.org/r/3019/ ........ Merged revisions 402926 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402928 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/stasis')
-rw-r--r--res/stasis/control.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/res/stasis/control.c b/res/stasis/control.c
index 868aff5ea..1c4f93862 100644
--- a/res/stasis/control.c
+++ b/res/stasis/control.c
@@ -59,6 +59,10 @@ struct stasis_app_control {
*/
struct ast_pbx *pbx;
/*!
+ * Silence generator, when silence is being generated.
+ */
+ struct ast_silence_generator *silgen;
+ /*!
* When set, /c app_stasis should exit and continue in the dialplan.
*/
int is_done:1;
@@ -68,6 +72,10 @@ static void control_dtor(void *obj)
{
struct stasis_app_control *control = obj;
+ /* We may have a lingering silence generator; free it */
+ ast_channel_stop_silence_generator(control->channel, control->silgen);
+ control->silgen = NULL;
+
ao2_cleanup(control->command_queue);
ast_cond_destroy(&control->wait_cond);
}
@@ -502,6 +510,55 @@ void stasis_app_control_moh_stop(struct stasis_app_control *control)
stasis_app_send_command_async(control, app_control_moh_stop, NULL);
}
+static void *app_control_silence_start(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ if (control->silgen) {
+ /* We have a silence generator, but it may have been implicitly
+ * disabled by media actions (music on hold, playing media,
+ * etc.) Just stop it and restart a new one.
+ */
+ ast_channel_stop_silence_generator(
+ control->channel, control->silgen);
+ }
+
+ ast_debug(3, "%s: Starting silence generator\n",
+ stasis_app_control_get_channel_id(control));
+ control->silgen = ast_channel_start_silence_generator(control->channel);
+
+ if (!control->silgen) {
+ ast_log(LOG_WARNING,
+ "%s: Failed to start silence generator.\n",
+ stasis_app_control_get_channel_id(control));
+ }
+
+ return NULL;
+}
+
+void stasis_app_control_silence_start(struct stasis_app_control *control)
+{
+ stasis_app_send_command_async(control, app_control_silence_start, NULL);
+}
+
+static void *app_control_silence_stop(struct stasis_app_control *control,
+ struct ast_channel *chan, void *data)
+{
+ if (control->silgen) {
+ ast_debug(3, "%s: Stopping silence generator\n",
+ stasis_app_control_get_channel_id(control));
+ ast_channel_stop_silence_generator(
+ control->channel, control->silgen);
+ control->silgen = NULL;
+ }
+
+ return NULL;
+}
+
+void stasis_app_control_silence_stop(struct stasis_app_control *control)
+{
+ stasis_app_send_command_async(control, app_control_silence_stop, NULL);
+}
+
struct ast_channel_snapshot *stasis_app_control_get_snapshot(
const struct stasis_app_control *control)
{