[asterisk-commits] file: branch file/audiohooks-1.4 r87816 - in /team/file/audiohooks-1.4: inclu...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 31 11:12:07 CDT 2007
Author: file
Date: Wed Oct 31 11:12:07 2007
New Revision: 87816
URL: http://svn.digium.com/view/asterisk?view=rev&rev=87816
Log:
Remove old spy stuff.
Removed:
team/file/audiohooks-1.4/include/asterisk/chanspy.h
Modified:
team/file/audiohooks-1.4/include/asterisk/channel.h
team/file/audiohooks-1.4/main/Makefile
team/file/audiohooks-1.4/main/channel.c
team/file/audiohooks-1.4/main/rtp.c
Modified: team/file/audiohooks-1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/file/audiohooks-1.4/include/asterisk/channel.h?view=diff&rev=87816&r1=87815&r2=87816
==============================================================================
--- team/file/audiohooks-1.4/include/asterisk/channel.h (original)
+++ team/file/audiohooks-1.4/include/asterisk/channel.h Wed Oct 31 11:12:07 2007
@@ -273,9 +273,6 @@
int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
};
-struct ast_channel_spy_list;
-struct ast_channel_whisper_buffer;
-
#define DEBUGCHAN_FLAG 0x80000000
#define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
@@ -427,8 +424,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/file/audiohooks-1.4/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/file/audiohooks-1.4/main/Makefile?view=diff&rev=87816&r1=87815&r2=87816
==============================================================================
--- team/file/audiohooks-1.4/main/Makefile (original)
+++ team/file/audiohooks-1.4/main/Makefile Wed Oct 31 11:12:07 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 astobj2.o
+ strcompat.o threadstorage.o dial.o astobj2.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/file/audiohooks-1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/audiohooks-1.4/main/channel.c?view=diff&rev=87816&r1=87815&r2=87816
==============================================================================
--- team/file/audiohooks-1.4/main/channel.c (original)
+++ team/file/audiohooks-1.4/main/channel.c Wed Oct 31 11:12:07 2007
@@ -47,7 +47,7 @@
#include "asterisk/sched.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
+#include "asterisk/audiohook.h"
#include "asterisk/musiconhold.h"
#include "asterisk/logger.h"
#include "asterisk/say.h"
@@ -69,24 +69,6 @@
#include "asterisk/sha1.h"
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
-
-struct channel_spy_trans {
- int last_format;
- struct ast_trans_pvt *path;
-};
-
-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;
-};
-
-struct ast_channel_whisper_buffer {
- ast_mutex_t lock;
- struct ast_slinfactory sf;
- unsigned int original_format;
- struct ast_trans_pvt *path;
-};
/* uncomment if you have problems with 'monitoring' synchronized files */
#if 0
@@ -1225,10 +1207,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);
@@ -1368,176 +1346,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);
- }
-
- if (option_debug)
- ast_log(LOG_DEBUG, "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);
- 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);
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
- ast_mutex_unlock(&spy->lock);
- }
-
- 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)
{
@@ -1562,129 +1370,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) {
- if (option_debug)
- ast_log(LOG_DEBUG, "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);
- if (option_debug)
- ast_log(LOG_DEBUG, "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);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to read-trigger mode\n",
- spy->type, chan->name);
- }
- break;
- }
- if (option_debug)
- ast_log(LOG_DEBUG, "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 {
- if (option_debug)
- ast_log(LOG_DEBUG, "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)
@@ -1706,8 +1391,6 @@
/* Don't actually hang up a channel that will masquerade as someone else, or
if someone is going to masquerade as us */
ast_channel_lock(chan);
-
- detach_spies(chan); /* get rid of spies */
if (chan->masq) {
if (ast_do_masquerade(chan))
@@ -2495,8 +2178,6 @@
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);
if (chan->monitor && chan->monitor->read_stream ) {
/* XXX what does this do ? */
@@ -2869,42 +2550,18 @@
case AST_FRAME_VOICE:
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 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) {
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) {
@@ -2933,29 +2590,6 @@
}
}
- /* 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;
- }
if (f) {
struct ast_channel *base = NULL;
if (!chan->tech->get_base_channel || chan == chan->tech->get_base_channel(chan))
@@ -3604,8 +3238,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;
@@ -3690,27 +3322,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;
@@ -3774,16 +3385,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))
AST_LIST_INSERT_TAIL(&original->datastores, AST_LIST_FIRST(&clone->datastores), entry);
@@ -4294,7 +3895,7 @@
(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) &&
!c0->masq && !c0->masqr && !c1->masq && !c1->masqr) {
/* Looks like they share a bridge method and nothing else is in the way */
@@ -4675,129 +4276,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))) {
- ast_log(LOG_ERROR, "Ran out of frames before buffer filled!\n");
- break;
- }
-
- tocopy = (f->samples > samples) ? samples : f->samples;
- bytestocopy = ast_codec_get_len(queue->format, tocopy);
- memcpy(buf, f->data, bytestocopy);
- samples -= tocopy;
- buf += tocopy;
- f->samples -= tocopy;
- f->data += bytestocopy;
- f->datalen -= bytestocopy;
- f->offset += bytestocopy;
- queue->samples -= tocopy;
-
- if (!f->samples)
- ast_frfree(AST_LIST_REMOVE_HEAD(&queue->list, frame_list));
- }
-}
-
-struct ast_frame *ast_channel_spy_read_frame(struct ast_channel_spy *spy, unsigned int samples)
-{
- struct ast_frame *result;
- /* buffers are allocated to hold SLINEAR, which is the largest format */
- short read_buf[samples];
- short write_buf[samples];
- struct ast_frame *read_frame;
- struct ast_frame *write_frame;
- int need_dup;
- struct ast_frame stack_read_frame = { .frametype = AST_FRAME_VOICE,
- .subclass = spy->read_queue.format,
- .data = read_buf,
- .samples = samples,
- .datalen = ast_codec_get_len(spy->read_queue.format, samples),
- };
- struct ast_frame stack_write_frame = { .frametype = AST_FRAME_VOICE,
- .subclass = spy->write_queue.format,
- .data = write_buf,
- .samples = samples,
- .datalen = ast_codec_get_len(spy->write_queue.format, samples),
- };
-
- /* if a flush has been requested, dump everything in whichever queue is larger */
- if (ast_test_flag(spy, CHANSPY_TRIGGER_FLUSH)) {
- if (spy->read_queue.samples > spy->write_queue.samples) {
- if (ast_test_flag(spy, CHANSPY_READ_VOLADJUST)) {
- AST_LIST_TRAVERSE(&spy->read_queue.list, result, frame_list)
- ast_frame_adjust_volume(result, spy->read_vol_adjustment);
- }
- result = AST_LIST_FIRST(&spy->read_queue.list);
- AST_LIST_HEAD_SET_NOLOCK(&spy->read_queue.list, NULL);
- spy->read_queue.samples = 0;
- } else {
- if (ast_test_flag(spy, CHANSPY_WRITE_VOLADJUST)) {
- AST_LIST_TRAVERSE(&spy->write_queue.list, result, frame_list)
- ast_frame_adjust_volume(result, spy->write_vol_adjustment);
- }
- result = AST_LIST_FIRST(&spy->write_queue.list);
- AST_LIST_HEAD_SET_NOLOCK(&spy->write_queue.list, NULL);
- spy->write_queue.samples = 0;
- }
- ast_clear_flag(spy, CHANSPY_TRIGGER_FLUSH);
- return result;
- }
-
- if ((spy->read_queue.samples < samples) || (spy->write_queue.samples < samples))
- return NULL;
-
- /* short-circuit if both head frames have exactly what we want */
- if ((AST_LIST_FIRST(&spy->read_queue.list)->samples == samples) &&
- (AST_LIST_FIRST(&spy->write_queue.list)->samples == samples)) {
- read_frame = AST_LIST_REMOVE_HEAD(&spy->read_queue.list, frame_list);
- write_frame = AST_LIST_REMOVE_HEAD(&spy->write_queue.list, frame_list);
-
- spy->read_queue.samples -= samples;
- spy->write_queue.samples -= samples;
-
- need_dup = 0;
- } else {
- copy_data_from_queue(&spy->read_queue, read_buf, samples);
- copy_data_from_queue(&spy->write_queue, write_buf, samples);
-
- read_frame = &stack_read_frame;
- write_frame = &stack_write_frame;
- need_dup = 1;
- }
-
- if (ast_test_flag(spy, CHANSPY_READ_VOLADJUST))
- ast_frame_adjust_volume(read_frame, spy->read_vol_adjustment);
-
- if (ast_test_flag(spy, CHANSPY_WRITE_VOLADJUST))
- ast_frame_adjust_volume(write_frame, spy->write_vol_adjustment);
-
- if (ast_test_flag(spy, CHANSPY_MIXAUDIO)) {
- ast_frame_slinear_sum(read_frame, write_frame);
-
- if (need_dup)
- result = ast_frdup(read_frame);
- else {
- result = read_frame;
- ast_frfree(write_frame);
- }
- } else {
- if (need_dup) {
- result = ast_frdup(read_frame);
- AST_LIST_NEXT(result, frame_list) = ast_frdup(write_frame);
- } else {
- result = read_frame;
- AST_LIST_NEXT(result, frame_list) = write_frame;
- }
- }
-
- return result;
-}
-
static void *silence_generator_alloc(struct ast_channel *chan, void *data)
{
/* just store the data pointer in the channel structure */
@@ -5058,45 +4536,3 @@
return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd);
}
-int ast_channel_whisper_start(struct ast_channel *chan)
-{
- if (chan->whisper)
- return -1;
-
- if (!(chan->whisper = ast_calloc(1, sizeof(*chan->whisper))))
- return -1;
-
- ast_mutex_init(&chan->whisper->lock);
- ast_slinfactory_init(&chan->whisper->sf);
- ast_set_flag(chan, AST_FLAG_WHISPER);
-
- return 0;
-}
-
-int ast_channel_whisper_feed(struct ast_channel *chan, struct ast_frame *f)
-{
- if (!chan->whisper)
- return -1;
-
- ast_mutex_lock(&chan->whisper->lock);
- ast_slinfactory_feed(&chan->whisper->sf, f);
- ast_mutex_unlock(&chan->whisper->lock);
-
- return 0;
-}
-
-void ast_channel_whisper_stop(struct ast_channel *chan)
-{
- if (!chan->whisper)
- return;
-
- ast_clear_flag(chan, AST_FLAG_WHISPER);
- if (chan->whisper->path)
- ast_translator_free_path(chan->whisper->path);
- if (chan->whisper->original_format && chan->writeformat == AST_FORMAT_SLINEAR)
- ast_set_write_format(chan, chan->whisper->original_format);
- ast_slinfactory_destroy(&chan->whisper->sf);
- ast_mutex_destroy(&chan->whisper->lock);
- free(chan->whisper);
- chan->whisper = NULL;
-}
Modified: team/file/audiohooks-1.4/main/rtp.c
URL: http://svn.digium.com/view/asterisk/team/file/audiohooks-1.4/main/rtp.c?view=diff&rev=87816&r1=87815&r2=87816
==============================================================================
--- team/file/audiohooks-1.4/main/rtp.c (original)
+++ team/file/audiohooks-1.4/main/rtp.c Wed Oct 31 11:12:07 2007
@@ -2840,7 +2840,7 @@
if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr) ||
- (c0->monitor || c0->spies || c1->monitor || c1->spies)) {
+ (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks)) {
ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
if (c0->tech_pvt == pvt0)
if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0))
@@ -3118,7 +3118,7 @@
if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr) ||
- (c0->monitor || c0->spies || c1->monitor || c1->spies)) {
+ (c0->monitor || c0->audiohooks || c1->monitor || c1->audiohooks)) {
ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
if ((c0->masq || c0->masqr) && (fr = ast_read(c0)))
ast_frfree(fr);
More information about the asterisk-commits
mailing list