Add the video stream for AGI function STREAM FILE (issue #5392 reported by areski -- minor mods by me)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@30547 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2006-05-26 17:43:11 +00:00
parent ec42807ebd
commit 1c158f0ea4

View File

@@ -537,7 +537,9 @@ static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc
static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{
int res;
int vres;
struct ast_filestream *fs;
struct ast_filestream *vfs;
long sample_offset = 0;
long max_length;
@@ -547,15 +549,25 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SHOWUSAGE;
fs = ast_openstream(chan, argv[2], chan->language);
if (!fs) {
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset);
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
if (vfs)
ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
ast_seekstream(fs, 0, SEEK_END);
max_length = ast_tellstream(fs);
ast_seekstream(fs, sample_offset, SEEK_SET);
res = ast_applystream(chan, fs);
if (vfs)
vres = ast_applystream(chan, vfs);
res = ast_playstream(fs);
if (vfs)
vres = ast_playstream(vfs);
if (res) {
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
return (res >= 0) ? RESULT_SHOWUSAGE : RESULT_FAILURE;
@@ -577,7 +589,9 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char
static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{
int res;
int vres;
struct ast_filestream *fs;
struct ast_filestream *vfs;
long sample_offset = 0;
long max_length;
int timeout = 0;
@@ -602,6 +616,10 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *
ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]);
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
if (vfs)
ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout);
@@ -609,7 +627,11 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *
max_length = ast_tellstream(fs);
ast_seekstream(fs, sample_offset, SEEK_SET);
res = ast_applystream(chan, fs);
if (vfs)
vres = ast_applystream(chan, vfs);
res = ast_playstream(fs);
if (vfs)
vres = ast_playstream(vfs);
if (res) {
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
if (res >= 0)