[svn-commits] mogorman: branch group/asterisk-imap r38758 - in
/team/group/asterisk-imap: ....
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Wed Aug 2 14:02:12 MST 2006
Author: mogorman
Date: Wed Aug 2 16:02:12 2006
New Revision: 38758
URL: http://svn.digium.com/view/asterisk?rev=38758&view=rev
Log:
forgot to turn on automerge
Added:
team/group/asterisk-imap/pbx/ael/ael-test/ael-ntest12/
- copied from r38732, trunk/pbx/ael/ael-test/ael-ntest12/
team/group/asterisk-imap/pbx/ael/ael-test/ael-ntest12/extensions.ael
- copied unchanged from r38732, trunk/pbx/ael/ael-test/ael-ntest12/extensions.ael
team/group/asterisk-imap/pbx/ael/ael-test/ref.ael-ntest12
- copied unchanged from r38732, trunk/pbx/ael/ael-test/ref.ael-ntest12
Modified:
team/group/asterisk-imap/ (props changed)
team/group/asterisk-imap/.cleancount
team/group/asterisk-imap/Makefile
team/group/asterisk-imap/UPGRADE.txt
team/group/asterisk-imap/acl.c
team/group/asterisk-imap/apps/app_chanspy.c
team/group/asterisk-imap/apps/app_dial.c
team/group/asterisk-imap/apps/app_directed_pickup.c
team/group/asterisk-imap/apps/app_followme.c
team/group/asterisk-imap/apps/app_meetme.c
team/group/asterisk-imap/apps/app_queue.c
team/group/asterisk-imap/apps/app_rpt.c
team/group/asterisk-imap/apps/app_speech_utils.c
team/group/asterisk-imap/apps/app_voicemail.c
team/group/asterisk-imap/ast_expr2f.c
team/group/asterisk-imap/asterisk.c
team/group/asterisk-imap/autoservice.c
team/group/asterisk-imap/channel.c
team/group/asterisk-imap/channels/chan_agent.c
team/group/asterisk-imap/channels/chan_alsa.c
team/group/asterisk-imap/channels/chan_h323.c
team/group/asterisk-imap/channels/chan_iax2.c
team/group/asterisk-imap/channels/chan_jingle.c
team/group/asterisk-imap/channels/chan_mgcp.c
team/group/asterisk-imap/channels/chan_misdn.c
team/group/asterisk-imap/channels/chan_oss.c
team/group/asterisk-imap/channels/chan_phone.c
team/group/asterisk-imap/channels/chan_sip.c
team/group/asterisk-imap/channels/chan_skinny.c
team/group/asterisk-imap/channels/chan_vpb.cc
team/group/asterisk-imap/channels/chan_zap.c
team/group/asterisk-imap/channels/iax2-parser.c
team/group/asterisk-imap/channels/iax2-provision.c
team/group/asterisk-imap/cli.c
team/group/asterisk-imap/codecs/Makefile
team/group/asterisk-imap/codecs/gsm/Makefile
team/group/asterisk-imap/config.c
team/group/asterisk-imap/configs/alsa.conf.sample
team/group/asterisk-imap/configs/features.conf.sample
team/group/asterisk-imap/configs/iax.conf.sample
team/group/asterisk-imap/configs/manager.conf.sample
team/group/asterisk-imap/configs/queues.conf.sample
team/group/asterisk-imap/configs/sip.conf.sample
team/group/asterisk-imap/configs/skinny.conf.sample
team/group/asterisk-imap/configs/zapata.conf.sample
team/group/asterisk-imap/dnsmgr.c
team/group/asterisk-imap/doc/CODING-GUIDELINES
team/group/asterisk-imap/doc/asterisk-conf.txt
team/group/asterisk-imap/doc/speechrec.txt
team/group/asterisk-imap/formats/format_ogg_vorbis.c
team/group/asterisk-imap/frame.c
team/group/asterisk-imap/http.c
team/group/asterisk-imap/include/asterisk/abstract_jb.h
team/group/asterisk-imap/include/asterisk/app.h
team/group/asterisk-imap/include/asterisk/channel.h
team/group/asterisk-imap/include/asterisk/compiler.h
team/group/asterisk-imap/include/asterisk/config.h
team/group/asterisk-imap/include/asterisk/frame.h
team/group/asterisk-imap/include/asterisk/manager.h
team/group/asterisk-imap/include/asterisk/musiconhold.h
team/group/asterisk-imap/include/asterisk/options.h
team/group/asterisk-imap/include/asterisk/slinfactory.h
team/group/asterisk-imap/include/asterisk/speech.h
team/group/asterisk-imap/include/asterisk/utils.h
team/group/asterisk-imap/logger.c
team/group/asterisk-imap/manager.c
team/group/asterisk-imap/netsock.c
team/group/asterisk-imap/pbx.c
team/group/asterisk-imap/pbx/ael/ael.tab.c
team/group/asterisk-imap/pbx/ael/ael.tab.h
team/group/asterisk-imap/pbx/ael/ael.y
team/group/asterisk-imap/pbx/dundi-parser.c
team/group/asterisk-imap/pbx/pbx_ael.c
team/group/asterisk-imap/pbx/pbx_dundi.c
team/group/asterisk-imap/pbx/pbx_gtkconsole.c
team/group/asterisk-imap/res/res_agi.c
team/group/asterisk-imap/res/res_config_odbc.c
team/group/asterisk-imap/res/res_config_pgsql.c
team/group/asterisk-imap/res/res_features.c
team/group/asterisk-imap/res/res_monitor.c
team/group/asterisk-imap/res/res_musiconhold.c
team/group/asterisk-imap/res/res_speech.c
team/group/asterisk-imap/rtp.c
team/group/asterisk-imap/slinfactory.c
team/group/asterisk-imap/sounds/Makefile
team/group/asterisk-imap/udptl.c
team/group/asterisk-imap/utils.c
Propchange: team/group/asterisk-imap/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.
Propchange: team/group/asterisk-imap/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.
Propchange: team/group/asterisk-imap/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Aug 2 16:02:12 2006
@@ -1,1 +1,1 @@
-/trunk:1-37877
+/trunk:1-38757
Modified: team/group/asterisk-imap/.cleancount
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/.cleancount?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/.cleancount (original)
+++ team/group/asterisk-imap/.cleancount Wed Aug 2 16:02:12 2006
@@ -1,1 +1,1 @@
-19
+20
Modified: team/group/asterisk-imap/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/Makefile?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/Makefile (original)
+++ team/group/asterisk-imap/Makefile Wed Aug 2 16:02:12 2006
@@ -897,7 +897,7 @@
menuselect: menuselect/menuselect makeopts.xml
- at menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
-menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
+menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
@CFLAGS="-include $(ASTTOPDIR)/include/asterisk/autoconfig.h -I$(ASTTOPDIR)/include" PARENTSRC="$(ASTTOPDIR)" $(MAKE) -C menuselect menuselect
mxml/libmxml.a:
Modified: team/group/asterisk-imap/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/UPGRADE.txt?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/UPGRADE.txt (original)
+++ team/group/asterisk-imap/UPGRADE.txt Wed Aug 2 16:02:12 2006
@@ -315,3 +315,42 @@
ASTETCDIR /usr/local/etc/asterisk
ASTBINDIR /usr/local/bin/asterisk
ASTSBINDIR /usr/local/sbin/asterisk
+
+Music on Hold:
+
+* The music on hold handling has been changed in some significant ways in hopes
+ to make it work in a way that is much less confusing to users. Behavior will
+ not change if the same configuration is used from older versions of Asterisk.
+ However, there are some new configuration options that will make things work
+ in a way that makes more sense.
+
+ Previously, many of the channel drivers had an option called "musicclass" or
+ something similar. This option set what music on hold class this channel
+ would *hear* when put on hold. Some people expected (with good reason) that
+ this option was to configure what music on hold class to play when putting
+ the bridged channel on hold. This option has now been deprecated.
+
+ Two new music on hold related configuration options for channel drivers have
+ been introduced. Some channel drivers support both options, some just one,
+ and some support neither of them. Check the sample configuration files to see
+ which options apply to which channel driver.
+
+ The "mohsuggest" option specifies which music on hold class to suggest to the
+ bridged channel when putting them on hold. The only way that this class can
+ be overridden is if the bridged channel has a specific music class set that
+ was done in the dialplan using Set(CHANNEL(musicclass)=something).
+
+ The "mohinterpret" option is similar to the old "musicclass" option. It
+ specifies which music on hold class this channel would like to listen to when
+ put on hold. This music class is only effective if this channel has no music
+ class set on it from the dialplan and the bridged channel putting this one on
+ hold had no "mohsuggest" setting.
+
+ The IAX2 and Zap channel drivers have an additional feature for the
+ "mohinterpret" option. If this option is set to "passthrough", then these
+ channel drivers will pass through the HOLD message in signalling instead of
+ starting music on hold on the channel. An example for how this would be
+ useful is in an enterprise network of Asterisk servers. When one phone on one
+ server puts a phone on a different server on hold, the remote server will be
+ responsibile for playing the hold music to its local phone that was put on
+ hold instead of the far end server across the network playing the music.
Modified: team/group/asterisk-imap/acl.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/acl.c?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/acl.c (original)
+++ team/group/asterisk-imap/acl.c Wed Aug 2 16:02:12 2006
@@ -208,10 +208,9 @@
char iabuf[INET_ADDRSTRLEN];
char iabuf2[INET_ADDRSTRLEN];
/* DEBUG */
- ast_log(LOG_DEBUG,
- "##### Testing %s with %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr),
- ast_inet_ntoa(iabuf2, sizeof(iabuf2), ha->netaddr));
+ ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
+ ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
+ ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
/* For each rule, if this address and the netmask = the net address
apply the current rule */
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
Modified: team/group/asterisk-imap/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/apps/app_chanspy.c?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/apps/app_chanspy.c (original)
+++ team/group/asterisk-imap/apps/app_chanspy.c Wed Aug 2 16:02:12 2006
@@ -51,46 +51,76 @@
#include "asterisk/module.h"
#include "asterisk/lock.h"
-AST_MUTEX_DEFINE_STATIC(modlock);
-
#define AST_NAME_STRLEN 256
-#define ALL_DONE(u, ret) LOCAL_USER_REMOVE(u); return ret;
-#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
-
-static const char *tdesc = "Listen to the audio of an active channel";
-static const char *app = "ChanSpy";
-static const char *desc =
+
+static const char *tdesc = "Listen to a channel, and optionally whisper into it";
+static const char *app_chan = "ChanSpy";
+static const char *desc_chan =
" ChanSpy([chanprefix][|options]): This application is used to listen to the\n"
-"audio from an active Asterisk channel. This includes the audio coming in and\n"
+"audio from an Asterisk channel. This includes the audio coming in and\n"
"out of the channel being spied on. If the 'chanprefix' parameter is specified,\n"
"only channels beginning with this string will be spied upon.\n"
-" While Spying, the following actions may be performed:\n"
+" While spying, the following actions may be performed:\n"
" - Dialing # cycles the volume level.\n"
" - Dialing * will stop spying and look for another channel to spy on.\n"
" - Dialing a series of digits followed by # builds a channel name to append\n"
" to 'chanprefix'. For example, executing ChanSpy(Agent) and then dialing\n"
-" the digits '1234#' while spying will begin spying on the channel,\n"
+" the digits '1234#' while spying will begin spying on the channel\n"
" 'Agent/1234'.\n"
" Options:\n"
-" b - Only spy on channels involved in a bridged call.\n"
-" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"
-" contain 'grp' in an optional : delimited list.\n"
-" q - Don't play a beep when beginning to spy on a channel.\n"
+" b - Only spy on channels involved in a bridged call.\n"
+" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"
+" contain 'grp' in an optional : delimited list.\n"
+" q - Don't play a beep when beginning to spy on a channel, or speak the\n"
+" selected channel name.\n"
" r[(basename)] - Record the session to the monitor spool directory. An\n"
" optional base for the filename may be specified. The\n"
" default is 'chanspy'.\n"
-" v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
-" negative value refers to a quieter setting.\n"
+" v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
+" negative value refers to a quieter setting.\n"
+" w - Enable 'whisper' mode, so the spying channel can talk to\n"
+" the spied-on channel.\n"
+" W - Enable 'private whisper' mode, so the spying channel can\n"
+" talk to the spied-on channel but cannot listen to that\n"
+" channel.\n"
;
-static const char *chanspy_spy_type = "ChanSpy";
+static const char *app_ext = "ExtenSpy";
+static const char *desc_ext =
+" ExtenSpy(exten[@context][|options]): This application is used to listen to the\n"
+"audio from an Asterisk channel. This includes the audio coming in and\n"
+"out of the channel being spied on. Only channels created by outgoing calls for the\n"
+"specified extension will be selected for spying. If the optional context is not\n"
+"supplied, the current channel's context will be used.\n"
+" While spying, the following actions may be performed:\n"
+" - Dialing # cycles the volume level.\n"
+" - Dialing * will stop spying and look for another channel to spy on.\n"
+" Options:\n"
+" b - Only spy on channels involved in a bridged call.\n"
+" g(grp) - Match only channels where their ${SPYGROUP} variable is set to\n"
+" contain 'grp' in an optional : delimited list.\n"
+" q - Don't play a beep when beginning to spy on a channel, or speak the\n"
+" selected channel name.\n"
+" r[(basename)] - Record the session to the monitor spool directory. An\n"
+" optional base for the filename may be specified. The\n"
+" default is 'chanspy'.\n"
+" v([value]) - Adjust the initial volume in the range from -4 to 4. A\n"
+" negative value refers to a quieter setting.\n"
+" w - Enable 'whisper' mode, so the spying channel can talk to\n"
+" the spied-on channel.\n"
+" W - Enable 'private whisper' mode, so the spying channel can\n"
+" talk to the spied-on channel but cannot listen to that\n"
+" channel.\n"
+;
enum {
OPTION_QUIET = (1 << 0), /* Quiet, no announcement */
OPTION_BRIDGED = (1 << 1), /* Only look at bridged calls */
OPTION_VOLUME = (1 << 2), /* Specify initial volume */
OPTION_GROUP = (1 << 3), /* Only look at channels in group */
- OPTION_RECORD = (1 << 4), /* Record */
+ OPTION_RECORD = (1 << 4),
+ OPTION_WHISPER = (1 << 5),
+ OPTION_PRIVATE = (1 << 6), /* Private Whisper mode */
} chanspy_opt_flags;
enum {
@@ -100,9 +130,11 @@
OPT_ARG_ARRAY_SIZE,
} chanspy_opt_args;
-AST_APP_OPTIONS(chanspy_opts, {
+AST_APP_OPTIONS(spy_opts, {
AST_APP_OPTION('q', OPTION_QUIET),
AST_APP_OPTION('b', OPTION_BRIDGED),
+ AST_APP_OPTION('w', OPTION_WHISPER),
+ AST_APP_OPTION('W', OPTION_PRIVATE),
AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
AST_APP_OPTION_ARG('g', OPTION_GROUP, OPT_ARG_GROUP),
AST_APP_OPTION_ARG('r', OPTION_RECORD, OPT_ARG_RECORD),
@@ -116,34 +148,6 @@
int fd;
int volfactor;
};
-
-static struct ast_channel *local_channel_walk(struct ast_channel *chan)
-{
- struct ast_channel *ret;
- ast_mutex_lock(&modlock);
- if ((ret = ast_channel_walk_locked(chan))) {
- ast_mutex_unlock(&ret->lock);
- }
- ast_mutex_unlock(&modlock);
- return ret;
-}
-
-static struct ast_channel *local_get_channel_begin_name(char *name)
-{
- struct ast_channel *chan, *ret = NULL;
- ast_mutex_lock(&modlock);
- chan = local_channel_walk(NULL);
- while (chan) {
- if (!strncmp(chan->name, name, strlen(name))) {
- ret = chan;
- break;
- }
- chan = local_channel_walk(chan);
- }
- ast_mutex_unlock(&modlock);
-
- return ret;
-}
static void *spy_alloc(struct ast_channel *chan, void *data)
{
@@ -185,7 +189,6 @@
return 0;
}
-
static struct ast_generator spygen = {
.alloc = spy_alloc,
.release = spy_release,
@@ -203,26 +206,25 @@
res = ast_channel_spy_add(chan, spy);
ast_channel_unlock(chan);
- if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan))) {
+ if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
- }
return res;
}
-static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy)
+static void stop_spying(struct ast_channel_spy *spy)
{
/* If our status has changed to DONE, then the channel we're spying on is gone....
DON'T TOUCH IT!!! RUN AWAY!!! */
if (spy->status == CHANSPY_DONE)
return;
- if (!chan)
+ if (!spy->chan)
return;
- ast_channel_lock(chan);
- ast_channel_spy_remove(chan, spy);
- ast_channel_unlock(chan);
+ ast_channel_lock(spy->chan);
+ ast_channel_spy_remove(spy->chan, spy);
+ ast_channel_unlock(spy->chan);
};
/* Map 'volume' levels from -4 through +4 into
@@ -250,332 +252,463 @@
if (!ast_channel_setoption(chan, AST_OPTION_TXGAIN, &volume_adjust, sizeof(volume_adjust), 0))
csth->volfactor = 0;
-}
-
-static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd)
+ 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,
+ const struct ast_flags *flags)
{
struct chanspy_translation_helper csth;
- int running, res = 0, x = 0;
- char inp[24];
- char *name=NULL;
+ int running, res, x = 0;
+ char inp[24] = {0};
+ char *name;
struct ast_frame *f;
-
- running = (chan && !ast_check_hangup(chan) && spyee && !ast_check_hangup(spyee));
-
- if (running) {
- memset(inp, 0, sizeof(inp));
- name = ast_strdupa(spyee->name);
- if (option_verbose >= 2)
- 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_spy_type;
- 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);
- csth.spy.read_vol_adjustment = csth.volfactor;
- csth.spy.write_vol_adjustment = csth.volfactor;
- csth.fd = fd;
-
- if (start_spying(spyee, chan, &csth.spy))
+ struct ast_silence_generator *silgen = NULL;
+
+ if (ast_check_hangup(chan) || ast_check_hangup(spyee))
+ return 0;
+
+ name = ast_strdupa(spyee->name);
+ if (option_verbose >= 2)
+ 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);
+ csth.volfactor = *volfactor;
+ set_volume(chan, &csth);
+ 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;
+
+ ast_channel_whisper_start(csth.spy.chan);
+ 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);
+ }
+ }
+
+ if (ast_test_flag(flags, OPTION_PRIVATE))
+ silgen = ast_channel_start_silence_generator(chan);
+ else
+ ast_activate_generator(chan, &spygen, &csth);
+
+ /* We can no longer rely on 'spyee' being an actual channel;
+ it can be hung up and freed out from under us. However, the
+ channel destructor will put NULL into our csth.spy.chan
+ field when that happens, so that is our signal that the spyee
+ channel has gone away.
+ */
+
+ /* Note: it is very important that the ast_waitfor() be the first
+ condition in this expression, so that if we wait for some period
+ of time before receiving a frame from our spying channel, we check
+ for hangup on the spied-on channel _after_ knowing that a frame
+ 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 &&
+ !ast_check_hangup(chan) &&
+ csth.spy.chan) {
+ if (!(f = ast_read(chan)))
+ break;
+
+ if (ast_test_flag(flags, OPTION_WHISPER) &&
+ (f->frametype == AST_FRAME_VOICE)) {
+ ast_channel_whisper_feed(csth.spy.chan, f);
+ ast_frfree(f);
+ continue;
+ }
+
+ res = (f->frametype == AST_FRAME_DTMF) ? f->subclass : 0;
+ ast_frfree(f);
+ if (!res)
+ continue;
+
+ if (x == sizeof(inp))
+ x = 0;
+
+ if (res < 0) {
+ running = -1;
+ break;
+ }
+
+ if (res == '*') {
running = 0;
- }
-
- if (running) {
- running = 1;
- ast_activate_generator(chan, &spygen, &csth);
-
- while (csth.spy.status == CHANSPY_RUNNING &&
- chan && !ast_check_hangup(chan) &&
- spyee &&
- !ast_check_hangup(spyee) &&
- running == 1 &&
- (res = ast_waitfor(chan, -1) > -1)) {
- if ((f = ast_read(chan))) {
- res = 0;
- if (f->frametype == AST_FRAME_DTMF) {
- res = f->subclass;
- }
- ast_frfree(f);
- if (!res) {
- continue;
- }
- } else {
+ break;
+ } else if (res == '#') {
+ if (!ast_strlen_zero(inp)) {
+ running = atoi(inp);
break;
}
- if (x == sizeof(inp)) {
- x = 0;
+
+ (*volfactor)++;
+ if (*volfactor > 4)
+ *volfactor = -4;
+ 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);
+ } 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);
+
+ stop_spying(&csth.spy);
+
+ if (option_verbose >= 2)
+ ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
+
+ ast_mutex_destroy(&csth.spy.lock);
+
+ return running;
+}
+
+static struct ast_channel *next_channel(const struct ast_channel *last, const char *spec,
+ const char *exten, const char *context)
+{
+ struct ast_channel *this;
+
+ if (spec)
+ this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
+ else if (exten)
+ this = ast_walk_channel_by_exten_locked(last, exten, context);
+ else
+ this = ast_channel_walk_locked(last);
+
+ if (this)
+ ast_channel_unlock(this);
+
+ return this;
+}
+
+static int common_exec(struct ast_channel *chan, const struct ast_flags *flags,
+ int volfactor, const int fd, const char *mygroup, const char *spec,
+ const char *exten, const char *context)
+{
+ struct ast_channel *peer, *prev, *next;
+ char nameprefix[AST_NAME_STRLEN];
+ char peer_name[AST_NAME_STRLEN + 5];
+ signed char zero_volume = 0;
+ int waitms;
+ int res;
+ char *ptr;
+ int num;
+
+ if (chan->_state != AST_STATE_UP)
+ ast_answer(chan);
+
+ ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
+
+ waitms = 100;
+
+ for (;;) {
+ if (!ast_test_flag(flags, OPTION_QUIET)) {
+ res = ast_streamfile(chan, "beep", chan->language);
+ if (!res)
+ res = ast_waitstream(chan, "");
+ else if (res < 0) {
+ ast_clear_flag(chan, AST_FLAG_SPYING);
+ break;
}
- if (res < 0) {
- running = -1;
+ }
+
+ res = ast_waitfordigit(chan, waitms);
+ if (res < 0) {
+ ast_clear_flag(chan, AST_FLAG_SPYING);
+ break;
+ }
+
+ /* reset for the next loop around, unless overridden later */
+ waitms = 100;
+ peer = prev = next = NULL;
+
+ for (peer = next_channel(peer, spec, exten, context);
+ peer;
+ prev = peer, peer = next ? next : next_channel(peer, spec, exten, context), next = NULL) {
+ const char *group;
+ int igrp = !mygroup;
+ char *groups[25];
+ int num_groups = 0;
+ char *dup_group;
+ int x;
+ char *s;
+
+ if (peer == prev)
+ break;
+
+ if (peer == chan)
+ continue;
+
+ if (ast_test_flag(flags, OPTION_BRIDGED) && !ast_bridged_channel(peer))
+ continue;
+
+ if (ast_check_hangup(peer) || ast_test_flag(peer, AST_FLAG_SPYING))
+ continue;
+
+ if (mygroup) {
+ if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
+ dup_group = ast_strdupa(group);
+ num_groups = ast_app_separate_args(dup_group, ':', groups,
+ sizeof(groups) / sizeof(groups[0]));
+ }
+
+ for (x = 0; x < num_groups; x++) {
+ if (!strcmp(mygroup, groups[x])) {
+ igrp = 1;
+ break;
+ }
+ }
}
- if (res == 0) {
+
+ if (!igrp)
continue;
- } else if (res == '*') {
- running = 0;
- } else if (res == '#') {
- if (!ast_strlen_zero(inp)) {
- running = x ? atoi(inp) : -1;
- break;
+
+ strcpy(peer_name, "spy-");
+ strncat(peer_name, peer->name, AST_NAME_STRLEN);
+ ptr = strchr(peer_name, '/');
+ *ptr++ = '\0';
+
+ for (s = peer_name; s < ptr; s++)
+ *s = tolower(*s);
+
+ if (!ast_test_flag(flags, OPTION_QUIET)) {
+ if (ast_fileexists(peer_name, NULL, NULL) != -1) {
+ res = ast_streamfile(chan, peer_name, chan->language);
+ if (!res)
+ res = ast_waitstream(chan, "");
+ if (res)
+ break;
+ } else
+ res = ast_say_character_str(chan, peer_name, "", chan->language);
+ if ((num = atoi(ptr)))
+ ast_say_digits(chan, atoi(ptr), "", chan->language);
+ }
+
+ waitms = 5000;
+ res = channel_spy(chan, peer, &volfactor, fd, flags);
+
+ if (res == -1) {
+ break;
+ } else if (res > 1 && spec) {
+ snprintf(nameprefix, AST_NAME_STRLEN, "%s/%d", spec, res);
+ if ((next = ast_get_channel_by_name_prefix_locked(nameprefix, strlen(nameprefix)))) {
+ ast_channel_unlock(next);
} else {
- (*volfactor)++;
- if (*volfactor > 4) {
- *volfactor = -4;
- }
- 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);
- csth.spy.read_vol_adjustment = csth.volfactor;
- csth.spy.write_vol_adjustment = csth.volfactor;
+ /* stay on this channel */
+ next = peer;
}
- } else if (res >= 48 && res <= 57) {
- inp[x++] = res;
+ peer = NULL;
}
}
- ast_deactivate_generator(chan);
- stop_spying(spyee, &csth.spy);
-
- if (option_verbose >= 2) {
- ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
- }
- } else {
- running = 0;
- }
-
- ast_mutex_destroy(&csth.spy.lock);
-
- return running;
+ }
+
+ ast_clear_flag(chan, AST_FLAG_SPYING);
+
+ ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
+
+ return res;
}
static int chanspy_exec(struct ast_channel *chan, void *data)
{
struct localuser *u;
- struct ast_channel *peer=NULL, *prev=NULL;
- char name[AST_NAME_STRLEN],
- peer_name[AST_NAME_STRLEN + 5],
- *args,
- *ptr = NULL,
- *options = NULL,
- *spec = NULL,
- *argv[5],
- *mygroup = NULL,
- *recbase = NULL;
- int res = -1,
- volfactor = 0,
- silent = 0,
- argc = 0,
- bronly = 0,
- chosen = 0,
- count=0,
- waitms = 100,
- num = 0,
- oldrf = 0,
- oldwf = 0,
- fd = 0;
+ char *options = NULL;
+ char *spec = NULL;
+ char *argv[2];
+ char *mygroup = NULL;
+ char *recbase = NULL;
+ int fd = 0;
struct ast_flags flags;
- signed char zero_volume = 0;
-
- if (!(args = ast_strdupa(data)))
- return -1;
+ int oldwf = 0;
+ int argc = 0;
+ int volfactor = 0;
+ int res;
+
+ data = ast_strdupa(data);
LOCAL_USER_ADD(u);
- oldrf = chan->readformat;
+ if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
+ spec = argv[0];
+ if (argc > 1)
+ options = argv[1];
+
+ if (ast_strlen_zero(spec) || !strcmp(spec, "all"))
+ spec = NULL;
+ }
+
+ if (options) {
+ char *opts[OPT_ARG_ARRAY_SIZE];
+
+ ast_app_parse_options(spy_opts, &flags, opts, options);
+ if (ast_test_flag(&flags, OPTION_GROUP))
+ mygroup = opts[OPT_ARG_GROUP];
+
+ if (ast_test_flag(&flags, OPTION_RECORD) &&
+ !(recbase = opts[OPT_ARG_RECORD]))
+ recbase = "chanspy";
+
+ if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
+ int vol;
+
+ if ((sscanf(opts[OPT_ARG_VOLUME], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
+ ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
+ else
+ volfactor = vol;
+ }
+
+ if (ast_test_flag(&flags, OPTION_PRIVATE))
+ ast_set_flag(&flags, OPTION_WHISPER);
+ }
+
oldwf = chan->writeformat;
- if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
- ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
- LOCAL_USER_REMOVE(u);
- return -1;
- }
-
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
LOCAL_USER_REMOVE(u);
return -1;
}
- ast_answer(chan);
-
- ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
-
- if ((argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
- spec = argv[0];
- if ( argc > 1) {
+ if (recbase) {
+ char filename[512];
+
+ snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
+ if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644)) <= 0) {
+ ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
+ fd = 0;
+ }
+ }
+
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, spec, NULL, NULL);
+
+ if (fd)
+ close(fd);
+
+ if (oldwf && ast_set_write_format(chan, oldwf) < 0)
+ ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+
+ LOCAL_USER_REMOVE(u);
+
+ return res;
+}
+
+static int extenspy_exec(struct ast_channel *chan, void *data)
+{
+ struct localuser *u;
+ char *options = NULL;
+ char *exten = NULL;
+ char *context = NULL;
+ char *argv[2];
+ char *mygroup = NULL;
+ char *recbase = NULL;
+ int fd = 0;
+ struct ast_flags flags;
+ int oldwf = 0;
+ int argc = 0;
+ int volfactor = 0;
+ int res;
+
+ data = ast_strdupa(data);
+
+ LOCAL_USER_ADD(u);
+
+ if ((argc = ast_app_separate_args(data, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
+ context = argv[0];
+ exten = strsep(&context, "@");
+ if (ast_strlen_zero(context))
+ context = ast_strdupa(chan->context);
+ if (argc > 1)
options = argv[1];
- }
- if (ast_strlen_zero(spec) || !strcmp(spec, "all")) {
- spec = NULL;
- }
}
if (options) {
char *opts[OPT_ARG_ARRAY_SIZE];
- ast_app_parse_options(chanspy_opts, &flags, opts, options);
- if (ast_test_flag(&flags, OPTION_GROUP)) {
- mygroup = opts[1];
- }
- if (ast_test_flag(&flags, OPTION_RECORD)) {
- if (!(recbase = opts[2])) {
- recbase = "chanspy";
- }
- }
- silent = ast_test_flag(&flags, OPTION_QUIET);
- bronly = ast_test_flag(&flags, OPTION_BRIDGED);
- if (ast_test_flag(&flags, OPTION_VOLUME) && opts[1]) {
+
+ ast_app_parse_options(spy_opts, &flags, opts, options);
+ if (ast_test_flag(&flags, OPTION_GROUP))
+ mygroup = opts[OPT_ARG_GROUP];
+
+ if (ast_test_flag(&flags, OPTION_RECORD) &&
+ !(recbase = opts[OPT_ARG_RECORD]))
+ recbase = "chanspy";
+
+ if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
int vol;
- if ((sscanf(opts[0], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
+ if ((sscanf(opts[OPT_ARG_VOLUME], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
else
volfactor = vol;
- }
+ }
+
+ if (ast_test_flag(&flags, OPTION_PRIVATE))
+ ast_set_flag(&flags, OPTION_WHISPER);
+ }
+
+ oldwf = chan->writeformat;
+ if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+ ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+ LOCAL_USER_REMOVE(u);
+ return -1;
}
if (recbase) {
char filename[512];
- snprintf(filename,sizeof(filename),"%s/%s.%d.raw",ast_config_AST_MONITOR_DIR, recbase, (int)time(NULL));
+
+ snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644)) <= 0) {
- ast_log(LOG_WARNING, "Cannot open %s for recording\n", filename);
+ ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
fd = 0;
}
}
- for(;;) {
- if (!silent) {
- res = ast_streamfile(chan, "beep", chan->language);
- if (!res)
- res = ast_waitstream(chan, "");
- if (res < 0) {
- ast_clear_flag(chan, AST_FLAG_SPYING);
- break;
- }
- }
-
- count = 0;
- res = ast_waitfordigit(chan, waitms);
- if (res < 0) {
- ast_clear_flag(chan, AST_FLAG_SPYING);
- break;
- }
-
- peer = local_channel_walk(NULL);
- prev=NULL;
- while(peer) {
- if (peer != chan) {
- const char *group = NULL;
- int igrp = 1;
- char *groups[25] = {0};
- int num_groups = 0;
- char *dup_group;
-
- if (peer == prev && !chosen) {
- break;
- }
- chosen = 0;
-
- if (mygroup) {
- int x;
-
- if ((group = pbx_builtin_getvar_helper(peer, "SPYGROUP"))) {
- dup_group = ast_strdupa(group);
- num_groups = ast_app_separate_args(dup_group, ':', groups, sizeof(groups) / sizeof(groups[0]));
- }
-
- igrp = 0;
- if (num_groups) {
- for (x = 0; x < num_groups; x++) {
- if (!strcmp(mygroup, groups[x])) {
- igrp = 1;
- break;
- }
- }
- }
- }
-
- if (igrp && (!spec || ((strlen(spec) <= strlen(peer->name) &&
- !strncasecmp(peer->name, spec, strlen(spec)))))) {
- if (peer && (!bronly || ast_bridged_channel(peer)) &&
- !ast_check_hangup(peer) && !ast_test_flag(peer, AST_FLAG_SPYING)) {
- int x = 0;
- strncpy(peer_name, "spy-", 5);
- strncpy(peer_name + strlen(peer_name), peer->name, AST_NAME_STRLEN);
- ptr = strchr(peer_name, '/');
- *ptr = '\0';
- ptr++;
- for (x = 0 ; x < strlen(peer_name) ; x++) {
- if (peer_name[x] == '/') {
- break;
- }
- peer_name[x] = tolower(peer_name[x]);
- }
-
- if (!silent) {
- if (ast_fileexists(peer_name, NULL, NULL) != -1) {
- res = ast_streamfile(chan, peer_name, chan->language);
- if (!res)
- res = ast_waitstream(chan, "");
- if (res)
- break;
- } else
- res = ast_say_character_str(chan, peer_name, "", chan->language);
- if ((num=atoi(ptr)))
- ast_say_digits(chan, atoi(ptr), "", chan->language);
- }
- count++;
- prev = peer;
- res = channel_spy(chan, peer, &volfactor, fd);
- if (res == -1) {
- break;
- } else if (res > 1 && spec) {
- snprintf(name, AST_NAME_STRLEN, "%s/%d", spec, res);
- if ((peer = local_get_channel_begin_name(name))) {
- chosen = 1;
- }
- continue;
- }
- }
- }
- }
- if ((peer = local_channel_walk(peer)) == NULL) {
- break;
- }
- }
- waitms = count ? 100 : 5000;
- }
-
-
- if (fd > 0) {
+ res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, exten, context);
+
+ if (fd)
close(fd);
- }
-
- if (oldrf && ast_set_read_format(chan, oldrf) < 0) {
- ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
- }
-
- if (oldwf && ast_set_write_format(chan, oldwf) < 0) {
+
+ if (oldwf && ast_set_write_format(chan, oldwf) < 0)
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
- }
-
- ast_clear_flag(chan, AST_FLAG_SPYING);
-
- ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);
-
- ALL_DONE(u, res);
+
+ LOCAL_USER_REMOVE(u);
+
+ return res;
}
static int unload_module(void *mod)
{
- int res;
-
- res = ast_unregister_application(app);
+ int res = 0;
+
+ res |= ast_unregister_application(app_chan);
+ res |= ast_unregister_application(app_ext);
STANDARD_HANGUP_LOCALUSERS;
@@ -584,8 +717,14 @@
static int load_module(void *mod)
{
+ int res = 0;
+
__mod_desc = mod;
- return ast_register_application(app, chanspy_exec, tdesc, desc);
+
+ res |= ast_register_application(app_chan, chanspy_exec, tdesc, desc_chan);
+ res |= ast_register_application(app_ext, extenspy_exec, tdesc, desc_ext);
+
+ return res;
}
static const char *description(void)
Modified: team/group/asterisk-imap/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-imap/apps/app_dial.c?rev=38758&r1=38757&r2=38758&view=diff
==============================================================================
--- team/group/asterisk-imap/apps/app_dial.c (original)
+++ team/group/asterisk-imap/apps/app_dial.c Wed Aug 2 16:02:12 2006
@@ -1214,8 +1214,8 @@
/* Our status will at least be NOANSWER */
strcpy(status, "NOANSWER");
if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
- moh=1;
- ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+ moh = 1;
+ ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
ast_indicate(chan, AST_CONTROL_RINGING);
sentringing++;
@@ -1273,7 +1273,7 @@
if (ast_test_flag(&opts, OPT_MUSICBACK) && !ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) {
ast_indicate(chan, -1);
- ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+ ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
ast_indicate(chan, AST_CONTROL_RINGING);
sentringing++;
@@ -1701,7 +1701,7 @@
res = ast_waitstream(chan, AST_DIGIT_ANY);
if (!res && sleep) {
if (!ast_test_flag(chan, AST_FLAG_MOH))
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
res = ast_waitfordigit(chan, sleep);
}
} else {
@@ -1709,7 +1709,7 @@
res = ast_waitstream(chan, "");
[... 11080 lines stripped ...]
More information about the svn-commits
mailing list