diff options
author | jmls <jmls@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-04-21 11:27:27 +0000 |
---|---|---|
committer | jmls <jmls@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-04-21 11:27:27 +0000 |
commit | f3be709455a2b44e437d1b05ac1970c75b98facc (patch) | |
tree | 0ab377462883dca1275581d02f2266f58e8fbb02 /main/audiohook.c | |
parent | 1a2a1549db0c0d26158df49131b9e29d027003f7 (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: http://svn.digium.com/svn/asterisk/trunk@258190 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/audiohook.c')
-rw-r--r-- | main/audiohook.c | 46 |
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); +} |