diff options
author | Joshua Colp <jcolp@digium.com> | 2013-11-01 14:38:21 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2013-11-01 14:38:21 +0000 |
commit | 7678fd040e95205b040d5d7393165990e51462f6 (patch) | |
tree | 7043c0056e8facf9bf0b509ac1254ba5ba25bb78 /res/stasis | |
parent | 98dea21bc14a16831710beaadb3b859b7b7a0637 (diff) |
res_ari_channels: Add ring operation, dtmf operation, hangup reasons, and tweak early media.
The ring operation sends ringing to the specified channel it is invoked on.
The dtmf operation can be used to send DTMF digits to the specified channel
of a specific length with a wait time in between. Finally hangup reasons
allow you to specify why a channel is being hung up (busy, congestion).
Early media behavior has also been tweaked slightly. When playing media to a channel
it will no longer automatically answer. If it has not been answered a progress indication
is sent instead.
(closes issue ASTERISK-22701)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2916/
........
Merged revisions 402358 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402359 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/stasis')
-rw-r--r-- | res/stasis/control.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/res/stasis/control.c b/res/stasis/control.c index 8a77deae4..6c61df061 100644 --- a/res/stasis/control.c +++ b/res/stasis/control.c @@ -38,6 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/frame.h" #include "asterisk/pbx.h" #include "asterisk/musiconhold.h" +#include "asterisk/app.h" struct stasis_app_control { ast_cond_t wait_cond; @@ -280,6 +281,66 @@ int stasis_app_control_continue(struct stasis_app_control *control, const char * return 0; } +struct stasis_app_control_dtmf_data { + int before; + int between; + unsigned int duration; + int after; + char dtmf[]; +}; + +static void *app_control_dtmf(struct stasis_app_control *control, + struct ast_channel *chan, void *data) +{ + RAII_VAR(struct stasis_app_control_dtmf_data *, dtmf_data, data, ast_free); + + if (dtmf_data->before) { + ast_safe_sleep(chan, dtmf_data->before); + } + + ast_dtmf_stream(chan, NULL, dtmf_data->dtmf, dtmf_data->between, dtmf_data->duration); + + if (dtmf_data->after) { + ast_safe_sleep(chan, dtmf_data->after); + } + + return NULL; +} + +int stasis_app_control_dtmf(struct stasis_app_control *control, const char *dtmf, int before, int between, unsigned int duration, int after) +{ + struct stasis_app_control_dtmf_data *dtmf_data; + + if (!(dtmf_data = ast_calloc(1, sizeof(*dtmf_data) + strlen(dtmf) + 1))) { + return -1; + } + + dtmf_data->before = before; + dtmf_data->between = between; + dtmf_data->duration = duration; + dtmf_data->after = after; + strcpy(dtmf_data->dtmf, dtmf); + + stasis_app_send_command_async(control, app_control_dtmf, dtmf_data); + + return 0; +} + +static void *app_control_ring(struct stasis_app_control *control, + struct ast_channel *chan, void *data) +{ + ast_indicate(control->channel, AST_CONTROL_RINGING); + + return NULL; +} + +int stasis_app_control_ring(struct stasis_app_control *control) +{ + stasis_app_send_command_async(control, app_control_ring, NULL); + + return 0; +} + struct stasis_app_control_mute_data { enum ast_frame_type frametype; unsigned int direction; |