[Asterisk-cvs] asterisk/res res_agi.c,1.46,1.47

kpfleming kpfleming
Mon Aug 22 17:57:19 CDT 2005


Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv9764/res

Modified Files:
	res_agi.c 
Log Message:
add CONTROL STREAM FILE AGI command (issue #4738)


Index: res_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_agi.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- res_agi.c	15 Aug 2005 02:45:34 -0000	1.46
+++ res_agi.c	22 Aug 2005 21:59:24 -0000	1.47
@@ -461,6 +461,51 @@
 		return RESULT_FAILURE;
 }
 
+static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+{
+	int res = 0;
+	int skipms = 3000;
+	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, NULL, 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;
@@ -1407,6 +1452,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 <filename> <escape digits> [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 <filename> <escape_digits> [timeout]\n"
 "	Behaves similar to STREAM FILE but used with a timeout option.\n";
@@ -1540,6 +1595,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 },




More information about the svn-commits mailing list