diff options
author | Russell Bryant <russell@russellbryant.com> | 2014-04-15 23:21:19 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2014-04-15 23:21:19 +0000 |
commit | 5b7a769fd8b02dcb1d6326ebbe1d4eafcdc75491 (patch) | |
tree | 04a508265c012a493e472d4380bafb7884257896 /funcs/func_periodic_hook.c | |
parent | ba1db5d8f536807415068810832ab2daed56f3bb (diff) |
(mix)monitor: Add options to enable a periodic beep
Add an option to enable a periodic beep to be played into a call if it
is being recorded. If enabled, it uses the PERIODIC_HOOK() function
internally to play the 'beep' prompt into the call at a specified
interval. This option is provided for both Monitor() and
MixMonitor().
Review: https://reviewboard.asterisk.org/r/3424/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@412427 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_periodic_hook.c')
-rw-r--r-- | funcs/func_periodic_hook.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c index 661ebcbed..39dfab396 100644 --- a/funcs/func_periodic_hook.c +++ b/funcs/func_periodic_hook.c @@ -42,6 +42,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/pbx.h" #include "asterisk/app.h" #include "asterisk/audiohook.h" +#define AST_API_MODULE +#include "asterisk/beep.h" /*** DOCUMENTATION <function name="PERIODIC_HOOK" language="en_US"> @@ -93,6 +95,8 @@ static const char context_name[] = "__func_periodic_hook_context__"; static const char exten_name[] = "hook"; static const char full_exten_name[] = "hook@__func_periodic_hook_context__"; +static const char beep_exten[] = "beep"; + /*! * \brief Last used hook ID * @@ -485,9 +489,35 @@ static int load_module(void) ast_add_extension(context_name, 1, exten_name, 6, "", "", "ChanSpy", "${ChannelToSpy},qEB", NULL, AST_MODULE); + res = ast_add_extension(context_name, 1, beep_exten, 1, "", "", + "Answer", "", NULL, AST_MODULE); + res |= ast_add_extension(context_name, 1, beep_exten, 2, "", "", + "Playback", "beep", NULL, AST_MODULE); + res = ast_custom_function_register_escalating(&hook_function, AST_CFE_BOTH); return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; } +int AST_OPTIONAL_API_NAME(ast_beep_start)(struct ast_channel *chan, + unsigned int interval, char *beep_id, size_t len) +{ + char args[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 32]; + + snprintf(args, sizeof(args), "%s,%s,%u", + context_name, beep_exten, interval); + + if (hook_read(chan, NULL, args, beep_id, len)) { + ast_log(LOG_WARNING, "Failed to enable periodic beep.\n"); + return -1; + } + + return 0; +} + +int AST_OPTIONAL_API_NAME(ast_beep_stop)(struct ast_channel *chan, const char *beep_id) +{ + return hook_write(chan, NULL, (char *) beep_id, "off"); +} + AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Periodic dialplan hooks."); |