summaryrefslogtreecommitdiff
path: root/apps/app_externalivr.c
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2012-05-08 21:46:21 +0000
committerSean Bright <sean@malleable.com>2012-05-08 21:46:21 +0000
commitc8945a4070419392af7a0ae3283585fb7c491a0e (patch)
treef6cd0a795c2c3510552b5f9f532ddfead16bbd3e /apps/app_externalivr.c
parentb1a94ddcdd7d787dae5a02c865c0473f997605bc (diff)
Add interrupt ('I') command to ExternalIVR.
Sending the 'I' command from an external process will cause the current playlist to be cleared, including stopping any audio file that is currently playing. This is useful when you want to interrupt audio playback only when specific DTMF is entered by the caller. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@365751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_externalivr.c')
-rw-r--r--apps/app_externalivr.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 036bbeeef..07fbcba01 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -105,6 +105,7 @@ static const char app[] = "ExternalIVR";
#define EIVR_CMD_EXIT 'E' /* exit */
#define EIVR_CMD_GET 'G' /* get channel varable(s) */
#define EIVR_CMD_HGUP 'H' /* hangup */
+#define EIVR_CMD_IRPT 'I' /* interrupt */
#define EIVR_CMD_LOG 'L' /* log message */
#define EIVR_CMD_OPT 'O' /* option */
#define EIVR_CMD_PARM 'P' /* return supplied params */
@@ -761,6 +762,28 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
u->gen_active = 1;
}
}
+ } else if (input[0] == EIVR_CMD_IRPT) {
+ if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
+ ast_chan_log(LOG_WARNING, chan, "Queue 'I'nterrupt called on unanswered channel\n");
+ send_eivr_event(eivr_events, 'Z', NULL, chan);
+ continue;
+ }
+ AST_LIST_LOCK(&u->playlist);
+ if (!u->abort_current_sound && !u->playing_silence) {
+ /* send interrupted file as T data */
+ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
+ send_eivr_event(eivr_events, 'T', entry->filename, chan);
+ ast_free(entry);
+ }
+ }
+ while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
+ send_eivr_event(eivr_events, 'D', entry->filename, chan);
+ ast_free(entry);
+ }
+ if (!u->playing_silence) {
+ u->abort_current_sound = 1;
+ }
+ AST_LIST_UNLOCK(&u->playlist);
} else if (input[0] == EIVR_CMD_SQUE) {
if (ast_channel_state(chan) != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue re'S'et called on unanswered channel\n");