mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
Added MixMonitorMute manager command
Added a new manager command to mute/unmute MixMonitor audio on a channel. Added a new feature to audiohooks so that you can mute either read / write (or both) types of frames - this allows for MixMonitor to mute either side of the conversation without affecting the conversation itself. (closes issue #16740) Reported by: jmls Review: https://reviewboard.asterisk.org/r/487/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@258190 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -127,6 +127,7 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo
|
||||
int our_factory_ms;
|
||||
int other_factory_samples;
|
||||
int other_factory_ms;
|
||||
int muteme = 0;
|
||||
|
||||
/* Update last feeding time to be current */
|
||||
*rwtime = ast_tvnow();
|
||||
@@ -151,6 +152,17 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo
|
||||
ast_slinfactory_flush(other_factory);
|
||||
}
|
||||
|
||||
/* swap frame data for zeros if mute is required */
|
||||
if ((ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) ||
|
||||
(ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_WRITE) && (direction == AST_AUDIOHOOK_DIRECTION_WRITE)) ||
|
||||
(ast_test_flag(audiohook, AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE) == (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE))) {
|
||||
muteme = 1;
|
||||
}
|
||||
|
||||
if (muteme && frame->datalen > 0) {
|
||||
ast_frame_clear(frame);
|
||||
}
|
||||
|
||||
/* Write frame out to respective factory */
|
||||
ast_slinfactory_feed(factory, frame);
|
||||
|
||||
@@ -1001,3 +1013,37 @@ int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_dir
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \brief Mute frames read from or written to a channel
|
||||
* \param chan Channel to muck with
|
||||
* \param source Type of audiohook
|
||||
* \param flag which flag to set / clear
|
||||
* \param clear set or clear
|
||||
* \return Returns 0 on success, -1 on failure
|
||||
*/
|
||||
int ast_audiohook_set_mute(struct ast_channel *chan, const char *source, enum ast_audiohook_flags flag, int clear)
|
||||
{
|
||||
struct ast_audiohook *audiohook = NULL;
|
||||
|
||||
ast_channel_lock(chan);
|
||||
|
||||
/* Ensure the channel has audiohooks on it */
|
||||
if (!chan->audiohooks) {
|
||||
ast_channel_unlock(chan);
|
||||
return -1;
|
||||
}
|
||||
|
||||
audiohook = find_audiohook_by_source(chan->audiohooks, source);
|
||||
|
||||
if (audiohook) {
|
||||
if (clear) {
|
||||
ast_clear_flag(audiohook, flag);
|
||||
} else {
|
||||
ast_set_flag(audiohook, flag);
|
||||
}
|
||||
}
|
||||
|
||||
ast_channel_unlock(chan);
|
||||
|
||||
return (audiohook ? 0 : -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user