summaryrefslogtreecommitdiff
path: root/apps/app_chanspy.c
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2011-12-23 17:36:14 +0000
committerSean Bright <sean@malleable.com>2011-12-23 17:36:14 +0000
commit35a64c2e6162644970ffc26e533ec41b2891f4db (patch)
treef1516a27241da2a17488205f0ae688d7ec262bdd /apps/app_chanspy.c
parent011843e36cc0642ae8ee42bd9ac4a8faa2d2e116 (diff)
Merged revisions 349045 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r349045 | seanbright | 2011-12-23 12:32:33 -0500 (Fri, 23 Dec 2011) | 25 lines Merged revisions 349044 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r349044 | seanbright | 2011-12-23 12:25:01 -0500 (Fri, 23 Dec 2011) | 18 lines In ChanSpy, don't create audiohooks that will never be used. When ChanSpy is initialized it creates and attaches 3 audiohooks: 1) Read audio off of the channel that we are spying on 2) Write audio to the channel that we are spying on 3) Write audio to the channel that is bridged to the channel that we are spying on. The first is always necessary, but the others are used only when specific options are passed to the ChanSpy application (B, d, w, and W to be specific). When those flags are not passed, neither of those audiohooks are ever sent frames, but we still try to process the hooks for each voice frame that we recieve on the channel. So in short - only create and attach audiohooks that we actually need. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@349046 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 92e0ba513..278098c10 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -546,6 +546,9 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
memset(&csth, 0, sizeof(csth));
ast_copy_flags(&csth.flags, flags, AST_FLAGS_ALL);
+ /* This is the audiohook which gives us the audio off the channel we are
+ spying on.
+ */
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy", 0);
if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook)) {
@@ -553,17 +556,30 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
return 0;
}
- ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
- ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
- if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
- ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
+ if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+ /* This audiohook will let us inject audio from our channel into the
+ channel we are currently spying on.
+ */
+ ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
+
+ if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
+ ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
+ }
}
- if ((spyee_bridge_autochan = ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
- ast_channel_lock(spyee_bridge_autochan->chan);
- if (start_spying(spyee_bridge_autochan, spyer_name, &csth.bridge_whisper_audiohook)) {
- ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
+
+ if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+ /* And this hook lets us inject audio into the channel that the spied on
+ channel is currently bridged with.
+ */
+ ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
+
+ if ((spyee_bridge_autochan = ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
+ ast_channel_lock(spyee_bridge_autochan->chan);
+ if (start_spying(spyee_bridge_autochan, spyer_name, &csth.bridge_whisper_audiohook)) {
+ ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
+ }
+ ast_channel_unlock(spyee_bridge_autochan->chan);
}
- ast_channel_unlock(spyee_bridge_autochan->chan);
}
ast_channel_lock(chan);
@@ -686,15 +702,19 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
ast_channel_unlock(chan);
- ast_audiohook_lock(&csth.whisper_audiohook);
- ast_audiohook_detach(&csth.whisper_audiohook);
- ast_audiohook_unlock(&csth.whisper_audiohook);
- ast_audiohook_destroy(&csth.whisper_audiohook);
-
- ast_audiohook_lock(&csth.bridge_whisper_audiohook);
- ast_audiohook_detach(&csth.bridge_whisper_audiohook);
- ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
- ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
+ if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+ ast_audiohook_lock(&csth.whisper_audiohook);
+ ast_audiohook_detach(&csth.whisper_audiohook);
+ ast_audiohook_unlock(&csth.whisper_audiohook);
+ ast_audiohook_destroy(&csth.whisper_audiohook);
+ }
+
+ if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
+ ast_audiohook_lock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_detach(&csth.bridge_whisper_audiohook);
+ ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
+ }
ast_audiohook_lock(&csth.spy_audiohook);
ast_audiohook_detach(&csth.spy_audiohook);