2 * Asterisk -- A telephony toolkit for Linux.
4 * Trivial application to control playback a sound file
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #include <asterisk/lock.h>
15 #include <asterisk/file.h>
16 #include <asterisk/logger.h>
17 #include <asterisk/channel.h>
18 #include <asterisk/pbx.h>
19 #include <asterisk/app.h>
20 #include <asterisk/module.h>
21 #include <asterisk/translate.h>
22 #include <asterisk/utils.h>
27 static char *tdesc = "Control Playback Application";
29 static char *app = "ControlPlayback";
31 static char *synopsis = "Play a file with fast forward and rewind";
33 static char *descrip =
34 " ControlPlayback(filename[|skipms][|endplay]): Plays back a given filename\n"
35 "(do not put extension). Options may also be included following a pipe symbol.\n"
36 "you can use * and # to rewind and fast forward the playback specified. If 'endplay' is.\n"
37 "added the file will terminate playback when 1 is pressed. Returns -1 if the channel\n"
38 "was hung up, or if the file does not exist. Returns 0 otherwise.\n";
44 static int controlplayback_exec(struct ast_channel *chan, void *data)
51 int option_endplay = 0;
52 if (!data || ast_strlen_zero((char *)data)) {
53 ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
56 strncpy(tmp, (char *)data, sizeof(tmp)-1);
57 if((skip=strchr(tmp,'|'))) {
60 if((endplay=strchr(skip,'|'))) {
63 if(!strcmp(endplay,"endplay")) {
76 if (chan->_state != AST_STATE_UP)
77 res = ast_answer(chan);
81 res = ast_control_streamfile(chan, tmp, "#", "*", skipms);
84 if(option_endplay && res == 49) {
94 int unload_module(void)
96 STANDARD_HANGUP_LOCALUSERS;
97 return ast_unregister_application(app);
100 int load_module(void)
102 return ast_register_application(app, controlplayback_exec, synopsis, descrip);
105 char *description(void)
113 STANDARD_USECOUNT(res);
119 return ASTERISK_GPL_KEY;