#include "asterisk/mixmonitor.h"
#include "asterisk/audiohook.h"
#include "asterisk/causes.h"
+#include "asterisk/beep.h"
enum set_touch_variables_res {
SET_TOUCH_SUCCESS,
}
}
-static enum set_touch_variables_res set_touch_variables(struct ast_channel *chan, int is_mixmonitor, char **touch_format, char **touch_monitor, char **touch_monitor_prefix)
+static enum set_touch_variables_res set_touch_variables(struct ast_channel *chan, int is_mixmonitor, char **touch_format, char **touch_monitor, char **touch_monitor_prefix, char **touch_monitor_beep)
{
enum set_touch_variables_res res = SET_TOUCH_UNSET;
const char *var_format;
const char *var_monitor;
const char *var_prefix;
+ const char *var_beep;
SCOPED_CHANNELLOCK(lock, chan);
var_format = "TOUCH_MIXMONITOR_FORMAT";
var_monitor = "TOUCH_MIXMONITOR";
var_prefix = "TOUCH_MIXMONITOR_PREFIX";
+ var_beep = "TOUCH_MIXMONITOR_BEEP";
} else {
var_format = "TOUCH_MONITOR_FORMAT";
var_monitor = "TOUCH_MONITOR";
var_prefix = "TOUCH_MONITOR_PREFIX";
+ var_beep = "TOUCH_MONITOR_BEEP";
}
set_touch_variable(&res, chan, var_format, touch_format);
set_touch_variable(&res, chan, var_monitor, touch_monitor);
set_touch_variable(&res, chan, var_prefix, touch_monitor_prefix);
+ set_touch_variable(&res, chan, var_beep, touch_monitor_beep);
return res;
}
char *touch_filename;
size_t len;
int x;
+ char beep_id[64] = "";
enum set_touch_variables_res set_touch_res;
RAII_VAR(char *, touch_format, NULL, ast_free);
RAII_VAR(char *, touch_monitor, NULL, ast_free);
RAII_VAR(char *, touch_monitor_prefix, NULL, ast_free);
+ RAII_VAR(char *, touch_monitor_beep, NULL, ast_free);
set_touch_res = set_touch_variables(bridge_channel->chan, 0, &touch_format,
- &touch_monitor, &touch_monitor_prefix);
+ &touch_monitor, &touch_monitor_prefix, &touch_monitor_beep);
switch (set_touch_res) {
case SET_TOUCH_SUCCESS:
break;
case SET_TOUCH_UNSET:
set_touch_res = set_touch_variables(peer_chan, 0, &touch_format, &touch_monitor,
- &touch_monitor_prefix);
+ &touch_monitor_prefix, &touch_monitor_beep);
if (set_touch_res == SET_TOUCH_ALLOC_FAILURE) {
return;
}
ast_verb(4, "AutoMonitor used to record call. Filename: %s\n", touch_filename);
- if (ast_monitor_start(peer_chan, touch_format, touch_filename, 1, X_REC_IN | X_REC_OUT, NULL)) {
+ if (!ast_strlen_zero(touch_monitor_beep)) {
+ unsigned int interval = 15;
+ if (sscanf(touch_monitor_beep, "%30u", &interval) != 1) {
+ ast_log(LOG_WARNING, "Invalid interval '%s' for periodic beep. Using default of %u\n",
+ touch_monitor_beep, interval);
+ }
+
+ if (interval > 0) {
+ if (interval < 5) {
+ interval = 5;
+ ast_log(LOG_WARNING, "Interval '%s' too small for periodic beep. Using minimum of %u\n",
+ touch_monitor_beep, interval);
+ }
+
+ if (ast_beep_start(peer_chan, interval, beep_id, sizeof(beep_id))) {
+ ast_log(LOG_WARNING, "Unable to enable periodic beep, please ensure func_periodic_hook is loaded.\n");
+ return;
+ }
+ }
+ }
+
+ if (ast_monitor_start(peer_chan, touch_format, touch_filename, 1, X_REC_IN | X_REC_OUT, beep_id)) {
ast_verb(4, "AutoMonitor feature was tried by '%s' but monitor failed to start.\n",
ast_channel_name(bridge_channel->chan));
return;
static void start_automixmonitor(struct ast_bridge_channel *bridge_channel, struct ast_channel *peer_chan, struct ast_features_general_config *features_cfg, const char *start_message)
{
- char *touch_filename;
+ char *touch_filename, mix_options[32] = "b";
size_t len;
int x;
enum set_touch_variables_res set_touch_res;
RAII_VAR(char *, touch_format, NULL, ast_free);
RAII_VAR(char *, touch_monitor, NULL, ast_free);
RAII_VAR(char *, touch_monitor_prefix, NULL, ast_free);
+ RAII_VAR(char *, touch_monitor_beep, NULL, ast_free);
set_touch_res = set_touch_variables(bridge_channel->chan, 1, &touch_format,
- &touch_monitor, &touch_monitor_prefix);
+ &touch_monitor, &touch_monitor_prefix, &touch_monitor_beep);
switch (set_touch_res) {
case SET_TOUCH_SUCCESS:
break;
case SET_TOUCH_UNSET:
set_touch_res = set_touch_variables(peer_chan, 1, &touch_format, &touch_monitor,
- &touch_monitor_prefix);
+ &touch_monitor_prefix, &touch_monitor_beep);
if (set_touch_res == SET_TOUCH_ALLOC_FAILURE) {
return;
}
ast_verb(4, "AutoMixMonitor used to record call. Filename: %s\n", touch_filename);
- if (ast_start_mixmonitor(peer_chan, touch_filename, "b")) {
+ if (!ast_strlen_zero(touch_monitor_beep)) {
+ unsigned int interval = 15;
+ if (sscanf(touch_monitor_beep, "%30u", &interval) != 1) {
+ ast_log(LOG_WARNING, "Invalid interval '%s' for periodic beep. Using default of %u\n",
+ touch_monitor_beep, interval);
+ }
+
+ if (interval < 5) {
+ interval = 5;
+ ast_log(LOG_WARNING, "Interval '%s' too small for periodic beep. Using minimum of %u\n",
+ touch_monitor_beep, interval);
+ }
+ snprintf(mix_options, sizeof(mix_options), "bB(%d)", interval);
+ }
+
+ if (ast_start_mixmonitor(peer_chan, touch_filename, mix_options)) {
ast_verb(4, "AutoMixMonitor feature was tried by '%s' but MixMonitor failed to start.\n",
ast_channel_name(bridge_channel->chan));