From ae92549c934d80d70309f26f758afc3d7910bc07 Mon Sep 17 00:00:00 2001 From: Jonathan Rose Date: Thu, 5 Dec 2013 23:40:38 +0000 Subject: app_record: Add an option that allows DTMF '0' to act as an additional terminator Using this terminator when active results in ${RECORD_STATUS} being set to 'OPERATOR' instead of 'DTMF' (closes issue AFS-7) Review: https://reviewboard.asterisk.org/r/3041/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403414 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_record.c | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/apps/app_record.c b/apps/app_record.c index 051f97bb8..45f1d8602 100644 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -67,6 +67,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") + @@ -113,6 +117,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") ***/ +#define OPERATOR_KEY '0' + static char *app = "Record"; enum { @@ -125,12 +131,14 @@ enum { OPTION_KEEP = (1 << 6), FLAG_HAS_PERCENT = (1 << 7), OPTION_ANY_TERMINATE = (1 << 8), + OPTION_OPERATOR_EXIT = (1 << 9), }; AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('a', OPTION_APPEND), - AST_APP_OPTION('k', OPTION_KEEP), + AST_APP_OPTION('k', OPTION_KEEP), AST_APP_OPTION('n', OPTION_NOANSWER), + AST_APP_OPTION('o', OPTION_OPERATOR_EXIT), AST_APP_OPTION('q', OPTION_QUIET), AST_APP_OPTION('s', OPTION_SKIP), AST_APP_OPTION('t', OPTION_STAR_TERMINATE), @@ -138,6 +146,36 @@ AST_APP_OPTIONS(app_opts,{ AST_APP_OPTION('x', OPTION_IGNORE_TERMINATE), }); +/*! + * \internal + * \brief Used to determine what action to take when DTMF is received while recording + * \since 13.0.0 + * + * \param chan channel being recorded + * \param flags option flags in use by the record application + * \param dtmf_integer the integer value of the DTMF key received + * \param terminator key currently set to be pressed for normal termination + * + * \retval 0 do not exit + * \retval -1 do exit + */ +static int record_dtmf_response(struct ast_channel *chan, struct ast_flags *flags, int dtmf_integer, int terminator) +{ + if ((dtmf_integer == OPERATOR_KEY) && + (ast_test_flag(flags, OPTION_OPERATOR_EXIT))) { + pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "OPERATOR"); + return -1; + } + + if ((dtmf_integer == terminator) || + (ast_test_flag(flags, OPTION_ANY_TERMINATE))) { + pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "DTMF"); + return -1; + } + + return 0; +} + static int record_exec(struct ast_channel *chan, const char *data) { int res = 0; @@ -384,12 +422,11 @@ static int record_exec(struct ast_channel *chan, const char *data) ast_frfree(f); break; } - } else if ((f->frametype == AST_FRAME_DTMF) && - ((f->subclass.integer == terminator) || - (ast_test_flag(&flags, OPTION_ANY_TERMINATE)))) { - ast_frfree(f); - pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "DTMF"); - break; + } else if (f->frametype == AST_FRAME_DTMF) { + if (record_dtmf_response(chan, &flags, f->subclass.integer, terminator)) { + ast_frfree(f); + break; + } } ast_frfree(f); } -- cgit v1.2.3