Janitor project, app_controlplayback (bug #5610)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6971 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-11-06 05:03:14 +00:00
parent 535ed63c6f
commit b721635619

View File

@@ -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);