Index: app.c =================================================================== RCS file: /usr/cvsroot/asterisk/app.c,v retrieving revision 1.68 diff -u -r1.68 app.c --- app.c 9 Jun 2005 19:27:19 -0000 1.68 +++ app.c 13 Jul 2005 03:37:12 -0000 @@ -406,7 +406,7 @@ return res; } -int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, int skipms) +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) { struct timeval started, ended; long elapsed = 0,last_elapsed =0; @@ -419,12 +419,18 @@ blen += strlen(stop); if (pause) blen += strlen(pause); + if (restart) + blen += strlen(restart); if (blen > 2) { breaks = alloca(blen + 1); breaks[0] = '\0'; - strcat(breaks, stop); - strcat(breaks, pause); + if (stop) + strcat(breaks, stop); + if (pause) + strcat(breaks, pause); + if (restart) + strcat(breaks, restart); } if (chan->_state != AST_STATE_UP) res = ast_answer(chan); @@ -466,6 +472,13 @@ if (res < 1) break; + + /* We go at next loop if we got the restart char */ + if (restart && strchr(restart, res)) { + ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); + elapsed=0; /* To make sure the next stream will start at beginning */ + continue; + } if (pause != NULL && strchr(pause, res)) { gettimeofday(&ended, NULL); Index: include/asterisk/app.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/app.h,v retrieving revision 1.35 diff -u -r1.35 app.h --- include/asterisk/app.h 4 May 2005 03:43:10 -0000 1.35 +++ include/asterisk/app.h 13 Jul 2005 03:38:26 -0000 @@ -124,8 +124,8 @@ /*! Stream a filename (or file descriptor) as a generator. */ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride); -/*! Stream a file with fast forward, pause, reverse. */ -int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, int skipms); +/*! Stream a file with fast forward, pause, reverse, restart. */ +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); /*! Play a stream and wait for a digit, returning the digit that was pressed */ int ast_play_and_wait(struct ast_channel *chan, const char *fn); Index: apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.222 diff -u -r1.222 app_voicemail.c --- apps/app_voicemail.c 11 Jul 2005 23:13:11 -0000 1.222 +++ apps/app_voicemail.c 13 Jul 2005 03:38:41 -0000 @@ -3179,7 +3179,7 @@ static int wait_file(struct ast_channel *chan, struct vm_state *vms, char *file) { - return ast_control_streamfile(chan, file, "#", "*", "1456789", "0", skipms); + return ast_control_streamfile(chan, file, "#", "*", "1456789", "0", "2", skipms); } static int play_message_category(struct ast_channel *chan, char *category) Index: apps/app_controlplayback.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_controlplayback.c,v retrieving revision 1.11 diff -u -r1.11 app_controlplayback.c --- apps/app_controlplayback.c 6 Jun 2005 22:39:31 -0000 1.11 +++ apps/app_controlplayback.c 13 Jul 2005 03:40:40 -0000 @@ -35,13 +35,14 @@ static char *synopsis = "Play a file with fast forward and rewind"; static char *descrip = -"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechr]]]]]):\n" +"ControlPlayback(filename[|skipms[|ffchar[|rewchar[|stopchar[|pausechar[|restartchar]]]]]]):\n" " Plays back a given filename (do not put extension). Options may also\n" " be included following a pipe symbol. You can use * and # to rewind and\n" " fast forward the playback specified. If 'stopchar' is added the file will\n" -" terminate playback when 'stopchar' is pressed. Returns -1 if the channel\n" +" terminate playback when 'stopchar' is pressed. If 'restartchar' is added, the file \n" +" will restart when 'restartchar' is pressed. Returns -1 if the channel\n" " was hung up. if the file does not exist jumps to n+101 if it present.\n\n" -" Example: exten => 1234,1,ControlPlayback(file|4000|*|#|1|0)\n\n"; +" Example: exten => 1234,1,ControlPlayback(file|4000|*|#|1|0|5)\n\n"; STANDARD_LOCAL_USER; @@ -58,7 +59,7 @@ int skipms = 0; struct localuser *u; char tmp[256]; - char *skip = NULL, *fwd = NULL, *rev = NULL, *stop = NULL, *pause = NULL, *file = NULL; + char *skip = NULL, *fwd = NULL, *rev = NULL, *stop = NULL, *pause = NULL, *file = NULL, *restart = NULL; if (!data || ast_strlen_zero((char *)data)) { @@ -83,6 +84,10 @@ pause = strchr(stop,'|'); if (pause) { *pause++ = '\0'; + restart = strchr(pause,'|'); + if (restart) { + *restart++ = '\0'; + } } } } @@ -101,10 +106,12 @@ stop = NULL; if (pause && !is_on_phonepad(*pause)) pause = NULL; + if (restart && !is_on_phonepad(*restart)) + restart = NULL; LOCAL_USER_ADD(u); - res = ast_control_streamfile(chan, file, fwd, rev, stop, pause, skipms); + res = ast_control_streamfile(chan, file, fwd, rev, stop, pause, restart, skipms); LOCAL_USER_REMOVE(u); @@ -114,7 +121,7 @@ if(res < 0) { if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) - chan->priority+=100; + chan->priority+=100; res = 0; } return res;