[svn-commits] russell: branch russell/res_monkeys r78674 - in /team/russell/res_monkeys: ./...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 8 14:46:35 CDT 2007


Author: russell
Date: Wed Aug  8 14:46:34 2007
New Revision: 78674

URL: http://svn.digium.com/view/asterisk?view=rev&rev=78674
Log:
fix conflict, sync with trunk, enable automerge

Added:
    team/russell/res_monkeys/funcs/func_volume.c
      - copied unchanged from r78649, trunk/funcs/func_volume.c
    team/russell/res_monkeys/include/asterisk/audiohook.h
      - copied unchanged from r78649, trunk/include/asterisk/audiohook.h
    team/russell/res_monkeys/main/audiohook.c
      - copied unchanged from r78649, trunk/main/audiohook.c
Removed:
    team/russell/res_monkeys/include/asterisk/chanspy.h
Modified:
    team/russell/res_monkeys/   (props changed)
    team/russell/res_monkeys/apps/app_chanspy.c
    team/russell/res_monkeys/apps/app_mixmonitor.c
    team/russell/res_monkeys/channels/chan_iax2.c
    team/russell/res_monkeys/doc/jabber.txt
    team/russell/res_monkeys/include/asterisk/channel.h
    team/russell/res_monkeys/include/asterisk/slinfactory.h
    team/russell/res_monkeys/main/Makefile
    team/russell/res_monkeys/main/channel.c
    team/russell/res_monkeys/main/slinfactory.c

Propchange: team/russell/res_monkeys/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/res_monkeys/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/russell/res_monkeys/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/russell/res_monkeys/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Aug  8 14:46:34 2007
@@ -1,1 +1,1 @@
-/trunk:1-78602
+/trunk:1-78673

Modified: team/russell/res_monkeys/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/apps/app_chanspy.c?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/apps/app_chanspy.c (original)
+++ team/russell/res_monkeys/apps/app_chanspy.c Wed Aug  8 14:46:34 2007
@@ -40,7 +40,7 @@
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
+#include "asterisk/audiohook.h"
 #include "asterisk/features.h"
 #include "asterisk/options.h"
 #include "asterisk/app.h"
@@ -166,7 +166,8 @@
 
 struct chanspy_translation_helper {
 	/* spy data */
-	struct ast_channel_spy spy;
+	struct ast_audiohook spy_audiohook;
+	struct ast_audiohook whisper_audiohook;
 	int fd;
 	int volfactor;
 };
@@ -185,15 +186,18 @@
 static int spy_generate(struct ast_channel *chan, void *data, int len, int samples) 
 {
 	struct chanspy_translation_helper *csth = data;
-	struct ast_frame *f;
+	struct ast_frame *f = NULL;
 		
-	if (csth->spy.status != CHANSPY_RUNNING)
+	ast_audiohook_lock(&csth->spy_audiohook);
+	if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
 		/* Channel is already gone more than likely */
+		ast_audiohook_unlock(&csth->spy_audiohook);
 		return -1;
-
-	ast_mutex_lock(&csth->spy.lock);
-	f = ast_channel_spy_read_frame(&csth->spy, samples);
-	ast_mutex_unlock(&csth->spy.lock);
+	}
+
+	f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
+
+	ast_audiohook_unlock(&csth->spy_audiohook);
 		
 	if (!f)
 		return 0;
@@ -217,50 +221,19 @@
 	.generate = spy_generate, 
 };
 
-static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_channel_spy *spy) 
-{
-	int res;
-	struct ast_channel *peer;
+static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_audiohook *audiohook) 
+{
+	int res = 0;
+	struct ast_channel *peer = NULL;
 
 	ast_log(LOG_NOTICE, "Attaching %s to %s\n", spychan->name, chan->name);
 
-	ast_channel_lock(chan);
-	res = ast_channel_spy_add(chan, spy);
-	ast_channel_unlock(chan);
+	res = ast_audiohook_attach(chan, audiohook);
 
 	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
 		ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);	
 
 	return res;
-}
-
-/* Map 'volume' levels from -4 through +4 into
-   decibel (dB) settings for channel drivers
-*/
-static signed char volfactor_map[] = {
-	-24,
-	-18,
-	-12,
-	-6,
-	0,
-	6,
-	12,
-	18,
-	24,
-};
-
-/* attempt to set the desired gain adjustment via the channel driver;
-   if successful, clear it out of the csth structure so the
-   generator will not attempt to do the adjustment itself
-*/
-static void set_volume(struct ast_channel *chan, struct chanspy_translation_helper *csth)
-{
-	signed char volume_adjust = volfactor_map[csth->volfactor + 4];
-
-	if (!ast_channel_setoption(chan, AST_OPTION_TXGAIN, &volume_adjust, sizeof(volume_adjust), 0))
-		csth->volfactor = 0;
-	csth->spy.read_vol_adjustment = csth->volfactor;
-	csth->spy.write_vol_adjustment = csth->volfactor;
 }
 
 static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd,
@@ -280,49 +253,17 @@
 	ast_verb(2, "Spying on channel %s\n", name);
 
 	memset(&csth, 0, sizeof(csth));
-	ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO);
-	ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE);
-	if (!ast_test_flag(flags, OPTION_READONLY))
-		ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO);
-	csth.spy.type = "ChanSpy";
-	csth.spy.status = CHANSPY_RUNNING;
-	csth.spy.read_queue.format = AST_FORMAT_SLINEAR;
-	csth.spy.write_queue.format = AST_FORMAT_SLINEAR;
-	ast_mutex_init(&csth.spy.lock);
-	csth.volfactor = *volfactor;
-	set_volume(chan, &csth);
-	if (csth.volfactor) {
-		ast_set_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-		csth.spy.read_vol_adjustment = csth.volfactor;
-		ast_set_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-		csth.spy.write_vol_adjustment = csth.volfactor;
-	}
-	csth.fd = fd;
+
+	ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
 	
-	if (start_spying(spyee, chan, &csth.spy)) {
-		ast_mutex_destroy(&csth.spy.lock);
+	if (start_spying(spyee, chan, &csth.spy_audiohook)) {
+		ast_audiohook_destroy(&csth.spy_audiohook);
 		return 0;
 	}
 
 	if (ast_test_flag(flags, OPTION_WHISPER)) {
-		struct ast_filestream *beepstream;
-		int old_write_format = 0;
-
-		ast_channel_whisper_start(csth.spy.chan);
-		old_write_format = chan->writeformat;
-		if ((beepstream = ast_openstream_full(chan, "beep", chan->language, 1))) {
-			struct ast_frame *f;
-
-			while ((f = ast_readframe(beepstream))) {
-				ast_channel_whisper_feed(csth.spy.chan, f);
-				ast_frfree(f);
-			}
-
-			ast_closestream(beepstream);
-			chan->stream = NULL;
-		}
-		if (old_write_format)
-			ast_set_write_format(chan, old_write_format);
+		ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
+		start_spying(spyee, chan, &csth.whisper_audiohook);
 	}
 
 	if (ast_test_flag(flags, OPTION_PRIVATE))
@@ -344,21 +285,20 @@
 	   has arrived, since the spied-on channel could have gone away while
 	   we were waiting
 	*/
-	while ((res = ast_waitfor(chan, -1) > -1) &&
-	       csth.spy.status == CHANSPY_RUNNING &&
-	       csth.spy.chan) {
+	while ((res = ast_waitfor(chan, -1) > -1) && csth.spy_audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
 		if (!(f = ast_read(chan)) || ast_check_hangup(chan)) {
 			running = -1;
 			break;
 		}
 
-		if (ast_test_flag(flags, OPTION_WHISPER) &&
-		    (f->frametype == AST_FRAME_VOICE)) {
-			ast_channel_whisper_feed(csth.spy.chan, f);
+		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);
 			ast_frfree(f);
 			continue;
 		}
-
+		
 		res = (f->frametype == AST_FRAME_DTMF) ? f->subclass : 0;
 		ast_frfree(f);
 		if (!res)
@@ -401,37 +341,25 @@
 			if (*volfactor > 4)
 				*volfactor = -4;
 			ast_verb(3, "Setting spy volume on %s to %d\n", chan->name, *volfactor);
-			csth.volfactor = *volfactor;
-			set_volume(chan, &csth);
-			if (csth.volfactor) {
-				ast_set_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-				csth.spy.read_vol_adjustment = csth.volfactor;
-				ast_set_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-				csth.spy.write_vol_adjustment = csth.volfactor;
-			} else {
-				ast_clear_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-				ast_clear_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-			}
-		}
-	}
-
-	if (ast_test_flag(flags, OPTION_WHISPER) && csth.spy.chan)
-		ast_channel_whisper_stop(csth.spy.chan);
+		}
+	}
 
 	if (ast_test_flag(flags, OPTION_PRIVATE))
 		ast_channel_stop_silence_generator(chan, silgen);
 	else
 		ast_deactivate_generator(chan);
 
-	csth.spy.status = CHANSPY_DONE;
-
-	/* If a channel still exists on our spy structure then we need to remove ourselves */
-	if (csth.spy.chan) {
-		ast_channel_lock(csth.spy.chan);
-		ast_channel_spy_remove(csth.spy.chan, &csth.spy);
-		ast_channel_unlock(csth.spy.chan);
-	}
-	ast_channel_spy_free(&csth.spy);
+	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);
+		ast_audiohook_destroy(&csth.whisper_audiohook);
+	}
+
+	ast_audiohook_lock(&csth.spy_audiohook);
+	ast_audiohook_detach(&csth.spy_audiohook);
+	ast_audiohook_unlock(&csth.spy_audiohook);
+	ast_audiohook_destroy(&csth.spy_audiohook);
 	
 	if (option_verbose >= 2)
 		ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);

Modified: team/russell/res_monkeys/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/apps/app_mixmonitor.c?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/apps/app_mixmonitor.c (original)
+++ team/russell/res_monkeys/apps/app_mixmonitor.c Wed Aug  8 14:46:34 2007
@@ -45,7 +45,7 @@
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
+#include "asterisk/audiohook.h"
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
@@ -93,7 +93,7 @@
 static const char *mixmonitor_spy_type = "MixMonitor";
 
 struct mixmonitor {
-	struct ast_channel_spy spy;
+	struct ast_audiohook audiohook;
 	char *filename;
 	char *post_process;
 	char *name;
@@ -123,17 +123,15 @@
 	AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
 });
 
-static int startmon(struct ast_channel *chan, struct ast_channel_spy *spy) 
-{
-	struct ast_channel *peer;
-	int res;
+static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook) 
+{
+	struct ast_channel *peer = NULL;
+	int res = 0;
 
 	if (!chan)
 		return -1;
 
-	ast_channel_lock(chan);
-	res = ast_channel_spy_add(chan, spy);
-	ast_channel_unlock(chan);
+	ast_audiohook_attach(chan, audiohook);
 
 	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
 		ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);	
@@ -146,7 +144,6 @@
 static void *mixmonitor_thread(void *obj) 
 {
 	struct mixmonitor *mixmonitor = obj;
-	struct ast_frame *f = NULL;
 	struct ast_filestream *fs = NULL;
 	unsigned int oflags;
 	char *ext;
@@ -155,59 +152,48 @@
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "Begin MixMonitor Recording %s\n", mixmonitor->name);
 	
-	ast_mutex_lock(&mixmonitor->spy.lock);
-
-	while (mixmonitor->spy.chan) {
-		struct ast_frame *next;
-		int write;
-
-		ast_channel_spy_trigger_wait(&mixmonitor->spy);
-		
-		if (!mixmonitor->spy.chan || mixmonitor->spy.status != CHANSPY_RUNNING)
+	ast_audiohook_lock(&mixmonitor->audiohook);
+
+	while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
+		struct ast_frame *fr = NULL;
+
+		ast_audiohook_trigger_wait(&mixmonitor->audiohook);
+
+		if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING)
 			break;
-		
-		while (1) {
-			if (!(f = ast_channel_spy_read_frame(&mixmonitor->spy, SAMPLES_PER_FRAME)))
-				break;
-
-			write = (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) ||
-				 ast_bridged_channel(mixmonitor->spy.chan));
-
-			/* it is possible for ast_channel_spy_read_frame() to return a chain
-			   of frames if a queue flush was necessary, so process them
-			*/
-			for (; f; f = next) {
-				next = AST_LIST_NEXT(f, frame_list);
-				if (write && errflag == 0) {
-					if (!fs) {
-						/* Determine creation flags and filename plus extension for filestream */
-						oflags = O_CREAT | O_WRONLY;
-						oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
-
-						if ((ext = strrchr(mixmonitor->filename, '.')))
-							*(ext++) = '\0';
-						else
-							ext = "raw";
-
-						/* Move onto actually creating the filestream */
-						if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) {
-							ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
-							errflag = 1;
-						}
-
-					}
-					if (fs)
-						ast_writestream(fs, f);
-				}
-				ast_frame_free(f, 0);
+
+		if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
+			continue;
+
+		/* Initialize the file if not already done so */
+		if (!fs && !errflag) {
+			oflags = O_CREAT | O_WRONLY;
+			oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
+
+			if ((ext = strrchr(mixmonitor->filename, '.')))
+				*(ext++) = '\0';
+			else
+				ext = "raw";
+
+			if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) {
+				ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
+				errflag = 1;
 			}
 		}
-	}
-
-	ast_mutex_unlock(&mixmonitor->spy.lock);
-
-	ast_channel_spy_free(&mixmonitor->spy);
-	
+
+		/* Write out frame */
+		if (fs)
+			ast_writestream(fs, fr);
+
+		/* All done! free it. */
+		ast_frame_free(fr, 0);
+
+	}
+
+	ast_audiohook_detach(&mixmonitor->audiohook);
+	ast_audiohook_unlock(&mixmonitor->audiohook);
+	ast_audiohook_destroy(&mixmonitor->audiohook);
+
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", mixmonitor->name);
 
@@ -270,27 +256,17 @@
 	strcpy(mixmonitor->filename, filename);
 
 	/* Setup the actual spy before creating our thread */
-	ast_set_flag(&mixmonitor->spy, CHANSPY_FORMAT_AUDIO);
-	ast_set_flag(&mixmonitor->spy, CHANSPY_MIXAUDIO);
-	mixmonitor->spy.type = mixmonitor_spy_type;
-	mixmonitor->spy.status = CHANSPY_RUNNING;
-	mixmonitor->spy.read_queue.format = AST_FORMAT_SLINEAR;
-	mixmonitor->spy.write_queue.format = AST_FORMAT_SLINEAR;
-	if (readvol) {
-		ast_set_flag(&mixmonitor->spy, CHANSPY_READ_VOLADJUST);
-		mixmonitor->spy.read_vol_adjustment = readvol;
-	}
-	if (writevol) {
-		ast_set_flag(&mixmonitor->spy, CHANSPY_WRITE_VOLADJUST);
-		mixmonitor->spy.write_vol_adjustment = writevol;
-	}
-	ast_mutex_init(&mixmonitor->spy.lock);
-
-	if (startmon(chan, &mixmonitor->spy)) {
+	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
+		free(mixmonitor);
+		return;
+	}
+
+	ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_WRITE);
+
+	if (startmon(chan, &mixmonitor->audiohook)) {
 		ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
-			mixmonitor->spy.type, chan->name);
-		/* Since we couldn't add ourselves - bail out! */
-		ast_mutex_destroy(&mixmonitor->spy.lock);
+			mixmonitor_spy_type, chan->name);
+		ast_audiohook_destroy(&mixmonitor->audiohook);
 		ast_free(mixmonitor);
 		return;
 	}
@@ -382,9 +358,7 @@
 
 static int stop_mixmonitor_exec(struct ast_channel *chan, void *data)
 {
-	ast_channel_lock(chan);
-	ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
-	ast_channel_unlock(chan);
+	ast_audiohook_detach_source(chan, mixmonitor_spy_type);
 	return 0;
 }
 
@@ -400,12 +374,13 @@
 		return RESULT_SUCCESS;
 	}
 
-	if (!strcasecmp(argv[1], "start"))
+	if (!strcasecmp(argv[1], "start")) {
 		mixmonitor_exec(chan, argv[3]);
-	else if (!strcasecmp(argv[1], "stop"))
-		ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
-
-	ast_channel_unlock(chan);
+		ast_channel_unlock(chan);
+	} else {
+		ast_channel_unlock(chan);
+		ast_audiohook_detach_source(chan, mixmonitor_spy_type);
+	}
 
 	return RESULT_SUCCESS;
 }

Modified: team/russell/res_monkeys/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/channels/chan_iax2.c?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/channels/chan_iax2.c (original)
+++ team/russell/res_monkeys/channels/chan_iax2.c Wed Aug  8 14:46:34 2007
@@ -8948,7 +8948,7 @@
 	}
 	ast_pthread_create_background(&schedthreadid, NULL, sched_thread, NULL);
 	ast_pthread_create_background(&netthreadid, NULL, network_thread, NULL);
-	ast_verb(2, "%d helper threaads started\n", threadcount);
+	ast_verb(2, "%d helper threads started\n", threadcount);
 	return 0;
 }
 

Modified: team/russell/res_monkeys/doc/jabber.txt
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/doc/jabber.txt?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/doc/jabber.txt (original)
+++ team/russell/res_monkeys/doc/jabber.txt Wed Aug  8 14:46:34 2007
@@ -11,5 +11,5 @@
 the dial plan, jabberstatus, jabbersend, and soon jabberrecv.  res_jabber is also used
 to provide the connection interface for chan_jingle.
 
-The maintainer of res_jabber is Matthew O'Gorman <mogorman at digum.com> or
+The maintainer of res_jabber is Matthew O'Gorman <mogorman at digium.com> or
 mog_work on irc or (preferred) mogorman at astjab.org over jabber.

Modified: team/russell/res_monkeys/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/include/asterisk/channel.h?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/include/asterisk/channel.h (original)
+++ team/russell/res_monkeys/include/asterisk/channel.h Wed Aug  8 14:46:34 2007
@@ -316,9 +316,6 @@
 	int (* func_channel_write)(struct ast_channel *chan, const char *function, char *data, const char *value);
 };
 
-struct ast_channel_spy_list;	/*!< \todo Add explanation here */
-struct ast_channel_whisper_buffer;	/*!< \todo Add explanation here */
-
 /*!
  * The high bit of the frame count is used as a debug marker, so
  * increments of the counters must be done with care.
@@ -481,8 +478,8 @@
 	int rawreadformat;				/*!< Raw read format */
 	int rawwriteformat;				/*!< Raw write format */
 
-	struct ast_channel_spy_list *spies;		/*!< Chan Spy stuff */
-	struct ast_channel_whisper_buffer *whisper;	/*!< Whisper Paging buffer */
+	struct ast_audiohook_list *audiohooks;
+
 	AST_LIST_ENTRY(ast_channel) chan_list;		/*!< For easy linking */
 	
 	struct ast_jb jb;				/*!< The jitterbuffer state  */

Modified: team/russell/res_monkeys/include/asterisk/slinfactory.h
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/include/asterisk/slinfactory.h?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/include/asterisk/slinfactory.h (original)
+++ team/russell/res_monkeys/include/asterisk/slinfactory.h Wed Aug  8 14:46:34 2007
@@ -46,6 +46,7 @@
 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
 int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
 unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
+void ast_slinfactory_flush(struct ast_slinfactory *sf);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/russell/res_monkeys/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/main/Makefile?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/main/Makefile (original)
+++ team/russell/res_monkeys/main/Makefile Wed Aug  8 14:46:34 2007
@@ -26,7 +26,7 @@
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
 	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
-	strcompat.o threadstorage.o dial.o event.o adsistub.o
+	strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static

Modified: team/russell/res_monkeys/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/main/channel.c?view=diff&rev=78674&r1=78673&r2=78674
==============================================================================
--- team/russell/res_monkeys/main/channel.c (original)
+++ team/russell/res_monkeys/main/channel.c Wed Aug  8 14:46:34 2007
@@ -44,7 +44,6 @@
 #include "asterisk/sched.h"
 #include "asterisk/options.h"
 #include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/logger.h"
 #include "asterisk/say.h"
@@ -66,27 +65,7 @@
 #include "asterisk/sha1.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/slinfactory.h"
-
-struct channel_spy_trans {
-	int last_format;
-	struct ast_trans_pvt *path;
-};
-
-/*! \brief List of SPY structures 
-*/
-struct ast_channel_spy_list {
-	struct channel_spy_trans read_translator;
-	struct channel_spy_trans write_translator;
-	AST_LIST_HEAD_NOLOCK(, ast_channel_spy) list;
-};
-
-/*! \brief Definition of the Whisper buffer */
-struct ast_channel_whisper_buffer {
-	ast_mutex_t lock;
-	struct ast_slinfactory sf;
-	unsigned int original_format;
-	struct ast_trans_pvt *path;
-};
+#include "asterisk/audiohook.h"
 
 /* uncomment if you have problems with 'monitoring' synchronized files */
 #if 0
@@ -1121,10 +1100,6 @@
 	if (chan->music_state)
 		ast_moh_cleanup(chan);
 
-	/* if someone is whispering on the channel, stop them */
-	if (chan->whisper)
-		ast_channel_whisper_stop(chan);
-
 	/* Free translators */
 	if (chan->readtrans)
 		ast_translator_free_path(chan->readtrans);
@@ -1281,176 +1256,6 @@
 	return datastore;
 }
 
-int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
-{
-	/* Link the owner channel to the spy */
-	spy->chan = chan;
-
-	if (!ast_test_flag(spy, CHANSPY_FORMAT_AUDIO)) {
-		ast_log(LOG_WARNING, "Could not add channel spy '%s' to channel '%s', only audio format spies are supported.\n",
-			spy->type, chan->name);
-		return -1;
-	}
-
-	if (ast_test_flag(spy, CHANSPY_READ_VOLADJUST) && (spy->read_queue.format != AST_FORMAT_SLINEAR)) {
-		ast_log(LOG_WARNING, "Cannot provide volume adjustment on '%s' format spies\n",
-			ast_getformatname(spy->read_queue.format));
-		return -1;
-	}
-
-	if (ast_test_flag(spy, CHANSPY_WRITE_VOLADJUST) && (spy->write_queue.format != AST_FORMAT_SLINEAR)) {
-		ast_log(LOG_WARNING, "Cannot provide volume adjustment on '%s' format spies\n",
-			ast_getformatname(spy->write_queue.format));
-		return -1;
-	}
-
-	if (ast_test_flag(spy, CHANSPY_MIXAUDIO) &&
-	    ((spy->read_queue.format != AST_FORMAT_SLINEAR) ||
-	     (spy->write_queue.format != AST_FORMAT_SLINEAR))) {
-		ast_log(LOG_WARNING, "Cannot provide audio mixing on '%s'-'%s' format spies\n",
-			ast_getformatname(spy->read_queue.format), ast_getformatname(spy->write_queue.format));
-		return -1;
-	}
-
-	if (!chan->spies) {
-		if (!(chan->spies = ast_calloc(1, sizeof(*chan->spies)))) {
-			return -1;
-		}
-
-		AST_LIST_HEAD_INIT_NOLOCK(&chan->spies->list);
-		AST_LIST_INSERT_HEAD(&chan->spies->list, spy, list);
-	} else {
-		AST_LIST_INSERT_TAIL(&chan->spies->list, spy, list);
-	}
-
-	if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE) {
-		ast_cond_init(&spy->trigger, NULL);
-		ast_set_flag(spy, CHANSPY_TRIGGER_READ);
-		ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
-	}
-
-	ast_debug(1, "Spy %s added to channel %s\n",
-		spy->type, chan->name);
-
-	return 0;
-}
-
-/* Clean up a channel's spy information */
-static void spy_cleanup(struct ast_channel *chan)
-{
-	if (!AST_LIST_EMPTY(&chan->spies->list))
-		return;
-	if (chan->spies->read_translator.path)
-		ast_translator_free_path(chan->spies->read_translator.path);
-	if (chan->spies->write_translator.path)
-		ast_translator_free_path(chan->spies->write_translator.path);
-	ast_free(chan->spies);
-	chan->spies = NULL;
-	return;
-}
-
-/* Detach a spy from it's channel */
-static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
-{
-	/* We only need to poke them if they aren't already done */
-	if (spy->status != CHANSPY_DONE) {
-		ast_mutex_lock(&spy->lock);
-		/* Indicate to the spy to stop */
-		spy->status = CHANSPY_STOP;
-		spy->chan = NULL;
-		/* Poke the spy if needed */
-		if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
-			ast_cond_signal(&spy->trigger);
-		ast_mutex_unlock(&spy->lock);
-	}
-
-	/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
-	ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name);
-
-	return;
-}
-
-void ast_channel_spy_stop_by_type(struct ast_channel *chan, const char *type)
-{
-	struct ast_channel_spy *spy = NULL;
-	
-	if (!chan->spies)
-		return;
-
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
-		if ((spy->type == type) && (spy->status == CHANSPY_RUNNING)) {
-			AST_LIST_REMOVE_CURRENT(&chan->spies->list, list);
-			spy_detach(spy, chan);
-		}
-	}
-	AST_LIST_TRAVERSE_SAFE_END
-	spy_cleanup(chan);
-}
-
-void ast_channel_spy_trigger_wait(struct ast_channel_spy *spy)
-{
-	struct timeval tv;
-	struct timespec ts;
-
-	tv = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000));
-	ts.tv_sec = tv.tv_sec;
-	ts.tv_nsec = tv.tv_usec * 1000;
-
-	ast_cond_timedwait(&spy->trigger, &spy->lock, &ts);
-}
-
-void ast_channel_spy_remove(struct ast_channel *chan, struct ast_channel_spy *spy)
-{
-	if (!chan->spies)
-		return;
-
-	AST_LIST_REMOVE(&chan->spies->list, spy, list);
-	spy_detach(spy, chan);
-	spy_cleanup(chan);
-}
-
-void ast_channel_spy_free(struct ast_channel_spy *spy)
-{
-	struct ast_frame *f = NULL;
-
-	if (spy->status == CHANSPY_DONE)
-		return;
-
-	/* Switch status to done in case we get called twice */
-	spy->status = CHANSPY_DONE;
-
-	/* Drop any frames in the queue */
-	while ((f = AST_LIST_REMOVE_HEAD(&spy->write_queue.list, frame_list)))
-		ast_frfree(f);
-	while ((f = AST_LIST_REMOVE_HEAD(&spy->read_queue.list, frame_list)))
-		ast_frfree(f);
-
-	/* Destroy the condition if in use */
-	if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
-		ast_cond_destroy(&spy->trigger);
-
-	/* Destroy our mutex since it is no longer in use */
-	ast_mutex_destroy(&spy->lock);
-
-	return;
-}
-
-static void detach_spies(struct ast_channel *chan)
-{
-	struct ast_channel_spy *spy = NULL;
-
-	if (!chan->spies)
-		return;
-
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
-		AST_LIST_REMOVE_CURRENT(&chan->spies->list, list);
-		spy_detach(spy, chan);
-	}
-	AST_LIST_TRAVERSE_SAFE_END
-
-	spy_cleanup(chan);
-}
-
 /*! \brief Softly hangup a channel, don't lock */
 int ast_softhangup_nolock(struct ast_channel *chan, int cause)
 {
@@ -1474,124 +1279,6 @@
 	return res;
 }
 
-enum spy_direction {
-	SPY_READ,
-	SPY_WRITE,
-};
-
-#define SPY_QUEUE_SAMPLE_LIMIT 4000			/* half of one second */
-
-static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f, enum spy_direction dir)
-{
-	struct ast_frame *translated_frame = NULL;
-	struct ast_channel_spy *spy;
-	struct channel_spy_trans *trans;
-
-	trans = (dir == SPY_READ) ? &chan->spies->read_translator : &chan->spies->write_translator;
-
-	AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
-		struct ast_channel_spy_queue *queue;
-		struct ast_frame *duped_fr;
-
-		if (spy->status != CHANSPY_RUNNING)
-			continue;
-
-		ast_mutex_lock(&spy->lock);
-
-		queue = (dir == SPY_READ) ? &spy->read_queue : &spy->write_queue;
-
-		if ((queue->format == AST_FORMAT_SLINEAR) && (f->subclass != AST_FORMAT_SLINEAR)) {
-			if (!translated_frame) {
-				if (trans->path && (trans->last_format != f->subclass)) {
-					ast_translator_free_path(trans->path);
-					trans->path = NULL;
-				}
-				if (!trans->path) {
-					ast_debug(1, "Building translator from %s to SLINEAR for spies on channel %s\n",
-							ast_getformatname(f->subclass), chan->name);
-					if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
-						ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
-							ast_getformatname(f->subclass), ast_getformatname(AST_FORMAT_SLINEAR));
-						ast_mutex_unlock(&spy->lock);
-						continue;
-					} else {
-						trans->last_format = f->subclass;
-					}
-				}
-				if (!(translated_frame = ast_translate(trans->path, f, 0))) {
-					ast_log(LOG_ERROR, "Translation to %s failed, dropping frame for spies\n",
-						ast_getformatname(AST_FORMAT_SLINEAR));
-					ast_mutex_unlock(&spy->lock);
-					break;
-				}
-			}
-			duped_fr = ast_frdup(translated_frame);
-		} else if (f->subclass != queue->format) {
-			ast_log(LOG_WARNING, "Spy '%s' on channel '%s' wants format '%s', but frame is '%s', dropping\n",
-				spy->type, chan->name,
-				ast_getformatname(queue->format), ast_getformatname(f->subclass));
-			ast_mutex_unlock(&spy->lock);
-			continue;
-		} else
-			duped_fr = ast_frdup(f);
-
-		AST_LIST_INSERT_TAIL(&queue->list, duped_fr, frame_list);
-
-		queue->samples += f->samples;
-
-		if (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
-			if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE) {
-				switch (ast_test_flag(spy, CHANSPY_TRIGGER_MODE)) {
-				case CHANSPY_TRIGGER_READ:
-					if (dir == SPY_WRITE) {
-						ast_set_flag(spy, CHANSPY_TRIGGER_WRITE);
-						ast_clear_flag(spy, CHANSPY_TRIGGER_READ);
-						ast_debug(1, "Switching spy '%s' on '%s' to write-trigger mode\n",
-							spy->type, chan->name);
-					}
-					break;
-				case CHANSPY_TRIGGER_WRITE:
-					if (dir == SPY_READ) {
-						ast_set_flag(spy, CHANSPY_TRIGGER_READ);
-						ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
-						ast_debug(1, "Switching spy '%s' on '%s' to read-trigger mode\n",
-							spy->type, chan->name);
-					}
-					break;
-				}
-				ast_debug(1, "Triggering queue flush for spy '%s' on '%s'\n",
-					spy->type, chan->name);
-				ast_set_flag(spy, CHANSPY_TRIGGER_FLUSH);
-				ast_cond_signal(&spy->trigger);
-			} else {
-				ast_debug(1, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
-					spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
-				while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
-					struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list);
-					queue->samples -= drop->samples;
-					ast_frfree(drop);
-				}
-			}
-		} else {
-			switch (ast_test_flag(spy, CHANSPY_TRIGGER_MODE)) {
-			case CHANSPY_TRIGGER_READ:
-				if (dir == SPY_READ)
-					ast_cond_signal(&spy->trigger);
-				break;
-			case CHANSPY_TRIGGER_WRITE:
-				if (dir == SPY_WRITE)
-					ast_cond_signal(&spy->trigger);
-				break;
-			}
-		}
-
-		ast_mutex_unlock(&spy->lock);
-	}
-
-	if (translated_frame)
-		ast_frfree(translated_frame);
-}
-
 static void free_translation(struct ast_channel *clone)
 {
 	if (clone->writetrans)
@@ -1614,7 +1301,10 @@
 	   if someone is going to masquerade as us */
 	ast_channel_lock(chan);
 
-	detach_spies(chan);		/* get rid of spies */
+	if (chan->audiohooks) {
+		ast_audiohook_detach_list(chan->audiohooks);
+		chan->audiohooks = NULL;
+	}
 
 	if (chan->masq) {
 		if (ast_do_masquerade(chan))
@@ -2310,6 +2000,8 @@
 						chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
 					ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass, chan->emulate_dtmf_duration, chan->name);
 				}
+				if (chan->audiohooks)
+					f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
 			} else {
 				struct timeval now = ast_tvnow();
 				if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
@@ -2331,6 +2023,8 @@
 					ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass, chan->name);
 					chan->dtmf_tv = now;
 				}
+				if (chan->audiohooks)
+					f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
 			}
 			break;
 		case AST_FRAME_DTMF_BEGIN:
@@ -2392,6 +2086,8 @@
 					f->subclass = chan->emulate_dtmf_digit;
 					f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
 					chan->dtmf_tv = now;
+					if (chan->audiohooks)
+						f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
 					ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
 				} else {
 					/* Drop voice frames while we're still in the middle of the digit */
@@ -2406,9 +2102,9 @@
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else if ((f->frametype == AST_FRAME_VOICE)) {
-				if (chan->spies)
-					queue_frame_to_spies(chan, f, SPY_READ);
-				
+				/* Send frame to audiohooks if present */
+				if (chan->audiohooks)
+					f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
 				if (chan->monitor && chan->monitor->read_stream ) {
 					/* XXX what does this do ? */
 #ifndef MONITOR_CONSTANT_DELAY
@@ -2746,6 +2442,8 @@
 			chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen);
 		break;
 	case AST_FRAME_DTMF_BEGIN:
+		if (chan->audiohooks)
+			fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
 		send_dtmf_event(chan, "Sent", fr->subclass, "Yes", "No");
 		ast_clear_flag(chan, AST_FLAG_BLOCKING);
 		ast_channel_unlock(chan);
@@ -2754,6 +2452,8 @@
 		CHECK_BLOCKING(chan);
 		break;
 	case AST_FRAME_DTMF_END:
+		if (chan->audiohooks)
+			fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
 		send_dtmf_event(chan, "Sent", fr->subclass, "No", "Yes");
 		ast_clear_flag(chan, AST_FLAG_BLOCKING);
 		ast_channel_unlock(chan);
@@ -2787,41 +2487,20 @@
 		if (chan->tech->write == NULL)
 			break;	/*! \todo XXX should return 0 maybe ? */
 
-		/* If someone is whispering on this channel then we must ensure that we are always getting signed linear frames */
-		if (ast_test_flag(chan, AST_FLAG_WHISPER)) {
-			if (fr->subclass == AST_FORMAT_SLINEAR)
-				f = fr;
-			else {
-				ast_mutex_lock(&chan->whisper->lock);
-				if (chan->writeformat != AST_FORMAT_SLINEAR) {
-					/* Rebuild the translation path and set our write format back to signed linear */
-					chan->whisper->original_format = chan->writeformat;
-					ast_set_write_format(chan, AST_FORMAT_SLINEAR);
-					if (chan->whisper->path)
-						ast_translator_free_path(chan->whisper->path);
-					chan->whisper->path = ast_translator_build_path(AST_FORMAT_SLINEAR, chan->whisper->original_format);
-				}
-				/* Translate frame using the above translation path */
-				f = (chan->whisper->path) ? ast_translate(chan->whisper->path, fr, 0) : fr;
-				ast_mutex_unlock(&chan->whisper->lock);
-			}
-		} else {
-			/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
-			if (fr->subclass == chan->rawwriteformat)
-				f = fr;
-			else
-				f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
-		}
-
-		/* If we have no frame of audio, then we have to bail out */
-		if (f == NULL) {
+		/* If audiohooks are present, write the frame out */
+		if (chan->audiohooks)
+			fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+		
+		/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
+		if (fr->subclass == chan->rawwriteformat)
+			f = fr;
+		else
+			f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
+
+		if (!f) {
 			res = 0;
 			break;
 		}
-
-		/* If spies are on the channel then queue the frame out to them */
-		if (chan->spies)
-			queue_frame_to_spies(chan, f, SPY_WRITE);
 
 		/* If Monitor is running on this channel, then we have to write frames out there too */
 		if (chan->monitor && chan->monitor->write_stream) {
@@ -2849,30 +2528,6 @@
 					ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n");
 			}
 		}
-
-		/* Finally the good part! Write this out to the channel */
-		if (ast_test_flag(chan, AST_FLAG_WHISPER)) {
-			/* frame is assumed to be in SLINEAR, since that is
-			   required for whisper mode */
-			ast_frame_adjust_volume(f, -2);
-			if (ast_slinfactory_available(&chan->whisper->sf) >= f->samples) {
-				short buf[f->samples];
-				struct ast_frame whisper = {
-					.frametype = AST_FRAME_VOICE,
-					.subclass = AST_FORMAT_SLINEAR,
-					.data = buf,
-					.datalen = sizeof(buf),
-					.samples = f->samples,
-				};
-				
-				ast_mutex_lock(&chan->whisper->lock);
-				if (ast_slinfactory_read(&chan->whisper->sf, buf, f->samples))
-					ast_frame_slinear_sum(f, &whisper);
-				ast_mutex_unlock(&chan->whisper->lock);
-			}
-			/* and now put it through the regular translator */
-			f = (chan->writetrans) ? ast_translate(chan->writetrans, f, 0) : f;
-		}
 		res = f ? chan->tech->write(chan, f) : 0;
 		break;
 	case AST_FRAME_NULL:
@@ -3460,8 +3115,6 @@
 	void *t_pvt;
 	struct ast_callerid tmpcid;
 	struct ast_channel *clone = original->masq;
-	struct ast_channel_spy_list *spy_list = NULL;
-	struct ast_channel_spy *spy = NULL;
 	struct ast_cdr *cdr;
 	int rformat = original->readformat;
 	int wformat = original->writeformat;
@@ -3547,27 +3200,6 @@
 	original->rawwriteformat = clone->rawwriteformat;
 	clone->rawwriteformat = x;
 
-	/* Swap the spies */
-	spy_list = original->spies;
-	original->spies = clone->spies;
-	clone->spies = spy_list;
-
-	/* Update channel on respective spy lists if present */
-	if (original->spies) {
-		AST_LIST_TRAVERSE(&original->spies->list, spy, list) {
-			ast_mutex_lock(&spy->lock);
-			spy->chan = original;
-			ast_mutex_unlock(&spy->lock);
-		}
-	}
-	if (clone->spies) {
-		AST_LIST_TRAVERSE(&clone->spies->list, spy, list) {
-			ast_mutex_lock(&spy->lock);
-			spy->chan = clone;
-			ast_mutex_unlock(&spy->lock);
-		}
-	}
-
 	/* Save any pending frames on both sides.  Start by counting
 	 * how many we're going to need... */
 	x = 0;
@@ -3631,15 +3263,6 @@
 	}
 
 	ast_app_group_update(clone, original);
-
-	/* move any whisperer over */
-	ast_channel_whisper_stop(original);
-	if (ast_test_flag(clone, AST_FLAG_WHISPER)) {
-		original->whisper = clone->whisper;
-		ast_set_flag(original, AST_FLAG_WHISPER);
-		clone->whisper = NULL;
-		ast_clear_flag(clone, AST_FLAG_WHISPER);
-	}
 
 	/* Move data stores over */
 	if (AST_LIST_FIRST(&clone->datastores))
@@ -4152,7 +3775,8 @@
 		    (config->timelimit == 0) &&
 		    (c0->tech->bridge == c1->tech->bridge) &&
 		    !nativefailed && !c0->monitor && !c1->monitor &&
-		    !c0->spies && !c1->spies && !ast_test_flag(&(config->features_callee),AST_FEATURE_REDIRECT) &&
+		    !c0->audiohooks && !c1->audiohooks && 
+		    !ast_test_flag(&(config->features_callee),AST_FEATURE_REDIRECT) &&
 		    !ast_test_flag(&(config->features_caller),AST_FEATURE_REDIRECT) ) {
 			/* Looks like they share a bridge method and nothing else is in the way */
 			ast_set_flag(c0, AST_FLAG_NBRIDGE);
@@ -4525,129 +4149,6 @@
 		pbx_builtin_setvar_helper(chan, cur->name, cur->value);	
 }
 
-static void copy_data_from_queue(struct ast_channel_spy_queue *queue, short *buf, unsigned int samples)
-{
-	struct ast_frame *f;
-	int tocopy;
-	int bytestocopy;
-
-	while (samples) {
-		if (!(f = AST_LIST_FIRST(&queue->list))) {

[... 244 lines stripped ...]



More information about the svn-commits mailing list