# # patch "app.c" # from [2b482091da7e544199cdde13405ba3208d346dd5] # to [15802e3e951bf2c6618a393e5d3fab45f73cdfc4] # # patch "res/res_agi.c" # from [f10428af1545961ad59af8fabad7fc896c287d66] # to [093d9e35be33e2cab99141247ac0a07dc7cf7ba7] # --- app.c +++ app.c @@ -422,8 +422,10 @@ 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 (chan->_state != AST_STATE_UP) res = ast_answer(chan); --- res/res_agi.c +++ res/res_agi.c @@ -452,6 +452,52 @@ return RESULT_FAILURE; } +static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) +{ + int res = 0; + int skipms = 3000; + char *skip = NULL; + char *fwd = NULL; + char *rev = NULL; + char *pause = NULL; + char *stop = NULL; + + if (argc < 5 || argc > 9) + return RESULT_SHOWUSAGE; + + if (!ast_strlen_zero(argv[4])) + stop = argv[4]; + else + stop = NULL; + + if ((argc > 5) && (sscanf(argv[5], "%d", &skipms) != 1)) + return RESULT_SHOWUSAGE; + + if (argc > 6 && !ast_strlen_zero(argv[8])) + fwd = argv[6]; + else + fwd = "#"; + + if (argc > 7 && !ast_strlen_zero(argv[8])) + rev = argv[7]; + else + rev = "*"; + + if (argc > 8 && !ast_strlen_zero(argv[8])) + pause = argv[8]; + else + pause = NULL; + + res = ast_control_streamfile(chan, argv[3], fwd, rev, stop, pause, skipms); + + fdprintf(agi->fd, "200 result=%d\n", res); + + if (res >= 0) + return RESULT_SUCCESS; + else + return RESULT_FAILURE; +} + static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[]) { int res; @@ -1398,6 +1444,16 @@ " or -1 on error or if the channel was disconnected. Remember, the file\n" " extension must not be included in the filename.\n"; +static char usage_controlstreamfile[] = +" Usage: CONTROL STREAM FILE [skipms] [ffchar] [rewchr] [pausechr]\n" +" Send the given file, allowing playback to be controled by the given\n" +" digits, if any. Use double quotes for the digits if you wish none to be\n" +" permitted. Returns 0 if playback completes without a digit\n" +" being pressed, or the ASCII numerical value of the digit if one was pressed,\n" +" or -1 on error or if the channel was disconnected. Remember, the file\n" +" extension must not be included in the filename.\n\n" +" Note: ffchar and rewchar default to * and # respectively.\n"; + static char usage_getoption[] = " Usage: GET OPTION [timeout]\n" " Behaves similar to STREAM FILE but used with a timeout option.\n"; @@ -1531,6 +1587,7 @@ { { "set", "priority", NULL }, handle_setpriority, "Set channel dialplan priority", usage_setpriority }, { { "set", "variable", NULL }, handle_setvariable, "Sets a channel variable", usage_setvariable }, { { "stream", "file", NULL }, handle_streamfile, "Sends audio file on channel", usage_streamfile }, + { { "control", "stream", "file", NULL }, handle_controlstreamfile, "Sends audio file on channel and allows the listner to control the stream", usage_controlstreamfile }, { { "tdd", "mode", NULL }, handle_tddmode, "Toggles TDD mode (for the deaf)", usage_tddmode }, { { "verbose", NULL }, handle_verbose, "Logs a message to the asterisk verbose log", usage_verbose }, { { "wait", "for", "digit", NULL }, handle_waitfordigit, "Waits for a digit to be pressed", usage_waitfordigit },