diff --git a/apps/.app_mixmonitor.c.swp b/apps/.app_mixmonitor.c.swp deleted file mode 100644 index 92cbf3a..0000000 Binary files a/apps/.app_mixmonitor.c.swp and /dev/null differ diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c index 6746c47..661ec14 100644 --- a/apps/app_mixmonitor.c +++ b/apps/app_mixmonitor.c @@ -167,12 +167,39 @@ Monitor + MuteMixMonitor StopMixMonitor PauseMonitor UnpauseMonitor AUDIOHOOK_INHERIT + + + Mute recording a call through MixMonitor. + + + + If a valid Channel ID is provided, then this command will stop only that specific + MixMonitor. + + + The state is set to 1 or 0 to enable or disable the mute state. + + + Direction is set to either read, write, or both, from the perspective of + the recording file itself. + + + + Mutes the audio recording that was started with a call to MixMonitor() + on the current channel. + + + MixMonitor + StopMixMonitor + + Stop recording a call through MixMonitor, and free the recording's file handle. @@ -299,6 +326,8 @@ static const char * const app = "MixMonitor"; static const char * const stop_app = "StopMixMonitor"; +static const char * const mute_app = "MuteMixMonitor"; + static const char * const mixmonitor_spy_type = "MixMonitor"; /*! @@ -1147,6 +1176,65 @@ static int mixmonitor_exec(struct ast_channel *chan, const char *data) return 0; } +static int mute_mixmonitor_full(struct ast_channel *chan, const char *data) +{ + struct ast_channel *c; + char *parse = ""; + int clearmute = 1; + enum ast_audiohook_flags flag; + + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(channel); + AST_APP_ARG(state); + AST_APP_ARG(direction); + ); + + if (!ast_strlen_zero(data)) { + parse = ast_strdupa(data); + } + + AST_STANDARD_APP_ARGS(args, parse); + + if (!strcasecmp(args.direction, "read")) { + flag = AST_AUDIOHOOK_MUTE_READ; + } else if (!strcasecmp(args.direction, "write")) { + flag = AST_AUDIOHOOK_MUTE_WRITE; + } else if (!strcasecmp(args.direction, "both")) { + flag = AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE; + } else { + ast_log(LOG_WARNING, "MuteMixMonitor: Invalid direction '%s' specified. Must be read, write or both.\n", args.direction); + return -1; + } + + if (ast_strlen_zero(args.channel)) { + ast_log(LOG_WARNING, "MuteMixMonitor: No channel specified.\n"); + return -1; + } + + if (ast_strlen_zero(args.state)) { + ast_log(LOG_WARNING, "MuteMixMonitor: No state specified.\n"); + return -1; + } + + clearmute = ast_false(args.state); + + c = ast_channel_get_by_name(args.channel); + if (!c) { + ast_log(LOG_WARNING, "MuteMixMonitor: No such channel '%s'.\n", args.channel); + return -1; + } + + if (ast_audiohook_set_mute(c, mixmonitor_spy_type, flag, clearmute)) { + ast_channel_unref(c); + ast_log(LOG_WARNING, "MuteMixMonitor: Cannot set mute flag.\n"); + return -1; + } + + ast_channel_unref(c); + + return 0; +} + static int stop_mixmonitor_full(struct ast_channel *chan, const char *data) { struct ast_datastore *datastore = NULL; @@ -1213,6 +1301,12 @@ static int stop_mixmonitor_full(struct ast_channel *chan, const char *data) return 0; } +static int mute_mixmonitor_exec(struct ast_channel *chan, const char *data) +{ + mute_mixmonitor_full(chan, data); + return 0; +} + static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data) { stop_mixmonitor_full(chan, data); @@ -1541,6 +1635,7 @@ static int unload_module(void) ast_cli_unregister_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor)); res = ast_unregister_application(stop_app); + res |= ast_unregister_application(mute_app); res |= ast_unregister_application(app); res |= ast_manager_unregister("MixMonitorMute"); res |= ast_manager_unregister("MixMonitor"); @@ -1558,6 +1653,7 @@ static int load_module(void) ast_cli_register_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor)); res = ast_register_application_xml(app, mixmonitor_exec); res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec); + res |= ast_register_application_xml(mute_app, mute_mixmonitor_exec); res |= ast_manager_register_xml("MixMonitorMute", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, manager_mute_mixmonitor); res |= ast_manager_register_xml("MixMonitor", EVENT_FLAG_SYSTEM, manager_mixmonitor); res |= ast_manager_register_xml("StopMixMonitor", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, manager_stop_mixmonitor);