diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-08 21:02:46 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-08 21:02:46 +0000 |
commit | aae89d91628f6d3e2191d8578461a826f76fc846 (patch) | |
tree | 9980f4b3704ece77e3b9166bc57e0a5e33c971c6 /main | |
parent | 809ba665791d0a64139cdc2b588bac4a039b49ca (diff) |
Add an option for ControlPlayback to be able to start at an offset from
the beginning of the file. Also, add a channel variable that indicates
the location in the file where the Playback was stopped.
(closes issue #7655, patch from sharkey)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@68502 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/main/app.c b/main/app.c index b3fd264f1..22a29218e 100644 --- a/main/app.c +++ b/main/app.c @@ -395,13 +395,17 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, - const char *restart, int skipms) + const char *restart, int skipms, long *offsetms) { char *breaks = NULL; char *end = NULL; int blen = 2; int res; long pause_restart_point = 0; + long offset = 0; + + if (offsetms) + offset = *offsetms * 8; /* XXX Assumes 8kHz */ if (stop) blen += strlen(stop); @@ -440,9 +444,18 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file, ast_seekstream(chan->stream, pause_restart_point, SEEK_SET); pause_restart_point = 0; } - else if (end) { - ast_seekstream(chan->stream, 0, SEEK_END); + else if (end || offset < 0) { + if (offset == -8) + offset = 0; + ast_verbose(VERBOSE_PREFIX_3 "ControlPlayback seek to offset %ld from end\n", offset); + + ast_seekstream(chan->stream, offset, SEEK_END); end = NULL; + offset = 0; + } else if (offset) { + ast_verbose(VERBOSE_PREFIX_3 "ControlPlayback seek to offset %ld\n", offset); + ast_seekstream(chan->stream, offset, SEEK_SET); + offset = 0; }; res = ast_waitstream_fr(chan, breaks, fwd, rev, skipms); } @@ -482,6 +495,19 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file, break; } + if (pause_restart_point) { + offset = pause_restart_point; + } else { + if (chan->stream) { + offset = ast_tellstream(chan->stream); + } else { + offset = -8; /* indicate end of file */ + } + } + + if (offsetms) + *offsetms = offset / 8; /* samples --> ms ... XXX Assumes 8 kHz */ + ast_stopstream(chan); return res; |