Allow playback for multiple files (bug #3749)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5157 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
41f4391d2b
commit
d515962bfb
|
@ -3,9 +3,9 @@
|
||||||
*
|
*
|
||||||
* Trivial application to playback a sound file
|
* Trivial application to playback a sound file
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999, Mark Spencer
|
* Copyright (C) 1999-2005, Mark Spencer
|
||||||
*
|
*
|
||||||
* Mark Spencer <markster@linux-support.net>
|
* Mark Spencer <markster@digium.com>
|
||||||
*
|
*
|
||||||
* This program is free software, distributed under the terms of
|
* This program is free software, distributed under the terms of
|
||||||
* the GNU General Public License
|
* the GNU General Public License
|
||||||
|
@ -22,14 +22,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static char *tdesc = "Trivial Playback Application";
|
static char *tdesc = "Sound File Playback Application";
|
||||||
|
|
||||||
static char *app = "Playback";
|
static char *app = "Playback";
|
||||||
|
|
||||||
static char *synopsis = "Play a file";
|
static char *synopsis = "Play a file";
|
||||||
|
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
" Playback(filename[|option]): Plays back a given filename (do not put\n"
|
" Playback(filename[&filename2...][|option]): Plays back given filenames (do not put\n"
|
||||||
"extension). Options may also be included following a pipe symbol. The 'skip'\n"
|
"extension). Options may also be included following a pipe symbol. The 'skip'\n"
|
||||||
"option causes the playback of the message to be skipped if the channel\n"
|
"option causes the playback of the message to be skipped if the channel\n"
|
||||||
"is not in the 'up' state (i.e. it hasn't been answered yet. If 'skip' is \n"
|
"is not in the 'up' state (i.e. it hasn't been answered yet. If 'skip' is \n"
|
||||||
|
@ -47,17 +47,17 @@ static int playback_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char tmp[256];
|
char *tmp = NULL;
|
||||||
char *options;
|
char *options = NULL;
|
||||||
int option_skip=0;
|
int option_skip=0;
|
||||||
int option_noanswer = 0;
|
int option_noanswer = 0;
|
||||||
char *stringp;
|
char *stringp = NULL;
|
||||||
if (!data || ast_strlen_zero((char *)data)) {
|
char *front = NULL, *back = NULL;
|
||||||
|
if (!data || ast_strlen_zero((char *)data) || !(tmp = ast_strdupa(data))) {
|
||||||
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
|
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strncpy(tmp, (char *)data, sizeof(tmp)-1);
|
stringp = tmp;
|
||||||
stringp=tmp;
|
|
||||||
strsep(&stringp, "|");
|
strsep(&stringp, "|");
|
||||||
options = strsep(&stringp, "|");
|
options = strsep(&stringp, "|");
|
||||||
if (options && !strcasecmp(options, "skip"))
|
if (options && !strcasecmp(options, "skip"))
|
||||||
|
@ -76,16 +76,24 @@ static int playback_exec(struct ast_channel *chan, void *data)
|
||||||
}
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
res = ast_streamfile(chan, tmp, chan->language);
|
front = tmp;
|
||||||
if (!res)
|
while (!res && front) {
|
||||||
res = ast_waitstream(chan, "");
|
if ((back = strchr(front, '&'))) {
|
||||||
else {
|
*back = '\0';
|
||||||
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
|
back++;
|
||||||
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
|
}
|
||||||
chan->priority+=100;
|
res = ast_streamfile(chan, front, chan->language);
|
||||||
res = 0;
|
if (!res) {
|
||||||
|
res = ast_waitstream(chan, "");
|
||||||
|
ast_stopstream(chan);
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
|
||||||
|
if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
|
||||||
|
chan->priority+=100;
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
front = back;
|
||||||
}
|
}
|
||||||
ast_stopstream(chan);
|
|
||||||
}
|
}
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
return res;
|
return res;
|
||||||
|
|
Reference in New Issue