summaryrefslogtreecommitdiff
path: root/main/app.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-01-22 15:16:20 +0000
committerMatthew Jordan <mjordan@digium.com>2013-01-22 15:16:20 +0000
commit7d9871b3940fa50e85039aef6a8fb9870a7615b9 (patch)
tree05484de8505feb85d1e304b8868a87e29c0ca9f5 /main/app.c
parent985ea8b2c96ff16b5cbe4cd102b9224e171b2984 (diff)
Add ControlPlayback manager action
This patch adds the capability for asynchronous manipulation of audio being played back to a channel though a new AMI action "ControlPlayback". The ControlPlayback action supports a number of operations, the availability of which depend on the application being used to send audio to the channel. When the audio playback was initiated using the ControlPlayback application or CONTROL STREAM FILE AGI command, the audio can be paused, stopped, restarted, reversed, or skipped forward. When initiated by other mechanisms (such as the Playback application), the audio can be stopped, reversed, or skipped forward. Review: https://reviewboard.asterisk.org/r/2265/ (closes issue ASTERISK-20882) Reported by: mjordan git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@379830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/app.c')
-rw-r--r--main/app.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/main/app.c b/main/app.c
index 208db4b83..6db65f371 100644
--- a/main/app.c
+++ b/main/app.c
@@ -1004,24 +1004,37 @@ static int control_streamfile(struct ast_channel *chan,
}
/* We go at next loop if we got the restart char */
- if (restart && strchr(restart, res)) {
+ if ((restart && strchr(restart, res)) || res == AST_CONTROL_STREAM_RESTART) {
ast_debug(1, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
+ ast_test_suite_event_notify("PLAYBACK","Channel: %s\r\n"
+ "Control: %s\r\n",
+ ast_channel_name(chan),
+ "Restart");
continue;
}
- if (suspend && strchr(suspend, res)) {
+ if ((suspend && strchr(suspend, res)) || res == AST_CONTROL_STREAM_SUSPEND) {
pause_restart_point = ast_tellstream(ast_channel_stream(chan));
+ ast_test_suite_event_notify("PLAYBACK","Channel: %s\r\n"
+ "Control: %s\r\n",
+ ast_channel_name(chan),
+ "Pause");
for (;;) {
ast_stopstream(chan);
if (!(res = ast_waitfordigit(chan, 1000))) {
continue;
- } else if (res == -1 || strchr(suspend, res) || (stop && strchr(stop, res))) {
+ } else if (res == -1 || (suspend && strchr(suspend, res)) || (stop && strchr(stop, res))
+ || res == AST_CONTROL_STREAM_SUSPEND || res == AST_CONTROL_STREAM_STOP) {
break;
}
}
- if (res == *suspend) {
+ if ((suspend && (res == *suspend)) || res == AST_CONTROL_STREAM_SUSPEND) {
res = 0;
+ ast_test_suite_event_notify("PLAYBACK","Channel: %s\r\n"
+ "Control: %s\r\n",
+ ast_channel_name(chan),
+ "Unpause");
continue;
}
}
@@ -1031,7 +1044,11 @@ static int control_streamfile(struct ast_channel *chan,
}
/* if we get one of our stop chars, return it to the calling function */
- if (stop && strchr(stop, res)) {
+ if ((stop && strchr(stop, res)) || res == AST_CONTROL_STREAM_STOP) {
+ ast_test_suite_event_notify("PLAYBACK","Channel: %s\r\n"
+ "Control: %s\r\n",
+ ast_channel_name(chan),
+ "Stop");
break;
}
}
@@ -1050,11 +1067,6 @@ static int control_streamfile(struct ast_channel *chan,
*offsetms = offset / 8; /* samples --> ms ... XXX Assumes 8 kHz */
}
- /* If we are returning a digit cast it as char */
- if (res > 0 || ast_channel_stream(chan)) {
- res = (char)res;
- }
-
ast_stopstream(chan);
return res;