res_mixmonitor: MixMonitorMute by MixMonitor ID

While it is possible to create multiple mixmonitor instances
on a channel, it was not previously possible to mute individual
instances.

This change includes the ability to specify the MixMonitorID
when calling the manager action: MixMonitorMute.  This will
allow an individual MixMonitor instance to be muted via id.
This id can be stored as a channel variable using the 'i'
MixMonitor option.

As part of this change, if no MixMonitorID is specified in
the manager action MixMonitorMute, Asterisk will set the mute
flag on all MixMonitor spy-type audiohooks on the channel.
This is done via the new audiohook function:
ast_audiohook_set_mute_all.

ASTERISK-30464

Change-Id: Ibba8c7e750577aa1595a24b23316ef445245be98
(cherry picked from commit b2e9419961)
This commit is contained in:
Mike Bradeen
2023-03-13 13:27:06 -06:00
committed by Asterisk Development Team
parent 33a9c3be91
commit 03da795e3e
4 changed files with 123 additions and 8 deletions

View File

@@ -34,12 +34,12 @@
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/audiohook.h"
#include "asterisk/slinfactory.h"
#include "asterisk/frame.h"
#include "asterisk/translate.h"
#include "asterisk/format_cache.h"
#include "asterisk/test.h"
#define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*!< Tolerance in milliseconds for audiohooks synchronization */
#define AST_AUDIOHOOK_SMALL_QUEUE_TOLERANCE 100 /*!< When small queue is enabled, this is the maximum amount of audio that can remain queued at a time. */
@@ -1376,3 +1376,33 @@ int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum as
return (audiohook ? 0 : -1);
}
int ast_audiohook_set_mute_all(struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clearmute)
{
struct ast_audiohook *audiohook = NULL;
int count = 0;
ast_channel_lock(chan);
if (!ast_channel_audiohooks(chan)) {
return -1;
}
AST_LIST_TRAVERSE(&ast_channel_audiohooks(chan)->spy_list, audiohook, list) {
if (!strcasecmp(audiohook->source, source)) {
count++;
if (clearmute) {
ast_clear_flag(audiohook, flag);
} else {
ast_set_flag(audiohook, flag);
}
}
}
ast_test_suite_event_notify("AUDIOHOOK_GROUP_MUTE_TOGGLE", "Channel: %s\r\nSource: %s\r\nCount: %d\r\n",
ast_channel_name(chan), source, count);
ast_channel_unlock(chan);
return count;
}