Add the video stream for AGI function STREAM FILE (issue #5392 reported by areski -- minor mods by me)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@30547 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
328608aece
commit
cb0181db21
1 changed files with 56 additions and 34 deletions
|
@ -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[])
|
static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
int vres;
|
||||||
struct ast_filestream *fs;
|
struct ast_filestream *fs;
|
||||||
|
struct ast_filestream *vfs;
|
||||||
long sample_offset = 0;
|
long sample_offset = 0;
|
||||||
long max_length;
|
long max_length;
|
||||||
|
|
||||||
|
@ -547,15 +549,25 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
fs = ast_openstream(chan, argv[2], chan->language);
|
fs = ast_openstream(chan, argv[2], chan->language);
|
||||||
|
|
||||||
if (!fs) {
|
if (!fs) {
|
||||||
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset);
|
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", 0, sample_offset);
|
||||||
return RESULT_SUCCESS;
|
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);
|
ast_seekstream(fs, 0, SEEK_END);
|
||||||
max_length = ast_tellstream(fs);
|
max_length = ast_tellstream(fs);
|
||||||
ast_seekstream(fs, sample_offset, SEEK_SET);
|
ast_seekstream(fs, sample_offset, SEEK_SET);
|
||||||
res = ast_applystream(chan, fs);
|
res = ast_applystream(chan, fs);
|
||||||
|
if (vfs)
|
||||||
|
vres = ast_applystream(chan, vfs);
|
||||||
res = ast_playstream(fs);
|
res = ast_playstream(fs);
|
||||||
|
if (vfs)
|
||||||
|
vres = ast_playstream(vfs);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
|
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
|
||||||
return (res >= 0) ? RESULT_SHOWUSAGE : RESULT_FAILURE;
|
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[])
|
static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
int vres;
|
||||||
struct ast_filestream *fs;
|
struct ast_filestream *fs;
|
||||||
|
struct ast_filestream *vfs;
|
||||||
long sample_offset = 0;
|
long sample_offset = 0;
|
||||||
long max_length;
|
long max_length;
|
||||||
int timeout = 0;
|
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]);
|
ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]);
|
||||||
return RESULT_SUCCESS;
|
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)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout);
|
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);
|
max_length = ast_tellstream(fs);
|
||||||
ast_seekstream(fs, sample_offset, SEEK_SET);
|
ast_seekstream(fs, sample_offset, SEEK_SET);
|
||||||
res = ast_applystream(chan, fs);
|
res = ast_applystream(chan, fs);
|
||||||
|
if (vfs)
|
||||||
|
vres = ast_applystream(chan, vfs);
|
||||||
res = ast_playstream(fs);
|
res = ast_playstream(fs);
|
||||||
|
if (vfs)
|
||||||
|
vres = ast_playstream(vfs);
|
||||||
if (res) {
|
if (res) {
|
||||||
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
|
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
|
|
Reference in a new issue