2001-12-27 11:07:33 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2001-12-27 11:07:33 +00:00
|
|
|
*
|
2012-04-28 00:58:54 +00:00
|
|
|
* Copyright (C) 1999 - 2012, Digium, Inc.
|
|
|
|
* Copyright (C) 2012, Russell Bryant
|
2001-12-27 11:07:33 +00:00
|
|
|
*
|
2004-08-31 13:32:11 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2001-12-27 11:07:33 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
2001-12-27 11:07:33 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2006-01-19 22:09:18 +00:00
|
|
|
* \brief Routines implementing call features as call pickup, parking and transfer
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
2012-03-22 19:51:16 +00:00
|
|
|
* \author Mark Spencer <markster@digium.com>
|
2001-12-27 11:07:33 +00:00
|
|
|
*/
|
|
|
|
|
2012-10-18 14:17:40 +00:00
|
|
|
/*! \li \ref features.c uses the configuration file \ref features.conf
|
|
|
|
* \addtogroup configuration_file Configuration Files
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \page features.conf features.conf
|
|
|
|
* \verbinclude features.conf.sample
|
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2008-01-23 23:09:11 +00:00
|
|
|
#include "asterisk/_private.h"
|
|
|
|
|
2005-06-06 22:12:19 +00:00
|
|
|
#include <pthread.h>
|
2010-03-20 12:03:07 +00:00
|
|
|
#include <signal.h>
|
2005-06-06 22:12:19 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
2005-06-23 22:12:01 +00:00
|
|
|
#include "asterisk/causes.h"
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
#include "asterisk/app.h"
|
|
|
|
#include "asterisk/say.h"
|
|
|
|
#include "asterisk/features.h"
|
|
|
|
#include "asterisk/musiconhold.h"
|
|
|
|
#include "asterisk/config.h"
|
|
|
|
#include "asterisk/cli.h"
|
|
|
|
#include "asterisk/manager.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/adsi.h"
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
#include "asterisk/devicestate.h"
|
2005-11-08 04:02:35 +00:00
|
|
|
#include "asterisk/monitor.h"
|
2007-11-30 21:19:57 +00:00
|
|
|
#include "asterisk/audiohook.h"
|
2008-03-01 01:30:37 +00:00
|
|
|
#include "asterisk/global_datastores.h"
|
2008-04-21 23:42:45 +00:00
|
|
|
#include "asterisk/astobj2.h"
|
2010-03-10 20:51:23 +00:00
|
|
|
#include "asterisk/test.h"
|
2013-07-25 04:06:32 +00:00
|
|
|
#include "asterisk/bridge.h"
|
|
|
|
#include "asterisk/bridge_basic.h"
|
|
|
|
#include "asterisk/bridge_after.h"
|
2013-06-28 19:19:15 +00:00
|
|
|
#include "asterisk/stasis.h"
|
|
|
|
#include "asterisk/stasis_channels.h"
|
2013-06-06 21:40:35 +00:00
|
|
|
#include "asterisk/features_config.h"
|
|
|
|
|
|
|
|
/* BUGBUG TEST_FRAMEWORK is disabled because parking tests no longer work. */
|
|
|
|
#undef TEST_FRAMEWORK
|
2001-12-27 11:07:33 +00:00
|
|
|
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
/*
|
|
|
|
* Party A - transferee
|
|
|
|
* Party B - transferer
|
|
|
|
* Party C - target of transfer
|
|
|
|
*
|
|
|
|
* DTMF attended transfer works within the channel bridge.
|
|
|
|
* Unfortunately, when either party A or B in the channel bridge
|
|
|
|
* hangs up, that channel is not completely hung up until the
|
|
|
|
* transfer completes. This is a real problem depending upon
|
|
|
|
* the channel technology involved.
|
|
|
|
*
|
|
|
|
* For chan_dahdi, the channel is crippled until the hangup is
|
|
|
|
* complete. Either the channel is not useable (analog) or the
|
|
|
|
* protocol disconnect messages are held up (PRI/BRI/SS7) and
|
|
|
|
* the media is not released.
|
|
|
|
*
|
|
|
|
* For chan_sip, a call limit of one is going to block that
|
|
|
|
* endpoint from any further calls until the hangup is complete.
|
|
|
|
*
|
|
|
|
* For party A this is a minor problem. The party A channel
|
|
|
|
* will only be in this condition while party B is dialing and
|
|
|
|
* when party B and C are conferring. The conversation between
|
|
|
|
* party B and C is expected to be a short one. Party B is
|
|
|
|
* either asking a question of party C or announcing party A.
|
|
|
|
* Also party A does not have much incentive to hangup at this
|
|
|
|
* point.
|
|
|
|
*
|
|
|
|
* For party B this can be a major problem during a blonde
|
|
|
|
* transfer. (A blonde transfer is our term for an attended
|
|
|
|
* transfer that is converted into a blind transfer. :)) Party
|
|
|
|
* B could be the operator. When party B hangs up, he assumes
|
|
|
|
* that he is out of the original call entirely. The party B
|
|
|
|
* channel will be in this condition while party C is ringing,
|
|
|
|
* while attempting to recall party B, and while waiting between
|
|
|
|
* call attempts.
|
|
|
|
*
|
|
|
|
* WARNING:
|
|
|
|
* The ATXFER_NULL_TECH conditional is a hack to fix the
|
|
|
|
* problem. It will replace the party B channel technology with
|
|
|
|
* a NULL channel driver. The consequences of this code is that
|
|
|
|
* the 'h' extension will not be able to access any channel
|
|
|
|
* technology specific information like SIP statistics for the
|
|
|
|
* call.
|
|
|
|
*
|
|
|
|
* Uncomment the ATXFER_NULL_TECH define below to replace the
|
|
|
|
* party B channel technology in the channel bridge to complete
|
|
|
|
* hanging up the channel technology.
|
|
|
|
*/
|
|
|
|
//#define ATXFER_NULL_TECH 1
|
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Bridge" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Bridge two channels.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="channel" required="true">
|
|
|
|
<para>The current channel is bridged to the specified <replaceable>channel</replaceable>.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<optionlist>
|
|
|
|
<option name="p">
|
|
|
|
<para>Play a courtesy tone to <replaceable>channel</replaceable>.</para>
|
|
|
|
</option>
|
2012-03-22 21:25:22 +00:00
|
|
|
<option name="F" argsep="^">
|
|
|
|
<argument name="context" required="false" />
|
|
|
|
<argument name="exten" required="false" />
|
|
|
|
<argument name="priority" required="true" />
|
|
|
|
<para>When the bridger hangs up, transfer the <emphasis>bridged</emphasis> party
|
|
|
|
to the specified destination and <emphasis>start</emphasis> execution at that location.</para>
|
|
|
|
<note>
|
|
|
|
<para>Any channel variables you want the called channel to inherit from the caller channel must be
|
|
|
|
prefixed with one or two underbars ('_').</para>
|
|
|
|
</note>
|
|
|
|
<note>
|
|
|
|
<para>This option will override the 'x' option</para>
|
|
|
|
</note>
|
|
|
|
</option>
|
|
|
|
<option name="F">
|
|
|
|
<para>When the bridger hangs up, transfer the <emphasis>bridged</emphasis> party
|
|
|
|
to the next priority of the current extension and <emphasis>start</emphasis> execution
|
|
|
|
at that location.</para>
|
|
|
|
<note>
|
|
|
|
<para>Any channel variables you want the called channel to inherit from the caller channel must be
|
|
|
|
prefixed with one or two underbars ('_').</para>
|
|
|
|
</note>
|
|
|
|
<note>
|
|
|
|
<para>Using this option from a Macro() or GoSub() might not make sense as there would be no return points.</para>
|
|
|
|
</note>
|
|
|
|
<note>
|
|
|
|
<para>This option will override the 'x' option</para>
|
|
|
|
</note>
|
|
|
|
</option>
|
|
|
|
|
2009-09-24 20:29:51 +00:00
|
|
|
<option name="h">
|
|
|
|
<para>Allow the called party to hang up by sending the
|
|
|
|
<replaceable>*</replaceable> DTMF digit.</para>
|
|
|
|
</option>
|
|
|
|
<option name="H">
|
|
|
|
<para>Allow the calling party to hang up by pressing the
|
|
|
|
<replaceable>*</replaceable> DTMF digit.</para>
|
|
|
|
</option>
|
|
|
|
<option name="k">
|
|
|
|
<para>Allow the called party to enable parking of the call by sending
|
2011-08-16 17:23:08 +00:00
|
|
|
the DTMF sequence defined for call parking in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="K">
|
|
|
|
<para>Allow the calling party to enable parking of the call by sending
|
2011-08-16 17:23:08 +00:00
|
|
|
the DTMF sequence defined for call parking in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="L(x[:y][:z])">
|
|
|
|
<para>Limit the call to <replaceable>x</replaceable> ms. Play a warning
|
|
|
|
when <replaceable>y</replaceable> ms are left. Repeat the warning every
|
|
|
|
<replaceable>z</replaceable> ms. The following special variables can be
|
|
|
|
used with this option:</para>
|
|
|
|
<variablelist>
|
|
|
|
<variable name="LIMIT_PLAYAUDIO_CALLER">
|
|
|
|
<para>Play sounds to the caller. yes|no (default yes)</para>
|
|
|
|
</variable>
|
2012-03-22 19:51:16 +00:00
|
|
|
<variable name="LIMIT_PLAYAUDIO_CALLEE">
|
2009-09-24 20:29:51 +00:00
|
|
|
<para>Play sounds to the callee. yes|no</para>
|
|
|
|
</variable>
|
|
|
|
<variable name="LIMIT_TIMEOUT_FILE">
|
|
|
|
<para>File to play when time is up.</para>
|
|
|
|
</variable>
|
|
|
|
<variable name="LIMIT_CONNECT_FILE">
|
|
|
|
<para>File to play when call begins.</para>
|
|
|
|
</variable>
|
|
|
|
<variable name="LIMIT_WARNING_FILE">
|
|
|
|
<para>File to play as warning if <replaceable>y</replaceable> is
|
|
|
|
defined. The default is to say the time remaining.</para>
|
|
|
|
</variable>
|
|
|
|
</variablelist>
|
|
|
|
</option>
|
|
|
|
<option name="S(x)">
|
|
|
|
<para>Hang up the call after <replaceable>x</replaceable> seconds *after* the called party has answered the call.</para>
|
|
|
|
</option>
|
|
|
|
<option name="t">
|
|
|
|
<para>Allow the called party to transfer the calling party by sending the
|
2011-08-16 17:23:08 +00:00
|
|
|
DTMF sequence defined in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="T">
|
|
|
|
<para>Allow the calling party to transfer the called party by sending the
|
2011-08-16 17:23:08 +00:00
|
|
|
DTMF sequence defined in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="w">
|
|
|
|
<para>Allow the called party to enable recording of the call by sending
|
2011-08-16 17:23:08 +00:00
|
|
|
the DTMF sequence defined for one-touch recording in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="W">
|
|
|
|
<para>Allow the calling party to enable recording of the call by sending
|
2011-08-16 17:23:08 +00:00
|
|
|
the DTMF sequence defined for one-touch recording in <filename>features.conf</filename>.</para>
|
2009-09-24 20:29:51 +00:00
|
|
|
</option>
|
|
|
|
<option name="x">
|
|
|
|
<para>Cause the called party to be hung up after the bridge, instead of being
|
|
|
|
restarted in the dialplan.</para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Allows the ability to bridge two channels via the dialplan.</para>
|
|
|
|
<para>This application sets the following channel variable upon completion:</para>
|
|
|
|
<variablelist>
|
|
|
|
<variable name="BRIDGERESULT">
|
|
|
|
<para>The result of the bridge attempt as a text string.</para>
|
|
|
|
<value name="SUCCESS" />
|
|
|
|
<value name="FAILURE" />
|
|
|
|
<value name="LOOP" />
|
|
|
|
<value name="NONEXISTENT" />
|
|
|
|
<value name="INCOMPATIBLE" />
|
|
|
|
</variable>
|
|
|
|
</variablelist>
|
|
|
|
</description>
|
|
|
|
</application>
|
2009-05-22 17:52:35 +00:00
|
|
|
<manager name="Bridge" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Bridge two channels already in the PBX.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
|
|
|
|
<parameter name="Channel1" required="true">
|
|
|
|
<para>Channel to Bridge to Channel2.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="Channel2" required="true">
|
|
|
|
<para>Channel to Bridge to Channel1.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="Tone">
|
|
|
|
<para>Play courtesy tone to Channel 2.</para>
|
|
|
|
<enumlist>
|
|
|
|
<enum name="no" />
|
2013-05-28 14:45:31 +00:00
|
|
|
<enum name="Channel1" />
|
|
|
|
<enum name="Channel2" />
|
|
|
|
<enum name="Both" />
|
2009-05-22 17:52:35 +00:00
|
|
|
</enumlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Bridge together two channels already in the PBX.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
2013-06-28 19:19:15 +00:00
|
|
|
<managerEvent language="en_US" name="Pickup">
|
|
|
|
<managerEventInstance class="EVENT_FLAG_CALL">
|
|
|
|
<synopsis>Raised when a call pickup occurs.</synopsis>
|
|
|
|
<syntax>
|
2013-08-01 17:07:52 +00:00
|
|
|
<channel_snapshot/>
|
|
|
|
<channel_snapshot prefix="Target"/>
|
2013-06-28 19:19:15 +00:00
|
|
|
</syntax>
|
|
|
|
</managerEventInstance>
|
|
|
|
</managerEvent>
|
2008-11-01 21:10:07 +00:00
|
|
|
***/
|
|
|
|
|
2011-01-03 23:18:20 +00:00
|
|
|
#define DEFAULT_PARK_TIME 45000 /*!< ms */
|
|
|
|
#define DEFAULT_PARK_EXTENSION "700"
|
2012-01-20 20:47:42 +00:00
|
|
|
#define DEFAULT_COMEBACK_CONTEXT "parkedcallstimeout"
|
|
|
|
#define DEFAULT_COMEBACK_TO_ORIGIN 1
|
|
|
|
#define DEFAULT_COMEBACK_DIAL_TIME 30
|
2003-02-02 19:37:23 +00:00
|
|
|
|
2005-06-23 22:12:01 +00:00
|
|
|
#define AST_MAX_WATCHERS 256
|
Merged revisions 172517 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r172517 | twilson | 2009-01-30 11:47:41 -0600 (Fri, 30 Jan 2009) | 37 lines
Fix feature inheritance with builtin features
When using builtin features like parking and transfers, the AST_FEATURE_* flags
would not be set correctly for all instances when either performing a builtin
attended transfer, or parking a call and getting the timeout callback. Also,
there was no way on a per-call basis to specify what features someone should
have on picking up a parked call (since that doesn't involve the Dial() command).
There was a global option for setting whether or not all users who pickup a
parked call should have AST_FEATURE_REDIRECT set, but nothing for DISCONNECT,
AUTOMON, or PARKCALL.
This patch:
1) adds the BRIDGE_FEATURES dialplan variable which can be set either in the
dialplan or with setvar in channels that support it. This variable can be set
to any combination of 't', 'k', 'w', and 'h' (case insensitive matching of the
equivalent dial options), to set what features should be activated on this
channel. The patch moves the setting of the features datastores into the
bridging code instead of app_dial to help facilitate this.
2) adds global options parkedcallparking, parkedcallhangup, and
parkedcallrecording to be similar to the parkedcalltransfers option for
globally setting features.
3) has builtin_atxfer call builtin_parkcall if being transfered to the parking
extension since tracking everything through multiple masquerades, etc. is
difficult and error-prone
4) attempts to fix all cases of return calls from parking and completed builtin
transfers not having the correct permissions
(closes issue #14274)
Reported by: aragon
Patches:
fix_feature_inheritence.diff.txt uploaded by otherwiseguy (license 396)
Tested by: aragon, otherwiseguy
Review http://reviewboard.digium.com/r/138/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-01-30 21:29:12 +00:00
|
|
|
#define MAX_DIAL_FEATURE_OPTIONS 30
|
2005-06-23 22:12:01 +00:00
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/* TODO Scrape all of the parking stuff out of features.c */
|
|
|
|
|
Merged revisions 310902 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r310902 | twilson | 2011-03-16 12:19:57 -0500 (Wed, 16 Mar 2011) | 43 lines
Merged revisions 310889 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r310889 | twilson | 2011-03-16 12:03:27 -0500 (Wed, 16 Mar 2011) | 36 lines
Merged revisions 310888 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r310888 | twilson | 2011-03-16 11:58:42 -0500 (Wed, 16 Mar 2011) | 29 lines
Don't delay DTMF in core bridge while listening for DTMF features
This patch is mostly the work of Olle Johansson. I did some cleanup and
added the silence generating code if transmit_silence is set.
When a channel listens for DTMF in the core bridge, the outbound DTMF is not
sent until we have received DTMF_END. For a long DTMF, this is a disaster. We
send 4 seconds of DTMF to Asterisk, which sends no audio for those 4 seconds.
Some products see this delay and the time skew on RTP packets that results and
start ignoring the audio that is sent afterward.
With this change, the DTMF_BEGIN frame is inspected and checked. If it matches
a feature code, we wait for DTMF_END and activate the feature as before. If
transmit_silence=yes in asterisk.conf, silence is sent if we paritally match a
multi-digit feature. If it doesn't match a feature, the frame is forwarded
along with the DTMF_END without delay. By doing it this way, DTMF is not delayed.
(closes issue #15642)
Reported by: jasonshugart
Patches:
issue_15652_dtmf_ast-1.4.patch.txt uploaded by twilson (license 396)
Tested by: globalnetinc, jde
(closes issue #16625)
Reported by: sharvanek
Review: https://reviewboard.asterisk.org/r/1092/
Review: https://reviewboard.asterisk.org/r/1125/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@310941 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-03-16 17:29:16 +00:00
|
|
|
typedef enum {
|
|
|
|
FEATURE_INTERPRET_DETECT, /* Used by ast_feature_detect */
|
|
|
|
FEATURE_INTERPRET_DO, /* Used by feature_interpret */
|
|
|
|
FEATURE_INTERPRET_CHECK, /* Used by feature_check */
|
|
|
|
} feature_interpret_op;
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Parking lot access ramp dialplan usage entry. */
|
|
|
|
struct parking_dp_ramp {
|
|
|
|
/*! Next node in the parking lot spaces dialplan list. */
|
|
|
|
AST_LIST_ENTRY(parking_dp_ramp) node;
|
|
|
|
/*! TRUE if the parking lot access extension is exclusive. */
|
|
|
|
unsigned int exclusive:1;
|
|
|
|
/*! Parking lot access extension */
|
|
|
|
char exten[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! Parking lot dialplan access ramp map */
|
|
|
|
AST_LIST_HEAD_NOLOCK(parking_dp_ramp_map, parking_dp_ramp);
|
|
|
|
|
|
|
|
/*! Parking lot spaces dialplan usage entry. */
|
|
|
|
struct parking_dp_spaces {
|
|
|
|
/*! Next node in the parking lot spaces dialplan list. */
|
|
|
|
AST_LIST_ENTRY(parking_dp_spaces) node;
|
|
|
|
/*! First parking space */
|
|
|
|
int start;
|
|
|
|
/*! Last parking space */
|
|
|
|
int stop;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! Parking lot dialplan context space map */
|
|
|
|
AST_LIST_HEAD_NOLOCK(parking_dp_space_map, parking_dp_spaces);
|
|
|
|
|
|
|
|
/*! Parking lot context dialplan usage entry. */
|
|
|
|
struct parking_dp_context {
|
|
|
|
/*! Next node in the parking lot contexts dialplan list. */
|
|
|
|
AST_LIST_ENTRY(parking_dp_context) node;
|
|
|
|
/*! Parking access extensions defined in this context. */
|
|
|
|
struct parking_dp_ramp_map access_extens;
|
|
|
|
/*! Parking spaces defined in this context. */
|
|
|
|
struct parking_dp_space_map spaces;
|
|
|
|
/*! Parking hints defined in this context. */
|
|
|
|
struct parking_dp_space_map hints;
|
|
|
|
/*! Parking lot context name */
|
|
|
|
char context[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! Parking lot dialplan usage map. */
|
|
|
|
AST_LIST_HEAD_NOLOCK(parking_dp_map, parking_dp_context);
|
|
|
|
|
2011-05-20 17:04:53 +00:00
|
|
|
/*!
|
|
|
|
* \brief Description of one parked call, added to a list while active, then removed.
|
|
|
|
* The list belongs to a parkinglot.
|
|
|
|
*/
|
2008-04-21 23:42:45 +00:00
|
|
|
struct parkeduser {
|
2011-08-16 17:23:08 +00:00
|
|
|
struct ast_channel *chan; /*!< Parked channel */
|
|
|
|
struct timeval start; /*!< Time the park started */
|
|
|
|
int parkingnum; /*!< Parking lot space used */
|
2008-04-21 23:42:45 +00:00
|
|
|
char parkingexten[AST_MAX_EXTENSION]; /*!< If set beforehand, parking extension used for this call */
|
|
|
|
char context[AST_MAX_CONTEXT]; /*!< Where to go if our parking time expires */
|
|
|
|
char exten[AST_MAX_EXTENSION];
|
|
|
|
int priority;
|
2012-04-28 00:58:54 +00:00
|
|
|
unsigned int parkingtime; /*!< Maximum length in parking lot before return */
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Method to entertain the caller when parked: AST_CONTROL_RINGING, AST_CONTROL_HOLD, or 0(none) */
|
|
|
|
enum ast_control_frame_type hold_method;
|
2009-07-08 17:26:26 +00:00
|
|
|
unsigned int notquiteyet:1;
|
|
|
|
unsigned int options_specified:1;
|
2011-10-18 21:15:45 +00:00
|
|
|
char peername[AST_CHANNEL_NAME];
|
2008-04-21 23:42:45 +00:00
|
|
|
unsigned char moh_trys;
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Parking lot this entry belongs to. Holds a parking lot reference. */
|
2008-04-21 23:42:45 +00:00
|
|
|
struct ast_parkinglot *parkinglot;
|
|
|
|
AST_LIST_ENTRY(parkeduser) list;
|
|
|
|
};
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Parking lot configuration options. */
|
|
|
|
struct parkinglot_cfg {
|
|
|
|
/*! Music class used for parking */
|
|
|
|
char mohclass[MAX_MUSICCLASS];
|
|
|
|
/*! Extension to park calls in this parking lot. */
|
|
|
|
char parkext[AST_MAX_EXTENSION];
|
|
|
|
/*! Context for which parking is made accessible */
|
2012-01-20 20:47:42 +00:00
|
|
|
char parking_con[AST_MAX_CONTEXT];
|
|
|
|
/*! Context that timed-out parked calls are called back on when comebacktoorigin=no */
|
|
|
|
char comebackcontext[AST_MAX_CONTEXT];
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! First available extension for parking */
|
|
|
|
int parking_start;
|
|
|
|
/*! Last available extension for parking */
|
|
|
|
int parking_stop;
|
|
|
|
/*! Default parking time in ms. */
|
2012-04-28 00:58:54 +00:00
|
|
|
unsigned int parkingtime;
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \brief Enable DTMF based transfers on bridge when picking up parked calls.
|
|
|
|
*
|
|
|
|
* \details
|
|
|
|
* none(0)
|
|
|
|
* AST_FEATURE_FLAG_BYCALLEE
|
|
|
|
* AST_FEATURE_FLAG_BYCALLER
|
|
|
|
* AST_FEATURE_FLAG_BYBOTH
|
|
|
|
*/
|
|
|
|
int parkedcalltransfers;
|
|
|
|
/*!
|
|
|
|
* \brief Enable DTMF based parking on bridge when picking up parked calls.
|
|
|
|
*
|
|
|
|
* \details
|
|
|
|
* none(0)
|
|
|
|
* AST_FEATURE_FLAG_BYCALLEE
|
|
|
|
* AST_FEATURE_FLAG_BYCALLER
|
|
|
|
* AST_FEATURE_FLAG_BYBOTH
|
|
|
|
*/
|
|
|
|
int parkedcallreparking;
|
|
|
|
/*!
|
|
|
|
* \brief Enable DTMF based hangup on a bridge when pickup up parked calls.
|
|
|
|
*
|
|
|
|
* \details
|
|
|
|
* none(0)
|
|
|
|
* AST_FEATURE_FLAG_BYCALLEE
|
|
|
|
* AST_FEATURE_FLAG_BYCALLER
|
|
|
|
* AST_FEATURE_FLAG_BYBOTH
|
|
|
|
*/
|
|
|
|
int parkedcallhangup;
|
|
|
|
/*!
|
|
|
|
* \brief Enable DTMF based recording on a bridge when picking up parked calls.
|
|
|
|
*
|
|
|
|
* \details
|
|
|
|
* none(0)
|
|
|
|
* AST_FEATURE_FLAG_BYCALLEE
|
|
|
|
* AST_FEATURE_FLAG_BYCALLER
|
|
|
|
* AST_FEATURE_FLAG_BYBOTH
|
|
|
|
*/
|
|
|
|
int parkedcallrecording;
|
|
|
|
|
2012-01-20 20:47:42 +00:00
|
|
|
/*! Time in seconds to dial the device that parked a timedout parked call */
|
|
|
|
unsigned int comebackdialtime;
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! TRUE if findslot is set to next */
|
|
|
|
unsigned int parkfindnext:1;
|
|
|
|
/*! TRUE if the parking lot is exclusively accessed by parkext */
|
|
|
|
unsigned int parkext_exclusive:1;
|
|
|
|
/*! Add parking hints automatically */
|
|
|
|
unsigned int parkaddhints:1;
|
|
|
|
/*! TRUE if configuration is invalid and the parking lot should not be used. */
|
|
|
|
unsigned int is_invalid:1;
|
2012-01-20 20:47:42 +00:00
|
|
|
/*! TRUE if a timed out parked call goes back to the parker */
|
|
|
|
unsigned int comebacktoorigin:1;
|
2011-08-16 17:23:08 +00:00
|
|
|
};
|
|
|
|
|
2008-04-21 23:42:45 +00:00
|
|
|
/*! \brief Structure for parking lots which are put in a container. */
|
|
|
|
struct ast_parkinglot {
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Name of the parking lot. */
|
2008-04-21 23:42:45 +00:00
|
|
|
char name[AST_MAX_CONTEXT];
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Parking lot user configuration. */
|
|
|
|
struct parkinglot_cfg cfg;
|
|
|
|
|
|
|
|
/*! Parking space to start next park search. */
|
|
|
|
int next_parking_space;
|
|
|
|
|
|
|
|
/*! That which bears the_mark shall be deleted if parking lot empty! (Used during reloads.) */
|
|
|
|
unsigned int the_mark:1;
|
|
|
|
/*! TRUE if the parking lot is disabled. */
|
|
|
|
unsigned int disabled:1;
|
|
|
|
|
|
|
|
/*! List of active parkings in this parkinglot */
|
|
|
|
AST_LIST_HEAD(parkinglot_parklist, parkeduser) parkings;
|
2008-04-21 23:42:45 +00:00
|
|
|
};
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! \brief The configured parking lots container. Always at least one - the default parking lot */
|
2008-04-21 23:42:45 +00:00
|
|
|
static struct ao2_container *parkinglots;
|
2006-06-21 07:49:29 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Force a config reload to reload regardless of config file timestamp. */
|
2013-06-06 21:40:35 +00:00
|
|
|
#ifdef TEST_FRAMEWORK
|
2011-08-16 17:23:08 +00:00
|
|
|
static int force_reload_load;
|
2013-06-06 21:40:35 +00:00
|
|
|
#endif
|
2011-08-16 17:23:08 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Context for parking dialback to parker.
|
|
|
|
* \note The need for the context is a KLUDGE.
|
|
|
|
*
|
|
|
|
* \todo Might be able to eliminate the parking_con_dial context
|
|
|
|
* kludge by running app_dial directly in its own thread to
|
|
|
|
* simulate a PBX.
|
|
|
|
*/
|
|
|
|
static char parking_con_dial[] = "park-dial";
|
|
|
|
|
|
|
|
/*! Ensure that features.conf reloads on one thread at a time. */
|
|
|
|
AST_MUTEX_DEFINE_STATIC(features_reload_lock);
|
|
|
|
|
2008-01-23 23:09:11 +00:00
|
|
|
static char *registrar = "features"; /*!< Registrar for operations */
|
2001-12-27 11:07:33 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! PARK_APP_NAME application arguments */
|
|
|
|
AST_DEFINE_APP_ARGS_TYPE(park_app_args,
|
|
|
|
AST_APP_ARG(timeout); /*!< Time in ms to remain in the parking lot. */
|
|
|
|
AST_APP_ARG(return_con); /*!< Context to return parked call if timeout. */
|
|
|
|
AST_APP_ARG(return_ext); /*!< Exten to return parked call if timeout. */
|
|
|
|
AST_APP_ARG(return_pri); /*!< Priority to return parked call if timeout. */
|
|
|
|
AST_APP_ARG(options); /*!< Parking option flags. */
|
|
|
|
AST_APP_ARG(pl_name); /*!< Parking lot name to use if present. */
|
|
|
|
AST_APP_ARG(dummy); /*!< Place to put any remaining args string. */
|
|
|
|
);
|
|
|
|
|
2008-04-21 23:42:45 +00:00
|
|
|
static pthread_t parking_thread;
|
Merged revisions 172517 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r172517 | twilson | 2009-01-30 11:47:41 -0600 (Fri, 30 Jan 2009) | 37 lines
Fix feature inheritance with builtin features
When using builtin features like parking and transfers, the AST_FEATURE_* flags
would not be set correctly for all instances when either performing a builtin
attended transfer, or parking a call and getting the timeout callback. Also,
there was no way on a per-call basis to specify what features someone should
have on picking up a parked call (since that doesn't involve the Dial() command).
There was a global option for setting whether or not all users who pickup a
parked call should have AST_FEATURE_REDIRECT set, but nothing for DISCONNECT,
AUTOMON, or PARKCALL.
This patch:
1) adds the BRIDGE_FEATURES dialplan variable which can be set either in the
dialplan or with setvar in channels that support it. This variable can be set
to any combination of 't', 'k', 'w', and 'h' (case insensitive matching of the
equivalent dial options), to set what features should be activated on this
channel. The patch moves the setting of the features datastores into the
bridging code instead of app_dial to help facilitate this.
2) adds global options parkedcallparking, parkedcallhangup, and
parkedcallrecording to be similar to the parkedcalltransfers option for
globally setting features.
3) has builtin_atxfer call builtin_parkcall if being transfered to the parking
extension since tracking everything through multiple masquerades, etc. is
difficult and error-prone
4) attempts to fix all cases of return calls from parking and completed builtin
transfers not having the correct permissions
(closes issue #14274)
Reported by: aragon
Patches:
fix_feature_inheritence.diff.txt uploaded by otherwiseguy (license 396)
Tested by: aragon, otherwiseguy
Review http://reviewboard.digium.com/r/138/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-01-30 21:29:12 +00:00
|
|
|
struct ast_dial_features {
|
2012-04-25 01:26:44 +00:00
|
|
|
/*! Channel's feature flags. */
|
|
|
|
struct ast_flags my_features;
|
|
|
|
/*! Bridge peer's feature flags. */
|
|
|
|
struct ast_flags peer_features;
|
Merged revisions 172517 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r172517 | twilson | 2009-01-30 11:47:41 -0600 (Fri, 30 Jan 2009) | 37 lines
Fix feature inheritance with builtin features
When using builtin features like parking and transfers, the AST_FEATURE_* flags
would not be set correctly for all instances when either performing a builtin
attended transfer, or parking a call and getting the timeout callback. Also,
there was no way on a per-call basis to specify what features someone should
have on picking up a parked call (since that doesn't involve the Dial() command).
There was a global option for setting whether or not all users who pickup a
parked call should have AST_FEATURE_REDIRECT set, but nothing for DISCONNECT,
AUTOMON, or PARKCALL.
This patch:
1) adds the BRIDGE_FEATURES dialplan variable which can be set either in the
dialplan or with setvar in channels that support it. This variable can be set
to any combination of 't', 'k', 'w', and 'h' (case insensitive matching of the
equivalent dial options), to set what features should be activated on this
channel. The patch moves the setting of the features datastores into the
bridging code instead of app_dial to help facilitate this.
2) adds global options parkedcallparking, parkedcallhangup, and
parkedcallrecording to be similar to the parkedcalltransfers option for
globally setting features.
3) has builtin_atxfer call builtin_parkcall if being transfered to the parking
extension since tracking everything through multiple masquerades, etc. is
difficult and error-prone
4) attempts to fix all cases of return calls from parking and completed builtin
transfers not having the correct permissions
(closes issue #14274)
Reported by: aragon
Patches:
fix_feature_inheritence.diff.txt uploaded by otherwiseguy (license 396)
Tested by: aragon, otherwiseguy
Review http://reviewboard.digium.com/r/138/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-01-30 21:29:12 +00:00
|
|
|
};
|
2001-12-27 11:07:33 +00:00
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
static struct ast_manager_event_blob *call_pickup_to_ami(struct stasis_message *message);
|
|
|
|
|
|
|
|
STASIS_MESSAGE_TYPE_DEFN(
|
|
|
|
ast_call_pickup_type,
|
|
|
|
.to_ami = call_pickup_to_ami);
|
|
|
|
|
|
|
|
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
#if defined(ATXFER_NULL_TECH)
|
|
|
|
/*!
|
|
|
|
* \internal
|
2011-05-25 16:50:38 +00:00
|
|
|
* \brief Set the channel technology to the kill technology.
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
*
|
|
|
|
* \param chan Channel to change technology.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
2011-05-25 16:50:38 +00:00
|
|
|
static void set_kill_chan_tech(struct ast_channel *chan)
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
|
|
|
/* Hangup the channel's physical side */
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_tech(chan)->hangup) {
|
|
|
|
ast_channel_tech(chan)->hangup(chan);
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_tech_pvt(chan)) {
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n",
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_channel_name(chan));
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_free(ast_channel_tech_pvt(chan));
|
|
|
|
ast_channel_tech_pvt_set(chan, NULL);
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
}
|
|
|
|
|
2011-05-25 16:50:38 +00:00
|
|
|
/* Install the kill technology and wake up anyone waiting on it. */
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_tech_set(chan, &ast_kill_tech);
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
for (idx = 0; idx < AST_MAX_FDS; ++idx) {
|
|
|
|
switch (idx) {
|
|
|
|
case AST_ALERT_FD:
|
|
|
|
case AST_TIMING_FD:
|
|
|
|
case AST_GENERATOR_FD:
|
|
|
|
/* Don't clear these fd's. */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ast_channel_set_fd(chan, idx, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_queue_frame(chan, &ast_null_frame);
|
|
|
|
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
}
|
|
|
|
#endif /* defined(ATXFER_NULL_TECH) */
|
|
|
|
|
|
|
|
#if defined(ATXFER_NULL_TECH)
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Set the channel name to something unique.
|
|
|
|
*
|
|
|
|
* \param chan Channel to change name.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void set_new_chan_name(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
static int seq_num_last;
|
|
|
|
int seq_num;
|
|
|
|
int len;
|
|
|
|
char *chan_name;
|
|
|
|
char dummy[1];
|
|
|
|
|
|
|
|
/* Create the new channel name string. */
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
seq_num = ast_atomic_fetchadd_int(&seq_num_last, +1);
|
2012-01-09 22:15:50 +00:00
|
|
|
len = snprintf(dummy, sizeof(dummy), "%s<XFER_%x>", ast_channel_name(chan), seq_num) + 1;
|
2012-07-31 20:21:43 +00:00
|
|
|
chan_name = ast_alloca(len);
|
2012-01-09 22:15:50 +00:00
|
|
|
snprintf(chan_name, len, "%s<XFER_%x>", ast_channel_name(chan), seq_num);
|
Merged revisions 302174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
................
r302174 | rmudgett | 2011-01-18 12:11:43 -0600 (Tue, 18 Jan 2011) | 102 lines
Merged revisions 302173 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
................
r302173 | rmudgett | 2011-01-18 12:07:15 -0600 (Tue, 18 Jan 2011) | 95 lines
Merged revisions 302172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r302172 | rmudgett | 2011-01-18 12:04:36 -0600 (Tue, 18 Jan 2011) | 88 lines
Issues with DTMF triggered attended transfers.
Issue #17999
1) A calls B. B answers.
2) B using DTMF dial *2 (code in features.conf for attended transfer).
3) A hears MOH. B dial number C
4) C ringing. A hears MOH.
5) B hangup. A still hears MOH. C ringing.
6) A hangup. C still ringing until "atxfernoanswertimeout" expires.
For v1.4 C will ring forever until C answers the dead line. (Issue #17096)
Problem: When A and B hangup, C is still ringing.
Issue #18395
SIP call limit of B is 1
1. A call B, B answered
2. B *2(atxfer) call C
3. B hangup, C ringing
4. Timeout waiting for C to answer
5. Recall to B fails because B has reached its call limit.
Because B reached its call limit, it cannot do anything until the transfer
it started completes.
Issue #17273
Same scenario as issue 18395 but party B is an FXS port. Party B cannot
do anything until the transfer it started completes. If B goes back off
hook before C answers, B hears ringback instead of the expected dialtone.
**********
Note for the issue #17273 and #18395 fix:
DTMF attended transfer works within the channel bridge. Unfortunately,
when either party A or B in the channel bridge hangs up, that channel is
not completely hung up until the transfer completes. This is a real
problem depending upon the channel technology involved.
For chan_dahdi, the channel is crippled until the hangup is complete.
Either the channel is not useable (analog) or the protocol disconnect
messages are held up (PRI/BRI/SS7) and the media is not released.
For chan_sip, a call limit of one is going to block that endpoint from any
further calls until the hangup is complete.
For party A this is a minor problem. The party A channel will only be in
this condition while party B is dialing and when party B and C are
conferring. The conversation between party B and C is expected to be a
short one. Party B is either asking a question of party C or announcing
party A. Also party A does not have much incentive to hangup at this
point.
For party B this can be a major problem during a blonde transfer. (A
blonde transfer is our term for an attended transfer that is converted
into a blind transfer. :)) Party B could be the operator. When party B
hangs up, he assumes that he is out of the original call entirely. The
party B channel will be in this condition while party C is ringing, while
attempting to recall party B, and while waiting between call attempts.
WARNING:
The ATXFER_NULL_TECH conditional is a hack to fix the problem. It will
replace the party B channel technology with a NULL channel driver to
complete hanging up the party B channel technology. The consequences of
this code is that the 'h' extension will not be able to access any channel
technology specific information like SIP statistics for the call.
ATXFER_NULL_TECH is not defined by default.
**********
(closes issue #17999)
Reported by: iskatel
Tested by: rmudgett
JIRA SWP-2246
(closes issue #17096)
Reported by: gelo
Tested by: rmudgett
JIRA SWP-1192
(closes issue #18395)
Reported by: shihchuan
Tested by: rmudgett
(closes issue #17273)
Reported by: grecco
Tested by: rmudgett
Review: https://reviewboard.asterisk.org/r/1047/
........
................
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@302178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-01-18 18:17:01 +00:00
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
ast_change_name(chan, chan_name);
|
|
|
|
}
|
|
|
|
#endif /* defined(ATXFER_NULL_TECH) */
|
|
|
|
|
Merged revisions 172517 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r172517 | twilson | 2009-01-30 11:47:41 -0600 (Fri, 30 Jan 2009) | 37 lines
Fix feature inheritance with builtin features
When using builtin features like parking and transfers, the AST_FEATURE_* flags
would not be set correctly for all instances when either performing a builtin
attended transfer, or parking a call and getting the timeout callback. Also,
there was no way on a per-call basis to specify what features someone should
have on picking up a parked call (since that doesn't involve the Dial() command).
There was a global option for setting whether or not all users who pickup a
parked call should have AST_FEATURE_REDIRECT set, but nothing for DISCONNECT,
AUTOMON, or PARKCALL.
This patch:
1) adds the BRIDGE_FEATURES dialplan variable which can be set either in the
dialplan or with setvar in channels that support it. This variable can be set
to any combination of 't', 'k', 'w', and 'h' (case insensitive matching of the
equivalent dial options), to set what features should be activated on this
channel. The patch moves the setting of the features datastores into the
bridging code instead of app_dial to help facilitate this.
2) adds global options parkedcallparking, parkedcallhangup, and
parkedcallrecording to be similar to the parkedcalltransfers option for
globally setting features.
3) has builtin_atxfer call builtin_parkcall if being transfered to the parking
extension since tracking everything through multiple masquerades, etc. is
difficult and error-prone
4) attempts to fix all cases of return calls from parking and completed builtin
transfers not having the correct permissions
(closes issue #14274)
Reported by: aragon
Patches:
fix_feature_inheritence.diff.txt uploaded by otherwiseguy (license 396)
Tested by: aragon, otherwiseguy
Review http://reviewboard.digium.com/r/138/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@172580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-01-30 21:29:12 +00:00
|
|
|
static void *dial_features_duplicate(void *data)
|
|
|
|
{
|
|
|
|
struct ast_dial_features *df = data, *df_copy;
|
2012-03-22 19:51:16 +00:00
|
|
|
|
|
|
|
if (!(df_copy = ast_calloc(1, sizeof(*df)))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(df_copy, df, sizeof(*df));
|
|
|
|
|
|
|
|
return df_copy;
|
2009-06-15 17:34:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ast_datastore_info dial_features_info = {
|
2012-03-22 19:51:16 +00:00
|
|
|
.type = "dial-features",
|
2013-04-10 23:08:02 +00:00
|
|
|
.destroy = ast_free_ptr,
|
2012-03-22 19:51:16 +00:00
|
|
|
.duplicate = dial_features_duplicate,
|
2011-06-09 16:47:07 +00:00
|
|
|
};
|
2012-03-22 19:51:16 +00:00
|
|
|
|
2012-04-25 01:26:44 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Set the features datastore if it doesn't exist.
|
|
|
|
*
|
|
|
|
* \param chan Channel to add features datastore
|
|
|
|
* \param my_features The channel's feature flags
|
|
|
|
* \param peer_features The channel's bridge peer feature flags
|
|
|
|
*
|
|
|
|
* \retval TRUE if features datastore already existed.
|
|
|
|
*/
|
|
|
|
static int add_features_datastore(struct ast_channel *chan, const struct ast_flags *my_features, const struct ast_flags *peer_features)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore;
|
|
|
|
struct ast_dial_features *dialfeatures;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
datastore = ast_channel_datastore_find(chan, &dial_features_info, NULL);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
if (datastore) {
|
|
|
|
/* Already exists. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new datastore with specified feature flags. */
|
|
|
|
datastore = ast_datastore_alloc(&dial_features_info, NULL);
|
|
|
|
if (!datastore) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create channel features datastore.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
dialfeatures = ast_calloc(1, sizeof(*dialfeatures));
|
|
|
|
if (!dialfeatures) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to allocate memory for feature flags.\n");
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ast_copy_flags(&dialfeatures->my_features, my_features, AST_FLAGS_ALL);
|
|
|
|
ast_copy_flags(&dialfeatures->peer_features, peer_features, AST_FLAGS_ALL);
|
|
|
|
datastore->inheritance = DATASTORE_INHERIT_FOREVER;
|
|
|
|
datastore->data = dialfeatures;
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
ast_channel_datastore_add(chan, datastore);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-21 23:42:45 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
static void parkinglot_unref(struct ast_parkinglot *parkinglot);
|
2001-12-27 11:07:33 +00:00
|
|
|
|
2012-03-22 19:51:16 +00:00
|
|
|
struct ast_bridge_thread_obj
|
2005-01-05 19:56:47 +00:00
|
|
|
{
|
|
|
|
struct ast_bridge_config bconfig;
|
|
|
|
struct ast_channel *chan;
|
|
|
|
struct ast_channel *peer;
|
2012-03-29 20:01:20 +00:00
|
|
|
struct ast_callid *callid; /*<! callid pointer (Only used to bind thread) */
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
unsigned int return_to_pbx:1;
|
2005-01-05 19:56:47 +00:00
|
|
|
};
|
|
|
|
|
2008-04-21 23:42:45 +00:00
|
|
|
static int parkinglot_hash_cb(const void *obj, const int flags)
|
|
|
|
{
|
|
|
|
const struct ast_parkinglot *parkinglot = obj;
|
2008-11-15 04:25:57 +00:00
|
|
|
|
|
|
|
return ast_str_case_hash(parkinglot->name);
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
2007-03-30 14:37:21 +00:00
|
|
|
|
2008-11-25 01:01:49 +00:00
|
|
|
static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
|
2008-04-21 23:42:45 +00:00
|
|
|
{
|
2011-08-09 23:17:13 +00:00
|
|
|
struct ast_parkinglot *parkinglot = obj;
|
|
|
|
struct ast_parkinglot *parkinglot2 = arg;
|
2008-11-15 04:25:57 +00:00
|
|
|
|
2008-08-29 17:47:17 +00:00
|
|
|
return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0;
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
2007-03-30 14:37:21 +00:00
|
|
|
|
2007-08-07 23:04:01 +00:00
|
|
|
/*!
|
2012-03-22 19:51:16 +00:00
|
|
|
* \brief store context, extension and priority
|
2007-08-07 23:04:01 +00:00
|
|
|
* \param chan, context, ext, pri
|
2011-05-20 17:04:53 +00:00
|
|
|
*/
|
2006-04-17 04:31:21 +00:00
|
|
|
static void set_c_e_p(struct ast_channel *chan, const char *context, const char *ext, int pri)
|
2006-04-16 18:49:46 +00:00
|
|
|
{
|
2012-02-13 17:27:06 +00:00
|
|
|
ast_channel_context_set(chan, context);
|
|
|
|
ast_channel_exten_set(chan, ext);
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_priority_set(chan, pri);
|
2006-04-16 18:49:46 +00:00
|
|
|
}
|
|
|
|
|
2012-09-11 21:13:26 +00:00
|
|
|
static const struct ast_datastore_info channel_app_data_datastore = {
|
|
|
|
.type = "Channel appdata datastore",
|
|
|
|
.destroy = ast_free_ptr,
|
|
|
|
};
|
|
|
|
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
/*! \brief Notify metermaids that we've changed an extension */
|
2007-08-10 16:24:11 +00:00
|
|
|
static void notify_metermaids(const char *exten, char *context, enum ast_device_state state)
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
{
|
2011-02-04 16:55:39 +00:00
|
|
|
ast_debug(4, "Notification of state change to metermaids %s@%s\n to state '%s'",
|
2008-11-04 18:47:20 +00:00
|
|
|
exten, context, ast_devstate2str(state));
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
|
2013-01-02 18:11:59 +00:00
|
|
|
ast_devstate_changed(state, AST_DEVSTATE_CACHABLE, "park:%s@%s", exten, context);
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*! \brief metermaids callback from devicestate.c */
|
2007-02-13 22:02:20 +00:00
|
|
|
static enum ast_device_state metermaidstate(const char *data)
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
{
|
2007-07-08 13:22:30 +00:00
|
|
|
char *context;
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
char *exten;
|
|
|
|
|
2007-07-08 13:22:30 +00:00
|
|
|
context = ast_strdupa(data);
|
|
|
|
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
exten = strsep(&context, "@");
|
|
|
|
if (!context)
|
2007-07-08 13:22:30 +00:00
|
|
|
return AST_DEVICE_INVALID;
|
2011-02-04 16:55:39 +00:00
|
|
|
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(4, "Checking state of exten %s in context %s\n", exten, context);
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
|
2007-07-08 13:22:30 +00:00
|
|
|
if (!ast_exists_extension(NULL, context, exten, 1, NULL))
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
return AST_DEVICE_NOT_INUSE;
|
2007-07-08 13:22:30 +00:00
|
|
|
|
|
|
|
return AST_DEVICE_INUSE;
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
}
|
|
|
|
|
2009-03-13 17:49:01 +00:00
|
|
|
/*! Options to pass to park_call_full */
|
2008-04-25 18:18:27 +00:00
|
|
|
enum ast_park_call_options {
|
|
|
|
/*! Provide ringing to the parked caller instead of music on hold */
|
|
|
|
AST_PARK_OPT_RINGING = (1 << 0),
|
|
|
|
/*! Randomly choose a parking spot for the caller instead of choosing
|
|
|
|
* the first one that is available. */
|
|
|
|
AST_PARK_OPT_RANDOMIZE = (1 << 1),
|
2008-08-29 17:53:32 +00:00
|
|
|
/*! Do not announce the parking number */
|
|
|
|
AST_PARK_OPT_SILENCE = (1 << 2),
|
2008-04-25 18:18:27 +00:00
|
|
|
};
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! Optional additional parking options when parking a call. */
|
2008-04-25 18:18:27 +00:00
|
|
|
struct ast_park_call_args {
|
|
|
|
/*! How long to wait in the parking lot before the call gets sent back
|
|
|
|
* to the specified return extension (or a best guess at where it came
|
|
|
|
* from if not explicitly specified). */
|
|
|
|
int timeout;
|
|
|
|
/*! An output parameter to store the parking space where the parked caller
|
|
|
|
* was placed. */
|
|
|
|
int *extout;
|
|
|
|
const char *orig_chan_name;
|
|
|
|
const char *return_con;
|
|
|
|
const char *return_ext;
|
|
|
|
int return_pri;
|
|
|
|
uint32_t flags;
|
2009-02-04 21:17:53 +00:00
|
|
|
/*! Parked user that has already obtained a parking space */
|
|
|
|
struct parkeduser *pu;
|
2011-08-16 17:23:08 +00:00
|
|
|
/*! \brief Parkinglot to be parked in */
|
|
|
|
struct ast_parkinglot *parkinglot;
|
2008-04-25 18:18:27 +00:00
|
|
|
};
|
|
|
|
|
2012-03-22 19:51:16 +00:00
|
|
|
/*!
|
2013-06-06 21:40:35 +00:00
|
|
|
* \internal
|
|
|
|
* \brief Get the extension for a given builtin feature
|
2007-09-05 16:31:39 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \pre expects features_lock to be readlocked
|
2007-09-05 16:31:39 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \retval 0 success
|
|
|
|
* \retval non-zero failiure
|
2011-05-20 17:04:53 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static int builtin_feature_get_exten(struct ast_channel *chan, const char *feature_name,
|
|
|
|
char *buf, size_t len)
|
2005-08-23 02:22:33 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
SCOPED_CHANNELLOCK(lock, chan);
|
2008-12-11 17:06:16 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return ast_get_builtin_feature(chan, feature_name, buf, len);
|
2005-08-23 02:22:33 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static void set_config_flags(struct ast_channel *chan, struct ast_bridge_config *config)
|
2005-08-23 14:40:03 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
/* BUGBUG there is code that checks AST_BRIDGE_IGNORE_SIGS but no code to set it. */
|
|
|
|
/* BUGBUG there is code that checks AST_BRIDGE_REC_CHANNEL_0 but no code to set it. */
|
|
|
|
/* BUGBUG there is code that checks AST_BRIDGE_REC_CHANNEL_1 but no code to set it. */
|
|
|
|
ast_clear_flag(config, AST_FLAGS_ALL);
|
2005-08-23 14:40:03 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_test_flag(&config->features_caller, AST_FEATURE_DTMF_MASK)) {
|
|
|
|
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
|
2008-12-11 17:06:16 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_test_flag(&config->features_callee, AST_FEATURE_DTMF_MASK)) {
|
|
|
|
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
|
2005-08-23 02:22:33 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) {
|
|
|
|
RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
|
2005-08-23 02:22:33 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
applicationmap = ast_get_chan_applicationmap(chan);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
if (!applicationmap) {
|
|
|
|
return;
|
2007-05-31 18:21:47 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* If an applicationmap exists for this channel at all, then the channel needs the DTMF flag set */
|
|
|
|
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
|
2007-05-31 18:21:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
void ast_channel_log(char *title, struct ast_channel *chan);
|
Merged revisions 183126 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r183126 | dvossel | 2009-03-19 11:15:16 -0500 (Thu, 19 Mar 2009) | 17 lines
Allow disconnect feature before a call is bridged
feature.conf has a disconnect option. By default this option is set to '*', but it could be anything. If a user wishes to disconnect a call before the other side answers, only '*' will work, regardless if the disconnect option is set to something else. This is because features are unavailable until bridging takes place. The default disconnect option, '*', was hardcoded in app_dial, which doesn't make any sense from a user perspective since they may expect it to be something different. This patch allows features to be detected from outside of the bridge, but not operated on. In this case, the disconnect feature can be detected before briding and handled outside of features.c.
(closes issue #11583)
Reported by: sobomax
Patches:
patch-apps__app_dial.c uploaded by sobomax (license 359)
11583.latest-patch uploaded by murf (license 17)
detect_disconnect.diff uploaded by dvossel (license 671)
Tested by: sobomax, dvossel
Review: http://reviewboard.digium.com/r/195/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@183172 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-19 16:28:33 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this is handy enough to justify keeping it in the source */
|
|
|
|
{
|
|
|
|
ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long) chan);
|
|
|
|
ast_log(LOG_NOTICE, "CHAN: name: %s; appl: %s; data: %s; contxt: %s; exten: %s; pri: %d;\n",
|
|
|
|
ast_channel_name(chan), ast_channel_appl(chan), ast_channel_data(chan),
|
|
|
|
ast_channel_context(chan), ast_channel_exten(chan), ast_channel_priority(chan));
|
|
|
|
ast_log(LOG_NOTICE, "CHAN: acctcode: %s; dialcontext: %s; amaflags: %x; maccontxt: %s; macexten: %s; macpri: %d;\n",
|
|
|
|
ast_channel_accountcode(chan), ast_channel_dialcontext(chan), ast_channel_amaflags(chan),
|
|
|
|
ast_channel_macrocontext(chan), ast_channel_macroexten(chan), ast_channel_macropriority(chan));
|
|
|
|
ast_log(LOG_NOTICE, "CHAN: masq: %p; masqr: %p; uniqueID: %s; linkedID:%s\n",
|
|
|
|
ast_channel_masq(chan), ast_channel_masqr(chan),
|
|
|
|
ast_channel_uniqueid(chan), ast_channel_linkedid(chan));
|
|
|
|
if (ast_channel_masqr(chan)) {
|
|
|
|
ast_log(LOG_NOTICE, "CHAN: masquerading as: %s; cdr: %p;\n",
|
|
|
|
ast_channel_name(ast_channel_masqr(chan)), ast_channel_cdr(ast_channel_masqr(chan)));
|
2012-12-12 04:43:18 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_log(LOG_NOTICE, "===== done ====\n");
|
Merged revisions 183126 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r183126 | dvossel | 2009-03-19 11:15:16 -0500 (Thu, 19 Mar 2009) | 17 lines
Allow disconnect feature before a call is bridged
feature.conf has a disconnect option. By default this option is set to '*', but it could be anything. If a user wishes to disconnect a call before the other side answers, only '*' will work, regardless if the disconnect option is set to something else. This is because features are unavailable until bridging takes place. The default disconnect option, '*', was hardcoded in app_dial, which doesn't make any sense from a user perspective since they may expect it to be something different. This patch allows features to be detected from outside of the bridge, but not operated on. In this case, the disconnect feature can be detected before briding and handled outside of features.c.
(closes issue #11583)
Reported by: sobomax
Patches:
patch-apps__app_dial.c uploaded by sobomax (license 359)
11583.latest-patch uploaded by murf (license 17)
detect_disconnect.diff uploaded by dvossel (license 671)
Tested by: sobomax, dvossel
Review: http://reviewboard.digium.com/r/195/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@183172 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-19 16:28:33 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static void set_bridge_features_on_config(struct ast_bridge_config *config, const char *features)
|
2005-01-04 04:01:40 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
const char *feature;
|
2007-05-08 16:31:16 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_strlen_zero(features)) {
|
|
|
|
return;
|
2005-01-04 04:01:40 +00:00
|
|
|
}
|
2005-09-07 21:36:30 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
for (feature = features; *feature; feature++) {
|
|
|
|
struct ast_flags *party;
|
2010-07-09 21:57:21 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (isupper(*feature)) {
|
|
|
|
party = &config->features_caller;
|
|
|
|
} else {
|
|
|
|
party = &config->features_callee;
|
2005-09-07 21:36:30 +00:00
|
|
|
}
|
2005-01-04 04:01:40 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
switch (tolower(*feature)) {
|
|
|
|
case 't' :
|
|
|
|
ast_set_flag(party, AST_FEATURE_REDIRECT);
|
|
|
|
break;
|
|
|
|
case 'k' :
|
|
|
|
ast_set_flag(party, AST_FEATURE_PARKCALL);
|
|
|
|
break;
|
|
|
|
case 'h' :
|
|
|
|
ast_set_flag(party, AST_FEATURE_DISCONNECT);
|
|
|
|
break;
|
|
|
|
case 'w' :
|
|
|
|
ast_set_flag(party, AST_FEATURE_AUTOMON);
|
|
|
|
break;
|
|
|
|
case 'x' :
|
|
|
|
ast_set_flag(party, AST_FEATURE_AUTOMIXMON);
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
ast_log(LOG_WARNING, "Skipping unknown feature code '%c'\n", *feature);
|
2011-08-16 17:23:08 +00:00
|
|
|
break;
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static void add_features_datastores(struct ast_channel *caller, struct ast_channel *callee, struct ast_bridge_config *config)
|
2008-04-21 23:42:45 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
if (add_features_datastore(caller, &config->features_caller, &config->features_callee)) {
|
|
|
|
/*
|
|
|
|
* If we don't return here, then when we do a builtin_atxfer we
|
|
|
|
* will copy the disconnect flags over from the atxfer to the
|
|
|
|
* callee (Party C).
|
|
|
|
*/
|
|
|
|
return;
|
2001-12-27 11:07:33 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
add_features_datastore(callee, &config->features_callee, &config->features_caller);
|
2001-12-27 11:07:33 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static void clear_dialed_interfaces(struct ast_channel *chan)
|
2008-04-21 23:42:45 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
struct ast_datastore *di_datastore;
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
if ((di_datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL))) {
|
|
|
|
if (option_debug) {
|
|
|
|
ast_log(LOG_DEBUG, "Removing dialed interfaces datastore on %s since we're bridging\n", ast_channel_name(chan));
|
|
|
|
}
|
|
|
|
if (!ast_channel_datastore_remove(chan, di_datastore)) {
|
|
|
|
ast_datastore_free(di_datastore);
|
|
|
|
}
|
2010-09-15 19:23:56 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_unlock(chan);
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 20:28:59 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Helper to add a builtin DTMF feature hook to the features struct.
|
|
|
|
* \since 12.0.0
|
|
|
|
*
|
|
|
|
* \param features Bridge features to setup.
|
|
|
|
* \param chan Get features from this channel.
|
|
|
|
* \param flags Feature flags on the channel.
|
|
|
|
* \param feature_flag Feature flag to test.
|
|
|
|
* \param feature_name features.conf name of feature.
|
|
|
|
* \param feature_bridge Bridge feature enum to get hook callback.
|
|
|
|
*
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on error.
|
|
|
|
*/
|
|
|
|
static int builtin_features_helper(struct ast_bridge_features *features, struct ast_channel *chan,
|
|
|
|
struct ast_flags *flags, unsigned int feature_flag, const char *feature_name, enum ast_bridge_builtin_feature feature_bridge)
|
|
|
|
{
|
|
|
|
char dtmf[AST_FEATURE_MAX_LEN];
|
|
|
|
int res;
|
|
|
|
|
|
|
|
res = 0;
|
|
|
|
if (ast_test_flag(flags, feature_flag)
|
|
|
|
&& !builtin_feature_get_exten(chan, feature_name, dtmf, sizeof(dtmf))
|
|
|
|
&& !ast_strlen_zero(dtmf)) {
|
|
|
|
res = ast_bridge_features_enable(features, feature_bridge, dtmf, NULL, NULL,
|
|
|
|
AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
|
|
|
|
if (res) {
|
|
|
|
ast_log(LOG_ERROR, "Channel %s: Requested DTMF feature %s not available.\n",
|
|
|
|
ast_channel_name(chan), feature_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-05-20 17:04:53 +00:00
|
|
|
/*!
|
2013-06-06 21:40:35 +00:00
|
|
|
* \internal
|
|
|
|
* \brief Setup bridge builtin features.
|
|
|
|
* \since 12.0.0
|
|
|
|
*
|
|
|
|
* \param features Bridge features to setup.
|
|
|
|
* \param chan Get features from this channel.
|
|
|
|
*
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on error.
|
2011-05-20 17:04:53 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static int setup_bridge_features_builtin(struct ast_bridge_features *features, struct ast_channel *chan)
|
2008-04-21 23:42:45 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
struct ast_flags *flags;
|
|
|
|
int res;
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
flags = ast_bridge_features_ds_get(chan);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
if (!flags) {
|
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
res = 0;
|
2013-07-24 20:28:59 +00:00
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_REDIRECT, "blindxfer", AST_BRIDGE_BUILTIN_BLINDTRANSFER);
|
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_REDIRECT, "atxfer", AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER);
|
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_DISCONNECT, "disconnect", AST_BRIDGE_BUILTIN_HANGUP);
|
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_PARKCALL, "parkcall", AST_BRIDGE_BUILTIN_PARKCALL);
|
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_AUTOMON, "automon", AST_BRIDGE_BUILTIN_AUTOMON);
|
|
|
|
res |= builtin_features_helper(features, chan, flags, AST_FEATURE_AUTOMIXMON, "automixmon", AST_BRIDGE_BUILTIN_AUTOMIXMON);
|
2010-09-15 19:23:56 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return res ? -1 : 0;
|
|
|
|
}
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 22:46:54 +00:00
|
|
|
struct dynamic_dtmf_hook_run {
|
|
|
|
/*! Offset into app_name[] where the channel name that activated the hook starts. */
|
|
|
|
int activated_offset;
|
|
|
|
/*! Offset into app_name[] where the dynamic feature name starts. */
|
|
|
|
int feature_offset;
|
|
|
|
/*! Offset into app_name[] where the MOH class name starts. (zero if no MOH) */
|
|
|
|
int moh_offset;
|
|
|
|
/*! Offset into app_name[] where the application argument string starts. (zero if no arguments) */
|
|
|
|
int app_args_offset;
|
|
|
|
/*! Application name to run. */
|
|
|
|
char app_name[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
static void dynamic_dtmf_hook_callback(struct ast_bridge_channel *bridge_channel,
|
|
|
|
const void *payload, size_t payload_size)
|
|
|
|
{
|
|
|
|
struct ast_channel *chan = bridge_channel->chan;
|
|
|
|
const struct dynamic_dtmf_hook_run *run_data = payload;
|
|
|
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "DYNAMIC_FEATURENAME",
|
|
|
|
&run_data->app_name[run_data->feature_offset]);
|
|
|
|
pbx_builtin_setvar_helper(chan, "DYNAMIC_WHO_ACTIVATED",
|
|
|
|
&run_data->app_name[run_data->activated_offset]);
|
|
|
|
|
|
|
|
ast_bridge_channel_run_app(bridge_channel, run_data->app_name,
|
|
|
|
run_data->app_args_offset ? &run_data->app_name[run_data->app_args_offset] : NULL,
|
|
|
|
run_data->moh_offset ? &run_data->app_name[run_data->moh_offset] : NULL);
|
|
|
|
}
|
|
|
|
|
2013-06-21 17:48:14 +00:00
|
|
|
static int dynamic_dtmf_hook_run_callback(struct ast_bridge_channel *bridge_channel,
|
2013-06-06 22:46:54 +00:00
|
|
|
ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
|
|
|
|
{
|
|
|
|
callback(bridge_channel, payload, payload_size);
|
2013-06-21 17:48:14 +00:00
|
|
|
return 0;
|
2013-06-06 22:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct dynamic_dtmf_hook_data {
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! Which side of bridge to run app (AST_FEATURE_FLAG_ONSELF/AST_FEATURE_FLAG_ONPEER) */
|
|
|
|
unsigned int flags;
|
2013-06-06 22:46:54 +00:00
|
|
|
/*! Offset into app_name[] where the dynamic feature name starts. */
|
|
|
|
int feature_offset;
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! Offset into app_name[] where the MOH class name starts. (zero if no MOH) */
|
|
|
|
int moh_offset;
|
|
|
|
/*! Offset into app_name[] where the application argument string starts. (zero if no arguments) */
|
|
|
|
int app_args_offset;
|
|
|
|
/*! Application name to run. */
|
|
|
|
char app_name[0];
|
2011-08-16 17:23:08 +00:00
|
|
|
};
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
2013-06-06 22:46:54 +00:00
|
|
|
* \brief Activated dynamic DTMF feature hook.
|
2013-06-06 21:40:35 +00:00
|
|
|
* \since 12.0.0
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param bridge_channel Channel executing the feature
|
|
|
|
* \param hook_pvt Private data passed in when the hook was created
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \retval 0 Keep the callback hook.
|
|
|
|
* \retval -1 Remove the callback hook.
|
2011-08-16 17:23:08 +00:00
|
|
|
*/
|
2013-07-26 21:34:23 +00:00
|
|
|
static int dynamic_dtmf_hook_trip(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 22:46:54 +00:00
|
|
|
struct dynamic_dtmf_hook_data *pvt = hook_pvt;
|
2013-06-21 17:48:14 +00:00
|
|
|
int (*run_it)(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size);
|
2013-06-06 22:46:54 +00:00
|
|
|
struct dynamic_dtmf_hook_run *run_data;
|
|
|
|
const char *activated_name;
|
|
|
|
size_t len_name;
|
|
|
|
size_t len_args;
|
|
|
|
size_t len_moh;
|
|
|
|
size_t len_feature;
|
|
|
|
size_t len_activated;
|
|
|
|
size_t len_data;
|
|
|
|
|
|
|
|
/* Determine lengths of things. */
|
|
|
|
len_name = strlen(pvt->app_name) + 1;
|
|
|
|
len_args = pvt->app_args_offset ? strlen(&pvt->app_name[pvt->app_args_offset]) + 1 : 0;
|
|
|
|
len_moh = pvt->moh_offset ? strlen(&pvt->app_name[pvt->moh_offset]) + 1 : 0;
|
|
|
|
len_feature = strlen(&pvt->app_name[pvt->feature_offset]) + 1;
|
|
|
|
ast_channel_lock(bridge_channel->chan);
|
|
|
|
activated_name = ast_strdupa(ast_channel_name(bridge_channel->chan));
|
|
|
|
ast_channel_unlock(bridge_channel->chan);
|
|
|
|
len_activated = strlen(activated_name) + 1;
|
|
|
|
len_data = sizeof(*run_data) + len_name + len_args + len_moh + len_feature + len_activated;
|
|
|
|
|
|
|
|
/* Fill in dynamic feature run hook data. */
|
|
|
|
run_data = ast_alloca(len_data);
|
|
|
|
run_data->app_args_offset = len_args ? len_name : 0;
|
|
|
|
run_data->moh_offset = len_moh ? len_name + len_args : 0;
|
|
|
|
run_data->feature_offset = len_name + len_args + len_moh;
|
|
|
|
run_data->activated_offset = len_name + len_args + len_moh + len_feature;
|
|
|
|
strcpy(run_data->app_name, pvt->app_name);/* Safe */
|
|
|
|
if (len_args) {
|
|
|
|
strcpy(&run_data->app_name[run_data->app_args_offset],
|
|
|
|
&pvt->app_name[pvt->app_args_offset]);/* Safe */
|
|
|
|
}
|
|
|
|
if (len_moh) {
|
|
|
|
strcpy(&run_data->app_name[run_data->moh_offset],
|
|
|
|
&pvt->app_name[pvt->moh_offset]);/* Safe */
|
|
|
|
}
|
|
|
|
strcpy(&run_data->app_name[run_data->feature_offset],
|
|
|
|
&pvt->app_name[pvt->feature_offset]);/* Safe */
|
|
|
|
strcpy(&run_data->app_name[run_data->activated_offset], activated_name);/* Safe */
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(pvt, AST_FEATURE_FLAG_ONPEER)) {
|
2013-06-06 22:46:54 +00:00
|
|
|
run_it = ast_bridge_channel_write_callback;
|
2013-06-06 21:40:35 +00:00
|
|
|
} else {
|
2013-06-06 22:46:54 +00:00
|
|
|
run_it = dynamic_dtmf_hook_run_callback;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 22:46:54 +00:00
|
|
|
run_it(bridge_channel, dynamic_dtmf_hook_callback, run_data, len_data);
|
2013-06-06 21:40:35 +00:00
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief Add a dynamic DTMF feature hook to the bridge features.
|
|
|
|
* \since 12.0.0
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param features Bridge features to setup.
|
|
|
|
* \param flags Which side of bridge to run app (AST_FEATURE_FLAG_ONSELF/AST_FEATURE_FLAG_ONPEER).
|
|
|
|
* \param dtmf DTMF trigger sequence.
|
2013-06-06 22:46:54 +00:00
|
|
|
* \param feature_name Name of the dynamic feature.
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param app_name Dialplan application name to run.
|
|
|
|
* \param app_args Dialplan application arguments. (Empty or NULL if no arguments)
|
|
|
|
* \param moh_class MOH class to play to peer. (Empty or NULL if no MOH played)
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on error.
|
|
|
|
*/
|
2013-06-06 22:46:54 +00:00
|
|
|
static int dynamic_dtmf_hook_add(struct ast_bridge_features *features, unsigned int flags, const char *dtmf, const char *feature_name, const char *app_name, const char *app_args, const char *moh_class)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 22:46:54 +00:00
|
|
|
struct dynamic_dtmf_hook_data *hook_data;
|
2013-06-06 21:40:35 +00:00
|
|
|
size_t len_name = strlen(app_name) + 1;
|
|
|
|
size_t len_args = ast_strlen_zero(app_args) ? 0 : strlen(app_args) + 1;
|
|
|
|
size_t len_moh = ast_strlen_zero(moh_class) ? 0 : strlen(moh_class) + 1;
|
2013-06-06 22:46:54 +00:00
|
|
|
size_t len_feature = strlen(feature_name) + 1;
|
|
|
|
size_t len_data = sizeof(*hook_data) + len_name + len_args + len_moh + len_feature;
|
2013-06-20 17:21:40 +00:00
|
|
|
int res;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Fill in application run hook data. */
|
2013-06-06 22:46:54 +00:00
|
|
|
hook_data = ast_malloc(len_data);
|
|
|
|
if (!hook_data) {
|
2013-06-06 21:40:35 +00:00
|
|
|
return -1;
|
2010-09-15 19:23:56 +00:00
|
|
|
}
|
2013-06-06 22:46:54 +00:00
|
|
|
hook_data->flags = flags;
|
|
|
|
hook_data->app_args_offset = len_args ? len_name : 0;
|
|
|
|
hook_data->moh_offset = len_moh ? len_name + len_args : 0;
|
|
|
|
hook_data->feature_offset = len_name + len_args + len_moh;
|
|
|
|
strcpy(hook_data->app_name, app_name);/* Safe */
|
2013-06-06 21:40:35 +00:00
|
|
|
if (len_args) {
|
2013-06-06 22:46:54 +00:00
|
|
|
strcpy(&hook_data->app_name[hook_data->app_args_offset], app_args);/* Safe */
|
2012-01-20 20:47:42 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
if (len_moh) {
|
2013-06-06 22:46:54 +00:00
|
|
|
strcpy(&hook_data->app_name[hook_data->moh_offset], moh_class);/* Safe */
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
2013-06-06 22:46:54 +00:00
|
|
|
strcpy(&hook_data->app_name[hook_data->feature_offset], feature_name);/* Safe */
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-20 17:21:40 +00:00
|
|
|
res = ast_bridge_dtmf_hook(features, dtmf, dynamic_dtmf_hook_trip, hook_data,
|
2013-06-06 22:46:54 +00:00
|
|
|
ast_free_ptr, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
|
2013-06-20 17:21:40 +00:00
|
|
|
if (res) {
|
|
|
|
ast_free(hook_data);
|
|
|
|
}
|
|
|
|
return res;
|
2013-06-06 21:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_dynamic_feature(void *obj, void *arg, void *data, int flags)
|
|
|
|
{
|
|
|
|
struct ast_applicationmap_item *item = obj;
|
|
|
|
struct ast_bridge_features *features = arg;
|
|
|
|
int *res = data;
|
|
|
|
|
2013-06-06 22:46:54 +00:00
|
|
|
*res |= dynamic_dtmf_hook_add(features,
|
|
|
|
item->activate_on_self ? AST_FEATURE_FLAG_ONSELF : AST_FEATURE_FLAG_ONPEER,
|
|
|
|
item->dtmf, item->name, item->app, item->app_data, item->moh_class);
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief Setup bridge dynamic features.
|
|
|
|
* \since 12.0.0
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param features Bridge features to setup.
|
|
|
|
* \param chan Get features from this channel.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on error.
|
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static int setup_bridge_features_dynamic(struct ast_bridge_features *features, struct ast_channel *chan)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
RAII_VAR(struct ao2_container *, applicationmap, NULL, ao2_cleanup);
|
|
|
|
int res = 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
applicationmap = ast_get_chan_applicationmap(chan);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
if (!applicationmap) {
|
|
|
|
return 0;
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ao2_callback_data(applicationmap, 0, setup_dynamic_feature, features, &res);
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return res;
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* BUGBUG this really should be made a private function of bridging_basic.c after struct ast_call_feature is made an ao2 object. */
|
|
|
|
int ast_bridge_channel_setup_features(struct ast_bridge_channel *bridge_channel)
|
|
|
|
{
|
|
|
|
int res = 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Always pass through any DTMF digits. */
|
|
|
|
bridge_channel->features->dtmf_passthrough = 1;
|
|
|
|
|
|
|
|
res |= setup_bridge_features_builtin(bridge_channel->features, bridge_channel->chan);
|
|
|
|
res |= setup_bridge_features_dynamic(bridge_channel->features, bridge_channel->chan);
|
|
|
|
|
|
|
|
return res;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static void bridge_config_set_limits_warning_values(struct ast_bridge_config *config, struct ast_bridge_features_limits *limits)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
if (config->end_sound) {
|
|
|
|
ast_string_field_set(limits, duration_sound, config->end_sound);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (config->warning_sound) {
|
|
|
|
ast_string_field_set(limits, warning_sound, config->warning_sound);
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (config->start_sound) {
|
|
|
|
ast_string_field_set(limits, connect_sound, config->start_sound);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2010-09-15 19:23:56 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
limits->frequency = config->warning_freq;
|
|
|
|
limits->warning = config->play_warning;
|
|
|
|
}
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*!
|
|
|
|
* \internal brief Setup limit hook structures on calls that need limits
|
|
|
|
*
|
|
|
|
* \param config ast_bridge_config which provides the limit data
|
|
|
|
* \param caller_limits pointer to an ast_bridge_features_limits struct which will store the caller side limits
|
|
|
|
* \param callee_limits pointer to an ast_bridge_features_limits struct which will store the callee side limits
|
|
|
|
*/
|
|
|
|
static void bridge_config_set_limits(struct ast_bridge_config *config, struct ast_bridge_features_limits *caller_limits, struct ast_bridge_features_limits *callee_limits)
|
|
|
|
{
|
|
|
|
if (ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING)) {
|
|
|
|
bridge_config_set_limits_warning_values(config, caller_limits);
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING)) {
|
|
|
|
bridge_config_set_limits_warning_values(config, callee_limits);
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
caller_limits->duration = config->timelimit;
|
|
|
|
callee_limits->duration = config->timelimit;
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief Check if Monitor needs to be started on a channel.
|
|
|
|
* \since 12.0.0
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param chan The bridge considers this channel the caller.
|
|
|
|
* \param peer The bridge considers this channel the callee.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static void bridge_check_monitor(struct ast_channel *chan, struct ast_channel *peer)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
const char *value;
|
|
|
|
const char *monitor_args = NULL;
|
|
|
|
struct ast_channel *monitor_chan = NULL;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
value = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR");
|
|
|
|
if (!ast_strlen_zero(value)) {
|
|
|
|
monitor_args = ast_strdupa(value);
|
|
|
|
monitor_chan = chan;
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
if (!monitor_chan) {
|
|
|
|
ast_channel_lock(peer);
|
|
|
|
value = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR");
|
|
|
|
if (!ast_strlen_zero(value)) {
|
|
|
|
monitor_args = ast_strdupa(value);
|
|
|
|
monitor_chan = peer;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_unlock(peer);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
if (monitor_chan) {
|
|
|
|
struct ast_app *monitor_app;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
monitor_app = pbx_findapp("Monitor");
|
|
|
|
if (monitor_app) {
|
|
|
|
pbx_exec(monitor_chan, monitor_app, monitor_args);
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Send the peer channel on its way on bridge start failure.
|
|
|
|
* \since 12.0.0
|
|
|
|
*
|
|
|
|
* \param chan Chan to put into autoservice.
|
|
|
|
* \param peer Chan to send to after bridge goto or run hangup handlers and hangup.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void bridge_failed_peer_goto(struct ast_channel *chan, struct ast_channel *peer)
|
|
|
|
{
|
2013-07-25 02:20:23 +00:00
|
|
|
if (ast_bridge_setup_after_goto(peer)
|
2013-06-06 21:40:35 +00:00
|
|
|
|| ast_pbx_start(peer)) {
|
|
|
|
ast_autoservice_chan_hangup_peer(chan, peer);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
static int pre_bridge_setup(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config,
|
|
|
|
struct ast_bridge_features *chan_features, struct ast_bridge_features *peer_features)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
set_bridge_features_on_config(config, pbx_builtin_getvar_helper(chan, "BRIDGE_FEATURES"));
|
|
|
|
add_features_datastores(chan, peer, config);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is an interesting case. One example is if a ringing
|
|
|
|
* channel gets redirected to an extension that picks up a
|
|
|
|
* parked call. This will make sure that the call taken out of
|
|
|
|
* parking gets told that the channel it just got bridged to is
|
|
|
|
* still ringing.
|
|
|
|
*/
|
|
|
|
if (ast_channel_state(chan) == AST_STATE_RINGING
|
|
|
|
&& ast_channel_visible_indication(peer) != AST_CONTROL_RINGING) {
|
|
|
|
ast_indicate(peer, AST_CONTROL_RINGING);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
bridge_check_monitor(chan, peer);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
set_config_flags(chan, config);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Answer if need be */
|
|
|
|
if (ast_channel_state(chan) != AST_STATE_UP) {
|
2013-06-17 03:00:38 +00:00
|
|
|
if (ast_raw_answer(chan)) {
|
2013-06-06 21:40:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
#ifdef FOR_DEBUG
|
|
|
|
/* show the two channels and cdrs involved in the bridge for debug & devel purposes */
|
|
|
|
ast_channel_log("Pre-bridge CHAN Channel info", chan);
|
|
|
|
ast_channel_log("Pre-bridge PEER Channel info", peer);
|
|
|
|
#endif
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/*
|
2013-06-06 21:40:35 +00:00
|
|
|
* If we are bridging a call, stop worrying about forwarding
|
|
|
|
* loops. We presume that if a call is being bridged, that the
|
|
|
|
* humans in charge know what they're doing. If they don't,
|
|
|
|
* well, what can we do about that?
|
2013-05-21 18:00:22 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
clear_dialed_interfaces(chan);
|
|
|
|
clear_dialed_interfaces(peer);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
res = 0;
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
res |= ast_bridge_features_ds_set(chan, &config->features_caller);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
ast_channel_lock(peer);
|
|
|
|
res |= ast_bridge_features_ds_set(peer, &config->features_callee);
|
|
|
|
ast_channel_unlock(peer);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (res) {
|
|
|
|
return -1;
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (config->timelimit) {
|
|
|
|
struct ast_bridge_features_limits call_duration_limits_chan;
|
|
|
|
struct ast_bridge_features_limits call_duration_limits_peer;
|
|
|
|
int abandon_call = 0; /* TRUE if set limits fails so we can abandon the call. */
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_bridge_features_limits_construct(&call_duration_limits_chan)) {
|
|
|
|
ast_log(LOG_ERROR, "Could not construct caller duration limits. Bridge canceled.\n");
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return -1;
|
2011-08-09 23:17:13 +00:00
|
|
|
}
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_bridge_features_limits_construct(&call_duration_limits_peer)) {
|
|
|
|
ast_log(LOG_ERROR, "Could not construct callee duration limits. Bridge canceled.\n");
|
|
|
|
ast_bridge_features_limits_destroy(&call_duration_limits_chan);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return -1;
|
2008-04-21 23:42:45 +00:00
|
|
|
}
|
2011-08-09 23:17:13 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
bridge_config_set_limits(config, &call_duration_limits_chan, &call_duration_limits_peer);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_bridge_features_set_limits(chan_features, &call_duration_limits_chan, 0)) {
|
|
|
|
abandon_call = 1;
|
|
|
|
}
|
|
|
|
if (ast_bridge_features_set_limits(peer_features, &call_duration_limits_peer, 0)) {
|
|
|
|
abandon_call = 1;
|
2011-08-09 23:17:13 +00:00
|
|
|
}
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* At this point we are done with the limits structs since they have been copied to the individual feature sets. */
|
|
|
|
ast_bridge_features_limits_destroy(&call_duration_limits_chan);
|
|
|
|
ast_bridge_features_limits_destroy(&call_duration_limits_peer);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (abandon_call) {
|
|
|
|
ast_log(LOG_ERROR, "Could not set duration limits on one or more sides of the call. Bridge canceled.\n");
|
|
|
|
return -1;
|
2008-01-23 23:09:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief bridge the call and set CDR
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \param chan The bridge considers this channel the caller.
|
|
|
|
* \param peer The bridge considers this channel the callee.
|
|
|
|
* \param config Configuration for this bridge.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* Set start time, check for two channels,check if monitor on
|
|
|
|
* check for feature activation, create new CDR
|
|
|
|
* \retval res on success.
|
|
|
|
* \retval -1 on failure to bridge.
|
2011-08-16 17:23:08 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
int res;
|
|
|
|
struct ast_bridge *bridge;
|
|
|
|
struct ast_bridge_features chan_features;
|
|
|
|
struct ast_bridge_features *peer_features;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Setup features. */
|
|
|
|
res = ast_bridge_features_init(&chan_features);
|
|
|
|
peer_features = ast_bridge_features_new();
|
|
|
|
if (res || !peer_features) {
|
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
bridge_failed_peer_goto(chan, peer);
|
|
|
|
return -1;
|
2008-01-23 23:09:11 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
if (pre_bridge_setup(chan, peer, config, &chan_features, peer_features)) {
|
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
bridge_failed_peer_goto(chan, peer);
|
|
|
|
return -1;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
/* Create bridge */
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
if (!bridge) {
|
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
bridge_failed_peer_goto(chan, peer);
|
|
|
|
return -1;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Put peer into the bridge */
|
|
|
|
if (ast_bridge_impart(bridge, peer, NULL, peer_features, 1)) {
|
|
|
|
ast_bridge_destroy(bridge);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
bridge_failed_peer_goto(chan, peer);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Join bridge */
|
|
|
|
ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 1);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*
|
|
|
|
* If the bridge was broken for a hangup that isn't real, then
|
|
|
|
* don't run the h extension, because the channel isn't really
|
|
|
|
* hung up. This should really only happen with
|
|
|
|
* AST_SOFTHANGUP_ASYNCGOTO.
|
|
|
|
*/
|
|
|
|
res = -1;
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) {
|
|
|
|
res = 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_unlock(chan);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
2003-07-02 14:06:12 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* BUGBUG this is used by Dial and FollowMe for CDR information. By Queue for Queue stats like CDRs. */
|
|
|
|
if (res && config->end_bridge_callback) {
|
|
|
|
config->end_bridge_callback(config->end_bridge_callback_data);
|
2008-03-04 23:04:29 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
return res;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2007-06-06 14:45:29 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! \brief Output parking event to manager */
|
|
|
|
static void post_manager_event(const char *s, struct parkeduser *pu)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
manager_event(EVENT_FLAG_CALL, s,
|
|
|
|
"Exten: %s\r\n"
|
|
|
|
"Channel: %s\r\n"
|
|
|
|
"Parkinglot: %s\r\n"
|
|
|
|
"CallerIDNum: %s\r\n"
|
|
|
|
"CallerIDName: %s\r\n"
|
|
|
|
"ConnectedLineNum: %s\r\n"
|
|
|
|
"ConnectedLineName: %s\r\n"
|
|
|
|
"UniqueID: %s\r\n",
|
|
|
|
pu->parkingexten,
|
|
|
|
ast_channel_name(pu->chan),
|
|
|
|
pu->parkinglot->name,
|
|
|
|
S_COR(ast_channel_caller(pu->chan)->id.number.valid, ast_channel_caller(pu->chan)->id.number.str, "<unknown>"),
|
|
|
|
S_COR(ast_channel_caller(pu->chan)->id.name.valid, ast_channel_caller(pu->chan)->id.name.str, "<unknown>"),
|
|
|
|
S_COR(ast_channel_connected(pu->chan)->id.number.valid, ast_channel_connected(pu->chan)->id.number.str, "<unknown>"),
|
|
|
|
S_COR(ast_channel_connected(pu->chan)->id.name.valid, ast_channel_connected(pu->chan)->id.name.str, "<unknown>"),
|
|
|
|
ast_channel_uniqueid(pu->chan)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *callback_dialoptions(struct ast_flags *features_callee, struct ast_flags *features_caller, char *options, size_t len)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
enum {
|
|
|
|
OPT_CALLEE_REDIRECT = 't',
|
|
|
|
OPT_CALLER_REDIRECT = 'T',
|
|
|
|
OPT_CALLEE_AUTOMON = 'w',
|
|
|
|
OPT_CALLER_AUTOMON = 'W',
|
|
|
|
OPT_CALLEE_DISCONNECT = 'h',
|
|
|
|
OPT_CALLER_DISCONNECT = 'H',
|
|
|
|
OPT_CALLEE_PARKCALL = 'k',
|
|
|
|
OPT_CALLER_PARKCALL = 'K',
|
|
|
|
};
|
2007-06-06 14:45:29 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
memset(options, 0, len);
|
|
|
|
if (ast_test_flag(features_caller, AST_FEATURE_REDIRECT) && i < len) {
|
|
|
|
options[i++] = OPT_CALLER_REDIRECT;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_caller, AST_FEATURE_AUTOMON) && i < len) {
|
|
|
|
options[i++] = OPT_CALLER_AUTOMON;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_caller, AST_FEATURE_DISCONNECT) && i < len) {
|
|
|
|
options[i++] = OPT_CALLER_DISCONNECT;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_caller, AST_FEATURE_PARKCALL) && i < len) {
|
|
|
|
options[i++] = OPT_CALLER_PARKCALL;
|
2003-07-02 14:06:12 +00:00
|
|
|
}
|
2008-04-21 23:42:45 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (ast_test_flag(features_callee, AST_FEATURE_REDIRECT) && i < len) {
|
|
|
|
options[i++] = OPT_CALLEE_REDIRECT;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_callee, AST_FEATURE_AUTOMON) && i < len) {
|
|
|
|
options[i++] = OPT_CALLEE_AUTOMON;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_callee, AST_FEATURE_DISCONNECT) && i < len) {
|
|
|
|
options[i++] = OPT_CALLEE_DISCONNECT;
|
|
|
|
}
|
|
|
|
if (ast_test_flag(features_callee, AST_FEATURE_PARKCALL) && i < len) {
|
|
|
|
options[i++] = OPT_CALLEE_PARKCALL;
|
2010-07-09 21:57:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
return options;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2003-07-02 14:06:12 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief Run management on a parked call.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \note The parkinglot parkings list is locked on entry.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* \retval TRUE if the parking completed.
|
2011-08-16 17:23:08 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds, int nfds, struct pollfd **new_pfds, int *new_nfds, int *ms)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
struct ast_channel *chan = pu->chan; /* shorthand */
|
|
|
|
int tms; /* timeout for this item */
|
|
|
|
int x; /* fd index in channel */
|
2007-06-06 14:45:29 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
|
|
|
|
if (tms > pu->parkingtime) {
|
|
|
|
/*
|
|
|
|
* Call has been parked too long.
|
|
|
|
* Stop entertaining the caller.
|
|
|
|
*/
|
|
|
|
switch (pu->hold_method) {
|
|
|
|
case AST_CONTROL_HOLD:
|
|
|
|
ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
|
|
|
|
break;
|
|
|
|
case AST_CONTROL_RINGING:
|
|
|
|
ast_indicate(pu->chan, -1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pu->hold_method = 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Get chan, exten from derived kludge */
|
|
|
|
if (pu->peername[0]) {
|
|
|
|
char *peername;
|
|
|
|
char *dash;
|
|
|
|
char *peername_flat; /* using something like DAHDI/52 for an extension name is NOT a good idea */
|
|
|
|
char parkingslot[AST_MAX_EXTENSION]; /* buffer for parkinglot slot number */
|
|
|
|
int i;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
peername = ast_strdupa(pu->peername);
|
|
|
|
dash = strrchr(peername, '-');
|
|
|
|
if (dash) {
|
|
|
|
*dash = '\0';
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
peername_flat = ast_strdupa(peername);
|
|
|
|
for (i = 0; peername_flat[i]; i++) {
|
|
|
|
if (peername_flat[i] == '/') {
|
|
|
|
peername_flat[i] = '_';
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!ast_context_find_or_create(NULL, NULL, parking_con_dial, registrar)) {
|
|
|
|
ast_log(LOG_ERROR,
|
|
|
|
"Parking dial context '%s' does not exist and unable to create\n",
|
|
|
|
parking_con_dial);
|
|
|
|
} else {
|
|
|
|
char returnexten[AST_MAX_EXTENSION];
|
|
|
|
char comebackdialtime[AST_MAX_EXTENSION];
|
|
|
|
struct ast_datastore *features_datastore;
|
|
|
|
struct ast_dial_features *dialfeatures;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!strncmp(peername, "Parked/", 7)) {
|
|
|
|
peername += 7;
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
features_datastore = ast_channel_datastore_find(chan, &dial_features_info,
|
|
|
|
NULL);
|
|
|
|
if (features_datastore && (dialfeatures = features_datastore->data)) {
|
|
|
|
char buf[MAX_DIAL_FEATURE_OPTIONS] = {0,};
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
snprintf(returnexten, sizeof(returnexten), "%s,%u,%s", peername,
|
|
|
|
pu->parkinglot->cfg.comebackdialtime,
|
|
|
|
callback_dialoptions(&dialfeatures->peer_features,
|
|
|
|
&dialfeatures->my_features, buf, sizeof(buf)));
|
|
|
|
} else { /* Existing default */
|
|
|
|
ast_log(LOG_NOTICE, "Dial features not found on %s, using default!\n",
|
|
|
|
ast_channel_name(chan));
|
|
|
|
snprintf(returnexten, sizeof(returnexten), "%s,%u,t", peername,
|
|
|
|
pu->parkinglot->cfg.comebackdialtime);
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
2010-09-15 19:23:56 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
snprintf(comebackdialtime, sizeof(comebackdialtime), "%u",
|
|
|
|
pu->parkinglot->cfg.comebackdialtime);
|
|
|
|
pbx_builtin_setvar_helper(chan, "COMEBACKDIALTIME", comebackdialtime);
|
2010-09-15 19:23:56 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "PARKER", peername);
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
}
|
2003-07-02 14:06:12 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
|
|
|
|
pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parkingslot);
|
|
|
|
pbx_builtin_setvar_helper(chan, "PARKEDLOT", pu->parkinglot->name);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (pu->options_specified) {
|
|
|
|
/*
|
|
|
|
* Park() was called with overriding return arguments, respect
|
|
|
|
* those arguments.
|
|
|
|
*/
|
|
|
|
set_c_e_p(chan, pu->context, pu->exten, pu->priority);
|
|
|
|
} else if (pu->parkinglot->cfg.comebacktoorigin) {
|
|
|
|
set_c_e_p(chan, parking_con_dial, peername_flat, 1);
|
|
|
|
} else {
|
|
|
|
/* Handle fallback when extensions don't exist here since that logic was removed from pbx */
|
|
|
|
if (ast_exists_extension(chan, pu->parkinglot->cfg.comebackcontext, peername_flat, 1, NULL)) {
|
|
|
|
set_c_e_p(chan, pu->parkinglot->cfg.comebackcontext, peername_flat, 1);
|
|
|
|
} else if (ast_exists_extension(chan, pu->parkinglot->cfg.comebackcontext, "s", 1, NULL)) {
|
|
|
|
ast_verb(2, "Can not start %s at %s,%s,1. Using 's@%s' instead.\n", ast_channel_name(chan),
|
|
|
|
pu->parkinglot->cfg.comebackcontext, peername_flat, pu->parkinglot->cfg.comebackcontext);
|
|
|
|
set_c_e_p(chan, pu->parkinglot->cfg.comebackcontext, "s", 1);
|
|
|
|
} else {
|
|
|
|
ast_verb(2, "Can not start %s at %s,%s,1 and exten 's@%s' does not exist. Using 's@default'\n",
|
|
|
|
ast_channel_name(chan),
|
|
|
|
pu->parkinglot->cfg.comebackcontext, peername_flat,
|
|
|
|
pu->parkinglot->cfg.comebackcontext);
|
|
|
|
set_c_e_p(chan, "default", "s", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* They've been waiting too long, send them back to where they
|
|
|
|
* came. Theoretically they should have their original
|
|
|
|
* extensions and such, but we copy to be on the safe side.
|
|
|
|
*/
|
|
|
|
set_c_e_p(chan, pu->context, pu->exten, pu->priority);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
post_manager_event("ParkedCallTimeOut", pu);
|
2003-07-02 14:06:12 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
|
|
|
|
ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, ast_channel_context(pu->chan),
|
|
|
|
ast_channel_exten(pu->chan), ast_channel_priority(pu->chan));
|
2005-07-25 17:31:53 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Start up the PBX, or hang them up */
|
|
|
|
if (ast_pbx_start(chan)) {
|
|
|
|
ast_log(LOG_WARNING,
|
|
|
|
"Unable to restart the PBX for user on '%s', hanging them up...\n",
|
|
|
|
ast_channel_name(pu->chan));
|
|
|
|
ast_hangup(chan);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
|
|
|
|
/* And take them out of the parking lot */
|
|
|
|
return 1;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2009-10-07 22:58:38 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* still within parking time, process descriptors */
|
|
|
|
if (pfds) {
|
|
|
|
for (x = 0; x < AST_MAX_FDS; x++) {
|
|
|
|
struct ast_frame *f;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
if (!ast_channel_fd_isset(chan, x)) {
|
|
|
|
continue; /* nothing on this descriptor */
|
|
|
|
}
|
|
|
|
|
|
|
|
for (y = 0; y < nfds; y++) {
|
|
|
|
if (pfds[y].fd == ast_channel_fd(chan, x)) {
|
|
|
|
/* Found poll record! */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (y == nfds) {
|
|
|
|
/* Not found */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pfds[y].revents & (POLLIN | POLLERR | POLLPRI))) {
|
|
|
|
/* Next x */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pfds[y].revents & POLLPRI) {
|
|
|
|
ast_set_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION);
|
|
|
|
} else {
|
|
|
|
ast_clear_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION);
|
|
|
|
}
|
|
|
|
ast_channel_fdno_set(chan, x);
|
2004-01-30 05:49:44 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* See if they need servicing */
|
|
|
|
f = ast_read(pu->chan);
|
|
|
|
/* Hangup? */
|
|
|
|
if (!f || (f->frametype == AST_FRAME_CONTROL
|
|
|
|
&& f->subclass.integer == AST_CONTROL_HANGUP)) {
|
|
|
|
if (f) {
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
|
|
|
post_manager_event("ParkedCallGiveUp", pu);
|
2006-03-06 23:12:48 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* There's a problem, hang them up */
|
|
|
|
ast_verb(2, "%s got tired of being parked\n", ast_channel_name(chan));
|
|
|
|
ast_hangup(chan);
|
2006-03-06 23:12:48 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* And take them out of the parking lot */
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
/* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
|
|
|
|
ast_frfree(f);
|
|
|
|
if (pu->hold_method == AST_CONTROL_HOLD
|
|
|
|
&& pu->moh_trys < 3
|
|
|
|
&& !ast_channel_generatordata(chan)) {
|
|
|
|
ast_debug(1,
|
|
|
|
"MOH on parked call stopped by outside source. Restarting on channel %s.\n",
|
|
|
|
ast_channel_name(chan));
|
|
|
|
ast_indicate_data(chan, AST_CONTROL_HOLD,
|
|
|
|
S_OR(pu->parkinglot->cfg.mohclass, NULL),
|
|
|
|
(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
|
|
|
|
? strlen(pu->parkinglot->cfg.mohclass) + 1 : 0));
|
|
|
|
pu->moh_trys++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} /* End for */
|
|
|
|
}
|
2009-02-18 22:51:38 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* mark fds for next round */
|
|
|
|
for (x = 0; x < AST_MAX_FDS; x++) {
|
|
|
|
if (ast_channel_fd_isset(chan, x)) {
|
|
|
|
void *tmp = ast_realloc(*new_pfds,
|
|
|
|
(*new_nfds + 1) * sizeof(struct pollfd));
|
2008-01-23 23:09:11 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!tmp) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*new_pfds = tmp;
|
|
|
|
(*new_pfds)[*new_nfds].fd = ast_channel_fd(chan, x);
|
|
|
|
(*new_pfds)[*new_nfds].events = POLLIN | POLLERR | POLLPRI;
|
|
|
|
(*new_pfds)[*new_nfds].revents = 0;
|
|
|
|
(*new_nfds)++;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2006-03-06 23:12:48 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Keep track of our shortest wait */
|
|
|
|
if (tms < *ms || *ms < 0) {
|
|
|
|
*ms = tms;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Stay in the parking lot. */
|
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! \brief Run management on parkinglots, called once per parkinglot */
|
|
|
|
static void manage_parkinglot(struct ast_parkinglot *curlot, const struct pollfd *pfds, int nfds, struct pollfd **new_pfds, int *new_nfds, int *ms)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
struct parkeduser *pu;
|
|
|
|
struct ast_context *con;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Lock parkings list */
|
|
|
|
AST_LIST_LOCK(&curlot->parkings);
|
|
|
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&curlot->parkings, pu, list) {
|
|
|
|
if (pu->notquiteyet) { /* Pretend this one isn't here yet */
|
|
|
|
continue;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
if (manage_parked_call(pu, pfds, nfds, new_pfds, new_nfds, ms)) {
|
|
|
|
/* Parking is complete for this call so remove it from the parking lot. */
|
|
|
|
con = ast_context_find(pu->parkinglot->cfg.parking_con);
|
|
|
|
if (con) {
|
|
|
|
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL, 0)) {
|
|
|
|
ast_log(LOG_WARNING,
|
|
|
|
"Whoa, failed to remove the parking extension %s@%s!\n",
|
|
|
|
pu->parkingexten, pu->parkinglot->cfg.parking_con);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
notify_metermaids(pu->parkingexten, pu->parkinglot->cfg.parking_con,
|
|
|
|
AST_DEVICE_NOT_INUSE);
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING,
|
|
|
|
"Whoa, parking lot '%s' context '%s' does not exist.\n",
|
|
|
|
pu->parkinglot->name, pu->parkinglot->cfg.parking_con);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
AST_LIST_REMOVE_CURRENT(list);
|
|
|
|
parkinglot_unref(pu->parkinglot);
|
|
|
|
ast_free(pu);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2009-02-18 22:51:38 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
AST_LIST_TRAVERSE_SAFE_END;
|
|
|
|
AST_LIST_UNLOCK(&curlot->parkings);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2009-02-18 22:51:38 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
2013-06-06 21:40:35 +00:00
|
|
|
* \brief Take care of parked calls and unpark them if needed
|
|
|
|
* \param ignore unused var.
|
2011-08-16 17:23:08 +00:00
|
|
|
*
|
2013-06-06 21:40:35 +00:00
|
|
|
* Start inf loop, lock parking lot, check if any parked channels have gone above timeout
|
|
|
|
* if so, remove channel from parking lot and return it to the extension that parked it.
|
|
|
|
* Check if parked channel decided to hangup, wait until next FD via select().
|
2011-08-16 17:23:08 +00:00
|
|
|
*/
|
2013-06-06 21:40:35 +00:00
|
|
|
static void *do_parking_thread(void *ignore)
|
2011-08-16 17:23:08 +00:00
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
struct pollfd *pfds = NULL, *new_pfds = NULL;
|
|
|
|
int nfds = 0, new_nfds = 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
for (;;) {
|
|
|
|
struct ao2_iterator iter;
|
|
|
|
struct ast_parkinglot *curlot;
|
|
|
|
int ms = -1; /* poll2 timeout, uninitialized */
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
iter = ao2_iterator_init(parkinglots, 0);
|
|
|
|
while ((curlot = ao2_iterator_next(&iter))) {
|
|
|
|
manage_parkinglot(curlot, pfds, nfds, &new_pfds, &new_nfds, &ms);
|
|
|
|
ao2_ref(curlot, -1);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
ao2_iterator_destroy(&iter);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/* Recycle */
|
|
|
|
ast_free(pfds);
|
|
|
|
pfds = new_pfds;
|
|
|
|
nfds = new_nfds;
|
|
|
|
new_pfds = NULL;
|
|
|
|
new_nfds = 0;
|
|
|
|
|
|
|
|
/* Wait for something to happen */
|
|
|
|
ast_poll(pfds, nfds, ms);
|
|
|
|
pthread_testcancel();
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-06-06 21:40:35 +00:00
|
|
|
/* If this WERE reached, we'd need to free(pfds) */
|
|
|
|
return NULL; /* Never reached */
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
AST_APP_OPTIONS(park_call_options, BEGIN_OPTIONS
|
|
|
|
AST_APP_OPTION('r', AST_PARK_OPT_RINGING),
|
|
|
|
AST_APP_OPTION('R', AST_PARK_OPT_RANDOMIZE),
|
|
|
|
AST_APP_OPTION('s', AST_PARK_OPT_SILENCE),
|
|
|
|
END_OPTIONS );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unreference parkinglot object.
|
|
|
|
*/
|
|
|
|
static void parkinglot_unref(struct ast_parkinglot *parkinglot)
|
|
|
|
{
|
|
|
|
ast_debug(3, "Multiparking: %s refcount now %d\n", parkinglot->name,
|
|
|
|
ao2_ref(parkinglot, 0) - 1);
|
|
|
|
ao2_ref(parkinglot, -1);
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! Default configuration for default parking lot. */
|
|
|
|
static const struct parkinglot_cfg parkinglot_cfg_default_default = {
|
|
|
|
.mohclass = "default",
|
|
|
|
.parkext = DEFAULT_PARK_EXTENSION,
|
|
|
|
.parking_con = "parkedcalls",
|
|
|
|
.parking_start = 701,
|
|
|
|
.parking_stop = 750,
|
|
|
|
.parkingtime = DEFAULT_PARK_TIME,
|
|
|
|
.comebackdialtime = DEFAULT_COMEBACK_DIAL_TIME,
|
|
|
|
.comebackcontext = DEFAULT_COMEBACK_CONTEXT,
|
|
|
|
.comebacktoorigin = DEFAULT_COMEBACK_TO_ORIGIN,
|
|
|
|
};
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
/*! Default configuration for normal parking lots. */
|
|
|
|
static const struct parkinglot_cfg parkinglot_cfg_default = {
|
|
|
|
.parkext = DEFAULT_PARK_EXTENSION,
|
|
|
|
.parkingtime = DEFAULT_PARK_TIME,
|
|
|
|
.comebackdialtime = DEFAULT_COMEBACK_DIAL_TIME,
|
|
|
|
.comebackcontext = DEFAULT_COMEBACK_CONTEXT,
|
|
|
|
.comebacktoorigin = DEFAULT_COMEBACK_TO_ORIGIN,
|
|
|
|
};
|
2005-10-13 23:58:33 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
int ast_features_reload(void)
|
|
|
|
{
|
|
|
|
struct ast_context *con;
|
|
|
|
int res;
|
2005-08-23 02:22:33 +00:00
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
ast_mutex_lock(&features_reload_lock);/* Searialize reloading features.conf */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Always destroy the parking_con_dial context to remove buildup
|
|
|
|
* of recalled extensions in the context. At worst, the parked
|
|
|
|
* call gets hungup attempting to run an invalid extension when
|
|
|
|
* we are trying to callback the parker or the preset return
|
|
|
|
* extension. This is a small window of opportunity on an
|
|
|
|
* execution chain that is not expected to happen very often.
|
|
|
|
*/
|
|
|
|
con = ast_context_find(parking_con_dial);
|
|
|
|
if (con) {
|
|
|
|
ast_context_destroy(con, registrar);
|
|
|
|
}
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
res = ast_features_config_reload();
|
2011-08-16 17:23:08 +00:00
|
|
|
ast_mutex_unlock(&features_reload_lock);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *handle_features_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
|
|
|
{
|
2012-03-22 19:51:16 +00:00
|
|
|
switch (cmd) {
|
2011-08-16 17:23:08 +00:00
|
|
|
case CLI_INIT:
|
|
|
|
e->command = "features reload";
|
|
|
|
e->usage =
|
|
|
|
"Usage: features reload\n"
|
|
|
|
" Reloads configured call features from features.conf\n";
|
|
|
|
return NULL;
|
|
|
|
case CLI_GENERATE:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ast_features_reload();
|
|
|
|
|
|
|
|
return CLI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
enum play_tone_action {
|
|
|
|
PLAYTONE_NONE = 0,
|
|
|
|
PLAYTONE_CHANNEL1 = (1 << 0),
|
|
|
|
PLAYTONE_CHANNEL2 = (1 << 1),
|
|
|
|
PLAYTONE_BOTH = PLAYTONE_CHANNEL1 | PLAYTONE_CHANNEL2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum play_tone_action parse_playtone(const char *playtone_val)
|
|
|
|
{
|
|
|
|
if (ast_strlen_zero(playtone_val) || ast_false(playtone_val)) {
|
|
|
|
return PLAYTONE_NONE;
|
|
|
|
} if (!strcasecmp(playtone_val, "channel1")) {
|
|
|
|
return PLAYTONE_CHANNEL1;
|
|
|
|
} else if (!strcasecmp(playtone_val, "channel2") || ast_true(playtone_val)) {
|
|
|
|
return PLAYTONE_CHANNEL2;
|
|
|
|
} else if (!strcasecmp(playtone_val, "both")) {
|
|
|
|
return PLAYTONE_BOTH;
|
|
|
|
} else {
|
|
|
|
/* Invalid input. Assume none */
|
|
|
|
return PLAYTONE_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
/*!
|
|
|
|
* \brief Bridge channels together
|
|
|
|
* \param s
|
|
|
|
* \param m
|
2012-03-22 19:51:16 +00:00
|
|
|
*
|
|
|
|
* Make sure valid channels were specified,
|
2011-08-16 17:23:08 +00:00
|
|
|
* send errors if any of the channels could not be found/locked, answer channels if needed,
|
2012-03-22 19:51:16 +00:00
|
|
|
* create the placeholder channels and grab the other channels
|
|
|
|
* make the channels compatible, send error if we fail doing so
|
2011-08-16 17:23:08 +00:00
|
|
|
* setup the bridge thread object and start the bridge.
|
2012-03-22 19:51:16 +00:00
|
|
|
*
|
2012-06-23 00:29:18 +00:00
|
|
|
* \retval 0
|
2011-08-16 17:23:08 +00:00
|
|
|
*/
|
|
|
|
static int action_bridge(struct mansession *s, const struct message *m)
|
|
|
|
{
|
|
|
|
const char *channela = astman_get_header(m, "Channel1");
|
|
|
|
const char *channelb = astman_get_header(m, "Channel2");
|
2013-05-28 14:45:31 +00:00
|
|
|
enum play_tone_action playtone = parse_playtone(astman_get_header(m, "Tone"));
|
|
|
|
RAII_VAR(struct ast_channel *, chana, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_channel *, chanb, NULL, ao2_cleanup);
|
|
|
|
const char *chana_name;
|
|
|
|
const char *chana_exten;
|
|
|
|
const char *chana_context;
|
|
|
|
int chana_priority;
|
|
|
|
const char *chanb_name;
|
|
|
|
const char *chanb_exten;
|
|
|
|
const char *chanb_context;
|
|
|
|
int chanb_priority;
|
|
|
|
struct ast_bridge *bridge;
|
2012-06-23 00:29:18 +00:00
|
|
|
char buf[256];
|
2013-06-25 22:28:22 +00:00
|
|
|
RAII_VAR(struct ast_features_xfer_config *, xfer_cfg_a, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_features_xfer_config *, xfer_cfg_b, NULL, ao2_cleanup);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
|
|
|
/* make sure valid channels were specified */
|
|
|
|
if (ast_strlen_zero(channela) || ast_strlen_zero(channelb)) {
|
|
|
|
astman_send_error(s, m, "Missing channel parameter in request");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start with chana */
|
|
|
|
chana = ast_channel_get_by_name_prefix(channela, strlen(channela));
|
|
|
|
if (!chana) {
|
2013-05-28 14:45:31 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Channel1 does not exist: %s", channela);
|
2011-08-16 17:23:08 +00:00
|
|
|
astman_send_error(s, m, buf);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-06-25 22:28:22 +00:00
|
|
|
xfer_cfg_a = ast_get_chan_features_xfer_config(chana);
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_channel_lock(chana);
|
|
|
|
chana_name = ast_strdupa(ast_channel_name(chana));
|
|
|
|
chana_exten = ast_strdupa(ast_channel_exten(chana));
|
|
|
|
chana_context = ast_strdupa(ast_channel_context(chana));
|
|
|
|
chana_priority = ast_channel_priority(chana);
|
|
|
|
if (!ast_test_flag(ast_channel_flags(chana), AST_FLAG_IN_AUTOLOOP)) {
|
|
|
|
chana_priority++;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_channel_unlock(chana);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
|
|
|
chanb = ast_channel_get_by_name_prefix(channelb, strlen(channelb));
|
|
|
|
if (!chanb) {
|
2013-05-28 14:45:31 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Channel2 does not exist: %s", channelb);
|
2011-08-16 17:23:08 +00:00
|
|
|
astman_send_error(s, m, buf);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-06-26 01:39:04 +00:00
|
|
|
xfer_cfg_b = ast_get_chan_features_xfer_config(chanb);
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_channel_lock(chanb);
|
|
|
|
chanb_name = ast_strdupa(ast_channel_name(chanb));
|
|
|
|
chanb_exten = ast_strdupa(ast_channel_exten(chanb));
|
|
|
|
chanb_context = ast_strdupa(ast_channel_context(chanb));
|
|
|
|
chanb_priority = ast_channel_priority(chanb);
|
|
|
|
if (!ast_test_flag(ast_channel_flags(chanb), AST_FLAG_IN_AUTOLOOP)) {
|
|
|
|
chanb_priority++;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_channel_unlock(chanb);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
if (!bridge) {
|
|
|
|
astman_send_error(s, m, "Unable to create bridge\n");
|
2012-06-23 00:29:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-07-25 02:20:23 +00:00
|
|
|
ast_bridge_set_after_go_on(chana, chana_context, chana_exten, chana_priority, NULL);
|
2013-06-25 22:28:22 +00:00
|
|
|
if (ast_bridge_add_channel(bridge, chana, NULL, playtone & PLAYTONE_CHANNEL1, xfer_cfg_a ? xfer_cfg_a->xfersound : NULL)) {
|
2013-05-28 14:45:31 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Unable to add Channel1 to bridge: %s", ast_channel_name(chana));
|
|
|
|
astman_send_error(s, m, buf);
|
|
|
|
ast_bridge_destroy(bridge);
|
2012-06-23 00:29:18 +00:00
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2013-07-25 02:20:23 +00:00
|
|
|
ast_bridge_set_after_go_on(chanb, chanb_context, chanb_exten, chanb_priority, NULL);
|
2013-06-25 22:28:22 +00:00
|
|
|
if (ast_bridge_add_channel(bridge, chanb, NULL, playtone & PLAYTONE_CHANNEL2, xfer_cfg_b ? xfer_cfg_b->xfersound : NULL)) {
|
2013-05-28 14:45:31 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Unable to add Channel2 to bridge: %s", ast_channel_name(chanb));
|
|
|
|
astman_send_error(s, m, buf);
|
|
|
|
ast_bridge_destroy(bridge);
|
2012-06-23 00:29:18 +00:00
|
|
|
return 0;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
|
|
|
|
2012-07-10 22:26:27 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<managerEventInstance>
|
|
|
|
<synopsis>Raised when a bridge is successfully created due to a manager action.</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="Response">
|
|
|
|
<enumlist>
|
|
|
|
<enum name="Success"/>
|
|
|
|
<enum name="Failed"/>
|
|
|
|
</enumlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<see-also>
|
|
|
|
<ref type="manager">Bridge</ref>
|
|
|
|
</see-also>
|
|
|
|
</managerEventInstance>
|
|
|
|
***/
|
2013-05-28 14:45:31 +00:00
|
|
|
/* BUGBUG This event used to use ast_manager_event_multichan. Now channel variables are not included in the event */
|
|
|
|
manager_event(EVENT_FLAG_CALL, "BridgeAction",
|
2011-08-16 17:23:08 +00:00
|
|
|
"Response: Success\r\n"
|
|
|
|
"Channel1: %s\r\n"
|
2013-05-28 14:45:31 +00:00
|
|
|
"Channel2: %s\r\n", chana_name, chanb_name);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
astman_send_ack(s, m, "Channels have been bridged");
|
2011-08-16 17:23:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_cli_entry cli_features[] = {
|
|
|
|
AST_CLI_DEFINE(handle_features_reload, "Reloads configured features"),
|
|
|
|
};
|
|
|
|
|
2011-06-09 16:47:07 +00:00
|
|
|
/*!
|
|
|
|
* The presence of this datastore on the channel indicates that
|
|
|
|
* someone is attemting to pickup or has picked up the channel.
|
|
|
|
* The purpose is to prevent a race between two channels
|
|
|
|
* attempting to pickup the same channel.
|
|
|
|
*/
|
|
|
|
static const struct ast_datastore_info pickup_active = {
|
2012-03-22 19:51:16 +00:00
|
|
|
.type = "pickup-active",
|
2011-06-09 16:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int ast_can_pickup(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
if (!ast_channel_pbx(chan) && !ast_channel_masq(chan) && !ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE)
|
2012-02-20 23:43:27 +00:00
|
|
|
&& (ast_channel_state(chan) == AST_STATE_RINGING
|
|
|
|
|| ast_channel_state(chan) == AST_STATE_RING
|
2011-06-09 16:47:07 +00:00
|
|
|
/*
|
|
|
|
* Check the down state as well because some SIP devices do not
|
|
|
|
* give 180 ringing when they can just give 183 session progress
|
|
|
|
* instead. Issue 14005. (Some ISDN switches as well for that
|
|
|
|
* matter.)
|
|
|
|
*/
|
2012-02-20 23:43:27 +00:00
|
|
|
|| ast_channel_state(chan) == AST_STATE_DOWN)
|
2011-06-09 16:47:07 +00:00
|
|
|
&& !ast_channel_datastore_find(chan, &pickup_active, NULL)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
|
|
|
|
{
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target = obj;/*!< Potential pickup target */
|
2012-09-20 17:22:41 +00:00
|
|
|
struct ast_channel *chan = arg;/*!< Channel wanting to pickup call */
|
|
|
|
|
|
|
|
if (chan == target) {
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-20 16:20:25 +00:00
|
|
|
|
|
|
|
ast_channel_lock(target);
|
2012-09-20 17:22:41 +00:00
|
|
|
if (ast_can_pickup(target)) {
|
|
|
|
/* Lock both channels. */
|
|
|
|
while (ast_channel_trylock(chan)) {
|
|
|
|
ast_channel_unlock(target);
|
|
|
|
sched_yield();
|
|
|
|
ast_channel_lock(target);
|
|
|
|
}
|
2012-08-07 12:46:36 +00:00
|
|
|
|
|
|
|
/*
|
2012-09-20 17:22:41 +00:00
|
|
|
* Both callgroup and namedcallgroup pickup variants are
|
|
|
|
* matched independently. Checking for named group match is
|
|
|
|
* done last since it's a more expensive operation.
|
2012-08-07 12:46:36 +00:00
|
|
|
*/
|
2012-09-20 17:22:41 +00:00
|
|
|
if ((ast_channel_pickupgroup(chan) & ast_channel_callgroup(target))
|
|
|
|
|| (ast_namedgroups_intersect(ast_channel_named_pickupgroups(chan),
|
|
|
|
ast_channel_named_callgroups(target)))) {
|
|
|
|
struct ao2_container *candidates = data;/*!< Candidate channels found. */
|
|
|
|
|
|
|
|
/* This is a candidate to pickup */
|
|
|
|
ao2_link(candidates, target);
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
2011-05-20 15:52:20 +00:00
|
|
|
}
|
2011-05-20 16:20:25 +00:00
|
|
|
ast_channel_unlock(target);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2011-05-20 15:52:20 +00:00
|
|
|
return 0;
|
2008-11-09 01:59:59 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 17:22:41 +00:00
|
|
|
struct ast_channel *ast_pickup_find_by_group(struct ast_channel *chan)
|
2008-01-23 23:09:11 +00:00
|
|
|
{
|
2012-09-20 17:22:41 +00:00
|
|
|
struct ao2_container *candidates;/*!< Candidate channels found to pickup. */
|
2011-05-20 16:20:25 +00:00
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
|
2012-09-20 17:22:41 +00:00
|
|
|
candidates = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_NOLOCK, 1, NULL, NULL);
|
|
|
|
if (!candidates) {
|
|
|
|
return NULL;
|
2012-08-10 02:07:55 +00:00
|
|
|
}
|
2012-08-07 12:46:36 +00:00
|
|
|
|
2012-09-20 17:22:41 +00:00
|
|
|
/* Find all candidate targets by group. */
|
|
|
|
ast_channel_callback(find_channel_by_group, chan, candidates, 0);
|
|
|
|
|
|
|
|
/* Find the oldest pickup target candidate */
|
2012-08-07 12:46:36 +00:00
|
|
|
target = NULL;
|
2012-09-20 17:22:41 +00:00
|
|
|
for (;;) {
|
|
|
|
struct ast_channel *candidate;/*!< Potential new older target */
|
|
|
|
struct ao2_iterator iter;
|
|
|
|
|
|
|
|
iter = ao2_iterator_init(candidates, 0);
|
|
|
|
while ((candidate = ao2_iterator_next(&iter))) {
|
|
|
|
if (!target) {
|
|
|
|
/* First target. */
|
|
|
|
target = candidate;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ast_tvcmp(ast_channel_creationtime(candidate), ast_channel_creationtime(target)) < 0) {
|
|
|
|
/* We have a new target. */
|
|
|
|
ast_channel_unref(target);
|
|
|
|
target = candidate;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ast_channel_unref(candidate);
|
2012-08-10 02:07:55 +00:00
|
|
|
}
|
2012-09-20 17:22:41 +00:00
|
|
|
ao2_iterator_destroy(&iter);
|
|
|
|
if (!target) {
|
|
|
|
/* No candidates found. */
|
|
|
|
break;
|
2012-08-07 12:46:36 +00:00
|
|
|
}
|
2012-09-20 17:22:41 +00:00
|
|
|
|
2012-08-07 12:46:36 +00:00
|
|
|
/* The found channel must be locked and ref'd. */
|
2012-08-10 02:07:55 +00:00
|
|
|
ast_channel_lock(target);
|
2012-09-20 17:22:41 +00:00
|
|
|
|
2012-08-07 12:46:36 +00:00
|
|
|
/* Recheck pickup ability */
|
2012-09-20 17:22:41 +00:00
|
|
|
if (ast_can_pickup(target)) {
|
|
|
|
/* This is the channel to pickup. */
|
|
|
|
break;
|
2012-08-07 12:46:36 +00:00
|
|
|
}
|
2012-09-20 17:22:41 +00:00
|
|
|
|
|
|
|
/* Someone else picked it up or the call went away. */
|
|
|
|
ast_channel_unlock(target);
|
|
|
|
ao2_unlink(candidates, target);
|
|
|
|
target = ast_channel_unref(target);
|
2012-08-07 12:46:36 +00:00
|
|
|
}
|
2012-09-20 17:22:41 +00:00
|
|
|
ao2_ref(candidates, -1);
|
|
|
|
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Pickup a call
|
|
|
|
* \param chan channel that initiated pickup.
|
|
|
|
*
|
|
|
|
* Walk list of channels, checking it is not itself, channel is pbx one,
|
|
|
|
* check that the callgroup for both channels are the same and the channel is ringing.
|
|
|
|
* Answer calling channel, flag channel as answered on queue, masq channels together.
|
|
|
|
*/
|
|
|
|
int ast_pickup_call(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
struct ast_channel *target;/*!< Potential pickup target */
|
|
|
|
int res = -1;
|
2013-06-06 21:40:35 +00:00
|
|
|
RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
|
|
|
|
const char *pickup_sound;
|
|
|
|
const char *fail_sound;
|
2012-09-20 17:22:41 +00:00
|
|
|
|
|
|
|
ast_debug(1, "pickup attempt by %s\n", ast_channel_name(chan));
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
pickup_cfg = ast_get_chan_features_pickup_config(chan);
|
|
|
|
if (!pickup_cfg) {
|
|
|
|
ast_log(LOG_ERROR, "Unable to retrieve pickup configuration. Unable to play pickup sounds\n");
|
|
|
|
}
|
|
|
|
pickup_sound = ast_strdupa(pickup_cfg ? pickup_cfg->pickupsound : "");
|
|
|
|
fail_sound = ast_strdupa(pickup_cfg ? pickup_cfg->pickupfailsound : "");
|
|
|
|
ast_channel_unlock(chan);
|
2012-08-07 12:46:36 +00:00
|
|
|
|
2012-09-20 17:22:41 +00:00
|
|
|
/* The found channel is already locked. */
|
|
|
|
target = ast_pickup_find_by_group(chan);
|
2011-05-20 15:52:20 +00:00
|
|
|
if (target) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", ast_channel_name(target), ast_channel_name(chan));
|
2011-05-20 15:52:20 +00:00
|
|
|
|
|
|
|
res = ast_do_pickup(chan, target);
|
2011-05-27 08:37:59 +00:00
|
|
|
ast_channel_unlock(target);
|
2011-05-20 15:52:20 +00:00
|
|
|
if (!res) {
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!ast_strlen_zero(pickup_sound)) {
|
|
|
|
pbx_builtin_setvar_helper(target, "BRIDGE_PLAY_SOUND", pickup_sound);
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "pickup %s failed by %s\n", ast_channel_name(target), ast_channel_name(chan));
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
}
|
|
|
|
target = ast_channel_unref(target);
|
|
|
|
}
|
2009-04-03 22:41:46 +00:00
|
|
|
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
if (res < 0) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_debug(1, "No call pickup possible... for %s\n", ast_channel_name(chan));
|
2013-06-06 21:40:35 +00:00
|
|
|
if (!ast_strlen_zero(fail_sound)) {
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
ast_answer(chan);
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_stream_and_wait(chan, fail_sound, "");
|
2009-02-26 18:41:28 +00:00
|
|
|
}
|
2008-01-23 23:09:11 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
return res;
|
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
static struct ast_manager_event_blob *call_pickup_to_ami(struct stasis_message *message)
|
|
|
|
{
|
|
|
|
struct ast_multi_channel_blob *contents = stasis_message_data(message);
|
|
|
|
struct ast_channel_snapshot *chan;
|
|
|
|
struct ast_channel_snapshot *target;
|
|
|
|
struct ast_manager_event_blob *res;
|
|
|
|
|
|
|
|
RAII_VAR(struct ast_str *, channel_str, NULL, ast_free);
|
|
|
|
RAII_VAR(struct ast_str *, target_str, NULL, ast_free);
|
|
|
|
|
|
|
|
chan = ast_multi_channel_blob_get_channel(contents, "channel");
|
|
|
|
target = ast_multi_channel_blob_get_channel(contents, "target");
|
|
|
|
|
|
|
|
ast_assert(chan != NULL && target != NULL);
|
|
|
|
|
|
|
|
if (!(channel_str = ast_manager_build_channel_state_string(chan))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(target_str = ast_manager_build_channel_state_string_prefix(target, "Target"))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = ast_manager_event_blob_create(EVENT_FLAG_CALL, "Pickup",
|
|
|
|
"%s"
|
|
|
|
"%s",
|
|
|
|
ast_str_buffer(channel_str),
|
|
|
|
ast_str_buffer(target_str));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int send_call_pickup_stasis_message(struct ast_channel *picking_up, struct ast_channel_snapshot *chan, struct ast_channel_snapshot *target)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_multi_channel_blob *, pickup_payload, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
|
|
|
|
|
|
|
|
if (!(pickup_payload = ast_multi_channel_blob_create(ast_json_null()))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_multi_channel_blob_add_channel(pickup_payload, "channel", chan);
|
|
|
|
ast_multi_channel_blob_add_channel(pickup_payload, "target", target);
|
|
|
|
|
|
|
|
if (!(msg = stasis_message_create(ast_call_pickup_type(), pickup_payload))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
stasis_publish(ast_channel_topic(picking_up), msg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target)
|
|
|
|
{
|
|
|
|
struct ast_party_connected_line connected_caller;
|
2011-06-09 16:47:07 +00:00
|
|
|
struct ast_datastore *ds_pickup;
|
|
|
|
const char *chan_name;/*!< A masquerade changes channel names. */
|
|
|
|
const char *target_name;/*!< A masquerade changes channel names. */
|
|
|
|
int res = -1;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
RAII_VAR(struct ast_channel_snapshot *, chan_snapshot, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_channel_snapshot *, target_snapshot, NULL, ao2_cleanup);
|
|
|
|
|
2012-01-09 22:15:50 +00:00
|
|
|
target_name = ast_strdupa(ast_channel_name(target));
|
|
|
|
ast_debug(1, "Call pickup on '%s' by '%s'\n", target_name, ast_channel_name(chan));
|
2011-06-09 16:47:07 +00:00
|
|
|
|
|
|
|
/* Mark the target to block any call pickup race. */
|
|
|
|
ds_pickup = ast_datastore_alloc(&pickup_active, NULL);
|
|
|
|
if (!ds_pickup) {
|
|
|
|
ast_log(LOG_WARNING,
|
|
|
|
"Unable to create channel datastore on '%s' for call pickup\n", target_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ast_channel_datastore_add(target, ds_pickup);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
ast_party_connected_line_init(&connected_caller);
|
2012-02-29 16:52:47 +00:00
|
|
|
ast_party_connected_line_copy(&connected_caller, ast_channel_connected(target));
|
2011-06-09 16:47:07 +00:00
|
|
|
ast_channel_unlock(target);/* The pickup race is avoided so we do not need the lock anymore. */
|
Add private representation of caller, connected and redirecting party ids.
This patch adds the feature "Private representation of caller, connected
and redirecting party ids", as previously discussed with us (DATUS) and
Digium.
1. Feature motivation
Until now it is quite difficult to modify a party number or name which can
only be seen by exactly one particular instantiated technology channel
subscriber. One example where a modified party number or name on one
channel is spread over several channels are supplementary services like
call transfer or pickup. To implement these features Asterisk internally
copies caller and connected ids from one channel to another. Another
example are extension subscriptions. The monitoring entities (watchers)
are notified of state changes and - if desired - of party numbers or names
which represent the involving call parties. One major feature where a
private representation of party names is essentially needed, i.e. where a
party name shall be exclusively signaled to only one particular user, is a
private user-specific name resolution for party numbers. A lookup in a
private destination-dependent telephone book shall provide party names
which cannot be seen by any other user at any time.
2. Feature Description
This feature comes along with the implementation of additional private
party id elements for caller id, connected id and redirecting ids inside
Asterisk channels.
The private party id elements can be read or set by the user using
Asterisk dialplan functions.
When a technology channel is initiating a call, receives an internal
connected-line update event, or receives an internal redirecting update
event, it merges the corresponding public id with the private id to create
an effective party id. The effective party id is then used for protocol
signaling.
The channel technologies which initially support the private id
representation with this patch are SIP (chan_sip), mISDN (chan_misdn) and
PRI (chan_dahdi).
Once a private name or number on a channel is set and (implicitly) made
valid, it is generally used for any further protocol signaling until it is
rewritten or invalidated.
To simplify the invalidation of private ids all internally generated
connected/redirecting update events and also all connected/redirecting
update events which are generated by technology channels -- receiving
regarding protocol information - automatically trigger the invalidation of
private ids.
If not using the private party id representation feature at all, i.e. if
using only the 'regular' caller-id, connected and redirecting related
functions, the current characteristic of Asterisk is not affected by the
new extended functionality.
3. User interface Description
To grant access to the private name and number representation from the
Asterisk dialplan, the CALLERID, CONNECTEDLINE and REDIRECTING dialplan
functions are extended by the following data types. The formats of these
data types are equal to the corresponding regular 'non-private' already
existing data types:
CALLERID:
priv-all
priv-name priv-name-valid priv-name-charset priv-name-pres
priv-num priv-num-valid priv-num-plan priv-num-pres
priv-subaddr priv-subaddr-valid priv-subaddr-type priv-subaddr-odd
priv-tag
CONNECTEDLINE:
priv-name priv-name-valid priv-name-pres priv-name-charset
priv-num priv-num-valid priv-num-pres priv-num-plan
priv-subaddr priv-subaddr-valid priv-subaddr-type priv-subaddr-odd
priv-tag
REDIRECTING:
priv-orig-name priv-orig-name-valid priv-orig-name-pres priv-orig-name-charset
priv-orig-num priv-orig-num-valid priv-orig-num-pres priv-orig-num-plan
priv-orig-subaddr priv-orig-subaddr-valid priv-orig-subaddr-type priv-orig-subaddr-odd
priv-orig-tag
priv-from-name priv-from-name-valid priv-from-name-pres priv-from-name-charset
priv-from-num priv-from-num-valid priv-from-num-pres priv-from-num-plan
priv-from-subaddr priv-from-subaddr-valid priv-from-subaddr-type priv-from-subaddr-odd
priv-from-tag
priv-to-name priv-to-name-valid priv-to-name-pres priv-to-name-charset
priv-to-num priv-to-num-valid priv-to-num-pres priv-to-num-plan
priv-to-subaddr priv-to-subaddr-valid priv-to-subaddr-type priv-to-subaddr-odd
priv-to-tag
Reported by: Thomas Arimont
Review: https://reviewboard.asterisk.org/r/2030/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-08-10 19:54:55 +00:00
|
|
|
/* Reset any earlier private connected id representation */
|
|
|
|
ast_party_id_reset(&connected_caller.priv);
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
|
2012-02-27 16:50:19 +00:00
|
|
|
if (ast_channel_connected_line_sub(NULL, chan, &connected_caller, 0) &&
|
|
|
|
ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
|
2010-07-14 15:48:36 +00:00
|
|
|
ast_channel_update_connected_line(chan, &connected_caller, NULL);
|
2009-06-01 20:57:31 +00:00
|
|
|
}
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
ast_party_connected_line_free(&connected_caller);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
ast_channel_lock(chan);
|
2012-01-09 22:15:50 +00:00
|
|
|
chan_name = ast_strdupa(ast_channel_name(chan));
|
2012-02-29 16:52:47 +00:00
|
|
|
ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(chan));
|
Merged revisions 318671 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r318671 | alecdavis | 2011-05-13 10:52:08 +1200 (Fri, 13 May 2011) | 30 lines
Fix directed group pickup feature code *8 with pickupsounds enabled
Since 1.6.2, the new pickupsound and pickupfailsound in features.conf cause many issues.
1). chan_sip:handle_request_invite() shouldn't be playing out the fail/success audio, as it has 'netlock' locked.
2). dialplan applications for directed_pickups shouldn't beep.
3). feature code for directed pickup should beep on success/failure if configured.
Created a sip_pickup() thread to handle the pickup and playout the audio, spawned from handle_request_invite.
Moved app_directed:pickup_do() to features:ast_do_pickup().
Functions below, all now use the new ast_do_pickup()
app_directed_pickup.c:
pickup_by_channel()
pickup_by_exten()
pickup_by_mark()
pickup_by_part()
features.c:
ast_pickup_call()
(closes issue #18654)
Reported by: Docent
Patches:
ast_do_pickup_1.8_trunk.diff.txt uploaded by alecdavis (license 585)
Tested by: lmadsen, francesco_r, amilcar, isis242, alecdavis, irroot, rymkus, loloski, rmudgett
Review: https://reviewboard.asterisk.org/r/1185/
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@318672 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-12 22:56:43 +00:00
|
|
|
ast_channel_unlock(chan);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
|
|
|
|
|
|
|
|
if (ast_answer(chan)) {
|
2011-06-09 16:47:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan_name);
|
|
|
|
goto pickup_failed;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_queue_control(chan, AST_CONTROL_ANSWER)) {
|
2011-06-09 16:47:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan_name);
|
|
|
|
goto pickup_failed;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
2012-03-22 19:51:16 +00:00
|
|
|
|
2012-03-29 23:36:37 +00:00
|
|
|
ast_channel_queue_connected_line_update(chan, &connected_caller, NULL);
|
|
|
|
|
2012-06-05 14:41:43 +00:00
|
|
|
/* setting the HANGUPCAUSE so the ringing channel knows this call was not a missed call */
|
|
|
|
ast_channel_hangupcause_set(chan, AST_CAUSE_ANSWERED_ELSEWHERE);
|
2011-09-07 14:23:38 +00:00
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
if (!(chan_snapshot = ast_channel_snapshot_create(chan))) {
|
|
|
|
goto pickup_failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(target_snapshot = ast_channel_snapshot_create(target))) {
|
|
|
|
goto pickup_failed;
|
|
|
|
}
|
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
if (ast_channel_move(target, chan)) {
|
2011-06-09 16:47:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan_name,
|
|
|
|
target_name);
|
|
|
|
goto pickup_failed;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
/* target points to the channel that did the pickup at this point, so use that channel's topic instead of chan */
|
|
|
|
send_call_pickup_stasis_message(target, chan_snapshot, target_snapshot);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2011-06-09 16:47:07 +00:00
|
|
|
res = 0;
|
|
|
|
|
|
|
|
pickup_failed:
|
2011-05-20 15:52:20 +00:00
|
|
|
ast_channel_lock(target);
|
2011-06-09 16:47:07 +00:00
|
|
|
if (!ast_channel_datastore_remove(target, ds_pickup)) {
|
|
|
|
ast_datastore_free(ds_pickup);
|
|
|
|
}
|
2012-03-29 23:36:37 +00:00
|
|
|
ast_party_connected_line_free(&connected_caller);
|
2011-05-20 15:52:20 +00:00
|
|
|
|
2011-06-09 16:47:07 +00:00
|
|
|
return res;
|
2005-01-10 04:03:30 +00:00
|
|
|
}
|
|
|
|
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
static char *app_bridge = "Bridge";
|
|
|
|
|
|
|
|
enum {
|
|
|
|
BRIDGE_OPT_PLAYTONE = (1 << 0),
|
2009-09-24 20:29:51 +00:00
|
|
|
OPT_CALLEE_HANGUP = (1 << 1),
|
|
|
|
OPT_CALLER_HANGUP = (1 << 2),
|
|
|
|
OPT_DURATION_LIMIT = (1 << 3),
|
|
|
|
OPT_DURATION_STOP = (1 << 4),
|
|
|
|
OPT_CALLEE_TRANSFER = (1 << 5),
|
|
|
|
OPT_CALLER_TRANSFER = (1 << 6),
|
|
|
|
OPT_CALLEE_MONITOR = (1 << 7),
|
|
|
|
OPT_CALLER_MONITOR = (1 << 8),
|
|
|
|
OPT_CALLEE_PARK = (1 << 9),
|
|
|
|
OPT_CALLER_PARK = (1 << 10),
|
|
|
|
OPT_CALLEE_KILL = (1 << 11),
|
2012-03-22 21:25:22 +00:00
|
|
|
OPT_CALLEE_GO_ON = (1 << 12),
|
2009-09-24 20:29:51 +00:00
|
|
|
};
|
2012-03-22 19:51:16 +00:00
|
|
|
|
2009-09-24 20:29:51 +00:00
|
|
|
enum {
|
|
|
|
OPT_ARG_DURATION_LIMIT = 0,
|
|
|
|
OPT_ARG_DURATION_STOP,
|
2012-03-22 21:25:22 +00:00
|
|
|
OPT_ARG_CALLEE_GO_ON,
|
2009-09-24 20:29:51 +00:00
|
|
|
/* note: this entry _MUST_ be the last one in the enum */
|
|
|
|
OPT_ARG_ARRAY_SIZE,
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AST_APP_OPTIONS(bridge_exec_options, BEGIN_OPTIONS
|
2009-09-24 20:29:51 +00:00
|
|
|
AST_APP_OPTION('p', BRIDGE_OPT_PLAYTONE),
|
2012-03-22 21:25:22 +00:00
|
|
|
AST_APP_OPTION_ARG('F', OPT_CALLEE_GO_ON, OPT_ARG_CALLEE_GO_ON),
|
2009-09-24 20:29:51 +00:00
|
|
|
AST_APP_OPTION('h', OPT_CALLEE_HANGUP),
|
|
|
|
AST_APP_OPTION('H', OPT_CALLER_HANGUP),
|
|
|
|
AST_APP_OPTION('k', OPT_CALLEE_PARK),
|
|
|
|
AST_APP_OPTION('K', OPT_CALLER_PARK),
|
|
|
|
AST_APP_OPTION_ARG('L', OPT_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT),
|
|
|
|
AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
|
|
|
|
AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
|
|
|
|
AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
|
|
|
|
AST_APP_OPTION('w', OPT_CALLEE_MONITOR),
|
|
|
|
AST_APP_OPTION('W', OPT_CALLER_MONITOR),
|
|
|
|
AST_APP_OPTION('x', OPT_CALLEE_KILL),
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
END_OPTIONS );
|
|
|
|
|
2009-09-24 20:29:51 +00:00
|
|
|
int ast_bridge_timelimit(struct ast_channel *chan, struct ast_bridge_config *config,
|
|
|
|
char *parse, struct timeval *calldurationlimit)
|
|
|
|
{
|
|
|
|
char *stringp = ast_strdupa(parse);
|
|
|
|
char *limit_str, *warning_str, *warnfreq_str;
|
|
|
|
const char *var;
|
|
|
|
int play_to_caller = 0, play_to_callee = 0;
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
limit_str = strsep(&stringp, ":");
|
|
|
|
warning_str = strsep(&stringp, ":");
|
|
|
|
warnfreq_str = strsep(&stringp, ":");
|
|
|
|
|
|
|
|
config->timelimit = atol(limit_str);
|
|
|
|
if (warning_str)
|
|
|
|
config->play_warning = atol(warning_str);
|
|
|
|
if (warnfreq_str)
|
|
|
|
config->warning_freq = atol(warnfreq_str);
|
|
|
|
|
|
|
|
if (!config->timelimit) {
|
|
|
|
ast_log(LOG_WARNING, "Bridge does not accept L(%s), hanging up.\n", limit_str);
|
|
|
|
config->timelimit = config->play_warning = config->warning_freq = 0;
|
|
|
|
config->warning_sound = NULL;
|
|
|
|
return -1; /* error */
|
|
|
|
} else if ( (delta = config->play_warning - config->timelimit) > 0) {
|
|
|
|
int w = config->warning_freq;
|
|
|
|
|
2011-08-09 23:17:13 +00:00
|
|
|
/*
|
|
|
|
* If the first warning is requested _after_ the entire call
|
|
|
|
* would end, and no warning frequency is requested, then turn
|
|
|
|
* off the warning. If a warning frequency is requested, reduce
|
|
|
|
* the 'first warning' time by that frequency until it falls
|
|
|
|
* within the call's total time limit.
|
|
|
|
*
|
|
|
|
* Graphically:
|
|
|
|
* timelim->| delta |<-playwarning
|
|
|
|
* 0__________________|_________________|
|
|
|
|
* | w | | | |
|
|
|
|
*
|
|
|
|
* so the number of intervals to cut is 1+(delta-1)/w
|
|
|
|
*/
|
2009-09-24 20:29:51 +00:00
|
|
|
if (w == 0) {
|
|
|
|
config->play_warning = 0;
|
|
|
|
} else {
|
|
|
|
config->play_warning -= w * ( 1 + (delta-1)/w );
|
|
|
|
if (config->play_warning < 1)
|
|
|
|
config->play_warning = config->warning_freq = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-03-22 19:51:16 +00:00
|
|
|
|
2009-09-24 20:29:51 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
|
|
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLER");
|
|
|
|
play_to_caller = var ? ast_true(var) : 1;
|
|
|
|
|
|
|
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_PLAYAUDIO_CALLEE");
|
|
|
|
play_to_callee = var ? ast_true(var) : 0;
|
|
|
|
|
|
|
|
if (!play_to_caller && !play_to_callee)
|
|
|
|
play_to_caller = 1;
|
|
|
|
|
|
|
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_WARNING_FILE");
|
|
|
|
config->warning_sound = !ast_strlen_zero(var) ? ast_strdup(var) : ast_strdup("timeleft");
|
|
|
|
|
|
|
|
/* The code looking at config wants a NULL, not just "", to decide
|
|
|
|
* that the message should not be played, so we replace "" with NULL.
|
|
|
|
* Note, pbx_builtin_getvar_helper _can_ return NULL if the variable is
|
|
|
|
* not found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_TIMEOUT_FILE");
|
|
|
|
config->end_sound = !ast_strlen_zero(var) ? ast_strdup(var) : NULL;
|
|
|
|
|
|
|
|
var = pbx_builtin_getvar_helper(chan, "LIMIT_CONNECT_FILE");
|
|
|
|
config->start_sound = !ast_strlen_zero(var) ? ast_strdup(var) : NULL;
|
|
|
|
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
/* undo effect of S(x) in case they are both used */
|
|
|
|
calldurationlimit->tv_sec = 0;
|
|
|
|
calldurationlimit->tv_usec = 0;
|
|
|
|
|
|
|
|
/* more efficient to do it like S(x) does since no advanced opts */
|
|
|
|
if (!config->play_warning && !config->start_sound && !config->end_sound && config->timelimit) {
|
|
|
|
calldurationlimit->tv_sec = config->timelimit / 1000;
|
|
|
|
calldurationlimit->tv_usec = (config->timelimit % 1000) * 1000;
|
|
|
|
ast_verb(3, "Setting call duration limit to %.3lf seconds.\n",
|
|
|
|
calldurationlimit->tv_sec + calldurationlimit->tv_usec / 1000000.0);
|
2013-05-21 18:00:22 +00:00
|
|
|
play_to_caller = 0;
|
|
|
|
play_to_callee = 0;
|
|
|
|
config->timelimit = 0;
|
|
|
|
config->play_warning = 0;
|
|
|
|
config->warning_freq = 0;
|
2009-09-24 20:29:51 +00:00
|
|
|
} else {
|
2010-01-18 22:31:25 +00:00
|
|
|
ast_verb(4, "Limit Data for this call:\n");
|
|
|
|
ast_verb(4, "timelimit = %ld ms (%.3lf s)\n", config->timelimit, config->timelimit / 1000.0);
|
|
|
|
ast_verb(4, "play_warning = %ld ms (%.3lf s)\n", config->play_warning, config->play_warning / 1000.0);
|
2009-09-24 20:29:51 +00:00
|
|
|
ast_verb(4, "play_to_caller = %s\n", play_to_caller ? "yes" : "no");
|
|
|
|
ast_verb(4, "play_to_callee = %s\n", play_to_callee ? "yes" : "no");
|
2010-01-18 22:31:25 +00:00
|
|
|
ast_verb(4, "warning_freq = %ld ms (%.3lf s)\n", config->warning_freq, config->warning_freq / 1000.0);
|
2009-09-24 20:29:51 +00:00
|
|
|
ast_verb(4, "start_sound = %s\n", S_OR(config->start_sound, ""));
|
|
|
|
ast_verb(4, "warning_sound = %s\n", config->warning_sound);
|
|
|
|
ast_verb(4, "end_sound = %s\n", S_OR(config->end_sound, ""));
|
|
|
|
}
|
|
|
|
if (play_to_caller)
|
|
|
|
ast_set_flag(&(config->features_caller), AST_FEATURE_PLAY_WARNING);
|
|
|
|
if (play_to_callee)
|
|
|
|
ast_set_flag(&(config->features_callee), AST_FEATURE_PLAY_WARNING);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-07 23:04:01 +00:00
|
|
|
/*!
|
|
|
|
* \brief Bridge channels
|
|
|
|
* \param chan
|
2007-09-05 16:31:39 +00:00
|
|
|
* \param data channel to bridge with.
|
2012-03-22 19:51:16 +00:00
|
|
|
*
|
2007-08-07 23:04:01 +00:00
|
|
|
* Split data, check we aren't bridging with ourself, check valid channel,
|
|
|
|
* answer call if not already, check compatible channels, setup bridge config
|
|
|
|
* now bridge call, if transfered party hangs up return to PBX extension.
|
2011-05-20 17:04:53 +00:00
|
|
|
*/
|
2009-05-21 21:13:09 +00:00
|
|
|
static int bridge_exec(struct ast_channel *chan, const char *data)
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
{
|
2013-05-28 14:45:31 +00:00
|
|
|
RAII_VAR(struct ast_channel *, current_dest_chan, NULL, ao2_cleanup);
|
2013-05-21 18:00:22 +00:00
|
|
|
struct ast_channel *chans[2];
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
char *tmp_data = NULL;
|
|
|
|
struct ast_flags opts = { 0, };
|
|
|
|
struct ast_bridge_config bconfig = { { 0, }, };
|
2009-09-24 20:29:51 +00:00
|
|
|
char *opt_args[OPT_ARG_ARRAY_SIZE];
|
|
|
|
struct timeval calldurationlimit = { 0, };
|
2013-05-21 18:00:22 +00:00
|
|
|
const char *context;
|
|
|
|
const char *extension;
|
|
|
|
int priority;
|
2013-05-28 14:45:31 +00:00
|
|
|
struct ast_bridge_features chan_features;
|
|
|
|
struct ast_bridge_features *peer_features;
|
|
|
|
struct ast_bridge *bridge;
|
2013-06-25 22:28:22 +00:00
|
|
|
RAII_VAR(struct ast_features_xfer_config *, xfer_cfg, NULL, ao2_cleanup);
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(dest_chan);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
);
|
2012-03-22 19:51:16 +00:00
|
|
|
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
if (ast_strlen_zero(data)) {
|
|
|
|
ast_log(LOG_WARNING, "Bridge require at least 1 argument specifying the other end of the bridge\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_data = ast_strdupa(data);
|
|
|
|
AST_STANDARD_APP_ARGS(args, tmp_data);
|
|
|
|
if (!ast_strlen_zero(args.options))
|
2009-09-24 20:29:51 +00:00
|
|
|
ast_app_parse_options(bridge_exec_options, &opts, opt_args, args.options);
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
|
|
|
/* make sure we have a valid end point */
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
if (!(current_dest_chan = ast_channel_get_by_name_prefix(args.dest_chan,
|
|
|
|
strlen(args.dest_chan)))) {
|
2012-06-23 00:29:18 +00:00
|
|
|
ast_log(LOG_WARNING, "Bridge failed because channel %s does not exist\n",
|
|
|
|
args.dest_chan);
|
2009-11-13 20:42:03 +00:00
|
|
|
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
|
2012-06-23 00:29:18 +00:00
|
|
|
"Response: Failed\r\n"
|
|
|
|
"Reason: Channel2 does not exist\r\n"
|
|
|
|
"Channel1: %s\r\n"
|
|
|
|
"Channel2: %s\r\n", ast_channel_name(chan), args.dest_chan);
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
/* avoid bridge with ourselves */
|
|
|
|
if (chan == current_dest_chan) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", ast_channel_name(chan));
|
|
|
|
/*** DOCUMENTATION
|
|
|
|
<managerEventInstance>
|
|
|
|
<synopsis>Raised when an error occurs during bridge creation.</synopsis>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">Bridge</ref>
|
|
|
|
</see-also>
|
|
|
|
</managerEventInstance>
|
|
|
|
***/
|
2009-11-13 20:42:03 +00:00
|
|
|
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
|
2012-06-23 00:29:18 +00:00
|
|
|
"Response: Failed\r\n"
|
2013-05-28 14:45:31 +00:00
|
|
|
"Reason: Unable to bridge channel to itself\r\n"
|
2012-06-23 00:29:18 +00:00
|
|
|
"Channel1: %s\r\n"
|
2013-05-28 14:45:31 +00:00
|
|
|
"Channel2: %s\r\n",
|
|
|
|
ast_channel_name(chan), args.dest_chan);
|
|
|
|
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");
|
2012-06-23 00:29:18 +00:00
|
|
|
return 0;
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-06-23 00:29:18 +00:00
|
|
|
if (ast_test_flag(&opts, OPT_DURATION_LIMIT)
|
|
|
|
&& !ast_strlen_zero(opt_args[OPT_ARG_DURATION_LIMIT])
|
|
|
|
&& ast_bridge_timelimit(chan, &bconfig, opt_args[OPT_ARG_DURATION_LIMIT], &calldurationlimit)) {
|
|
|
|
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
|
|
|
|
"Response: Failed\r\n"
|
|
|
|
"Reason: Cannot setup bridge time limit\r\n"
|
|
|
|
"Channel1: %s\r\n"
|
|
|
|
"Channel2: %s\r\n", ast_channel_name(chan), args.dest_chan);
|
|
|
|
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
chans[0] = chan;
|
|
|
|
chans[1] = current_dest_chan;
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
|
|
|
/* Report that the bridge will be successfull */
|
2012-07-10 22:26:27 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<managerEventInstance>
|
|
|
|
<synopsis>Raised when the bridge is created successfully.</synopsis>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">Bridge</ref>
|
|
|
|
</see-also>
|
|
|
|
</managerEventInstance>
|
|
|
|
***/
|
2009-11-13 20:42:03 +00:00
|
|
|
ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeExec", 2, chans,
|
2012-06-23 00:29:18 +00:00
|
|
|
"Response: Success\r\n"
|
|
|
|
"Channel1: %s\r\n"
|
2013-05-28 14:45:31 +00:00
|
|
|
"Channel2: %s\r\n", ast_channel_name(chan), ast_channel_name(current_dest_chan));
|
2012-03-22 19:51:16 +00:00
|
|
|
|
2009-09-24 20:29:51 +00:00
|
|
|
if (ast_test_flag(&opts, OPT_CALLEE_TRANSFER))
|
|
|
|
ast_set_flag(&(bconfig.features_callee), AST_FEATURE_REDIRECT);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLER_TRANSFER))
|
|
|
|
ast_set_flag(&(bconfig.features_caller), AST_FEATURE_REDIRECT);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLEE_HANGUP))
|
|
|
|
ast_set_flag(&(bconfig.features_callee), AST_FEATURE_DISCONNECT);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLER_HANGUP))
|
|
|
|
ast_set_flag(&(bconfig.features_caller), AST_FEATURE_DISCONNECT);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLEE_MONITOR))
|
|
|
|
ast_set_flag(&(bconfig.features_callee), AST_FEATURE_AUTOMON);
|
2011-02-04 16:55:39 +00:00
|
|
|
if (ast_test_flag(&opts, OPT_CALLER_MONITOR))
|
2009-09-24 20:29:51 +00:00
|
|
|
ast_set_flag(&(bconfig.features_caller), AST_FEATURE_AUTOMON);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLEE_PARK))
|
|
|
|
ast_set_flag(&(bconfig.features_callee), AST_FEATURE_PARKCALL);
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLER_PARK))
|
|
|
|
ast_set_flag(&(bconfig.features_caller), AST_FEATURE_PARKCALL);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/* Setup after bridge goto location. */
|
|
|
|
if (ast_test_flag(&opts, OPT_CALLEE_GO_ON)) {
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
context = ast_strdupa(ast_channel_context(chan));
|
|
|
|
extension = ast_strdupa(ast_channel_exten(chan));
|
|
|
|
priority = ast_channel_priority(chan);
|
|
|
|
ast_channel_unlock(chan);
|
2013-07-25 02:20:23 +00:00
|
|
|
ast_bridge_set_after_go_on(current_dest_chan, context, extension, priority,
|
2013-05-21 18:00:22 +00:00
|
|
|
opt_args[OPT_ARG_CALLEE_GO_ON]);
|
|
|
|
} else if (!ast_test_flag(&opts, OPT_CALLEE_KILL)) {
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_channel_lock(current_dest_chan);
|
|
|
|
context = ast_strdupa(ast_channel_context(current_dest_chan));
|
|
|
|
extension = ast_strdupa(ast_channel_exten(current_dest_chan));
|
|
|
|
priority = ast_channel_priority(current_dest_chan);
|
|
|
|
ast_channel_unlock(current_dest_chan);
|
2013-07-25 02:20:23 +00:00
|
|
|
ast_bridge_set_after_goto(current_dest_chan, context, extension, priority);
|
2013-05-28 14:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_bridge_features_init(&chan_features)) {
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
goto done;
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
2013-05-28 14:45:31 +00:00
|
|
|
peer_features = ast_bridge_features_new();
|
|
|
|
if (!peer_features) {
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pre_bridge_setup(chan, current_dest_chan, &bconfig, &chan_features, peer_features)) {
|
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
bridge = ast_bridge_basic_new();
|
|
|
|
if (!bridge) {
|
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2013-06-25 22:28:22 +00:00
|
|
|
xfer_cfg = ast_get_chan_features_xfer_config(current_dest_chan);
|
2013-06-26 01:39:04 +00:00
|
|
|
if (ast_bridge_add_channel(bridge, current_dest_chan, peer_features,
|
|
|
|
ast_test_flag(&opts, BRIDGE_OPT_PLAYTONE), xfer_cfg ? xfer_cfg->xfersound : NULL)) {
|
2013-05-28 14:45:31 +00:00
|
|
|
ast_bridge_features_destroy(peer_features);
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
ast_bridge_destroy(bridge);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 1);
|
|
|
|
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
2012-06-23 00:29:18 +00:00
|
|
|
/* The bridge has ended, set BRIDGERESULT to SUCCESS. */
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
|
2009-09-24 20:29:51 +00:00
|
|
|
done:
|
2012-06-23 00:29:18 +00:00
|
|
|
ast_free((char *) bconfig.warning_sound);
|
|
|
|
ast_free((char *) bconfig.end_sound);
|
|
|
|
ast_free((char *) bconfig.start_sound);
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
#if defined(TEST_FRAMEWORK)
|
|
|
|
static int fake_fixup(struct ast_channel *clonechan, struct ast_channel *original)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* defined(TEST_FRAMEWORK) */
|
|
|
|
|
|
|
|
#if defined(TEST_FRAMEWORK)
|
|
|
|
static struct ast_channel *create_test_channel(const struct ast_channel_tech *fake_tech)
|
|
|
|
{
|
|
|
|
struct ast_channel *test_channel1;
|
|
|
|
struct ast_format tmp_fmt;
|
|
|
|
|
|
|
|
if (!(test_channel1 = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, 0, 0, "TestChannel1"))) {
|
|
|
|
ast_log(LOG_WARNING, "Whoa, test channel creation failed.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* normally this is done in the channel driver */
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_format_cap_add(ast_channel_nativeformats(test_channel1), ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2012-02-24 00:32:20 +00:00
|
|
|
ast_format_set(ast_channel_writeformat(test_channel1), AST_FORMAT_GSM, 0);
|
|
|
|
ast_format_set(ast_channel_rawwriteformat(test_channel1), AST_FORMAT_GSM, 0);
|
|
|
|
ast_format_set(ast_channel_readformat(test_channel1), AST_FORMAT_GSM, 0);
|
|
|
|
ast_format_set(ast_channel_rawreadformat(test_channel1), AST_FORMAT_GSM, 0);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_tech_set(test_channel1, fake_tech);
|
2011-08-16 17:23:08 +00:00
|
|
|
|
|
|
|
return test_channel1;
|
|
|
|
}
|
|
|
|
#endif /* defined(TEST_FRAMEWORK) */
|
|
|
|
|
2012-10-02 01:47:16 +00:00
|
|
|
/*! \internal \brief Clean up resources on Asterisk shutdown */
|
|
|
|
static void features_shutdown(void)
|
|
|
|
{
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_features_config_shutdown();
|
|
|
|
|
2013-04-26 21:27:24 +00:00
|
|
|
ast_cli_unregister_multiple(cli_features, ARRAY_LEN(cli_features));
|
2012-10-02 01:47:16 +00:00
|
|
|
ast_devstate_prov_del("Park");
|
|
|
|
ast_manager_unregister("Bridge");
|
|
|
|
ast_manager_unregister("Park");
|
2013-05-21 18:00:22 +00:00
|
|
|
|
2012-10-02 01:47:16 +00:00
|
|
|
ast_unregister_application(app_bridge);
|
|
|
|
|
2013-06-28 19:19:15 +00:00
|
|
|
STASIS_MESSAGE_TYPE_CLEANUP(ast_call_pickup_type);
|
2012-10-02 01:47:16 +00:00
|
|
|
pthread_cancel(parking_thread);
|
2013-04-26 21:27:24 +00:00
|
|
|
pthread_kill(parking_thread, SIGURG);
|
|
|
|
pthread_join(parking_thread, NULL);
|
|
|
|
ast_context_destroy(NULL, registrar);
|
2012-10-02 01:47:16 +00:00
|
|
|
ao2_ref(parkinglots, -1);
|
|
|
|
}
|
|
|
|
|
2011-08-16 17:23:08 +00:00
|
|
|
int ast_features_init(void)
|
|
|
|
{
|
|
|
|
int res;
|
Merge changes from team/russell/issue_5841:
This patch adds a "Bridge" Manager action, as well as a "Bridge" dialplan
application. The manager action will allow you to steal two active channels
in the system and bridge them together. Then, the one that did not hang up
will continue in the dialplan. Using the application will bridge the calling
channel to an arbitrary channel in the system. Whichever channel does not
hang up here will continue in the dialplan, as well.
This patch has been touched by a bunch of people over the course of a couple
years. Please forgive me if I have missed your name in the history of things.
The most recent patch came from issue #5841, but there is also a reference to
an earlier version of this patch from issue #4297. The people involved in writing
and/or reviewing the code include at least: twisted, mflorrel, heath1444, davetroy,
tim_ringenbach, moy, tmancill, serge-v, and me. There are also positive test
reports from many people.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-10 20:44:44 +00:00
|
|
|
|
2008-04-21 23:42:45 +00:00
|
|
|
parkinglots = ao2_container_alloc(7, parkinglot_hash_cb, parkinglot_cmp_cb);
|
2011-08-16 17:23:08 +00:00
|
|
|
if (!parkinglots) {
|
|
|
|
return -1;
|
|
|
|
}
|
2005-08-23 02:22:33 +00:00
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
res = ast_features_config_init();
|
2011-08-16 17:23:08 +00:00
|
|
|
if (res) {
|
2005-01-10 04:03:30 +00:00
|
|
|
return res;
|
2011-08-16 17:23:08 +00:00
|
|
|
}
|
2008-12-05 10:31:25 +00:00
|
|
|
ast_cli_register_multiple(cli_features, ARRAY_LEN(cli_features));
|
2012-05-10 18:35:14 +00:00
|
|
|
if (ast_pthread_create(&parking_thread, NULL, do_parking_thread, NULL)) {
|
2013-06-06 21:40:35 +00:00
|
|
|
ast_features_config_shutdown();
|
|
|
|
ast_cli_unregister_multiple(cli_features, ARRAY_LEN(cli_features));
|
2012-05-10 18:35:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2013-06-28 19:19:15 +00:00
|
|
|
STASIS_MESSAGE_TYPE_INIT(ast_call_pickup_type);
|
2013-06-06 21:40:35 +00:00
|
|
|
res |= ast_register_application2(app_bridge, bridge_exec, NULL, NULL, NULL);
|
|
|
|
res |= ast_manager_register_xml_core("Bridge", EVENT_FLAG_CALL, action_bridge);
|
METERMAIDS:
-----------
- Adding devicestate providers, a new architecture to add non-channel related
device state information, like parking lots, queues, meetmes, vending machines
and Windows 98 reboots (lots of blinking on those lights)
- Adding provider for parking lots, so you can subscribe to the status of a
parking lot
- Adding provider for meetme, so you can have a blinking lamp for a meetme
( Example: exten => edvina,hint,meetme:1234 )
- Adding support for directed parking - set the PARKINGEXTEN before you manually
call Park() and you will be parked on that space. If it's occupied, dialplan
execution will continue.
This work was sponsored by Voop A/S - www.voop.com
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@36055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-26 16:43:21 +00:00
|
|
|
|
|
|
|
res |= ast_devstate_prov_add("Park", metermaidstate);
|
|
|
|
|
2013-06-06 21:40:35 +00:00
|
|
|
if (res) {
|
|
|
|
features_shutdown();
|
|
|
|
} else {
|
|
|
|
ast_register_atexit(features_shutdown);
|
|
|
|
}
|
2012-10-02 01:47:16 +00:00
|
|
|
|
2001-12-27 11:07:33 +00:00
|
|
|
return res;
|
|
|
|
}
|