From a8a2d6ef0db455eb27769895ff749155707c8210 Mon Sep 17 00:00:00 2001 From: markster Date: Sun, 6 Nov 2005 05:03:14 +0000 Subject: Janitor project, app_controlplayback (bug #5610) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6971 f38db490-d61c-443f-a65b-d21fe96a405b --- apps/app_controlplayback.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'apps/app_controlplayback.c') diff --git a/apps/app_controlplayback.c b/apps/app_controlplayback.c index 0c56c926f..5fabc51f4 100755 --- a/apps/app_controlplayback.c +++ b/apps/app_controlplayback.c @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/module.h" #include "asterisk/translate.h" #include "asterisk/utils.h" +#include "asterisk/options.h" static const char *tdesc = "Control Playback Application"; @@ -45,13 +46,18 @@ static const char *app = "ControlPlayback"; static const char *synopsis = "Play a file with fast forward and rewind"; static const char *descrip = -"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechar[|restartchar]]]]]]):\n" +"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechar[|restartchar[|option]]]]]]]):\n" " Plays back a given filename (do not put extension). Options may also\n" " be included following a pipe symbol. You can use * and # to rewind and\n" " fast forward the playback specified. If 'stopchar' is added the file will\n" " terminate playback when 'stopchar' is pressed. If 'restartchar' is added, the file\n" " will restart when 'restartchar' is pressed. Returns -1 if the channel\n" -" was hung up. if the file does not exist jumps to n+101 if it present.\n\n" +" was hung up. \n\n" +" The option string may contain zero or the following character:\n" +" 'j' -- jump to +101 priority if the file requested isn't found.\n" +" This application sets the following channel variable upon completion:\n" +" CPLAYBACKSTATUS The status of the attempt to add a queue member as a text string, one of\n" +" SUCCESS | USERSTOPPED | ERROR\n" " Example: exten => 1234,1,ControlPlayback(file|4000|*|#|1|0|5)\n\n"; STANDARD_LOCAL_USER; @@ -65,12 +71,12 @@ static int is_on_phonepad(char key) static int controlplayback_exec(struct ast_channel *chan, void *data) { - int res = 0; + int res = 0, priority_jump = 0; int skipms = 0; struct localuser *u; char *tmp; int argc; - char *argv[7]; + char *argv[8]; enum arg_ids { arg_file = 0, arg_skip = 1, @@ -79,6 +85,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data) arg_stop = 4, arg_pause = 5, arg_restart = 6, + options = 7, }; if (ast_strlen_zero(data)) { @@ -114,15 +121,28 @@ static int controlplayback_exec(struct ast_channel *chan, void *data) if (argv[arg_restart] && !is_on_phonepad(*argv[arg_restart])) argv[arg_restart] = NULL; + if (argv[options]) { + if (strchr(argv[options], 'j')) + priority_jump = 1; + } + res = ast_control_streamfile(chan, argv[arg_file], argv[arg_fwd], argv[arg_rev], argv[arg_stop], argv[arg_pause], argv[arg_restart], skipms); /* If we stopped on one of our stop keys, return 0 */ - if (argv[arg_stop] && strchr(argv[arg_stop], res)) + if (argv[arg_stop] && strchr(argv[arg_stop], res)) { res = 0; - - if (res < 0) { - if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) + pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "USERSTOPPED"); + } else { + if (res < 0) { + if (priority_jump || option_priority_jumping) { + if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) { + ast_log(LOG_WARNING, "ControlPlayback tried to jump to priority n+101 as requested, but priority didn't exist\n"); + } + } res = 0; + pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "ERROR"); + } else + pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "SUCCESS"); } LOCAL_USER_REMOVE(u); -- cgit v1.2.3