[asterisk-commits] oej: branch oej/peerfailover r99300 - in /team/oej/peerfailover: ./ apps/ bui...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 22 10:39:28 CST 2008
Author: oej
Date: Mon Jan 21 09:55:24 2008
New Revision: 99300
URL: http://svn.digium.com/view/asterisk?view=rev&rev=99300
Log:
Reset automerge
Added:
team/oej/peerfailover/include/asterisk/audiohook.h
- copied unchanged from r99187, branches/1.4/include/asterisk/audiohook.h
team/oej/peerfailover/main/audiohook.c
- copied unchanged from r99187, branches/1.4/main/audiohook.c
Removed:
team/oej/peerfailover/include/asterisk/chanspy.h
Modified:
team/oej/peerfailover/ (props changed)
team/oej/peerfailover/.cleancount
team/oej/peerfailover/apps/app_chanspy.c
team/oej/peerfailover/apps/app_followme.c
team/oej/peerfailover/apps/app_meetme.c
team/oej/peerfailover/apps/app_mixmonitor.c
team/oej/peerfailover/apps/app_queue.c
team/oej/peerfailover/apps/app_voicemail.c
team/oej/peerfailover/build_tools/menuselect-deps.in
team/oej/peerfailover/channels/chan_iax2.c
team/oej/peerfailover/channels/chan_local.c
team/oej/peerfailover/channels/chan_sip.c
team/oej/peerfailover/codecs/codec_speex.c
team/oej/peerfailover/codecs/codec_zap.c
team/oej/peerfailover/codecs/gsm/Makefile
team/oej/peerfailover/configs/zapata.conf.sample
team/oej/peerfailover/configure
team/oej/peerfailover/configure.ac
team/oej/peerfailover/doc/security.txt
team/oej/peerfailover/include/asterisk/autoconfig.h.in
team/oej/peerfailover/include/asterisk/channel.h
team/oej/peerfailover/include/asterisk/frame.h
team/oej/peerfailover/include/asterisk/translate.h
team/oej/peerfailover/main/Makefile
team/oej/peerfailover/main/abstract_jb.c
team/oej/peerfailover/main/asterisk.c
team/oej/peerfailover/main/channel.c
team/oej/peerfailover/main/dial.c
team/oej/peerfailover/main/frame.c
team/oej/peerfailover/main/http.c
team/oej/peerfailover/main/rtp.c
team/oej/peerfailover/main/slinfactory.c
team/oej/peerfailover/main/translate.c
team/oej/peerfailover/makeopts.in
team/oej/peerfailover/pbx/pbx_dundi.c
team/oej/peerfailover/res/res_agi.c
team/oej/peerfailover/res/res_features.c
team/oej/peerfailover/res/res_odbc.c
Change Statistics:
team/oej/peerfailover/.cleancount | 2
team/oej/peerfailover/apps/app_chanspy.c | 162 --
team/oej/peerfailover/apps/app_followme.c | 1
team/oej/peerfailover/apps/app_meetme.c | 6
team/oej/peerfailover/apps/app_mixmonitor.c | 136 --
team/oej/peerfailover/apps/app_queue.c | 11
team/oej/peerfailover/apps/app_voicemail.c | 3
team/oej/peerfailover/build_tools/menuselect-deps.in | 1
team/oej/peerfailover/channels/chan_iax2.c | 31
team/oej/peerfailover/channels/chan_local.c | 10
team/oej/peerfailover/channels/chan_sip.c | 271 +---
team/oej/peerfailover/codecs/codec_speex.c | 1
team/oej/peerfailover/codecs/codec_zap.c | 35
team/oej/peerfailover/codecs/gsm/Makefile | 2
team/oej/peerfailover/configs/zapata.conf.sample | 2
team/oej/peerfailover/configure.ac | 8
team/oej/peerfailover/doc/security.txt | 7
team/oej/peerfailover/include/asterisk/autoconfig.h.in | 6
team/oej/peerfailover/include/asterisk/channel.h | 9
team/oej/peerfailover/include/asterisk/chanspy.h | 150 --
team/oej/peerfailover/include/asterisk/frame.h | 17
team/oej/peerfailover/include/asterisk/translate.h | 23
team/oej/peerfailover/main/Makefile | 6
team/oej/peerfailover/main/abstract_jb.c | 4
team/oej/peerfailover/main/asterisk.c | 31
team/oej/peerfailover/main/channel.c | 635 ----------
team/oej/peerfailover/main/dial.c | 15
team/oej/peerfailover/main/frame.c | 52
team/oej/peerfailover/main/http.c | 5
team/oej/peerfailover/main/rtp.c | 20
team/oej/peerfailover/main/slinfactory.c | 11
team/oej/peerfailover/main/translate.c | 40
team/oej/peerfailover/makeopts.in | 6
team/oej/peerfailover/pbx/pbx_dundi.c | 12
team/oej/peerfailover/res/res_agi.c | 2
team/oej/peerfailover/res/res_features.c | 4
team/oej/peerfailover/res/res_odbc.c | 1
37 files changed, 592 insertions(+), 1146 deletions(-)
Propchange: team/oej/peerfailover/
------------------------------------------------------------------------------
automerge = http://www.codename-pineapple.org/
Propchange: team/oej/peerfailover/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 21 09:55:24 2008
@@ -1,1 +1,1 @@
-/branches/1.4:1-98145
+/branches/1.4:1-99299
Modified: team/oej/peerfailover/.cleancount
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/.cleancount?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/.cleancount (original)
+++ team/oej/peerfailover/.cleancount Mon Jan 21 09:55:24 2008
@@ -1,1 +1,1 @@
-30
+32
Modified: team/oej/peerfailover/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_chanspy.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_chanspy.c (original)
+++ team/oej/peerfailover/apps/app_chanspy.c Mon Jan 21 09:55:24 2008
@@ -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"
@@ -143,7 +143,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;
};
@@ -163,15 +164,17 @@
{
struct chanspy_translation_helper *csth = data;
struct ast_frame *f;
-
- if (csth->spy.status != CHANSPY_RUNNING)
- /* Channel is already gone more than likely */
+
+ ast_audiohook_lock(&csth->spy_audiohook);
+ if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
+ 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;
@@ -194,50 +197,19 @@
.generate = spy_generate,
};
-static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_channel_spy *spy)
+static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_audiohook *audiohook)
{
int res;
struct ast_channel *peer;
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,
@@ -258,49 +230,27 @@
ast_verbose(VERBOSE_PREFIX_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);
- 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);
+
+ ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
+
+ if (start_spying(spyee, chan, &csth.spy_audiohook)) {
+ ast_audiohook_destroy(&csth.spy_audiohook);
+ return 0;
+ }
+
+ if (ast_test_flag(flags, OPTION_WHISPER)) {
+ ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
+ start_spying(spyee, chan, &csth.whisper_audiohook);
+ }
+
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.spy_audiohook.options.read_volume = csth.volfactor;
+ csth.spy_audiohook.options.write_volume = csth.volfactor;
+ }
+
csth.fd = fd;
-
- if (start_spying(spyee, chan, &csth.spy)) {
- ast_mutex_destroy(&csth.spy.lock);
- 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);
- }
if (ast_test_flag(flags, OPTION_PRIVATE))
silgen = ast_channel_start_silence_generator(chan);
@@ -321,17 +271,16 @@
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;
}
@@ -364,38 +313,29 @@
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_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);
- }
+ csth.spy_audiohook.options.read_volume = csth.volfactor;
+ csth.spy_audiohook.options.write_volume = csth.volfactor;
} else if (res >= '0' && res <= '9') {
inp[x++] = res;
}
}
-
- 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/oej/peerfailover/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_followme.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_followme.c (original)
+++ team/oej/peerfailover/apps/app_followme.c Mon Jan 21 09:55:24 2008
@@ -1048,7 +1048,6 @@
pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
if (outbound)
ast_hangup(outbound);
- res = 1;
}
}
outrun:
Modified: team/oej/peerfailover/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_meetme.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_meetme.c (original)
+++ team/oej/peerfailover/apps/app_meetme.c Mon Jan 21 09:55:24 2008
@@ -1578,7 +1578,7 @@
goto outrun;
}
- retryzap = (strcasecmp(chan->tech->type, "Zap") || (chan->spies || chan->monitor) ? 1 : 0);
+ retryzap = (strcasecmp(chan->tech->type, "Zap") || (chan->audiohooks || chan->monitor) ? 1 : 0);
user->zapchannel = !retryzap;
zapretry:
@@ -1896,14 +1896,14 @@
break;
if (c) {
- if (c->fds[0] != origfd || (user->zapchannel && (c->spies || c->monitor))) {
+ if (c->fds[0] != origfd || (user->zapchannel && (c->audiohooks || c->monitor))) {
if (using_pseudo) {
/* Kill old pseudo */
close(fd);
using_pseudo = 0;
}
ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
- retryzap = (strcasecmp(c->tech->type, "Zap") || (c->spies || c->monitor) ? 1 : 0);
+ retryzap = (strcasecmp(c->tech->type, "Zap") || (c->audiohooks || c->monitor) ? 1 : 0);
user->zapchannel = !retryzap;
goto zapretry;
}
Modified: team/oej/peerfailover/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_mixmonitor.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_mixmonitor.c (original)
+++ team/oej/peerfailover/apps/app_mixmonitor.c Mon Jan 21 09:55:24 2008
@@ -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,11 +93,12 @@
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;
unsigned int flags;
+ struct ast_channel *chan;
};
enum {
@@ -123,7 +124,7 @@
AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
});
-static int startmon(struct ast_channel *chan, struct ast_channel_spy *spy)
+static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook)
{
struct ast_channel *peer;
int res;
@@ -131,9 +132,7 @@
if (!chan)
return -1;
- 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);
@@ -146,7 +145,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,58 +153,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);
+ if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
+ continue;
+
+ if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) || ast_bridged_channel(mixmonitor->chan)) {
+ /* 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_frame_free(f, 0);
}
+
+ /* Write out the frame */
+ if (fs)
+ ast_writestream(fs, fr);
}
- }
-
- ast_mutex_unlock(&mixmonitor->spy.lock);
-
- ast_channel_spy_free(&mixmonitor->spy);
+
+ /* 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);
@@ -271,27 +259,23 @@
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 (readvol)
+ mixmonitor->audiohook.options.read_volume = readvol;
+ if (writevol)
+ mixmonitor->audiohook.options.write_volume = writevol;
+
+ if (startmon(chan, &mixmonitor->audiohook)) {
ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
- mixmonitor->spy.type, chan->name);
+ mixmonitor_spy_type, chan->name);
/* Since we couldn't add ourselves - bail out! */
- ast_mutex_destroy(&mixmonitor->spy.lock);
+ ast_audiohook_destroy(&mixmonitor->audiohook);
free(mixmonitor);
return;
}
@@ -391,9 +375,7 @@
u = ast_module_user_add(chan);
- 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);
ast_module_user_remove(u);
@@ -415,7 +397,7 @@
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_audiohook_detach_source(chan, mixmonitor_spy_type);
ast_channel_unlock(chan);
Modified: team/oej/peerfailover/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_queue.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_queue.c (original)
+++ team/oej/peerfailover/apps/app_queue.c Mon Jan 21 09:55:24 2008
@@ -795,6 +795,17 @@
q->context[0] = '\0';
q->monfmt[0] = '\0';
q->periodicannouncefrequency = 0;
+ q->reportholdtime = 0;
+ q->monjoin = 0;
+ q->wrapuptime = 0;
+ q->autofill = 0;
+ q->joinempty = 0;
+ q->leavewhenempty = 0;
+ q->memberdelay = 0;
+ q->maskmemberstatus = 0;
+ q->eventwhencalled = 0;
+ q->weight = 0;
+ q->timeoutrestart = 0;
if (!q->members)
q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn);
q->membercount = 0;
Modified: team/oej/peerfailover/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/apps/app_voicemail.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/apps/app_voicemail.c (original)
+++ team/oej/peerfailover/apps/app_voicemail.c Mon Jan 21 09:55:24 2008
@@ -8812,8 +8812,10 @@
if (vlist->vms->imapuser) {
if (!strcmp(vlist->vms->imapuser,user)) {
if (interactive == 2) {
+ ast_mutex_unlock(&vmstate_lock);
return vlist->vms;
} else if (vlist->vms->interactive == interactive) {
+ ast_mutex_unlock(&vmstate_lock);
return vlist->vms;
}
}
@@ -8849,6 +8851,7 @@
if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
if (option_debug > 2)
ast_log(LOG_DEBUG, " Found it!\n");
+ ast_mutex_unlock(&vmstate_lock);
return vlist->vms;
}
} else {
Modified: team/oej/peerfailover/build_tools/menuselect-deps.in
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/build_tools/menuselect-deps.in?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/build_tools/menuselect-deps.in (original)
+++ team/oej/peerfailover/build_tools/menuselect-deps.in Mon Jan 21 09:55:24 2008
@@ -22,6 +22,7 @@
PRI=@PBX_PRI@
RADIUS=@PBX_RADIUS@
SPEEX=@PBX_SPEEX@
+SPEEXDSP=@PBX_SPEEXDSP@
SQLITE=@PBX_SQLITE@
SSL=@PBX_OPENSSL@
TONEZONE=@PBX_TONEZONE@
Modified: team/oej/peerfailover/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/channels/chan_iax2.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/channels/chan_iax2.c (original)
+++ team/oej/peerfailover/channels/chan_iax2.c Mon Jan 21 09:55:24 2008
@@ -1801,7 +1801,7 @@
the IAX thread with the iaxsl lock held. */
struct iax_frame *fr = data;
fr->retrans = -1;
- fr->af.has_timing_info = 0;
+ ast_clear_flag(&fr->af, AST_FRFLAG_HAS_TIMING_INFO);
if (iaxs[fr->callno] && !ast_test_flag(iaxs[fr->callno], IAX_ALREADYGONE))
iax2_queue_frame(fr->callno, &fr->af);
/* Free our iax frame */
@@ -2683,7 +2683,7 @@
if (peername) {
var = ast_load_realtime("iaxpeers", "name", peername, "host", "dynamic", NULL);
if (!var && sin)
- var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr));
+ var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr), NULL);
} else if (sin) {
char porta[25];
sprintf(porta, "%d", ntohs(sin->sin_port));
@@ -2802,7 +2802,7 @@
var = ast_load_realtime("iaxusers", "name", username, "host", "dynamic", NULL);
if (!var)
- var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr));
+ var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr), NULL);
if (!var && sin) {
char porta[6];
snprintf(porta, sizeof(porta), "%d", ntohs(sin->sin_port));
@@ -2896,12 +2896,13 @@
char mohsuggest[MAX_MUSICCLASS];
};
-static int create_addr(const char *peername, struct sockaddr_in *sin, struct create_addr_info *cai)
+static int create_addr(const char *peername, struct ast_channel *c, struct sockaddr_in *sin, struct create_addr_info *cai)
{
struct ast_hostent ahp;
struct hostent *hp;
struct iax2_peer *peer;
int res = -1;
+ struct ast_codec_pref ourprefs;
ast_clear_flag(cai, IAX_SENDANI | IAX_TRUNK);
cai->sockfd = defaultsockfd;
@@ -2916,7 +2917,11 @@
memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
sin->sin_port = htons(IAX_DEFAULT_PORTNO);
/* use global iax prefs for unknown peer/user */
- ast_codec_pref_convert(&prefs, cai->prefs, sizeof(cai->prefs), 1);
+ /* But move the calling channel's native codec to the top of the preference list */
+ memcpy(&ourprefs, &prefs, sizeof(ourprefs));
+ if (c)
+ ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+ ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
return 0;
} else {
ast_log(LOG_WARNING, "No such host: %s\n", peername);
@@ -2940,7 +2945,13 @@
cai->encmethods = peer->encmethods;
cai->sockfd = peer->sockfd;
cai->adsi = peer->adsi;
- ast_codec_pref_convert(&peer->prefs, cai->prefs, sizeof(cai->prefs), 1);
+ memcpy(&ourprefs, &peer->prefs, sizeof(ourprefs));
+ /* Move the calling channel's native codec to the top of the preference list */
+ if (c) {
+ ast_log(LOG_DEBUG, "prepending %x to prefs\n", c->nativeformats);
+ ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+ }
+ ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
ast_copy_string(cai->context, peer->context, sizeof(cai->context));
ast_copy_string(cai->peercontext, peer->peercontext, sizeof(cai->peercontext));
ast_copy_string(cai->username, peer->username, sizeof(cai->username));
@@ -3115,7 +3126,7 @@
if (!pds.exten)
pds.exten = defaultrdest;
- if (create_addr(pds.peer, &sin, &cai)) {
+ if (create_addr(pds.peer, c, &sin, &cai)) {
ast_log(LOG_WARNING, "No address associated with '%s'\n", pds.peer);
return -1;
}
@@ -8499,7 +8510,7 @@
if (end) {
memcpy(&sin, end, sizeof(sin));
cai.sockfd = sockfd;
- } else if (create_addr(dest, &sin, &cai))
+ } else if (create_addr(dest, NULL, &sin, &cai))
return -1;
/* Build the rest of the message */
@@ -8722,7 +8733,7 @@
/* Populate our address from the given */
- if (create_addr(pds.peer, &sin, &cai)) {
+ if (create_addr(pds.peer, NULL, &sin, &cai)) {
*cause = AST_CAUSE_UNREGISTERED;
return NULL;
}
@@ -10037,7 +10048,7 @@
parse_dial_string(tmpstr, &pds);
/* Populate our address from the given */
- if (create_addr(pds.peer, &sin, &cai))
+ if (create_addr(pds.peer, NULL, &sin, &cai))
return -1;
if (option_debug)
Modified: team/oej/peerfailover/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/channels/chan_local.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/channels/chan_local.c (original)
+++ team/oej/peerfailover/channels/chan_local.c Mon Jan 21 09:55:24 2008
@@ -493,8 +493,16 @@
isoutbound = IS_OUTBOUND(ast, p);
if (isoutbound) {
const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
- if ((status) && (p->owner))
+ if ((status) && (p->owner)) {
+ /* Deadlock avoidance */
+ while (ast_channel_trylock(p->owner)) {
+ ast_mutex_unlock(&p->lock);
+ usleep(1);
+ ast_mutex_lock(&p->lock);
+ }
pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status);
+ ast_channel_unlock(p->owner);
+ }
p->chan = NULL;
ast_clear_flag(p, LOCAL_LAUNCHED_PBX);
ast_module_user_remove(p->u_chan);
Modified: team/oej/peerfailover/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/peerfailover/channels/chan_sip.c?view=diff&rev=99300&r1=99299&r2=99300
==============================================================================
--- team/oej/peerfailover/channels/chan_sip.c (original)
+++ team/oej/peerfailover/channels/chan_sip.c Mon Jan 21 09:55:24 2008
@@ -150,7 +150,6 @@
#include "asterisk/threadstorage.h"
#include "asterisk/translate.h"
#include "asterisk/dnsmgr.h"
-#include "asterisk/astobj2.h"
#ifndef FALSE
#define FALSE 0
@@ -1008,7 +1007,7 @@
struct sip_registry *registry; /*!< If this is a REGISTER dialog, to which registry */
struct ast_rtp *rtp; /*!< RTP Session */
struct ast_rtp *vrtp; /*!< Video RTP session */
- struct ao2_container *packets; /*!< Packets scheduled for re-transmission */
+ struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
struct sip_history_head *history; /*!< History of this SIP dialog */
size_t history_entries; /*!< Number of entires in the history */
struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
@@ -1025,6 +1024,7 @@
/*! \brief sip packet - raw format for outbound packets that are sent or scheduled for transmission */
struct sip_pkt {
+ struct sip_pkt *next; /*!< Next packet in linked list */
int retrans; /*!< Retransmission number */
int method; /*!< SIP method for this packet */
int seqno; /*!< Sequence number */
@@ -1852,7 +1852,7 @@
if (!(hist = ast_calloc(1, sizeof(*hist) + l)))
return;
if (!p->history && !(p->history = ast_calloc(1, sizeof(*p->history)))) {
- ast_free(hist);
+ free(hist);
return;
}
memcpy(hist->event, buf, l);
@@ -1889,15 +1889,12 @@
/*! \brief Retransmit SIP message if no answer (Called from scheduler) */
static int retrans_pkt(const void *data)
{
- struct sip_pkt *pkt = (struct sip_pkt *)data, *prev;
+ struct sip_pkt *pkt = (struct sip_pkt *)data, *prev, *cur = NULL;
int reschedule = DEFAULT_RETRANS;
int xmitres = 0;
- ao2_ref(pkt, 1); /* Make sure this cannot go away while we're using it */
-
/* Lock channel PVT */
- if (pkt->owner)
- ast_mutex_lock(&pkt->owner->lock);
+ ast_mutex_lock(&pkt->owner->lock);
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
@@ -1925,7 +1922,7 @@
ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
}
- if (pkt->owner && sip_debug_test_pvt(pkt->owner)) {
+ if (sip_debug_test_pvt(pkt->owner)) {
const struct sockaddr_in *dst = sip_real_dst(pkt->owner);
ast_verbose("Retransmitting #%d (%s) to %s:%d:\n%s\n---\n",
pkt->retrans, sip_nat_mode(pkt->owner),
@@ -1935,43 +1932,38 @@
append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data);
xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
- if (pkt->owner)
- ast_mutex_unlock(&pkt->owner->lock);
+ ast_mutex_unlock(&pkt->owner->lock);
if (xmitres == XMIT_ERROR)
- ast_log(LOG_WARNING, "Network error on retransmit in dialog %s\n", pkt->owner ? pkt->owner->callid : "<unknown>");
- else {
- ao2_ref(pkt, -1);
+ ast_log(LOG_WARNING, "Network error on retransmit in dialog %s\n", pkt->owner->callid);
+ else
return reschedule;
- }
}
/* Too many retries */
if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) {
if (ast_test_flag(pkt, FLAG_FATAL) || sipdebug) /* Tell us if it's critical or if we're debugging */
ast_log(LOG_WARNING, "Maximum retries exceeded on transmission %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (ast_test_flag(pkt, FLAG_FATAL)) ? "Critical" : "Non-critical", (ast_test_flag(pkt, FLAG_RESPONSE)) ? "Response" : "Request");
- } else if (pkt->owner && (pkt->method == SIP_OPTIONS) && sipdebug) {
- ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
- }
- if (pkt->owner) {
- if (xmitres == XMIT_ERROR) {
- ast_log(LOG_WARNING, "Transmit error :: Cancelling transmission of transaction in call id %s \n", pkt->owner->callid);
- append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
- } else
- append_history(pkt->owner, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
- }
+ } else if ((pkt->method == SIP_OPTIONS) && sipdebug) {
+ ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
+ }
+ if (xmitres == XMIT_ERROR) {
+ ast_log(LOG_WARNING, "Transmit error :: Cancelling transmission of transaction in call id %s \n", pkt->owner->callid);
+ append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+ } else
+ append_history(pkt->owner, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+
pkt->retransid = -1;
if (ast_test_flag(pkt, FLAG_FATAL)) {
- while (pkt->owner && pkt->owner->owner && ast_channel_trylock(pkt->owner->owner)) {
+ while(pkt->owner->owner && ast_channel_trylock(pkt->owner->owner)) {
ast_mutex_unlock(&pkt->owner->lock); /* SIP_PVT, not channel */
usleep(1);
- if (pkt->owner)
- ast_mutex_lock(&pkt->owner->lock);
- }
-
- if (pkt->owner && pkt->owner->owner && !pkt->owner->owner->hangupcause)
+ ast_mutex_lock(&pkt->owner->lock);
+ }
+
+ if (pkt->owner->owner && !pkt->owner->owner->hangupcause)
pkt->owner->owner->hangupcause = AST_CAUSE_NO_USER_RESPONSE;
- if (pkt->owner && pkt->owner->owner) {
+ if (pkt->owner->owner) {
sip_alreadygone(pkt->owner);
ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid);
ast_queue_hangup(pkt->owner->owner);
@@ -1980,7 +1972,7 @@
/* If no channel owner, destroy now */
/* Let the peerpoke system expire packets when the timer expires for poke_noanswer */
- if (pkt->owner && pkt->method != SIP_OPTIONS) {
+ if (pkt->method != SIP_OPTIONS) {
ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
sip_alreadygone(pkt->owner);
if (option_debug)
@@ -1989,7 +1981,7 @@
}
}
- if (pkt->owner && pkt->method == SIP_BYE) {
+ if (pkt->method == SIP_BYE) {
/* We're not getting answers on SIP BYE's. Tear down the call anyway. */
if (pkt->owner->owner)
ast_channel_unlock(pkt->owner->owner);
@@ -1998,23 +1990,23 @@
}
/* In any case, go ahead and remove the packet */
- if (pkt->owner && (prev = ao2_find(pkt->owner->packets, pkt, OBJ_UNLINK | OBJ_POINTER))) {
- /* Destroy the container's reference (inherited) */
- ao2_ref(prev, -1);
+ for (prev = NULL, cur = pkt->owner->packets; cur; prev = cur, cur = cur->next) {
+ if (cur == pkt)
+ break;
+ }
+ if (cur) {
+ if (prev)
+ prev->next = cur->next;
+ else
+ pkt->owner->packets = cur->next;
ast_mutex_unlock(&pkt->owner->lock);
- /* Now destroy our initial reference */
- ao2_ref(pkt, -1);
- /* And destroy the sched ref */
- ao2_ref(pkt, -1);
- return 0;
- } else {
+ free(cur);
+ pkt = NULL;
+ } else
ast_log(LOG_WARNING, "Weird, couldn't find packet owner!\n");
- if (pkt->owner)
- ast_mutex_unlock(&pkt->owner->lock);
- ao2_ref(pkt, -1); /* Initial ref */
- ao2_ref(pkt, -1); /* Sched ref */
- return 0;
- }
+ if (pkt)
+ ast_mutex_unlock(&pkt->owner->lock);
+ return 0;
}
/*! \brief Transmit packet with retransmits
@@ -2026,11 +2018,12 @@
int siptimer_a = DEFAULT_RETRANS;
int xmitres = 0;
- if (!(pkt = ao2_alloc(sizeof(*pkt) + len + 1, ast_free)))
+ if (!(pkt = ast_calloc(1, sizeof(*pkt) + len + 1)))
return AST_FAILURE;
memcpy(pkt->data, data, len);
pkt->method = sipmethod;
pkt->packetlen = len;
+ pkt->next = p->packets;
pkt->owner = p;
pkt->seqno = seqno;
if (resp)
@@ -2042,9 +2035,12 @@
if (pkt->timer_t1)
siptimer_a = pkt->timer_t1 * 2;
+ /* Schedule retransmission */
+ pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
if (option_debug > 3 && sipdebug)
ast_log(LOG_DEBUG, "*** SIP TIMER: Initializing retransmit timer on packet: Id #%d\n", pkt->retransid);
-
+ pkt->next = p->packets;
+ p->packets = pkt;
if (sipmethod == SIP_INVITE) {
/* Note this is a pending invite */
p->pendinginvite = seqno;
@@ -2054,25 +2050,11 @@
if (xmitres == XMIT_ERROR) { /* Serious network trouble, no need to try again */
append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+ ast_sched_del(sched, pkt->retransid); /* No more retransmission */
pkt->retransid = -1;
- ao2_ref(pkt, -1); /* and deallocate */
return AST_FAILURE;
- } else {
- /* Add refcount for scheduler pointer */
- ao2_ref(pkt, 1);
- /* Schedule retransmission */
- pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
- /* Link into the list of packets */
- ao2_link(p->packets, pkt);
+ } else
return AST_SUCCESS;
- }
-}
-
-static int __deref_ao2_owner_cb(void *obj, void *unused, int flags)
-{
- struct sip_pkt *pkt = obj;
- pkt->owner = NULL;
- return 0;
}
/*! \brief Kill a SIP dialog (called by scheduler) */
@@ -2086,15 +2068,16 @@
p->subscribed = NONE;
append_history(p, "Subscribestatus", "timeout");
if (option_debug > 2)
- ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subscription %s\n", p->callid ? p->callid : "<unknown>");
+ ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
return 10000; /* Reschedule this destruction so that we know that it's gone */
}
- /* If there are packets still waiting for delivery, make sure they can't callback to us anymore. */
- if (ao2_container_count(p->packets)) {
- ast_mutex_lock(&p->lock);
- ao2_callback(p->packets, 0, __deref_ao2_owner_cb, NULL);
- ast_mutex_unlock(&p->lock);
+ /* If there are packets still waiting for delivery, delay the destruction */
[... 2060 lines stripped ...]
More information about the asterisk-commits
mailing list