summaryrefslogtreecommitdiff
path: root/res/ari/resource_channels.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2013-11-01 14:38:21 +0000
committerJoshua Colp <jcolp@digium.com>2013-11-01 14:38:21 +0000
commit7678fd040e95205b040d5d7393165990e51462f6 (patch)
tree7043c0056e8facf9bf0b509ac1254ba5ba25bb78 /res/ari/resource_channels.c
parent98dea21bc14a16831710beaadb3b859b7b7a0637 (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/ari/resource_channels.c')
-rw-r--r--res/ari/resource_channels.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index 10d190534..482e4baa7 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -40,6 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/stasis_app_playback.h"
#include "asterisk/stasis_app_recording.h"
#include "asterisk/stasis_channels.h"
+#include "asterisk/causes.h"
#include "resource_channels.h"
#include <limits.h>
@@ -123,6 +124,22 @@ void ast_ari_answer_channel(struct ast_variable *headers,
ast_ari_response_no_content(response);
}
+void ast_ari_ring_channel(struct ast_variable *headers,
+ struct ast_ring_channel_args *args,
+ struct ast_ari_response *response)
+{
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ stasis_app_control_ring(control);
+
+ ast_ari_response_no_content(response);
+}
+
void ast_ari_mute_channel(struct ast_variable *headers, struct ast_mute_channel_args *args, struct ast_ari_response *response)
{
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -195,6 +212,27 @@ void ast_ari_unmute_channel(struct ast_variable *headers, struct ast_unmute_chan
ast_ari_response_no_content(response);
}
+void ast_ari_send_dtmfchannel(struct ast_variable *headers, struct ast_send_dtmfchannel_args *args, struct ast_ari_response *response)
+{
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ if (ast_strlen_zero(args->dtmf)) {
+ ast_ari_response_error(
+ response, 400, "Bad Request",
+ "DTMF is required");
+ return;
+ }
+
+ stasis_app_control_dtmf(control, args->dtmf, args->before, args->between, args->duration, args->after);
+
+ ast_ari_response_no_content(response);
+}
+
void ast_ari_hold_channel(struct ast_variable *headers, struct ast_hold_channel_args *args, struct ast_ari_response *response)
{
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
@@ -501,6 +539,7 @@ void ast_ari_delete_channel(struct ast_variable *headers,
struct ast_ari_response *response)
{
RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
+ int cause;
chan = ast_channel_get_by_name(args->channel_id);
if (chan == NULL) {
@@ -510,6 +549,20 @@ void ast_ari_delete_channel(struct ast_variable *headers,
return;
}
+ if (ast_strlen_zero(args->reason) || !strcmp(args->reason, "normal")) {
+ cause = AST_CAUSE_NORMAL;
+ } else if (!strcmp(args->reason, "busy")) {
+ cause = AST_CAUSE_BUSY;
+ } else if (!strcmp(args->reason, "congestion")) {
+ cause = AST_CAUSE_CONGESTION;
+ } else {
+ ast_ari_response_error(
+ response, 400, "Invalid Reason",
+ "Invalid reason for hangup provided");
+ return;
+ }
+
+ ast_channel_hangupcause_set(chan, cause);
ast_softhangup(chan, AST_SOFTHANGUP_EXPLICIT);
ast_ari_response_no_content(response);