--- res_features.c.orig 2006-06-23 10:53:21.000000000 +0200 +++ res_features.c 2006-06-23 17:23:30.000000000 +0200 @@ -443,10 +443,41 @@ #define FEATURE_SENSE_CHAN (1 << 0) #define FEATURE_SENSE_PEER (1 << 1) +static int play_am_announce(struct ast_channel *caller_chan, struct ast_channel *callee_chan, const char* sound, const char* silent) { + + if(strcasecmp(silent, "TRUE")) { /* if silent != TRUE */ + if (ast_autoservice_start(caller_chan)) + return -1; + if (!ast_streamfile(callee_chan, sound, caller_chan->language)) { + if (ast_waitstream(callee_chan, "") < 0) { + ast_log(LOG_WARNING, "Failed to play announce sound '%s'!\n", sound); + ast_autoservice_stop(caller_chan); + return -1; + } + } + if (ast_autoservice_stop(caller_chan)) + return -1; + } + + if (ast_autoservice_start(callee_chan)) /* play to caller of service to announce him about success. */ + return -1; + if (!ast_streamfile(caller_chan, sound, caller_chan->language)) { + if (ast_waitstream(caller_chan, "") < 0) { + ast_log(LOG_WARNING, "Failed to play announce sound '%s'!\n", sound); + ast_autoservice_stop(callee_chan); + return -1; + } + } + if (ast_autoservice_stop(callee_chan)) + return -1; + + return 0; +} static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense) { - char *touch_monitor = NULL, *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL, *touch_format = NULL; + char *touch_monitor = NULL, *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL, *touch_format = NULL, + *touch_args = NULL, *touch_silent = NULL, *touch_start_sound = NULL, *touch_stop_sound = NULL; int x = 0; size_t len; struct ast_channel *caller_chan = NULL, *callee_chan = NULL; @@ -472,7 +503,7 @@ return -1; } } - if (!ast_strlen_zero(courtesytone)) { + /*if (!ast_strlen_zero(courtesytone)) { if (ast_autoservice_start(callee_chan)) return -1; if (!ast_streamfile(caller_chan, courtesytone, caller_chan->language)) { @@ -484,25 +515,63 @@ } if (ast_autoservice_stop(callee_chan)) return -1; - } + }*/ + + /* get call recording announcement options */ + touch_silent = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_SILENT"); + if(!touch_silent) + touch_silent = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_SILENT"); + if(!touch_silent) + touch_silent = "TRUE"; + + touch_start_sound = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_START_SOUND"); + if(!touch_start_sound) + touch_start_sound = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_START_SOUND"); + if(!touch_start_sound) + touch_start_sound = "beep"; + + touch_stop_sound = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_STOP_SOUND"); + if(!touch_stop_sound) + touch_stop_sound = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_STOP_SOUND"); + if(!touch_stop_sound) + touch_stop_sound = "beep"; if (callee_chan->monitor) { if (option_verbose > 3) ast_verbose(VERBOSE_PREFIX_3 "User hit '%s' to stop recording call.\n", code); ast_monitor_stop(callee_chan, 1); + + if(play_am_announce(caller_chan, callee_chan, touch_stop_sound, touch_silent)) { + return -1; + } return FEATURE_RETURN_SUCCESS; + } else { + if(play_announce(caller_chan, callee_chan, touch_start_sound, touch_silent)) { + return -1; + } } if (caller_chan && callee_chan) { - touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT"); - if (!touch_format) - touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT"); - - touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR"); - if (!touch_monitor) - touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR"); - if (touch_monitor) { + touch_args = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_ARGS"); + if (!touch_args) + touch_args = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_ARGS"); + + if(!touch_args) { /* don't waste a time if TOUCH_MONITOR_ARGS are defined. */ + touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT"); + if (!touch_format) + touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT"); + + touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR"); + if (!touch_monitor) + touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR"); + } + + if(touch_args) { + len = strlen(touch_args); + args = alloca(len); + snprintf(args, len, "%s", touch_args); + } else if (touch_monitor) { len = strlen(touch_monitor) + 50; args = alloca(len); snprintf(args, len, "%s|auto-%ld-%s|m", (touch_format) ? touch_format : "wav", time(NULL), touch_monitor);