[asterisk-commits] mmichelson: trunk r114678 - in /trunk: CHANGES apps/app_chanspy.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 25 17:24:32 CDT 2008
Author: mmichelson
Date: Fri Apr 25 17:24:32 2008
New Revision: 114678
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114678
Log:
Adding a new option, 'B' to app_chanspy. This option allows the spy to
barge on the call. It is like the existing whisper option, except that
it allows the spy to talk to both sides of the conversation on which
he is spying.
This feature has existed in Switchvox, and this merges the functionality
into Asterisk.
(AST-32)
Modified:
trunk/CHANGES
trunk/apps/app_chanspy.c
Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=114678&r1=114677&r2=114678
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Fri Apr 25 17:24:32 2008
@@ -33,6 +33,9 @@
* ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
technology name (e.g. SIP, IAX, etc) of the channel being spied on.
* The Jack application now has a c() option to supply a custom client name.
+ * Chanspy has a new option, 'B', which can be used to "barge" on a call. This is
+ like the pre-existing whisper mode, except that the spy can also talk to the
+ participant on the bridged channel as well.
SIP Changes
-----------
Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=114678&r1=114677&r2=114678
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Fri Apr 25 17:24:32 2008
@@ -148,6 +148,7 @@
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
OPTION_ENFORCED = (1 << 9), /* Enforced mode */
OPTION_NOTECH = (1 << 10), /* Skip technology name playback */
+ OPTION_BARGE = (1 << 11), /* Barge mode (whisper to both channels) */
} chanspy_opt_flags;
enum {
@@ -161,6 +162,7 @@
AST_APP_OPTIONS(spy_opts, {
AST_APP_OPTION('q', OPTION_QUIET),
AST_APP_OPTION('b', OPTION_BRIDGED),
+ AST_APP_OPTION('B', OPTION_BARGE),
AST_APP_OPTION('w', OPTION_WHISPER),
AST_APP_OPTION('W', OPTION_PRIVATE),
AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
@@ -177,6 +179,7 @@
/* spy data */
struct ast_audiohook spy_audiohook;
struct ast_audiohook whisper_audiohook;
+ struct ast_audiohook bridge_whisper_audiohook;
int fd;
int volfactor;
};
@@ -230,7 +233,7 @@
.generate = spy_generate,
};
-static int start_spying(struct ast_channel *chan, const char *spychan_name, struct ast_audiohook *audiohook)
+static int start_spying(struct ast_channel *chan, const char *spychan_name, struct ast_audiohook *audiohook)
{
int res = 0;
struct ast_channel *peer = NULL;
@@ -296,10 +299,15 @@
return 0;
}
- if (ast_test_flag(flags, OPTION_WHISPER)) {
+ if (ast_test_flag(flags, OPTION_BARGE)) {
+ ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
+ ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy");
+ start_spying(spyee, spyer_name, &csth.whisper_audiohook); /* Unlocks spyee */
+ start_spying(ast_bridged_channel(spyee), spyer_name, &csth.bridge_whisper_audiohook);
+ } else if (ast_test_flag(flags, OPTION_WHISPER)) {
ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
- start_spying(spyee, spyer_name, &csth.whisper_audiohook);
- }
+ start_spying(spyee, spyer_name, &csth.whisper_audiohook); /* Unlocks spyee */
+ }
ast_channel_unlock(spyee);
spyee = NULL;
@@ -338,7 +346,16 @@
break;
}
- if (ast_test_flag(flags, OPTION_WHISPER) && f->frametype == AST_FRAME_VOICE) {
+ if (ast_test_flag(flags, OPTION_BARGE) && f->frametype == AST_FRAME_VOICE) {
+ ast_audiohook_lock(&csth.whisper_audiohook);
+ ast_audiohook_lock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
+ ast_audiohook_write_frame(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
+ ast_audiohook_unlock(&csth.whisper_audiohook);
+ ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
+ ast_frfree(f);
+ continue;
+ } else if (ast_test_flag(flags, OPTION_WHISPER) && f->frametype == AST_FRAME_VOICE) {
ast_audiohook_lock(&csth.whisper_audiohook);
ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
ast_audiohook_unlock(&csth.whisper_audiohook);
@@ -400,7 +417,16 @@
else
ast_deactivate_generator(chan);
- if (ast_test_flag(flags, OPTION_WHISPER)) {
+ if (ast_test_flag(flags, OPTION_BARGE)) {
+ 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);
+ } else if (ast_test_flag(flags, OPTION_WHISPER)) {
ast_audiohook_lock(&csth.whisper_audiohook);
ast_audiohook_detach(&csth.whisper_audiohook);
ast_audiohook_unlock(&csth.whisper_audiohook);
More information about the asterisk-commits
mailing list