aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapps/app_voicemail.c2
-rwxr-xr-xfile.c59
-rwxr-xr-xinclude/asterisk/file.h12
3 files changed, 72 insertions, 1 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 82150d9ee..0a95e5dd6 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1471,7 +1471,7 @@ forward_message(struct ast_channel *chan, struct ast_config *cfg, char *dir, int
#define WAITFILE(file) do { \
if (ast_streamfile(chan, file, chan->language)) \
ast_log(LOG_WARNING, "Unable to play message %s\n", file); \
- d = ast_waitstream(chan, AST_DIGIT_ANY); \
+ d = ast_waitstream_fr(chan, AST_DIGIT_ANY, "#", "*"); \
if (!d) { \
repeats = 0; \
goto instructions; \
diff --git a/file.c b/file.c
index a2e1efb17..fc4972c6e 100755
--- a/file.c
+++ b/file.c
@@ -659,6 +659,65 @@ char ast_waitstream(struct ast_channel *c, char *breakon)
return (c->_softhangup ? -1 : 0);
}
+char ast_waitstream_fr(struct ast_channel *c, char *breakon, char *forward, char *rewind)
+{
+ int res;
+ struct ast_frame *fr;
+ while(c->stream) {
+ res = ast_sched_wait(c->sched);
+ if (res < 0) {
+ ast_closestream(c->stream);
+ break;
+ }
+ res = ast_waitfor(c, res);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "Select failed (%s)\n", strerror(errno));
+ return res;
+ } else
+ if (res > 0) {
+ fr = ast_read(c);
+ if (!fr) {
+#if 0
+ ast_log(LOG_DEBUG, "Got hung up\n");
+#endif
+ return -1;
+ }
+
+ switch(fr->frametype) {
+ case AST_FRAME_DTMF:
+ res = fr->subclass;
+ if (strchr(forward,res)) {
+ ast_stream_fastforward(c->stream, 3000);
+ } else if (strchr(rewind,res)) {
+ ast_stream_rewind(c->stream, 3000);
+ } else if (strchr(breakon, res)) {
+ ast_frfree(fr);
+ return res;
+ }
+ break;
+ case AST_FRAME_CONTROL:
+ switch(fr->subclass) {
+ case AST_CONTROL_HANGUP:
+ ast_frfree(fr);
+ return -1;
+ case AST_CONTROL_RINGING:
+ case AST_CONTROL_ANSWER:
+ /* Unimportant */
+ break;
+ default:
+ ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass);
+ }
+ }
+ /* Ignore */
+ ast_frfree(fr);
+ } else
+ ast_sched_runq(c->sched);
+
+
+ }
+ return (c->_softhangup ? -1 : 0);
+}
+
char ast_waitstream_full(struct ast_channel *c, char *breakon, int audiofd, int cmdfd)
{
int res;
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index e7f19825d..45b947b9b 100755
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -123,6 +123,18 @@ int ast_filecopy(char *oldname, char *newname, char *fmt);
*/
char ast_waitstream(struct ast_channel *c, char *breakon);
+//! Same as waitstream but allows stream to be forwarded or rewound
+/*!
+ * \param c channel to waitstram on
+ * \param breakon string of DTMF digits to break upon
+ * \param forward DTMF digit to fast forward upon
+ * \param rewind DTMF digit to rewind upon
+ * Begins playback of a stream...
+ * Wait for a stream to stop or for any one of a given digit to arrive, Returns 0
+ * if the stream finishes, the character if it was interrupted, and -1 on error
+ */
+char ast_waitstream_fr(struct ast_channel *c, char *breakon, char *forward, char *rewind);
+
/* Same as waitstream, but with audio output to fd and monitored fd checking. Returns
1 if monfd is ready for reading */
char ast_waitstream_full(struct ast_channel *c, char *breakon, int audiofd, int monfd);