Skip to content
Snippets Groups Projects
Commit 08ae164b authored by Tilghman Lesher's avatar Tilghman Lesher
Browse files

Add RECORD_STATUS variable, as requested on the -users list.

Patch by me (license 14)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@165397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 6c459b1b
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,15 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ...@@ -88,6 +88,15 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<variable name="RECORDED_FILE"> <variable name="RECORDED_FILE">
<para>Will be set to the final filename of the recording.</para> <para>Will be set to the final filename of the recording.</para>
</variable> </variable>
<variable name="RECORD_STATUS">
<para>This is the final status of the command</para>
<value name="DTMF"><para>A terminating DTMF was received ('#' or '*', depending upon option 't')</para></value>
<value name="SILENCE"><para>The maximum silence occurred in the recording.</para></value>
<value name="SKIP"><para>The line was not yet answered and the 's' option was specified.</para></value>
<value name="TIMEOUT"><para>The maximum length was reached.</para></value>
<value name="HANGUP"><para>The channel was hung up.</para></value>
<value name="ERROR"><para>An unrecoverable error occurred, which resulted in a WARNING to the logs.</para></value>
</variable>
</variablelist> </variablelist>
</description> </description>
</application> </application>
...@@ -150,6 +159,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -150,6 +159,7 @@ static int record_exec(struct ast_channel *chan, void *data)
/* The next few lines of code parse out the filename and header from the input string */ /* The next few lines of code parse out the filename and header from the input string */
if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */ if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
ast_log(LOG_WARNING, "Record requires an argument (filename)\n"); ast_log(LOG_WARNING, "Record requires an argument (filename)\n");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
return -1; return -1;
} }
...@@ -171,6 +181,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -171,6 +181,7 @@ static int record_exec(struct ast_channel *chan, void *data)
} }
if (!ext) { if (!ext) {
ast_log(LOG_WARNING, "No extension specified to filename!\n"); ast_log(LOG_WARNING, "No extension specified to filename!\n");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
return -1; return -1;
} }
if (args.silence) { if (args.silence) {
...@@ -237,6 +248,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -237,6 +248,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (chan->_state != AST_STATE_UP) { if (chan->_state != AST_STATE_UP) {
if (ast_test_flag(&flags, OPTION_SKIP)) { if (ast_test_flag(&flags, OPTION_SKIP)) {
/* At the user's option, skip if the line is not up */ /* At the user's option, skip if the line is not up */
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "SKIP");
return 0; return 0;
} else if (!ast_test_flag(&flags, OPTION_NOANSWER)) { } else if (!ast_test_flag(&flags, OPTION_NOANSWER)) {
/* Otherwise answer unless we're supposed to record while on-hook */ /* Otherwise answer unless we're supposed to record while on-hook */
...@@ -246,6 +258,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -246,6 +258,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (res) { if (res) {
ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name); ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
goto out; goto out;
} }
...@@ -267,11 +280,13 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -267,11 +280,13 @@ static int record_exec(struct ast_channel *chan, void *data)
res = ast_set_read_format(chan, AST_FORMAT_SLINEAR); res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
if (res < 0) { if (res < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n"); ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
return -1; return -1;
} }
sildet = ast_dsp_new(); sildet = ast_dsp_new();
if (!sildet) { if (!sildet) {
ast_log(LOG_WARNING, "Unable to create silence detector :(\n"); ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
return -1; return -1;
} }
ast_dsp_set_threshold(sildet, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE)); ast_dsp_set_threshold(sildet, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
...@@ -288,6 +303,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -288,6 +303,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (!s) { if (!s) {
ast_log(LOG_WARNING, "Could not create file %s\n", args.filename); ast_log(LOG_WARNING, "Could not create file %s\n", args.filename);
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
goto out; goto out;
} }
...@@ -304,6 +320,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -304,6 +320,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (maxduration > 0) { if (maxduration > 0) {
if (waitres == 0) { if (waitres == 0) {
gottimeout = 1; gottimeout = 1;
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "TIMEOUT");
break; break;
} }
maxduration = waitres; maxduration = waitres;
...@@ -320,6 +337,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -320,6 +337,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (res) { if (res) {
ast_log(LOG_WARNING, "Problem writing frame\n"); ast_log(LOG_WARNING, "Problem writing frame\n");
ast_frfree(f); ast_frfree(f);
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
break; break;
} }
...@@ -335,6 +353,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -335,6 +353,7 @@ static int record_exec(struct ast_channel *chan, void *data)
/* Ended happily with silence */ /* Ended happily with silence */
ast_frfree(f); ast_frfree(f);
gotsilence = 1; gotsilence = 1;
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "SILENCE");
break; break;
} }
} }
...@@ -343,12 +362,14 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -343,12 +362,14 @@ static int record_exec(struct ast_channel *chan, void *data)
if (res) { if (res) {
ast_log(LOG_WARNING, "Problem writing frame\n"); ast_log(LOG_WARNING, "Problem writing frame\n");
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
ast_frfree(f); ast_frfree(f);
break; break;
} }
} else if ((f->frametype == AST_FRAME_DTMF) && } else if ((f->frametype == AST_FRAME_DTMF) &&
(f->subclass == terminator)) { (f->subclass == terminator)) {
ast_frfree(f); ast_frfree(f);
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "DTMF");
break; break;
} }
ast_frfree(f); ast_frfree(f);
...@@ -356,6 +377,7 @@ static int record_exec(struct ast_channel *chan, void *data) ...@@ -356,6 +377,7 @@ static int record_exec(struct ast_channel *chan, void *data)
if (!f) { if (!f) {
ast_debug(1, "Got hangup\n"); ast_debug(1, "Got hangup\n");
res = -1; res = -1;
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "HANGUP");
ast_filedelete(args.filename, NULL); ast_filedelete(args.filename, NULL);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment