summaryrefslogtreecommitdiff
path: root/main/audiohook.c
diff options
context:
space:
mode:
authorJulian Lyndon-Smith <julian@dotr.com>2010-04-21 11:27:27 +0000
committerJulian Lyndon-Smith <julian@dotr.com>2010-04-21 11:27:27 +0000
commitd85650e4aa89fe72850aad21fa25dd3fb3b05019 (patch)
tree0ab377462883dca1275581d02f2266f58e8fbb02 /main/audiohook.c
parentea9186d4ea4e58c51e12718ed64c4964546f552f (diff)
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
Diffstat (limited to 'main/audiohook.c')
-rw-r--r--main/audiohook.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/main/audiohook.c b/main/audiohook.c
index 4a24a2fce..f586b0911 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -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);
+}