2013-05-21 18:00:22 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Jonathan Rose <jrose@digium.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \brief Call Parking Applications
|
|
|
|
*
|
|
|
|
* \author Jonathan Rose <jrose@digium.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
#include "res_parking.h"
|
|
|
|
#include "asterisk/config.h"
|
|
|
|
#include "asterisk/config_options.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/astobj2.h"
|
|
|
|
#include "asterisk/features.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/app.h"
|
|
|
|
#include "asterisk/say.h"
|
2013-07-25 04:06:32 +00:00
|
|
|
#include "asterisk/bridge_basic.h"
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
#include "asterisk/format_cache.h"
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Park" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Park yourself.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="parking_lot_name">
|
|
|
|
<para>Specify in which parking lot to park a call.</para>
|
|
|
|
<para>The parking lot used is selected in the following order:</para>
|
|
|
|
<para>1) parking_lot_name option to this application</para>
|
|
|
|
<para>2) <variable>PARKINGLOT</variable> variable</para>
|
|
|
|
<para>3) <literal>CHANNEL(parkinglot)</literal> function
|
|
|
|
(Possibly preset by the channel driver.)</para>
|
|
|
|
<para>4) Default parking lot.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<para>A list of options for this parked call.</para>
|
|
|
|
<optionlist>
|
|
|
|
<option name="r">
|
|
|
|
<para>Send ringing instead of MOH to the parked call.</para>
|
|
|
|
</option>
|
|
|
|
<option name="R">
|
|
|
|
<para>Randomize the selection of a parking space.</para>
|
|
|
|
</option>
|
|
|
|
<option name="s">
|
|
|
|
<para>Silence announcement of the parking space number.</para>
|
|
|
|
</option>
|
|
|
|
<option name="c" argsep=",">
|
|
|
|
<argument name="context" required="false" />
|
|
|
|
<argument name="extension" required="false" />
|
|
|
|
<argument name="priority" required="true" />
|
|
|
|
<para>If the parking times out, go to this place in the dialplan
|
|
|
|
instead of where the parking lot defines the call should go.
|
|
|
|
</para>
|
|
|
|
</option>
|
|
|
|
<option name="t">
|
|
|
|
<argument name="duration" required="true" />
|
|
|
|
<para>Use a timeout of <literal>duration</literal> seconds instead
|
|
|
|
of the timeout specified by the parking lot.</para>
|
|
|
|
</option>
|
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Used to park yourself (typically in combination with an attended
|
|
|
|
transfer to know the parking space).</para>
|
|
|
|
<para>If you set the <variable>PARKINGEXTEN</variable> variable to a
|
|
|
|
parking space extension in the parking lot, Park() will attempt to park the
|
|
|
|
call on that extension. If the extension is already in use then execution
|
|
|
|
will continue at the next priority.
|
|
|
|
</para>
|
2014-12-15 13:23:53 +02:00
|
|
|
<para>If the <literal>parkeddynamic</literal> option is enabled in
|
|
|
|
<filename>res_parking.conf</filename> the following variables can be
|
|
|
|
used to dynamically create new parking lots. When using dynamic parking
|
|
|
|
lots, be aware of the conditions as explained in the notes section
|
|
|
|
below.
|
|
|
|
</para>
|
|
|
|
<para>The <variable>PARKINGDYNAMIC</variable> variable specifies the
|
|
|
|
parking lot to use as a template to create a dynamic parking lot. It
|
|
|
|
is an error to specify a non-existent parking lot for the template.
|
|
|
|
If not set then the default parking lot is used as the template.
|
|
|
|
</para>
|
|
|
|
<para>The <variable>PARKINGDYNCONTEXT</variable> variable specifies the
|
|
|
|
dialplan context to use for the newly created dynamic parking lot. If
|
|
|
|
not set then the context from the parking lot template is used. The
|
|
|
|
context is created if it does not already exist and the new parking lot
|
|
|
|
needs to create extensions.
|
|
|
|
</para>
|
|
|
|
<para>The <variable>PARKINGDYNEXTEN</variable> variable specifies the
|
|
|
|
<literal>parkext</literal> to use for the newly created dynamic
|
|
|
|
parking lot. If not set then the <literal>parkext</literal> is used from
|
|
|
|
the parking lot template. If the template does not specify a
|
|
|
|
<literal>parkext</literal> then no extensions are created for the newly
|
|
|
|
created parking lot. The dynamic parking lot cannot be created if it
|
|
|
|
needs to create extensions that overlap existing parking lot extensions.
|
|
|
|
The only exception to this is for the <literal>parkext</literal>
|
|
|
|
extension and only if neither of the overlaping parking lot's
|
|
|
|
<literal>parkext</literal> is exclusive.
|
|
|
|
</para>
|
|
|
|
<para>The <variable>PARKINGDYNPOS</variable> variable specifies the
|
|
|
|
parking positions to use for the newly created dynamic parking lot. If
|
|
|
|
not set then the <literal>parkpos</literal> from the parking lot template
|
|
|
|
is used.
|
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>This application must be used as the first extension priority
|
|
|
|
to be recognized as a parking access extension for blind transfers.
|
|
|
|
Blind transfers and the DTMF one-touch parking feature need this
|
|
|
|
distinction to operate properly. The parking access extension in
|
|
|
|
this case is treated like a dialplan hint.
|
|
|
|
</para>
|
|
|
|
</note>
|
2013-05-21 18:00:22 +00:00
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">ParkedCall</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
|
|
|
|
<application name="ParkedCall" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Retrieve a parked call.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="parking_lot_name">
|
|
|
|
<para>Specify from which parking lot to retrieve a parked call.</para>
|
|
|
|
<para>The parking lot used is selected in the following order:</para>
|
|
|
|
<para>1) parking_lot_name option</para>
|
|
|
|
<para>2) <variable>PARKINGLOT</variable> variable</para>
|
|
|
|
<para>3) <literal>CHANNEL(parkinglot)</literal> function
|
|
|
|
(Possibly preset by the channel driver.)</para>
|
|
|
|
<para>4) Default parking lot.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="parking_space">
|
|
|
|
<para>Parking space to retrieve a parked call from.
|
|
|
|
If not provided then the first available parked call in the
|
|
|
|
parking lot will be retrieved.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Used to retrieve a parked call from a parking lot.</para>
|
|
|
|
<note>
|
|
|
|
<para>If a parking lot's parkext option is set, then Parking lots
|
|
|
|
will automatically create and manage dialplan extensions in
|
|
|
|
the parking lot context. If that is the case then you will not
|
|
|
|
need to manage parking extensions yourself, just include the
|
|
|
|
parking context of the parking lot.</para>
|
|
|
|
</note>
|
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">Park</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
|
|
|
|
<application name="ParkAndAnnounce" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Park and Announce.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="parking_lot_name">
|
|
|
|
<para>Specify in which parking lot to park a call.</para>
|
|
|
|
<para>The parking lot used is selected in the following order:</para>
|
|
|
|
<para>1) parking_lot_name option to this application</para>
|
|
|
|
<para>2) <variable>PARKINGLOT</variable> variable</para>
|
|
|
|
<para>3) <literal>CHANNEL(parkinglot)</literal> function
|
|
|
|
(Possibly preset by the channel driver.)</para>
|
|
|
|
<para>4) Default parking lot.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<para>A list of options for this parked call.</para>
|
|
|
|
<optionlist>
|
|
|
|
<option name="r">
|
|
|
|
<para>Send ringing instead of MOH to the parked call.</para>
|
|
|
|
</option>
|
|
|
|
<option name="R">
|
|
|
|
<para>Randomize the selection of a parking space.</para>
|
|
|
|
</option>
|
|
|
|
<option name="c" argsep=",">
|
|
|
|
<argument name="context" required="false" />
|
|
|
|
<argument name="extension" required="false" />
|
|
|
|
<argument name="priority" required="true" />
|
|
|
|
<para>If the parking times out, go to this place in the dialplan
|
|
|
|
instead of where the parking lot defines the call should go.
|
|
|
|
</para>
|
|
|
|
</option>
|
|
|
|
<option name="t">
|
|
|
|
<argument name="duration" required="true" />
|
|
|
|
<para>Use a timeout of <literal>duration</literal> seconds instead
|
|
|
|
of the timeout specified by the parking lot.</para>
|
|
|
|
</option>
|
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="announce_template" required="true" argsep=":">
|
|
|
|
<argument name="announce" required="true">
|
|
|
|
<para>Colon-separated list of files to announce. The word
|
|
|
|
<literal>PARKED</literal> will be replaced by a say_digits of the extension in which
|
|
|
|
the call is parked.</para>
|
|
|
|
</argument>
|
|
|
|
<argument name="announce1" multiple="true" />
|
|
|
|
</parameter>
|
|
|
|
<parameter name="dial" required="true">
|
|
|
|
<para>The app_dial style resource to call to make the
|
|
|
|
announcement. Console/dsp calls the console.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Park a call into the parkinglot and announce the call to another channel.</para>
|
|
|
|
<para>The variable <variable>PARKEDAT</variable> will contain the parking extension
|
|
|
|
into which the call was placed. Use with the Local channel to allow the dialplan to make
|
|
|
|
use of this information.</para>
|
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">Park</ref>
|
|
|
|
<ref type="application">ParkedCall</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
***/
|
|
|
|
|
2013-08-17 15:01:54 +00:00
|
|
|
#define PARK_AND_ANNOUNCE_APPLICATION "ParkAndAnnounce"
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/* Park a call */
|
|
|
|
|
|
|
|
enum park_args {
|
|
|
|
OPT_ARG_COMEBACK,
|
|
|
|
OPT_ARG_TIMEOUT,
|
|
|
|
OPT_ARG_ARRAY_SIZE /* Always the last element of the enum */
|
|
|
|
};
|
|
|
|
|
|
|
|
enum park_flags {
|
|
|
|
MUXFLAG_RINGING = (1 << 0),
|
|
|
|
MUXFLAG_RANDOMIZE = (1 << 1),
|
|
|
|
MUXFLAG_NOANNOUNCE = (1 << 2),
|
|
|
|
MUXFLAG_COMEBACK_OVERRIDE = (1 << 3),
|
|
|
|
MUXFLAG_TIMEOUT_OVERRIDE = (1 << 4),
|
|
|
|
};
|
|
|
|
|
|
|
|
AST_APP_OPTIONS(park_opts, {
|
|
|
|
AST_APP_OPTION('r', MUXFLAG_RINGING),
|
|
|
|
AST_APP_OPTION('R', MUXFLAG_RANDOMIZE),
|
|
|
|
AST_APP_OPTION('s', MUXFLAG_NOANNOUNCE),
|
|
|
|
AST_APP_OPTION_ARG('c', MUXFLAG_COMEBACK_OVERRIDE, OPT_ARG_COMEBACK),
|
|
|
|
AST_APP_OPTION_ARG('t', MUXFLAG_TIMEOUT_OVERRIDE, OPT_ARG_TIMEOUT),
|
|
|
|
});
|
|
|
|
|
|
|
|
static int apply_option_timeout (int *var, char *timeout_arg)
|
|
|
|
{
|
|
|
|
if (ast_strlen_zero(timeout_arg)) {
|
|
|
|
ast_log(LOG_ERROR, "No duration value provided for the timeout ('t') option.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sscanf(timeout_arg, "%d", var) != 1 || *var < 0) {
|
|
|
|
ast_log(LOG_ERROR, "Duration value provided for timeout ('t') option must be 0 or greater.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int park_app_parse_data(const char *data, int *disable_announce, int *use_ringing, int *randomize, int *time_limit, char **comeback_override, char **lot_name)
|
|
|
|
{
|
|
|
|
char *parse;
|
|
|
|
struct ast_flags flags = { 0 };
|
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(lot_name);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
AST_APP_ARG(other); /* Any remaining unused arguments */
|
|
|
|
);
|
|
|
|
|
|
|
|
parse = ast_strdupa(data);
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
|
|
|
|
if (args.options) {
|
|
|
|
char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
|
|
|
|
ast_app_parse_options(park_opts, &flags, opts, args.options);
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_TIMEOUT_OVERRIDE)) {
|
|
|
|
if (apply_option_timeout(time_limit, opts[OPT_ARG_TIMEOUT])) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_COMEBACK_OVERRIDE)) {
|
|
|
|
*comeback_override = ast_strdup(opts[OPT_ARG_COMEBACK]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_NOANNOUNCE)) {
|
|
|
|
if (disable_announce) {
|
|
|
|
*disable_announce = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_RINGING)) {
|
|
|
|
*use_ringing = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_RANDOMIZE)) {
|
|
|
|
*randomize = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(args.lot_name)) {
|
|
|
|
*lot_name = ast_strdup(args.lot_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
void park_common_datastore_free(struct park_common_datastore *datastore)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
2013-07-04 18:46:56 +00:00
|
|
|
if (!datastore) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_free(datastore->parker_uuid);
|
2013-07-04 18:46:56 +00:00
|
|
|
ast_free(datastore->parker_dial_string);
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_free(datastore->comeback_override);
|
|
|
|
ast_free(datastore);
|
|
|
|
}
|
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
static void park_common_datastore_destroy(void *data)
|
|
|
|
{
|
|
|
|
struct park_common_datastore *datastore = data;
|
|
|
|
park_common_datastore_free(datastore);
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
static const struct ast_datastore_info park_common_info = {
|
|
|
|
.type = "park entry data",
|
|
|
|
.destroy = park_common_datastore_destroy,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void wipe_park_common_datastore(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
datastore = ast_channel_datastore_find(chan, &park_common_info, NULL);
|
|
|
|
if (datastore) {
|
|
|
|
ast_channel_datastore_remove(chan, datastore);
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int setup_park_common_datastore(struct ast_channel *parkee, const char *parker_uuid, const char *comeback_override, int randomize, int time_limit, int silence_announce)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore = NULL;
|
|
|
|
struct park_common_datastore *park_datastore;
|
2013-07-04 18:46:56 +00:00
|
|
|
const char *attended_transfer;
|
|
|
|
const char *blind_transfer;
|
|
|
|
char *parker_dial_string = NULL;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
wipe_park_common_datastore(parkee);
|
|
|
|
|
|
|
|
if (!(datastore = ast_datastore_alloc(&park_common_info, NULL))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(park_datastore = ast_calloc(1, sizeof(*park_datastore)))) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return -1;
|
|
|
|
}
|
2016-03-18 14:01:02 -05:00
|
|
|
datastore->data = park_datastore;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
2016-03-18 14:01:02 -05:00
|
|
|
park_datastore->parker_uuid = ast_strdup(parker_uuid);
|
|
|
|
if (!park_datastore->parker_uuid) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return -1;
|
2013-07-04 18:46:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ast_channel_lock(parkee);
|
|
|
|
attended_transfer = pbx_builtin_getvar_helper(parkee, "ATTENDEDTRANSFER");
|
|
|
|
blind_transfer = pbx_builtin_getvar_helper(parkee, "BLINDTRANSFER");
|
2015-07-14 14:36:42 -05:00
|
|
|
if (!ast_strlen_zero(attended_transfer)) {
|
|
|
|
parker_dial_string = ast_strdupa(attended_transfer);
|
|
|
|
} else if (!ast_strlen_zero(blind_transfer)) {
|
|
|
|
parker_dial_string = ast_strdupa(blind_transfer);
|
|
|
|
/* Ensure that attended_transfer is NULL and not an empty string. */
|
|
|
|
attended_transfer = NULL;
|
2013-07-04 18:46:56 +00:00
|
|
|
}
|
|
|
|
ast_channel_unlock(parkee);
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(parker_dial_string)) {
|
|
|
|
ast_channel_name_to_dial_string(parker_dial_string);
|
2015-07-14 14:29:07 -05:00
|
|
|
ast_verb(4, "Setting Parker dial string to %s from %s value\n",
|
|
|
|
parker_dial_string,
|
|
|
|
attended_transfer ? "ATTENDEDTRANSFER" : "BLINDTRANSFER");
|
2013-07-04 18:46:56 +00:00
|
|
|
park_datastore->parker_dial_string = ast_strdup(parker_dial_string);
|
2016-03-18 14:01:02 -05:00
|
|
|
if (!park_datastore->parker_dial_string) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return -1;
|
|
|
|
}
|
2013-07-04 18:46:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
park_datastore->randomize = randomize;
|
|
|
|
park_datastore->time_limit = time_limit;
|
|
|
|
park_datastore->silence_announce = silence_announce;
|
|
|
|
|
|
|
|
if (comeback_override) {
|
|
|
|
park_datastore->comeback_override = ast_strdup(comeback_override);
|
2016-03-18 14:01:02 -05:00
|
|
|
if (!park_datastore->comeback_override) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return -1;
|
|
|
|
}
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ast_channel_lock(parkee);
|
|
|
|
ast_channel_datastore_add(parkee, datastore);
|
|
|
|
ast_channel_unlock(parkee);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
struct park_common_datastore *get_park_common_datastore_copy(struct ast_channel *parkee)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
struct ast_datastore *datastore;
|
|
|
|
struct park_common_datastore *data;
|
2013-07-04 18:46:56 +00:00
|
|
|
struct park_common_datastore *data_copy;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
SCOPED_CHANNELLOCK(lock, parkee);
|
2016-03-18 14:01:02 -05:00
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
if (!(datastore = ast_channel_datastore_find(parkee, &park_common_info, NULL))) {
|
2013-07-04 18:46:56 +00:00
|
|
|
return NULL;
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data = datastore->data;
|
|
|
|
|
2016-03-18 14:01:02 -05:00
|
|
|
/* This data should always be populated if this datastore was appended to the channel */
|
|
|
|
ast_assert(data != NULL);
|
2013-05-21 18:00:22 +00:00
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
data_copy = ast_calloc(1, sizeof(*data_copy));
|
|
|
|
if (!data_copy) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-18 14:01:02 -05:00
|
|
|
data_copy->parker_uuid = ast_strdup(data->parker_uuid);
|
|
|
|
if (!data_copy->parker_uuid) {
|
2013-07-04 18:46:56 +00:00
|
|
|
park_common_datastore_free(data_copy);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
data_copy->randomize = data->randomize;
|
|
|
|
data_copy->time_limit = data->time_limit;
|
|
|
|
data_copy->silence_announce = data->silence_announce;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
if (data->comeback_override) {
|
2013-07-04 18:46:56 +00:00
|
|
|
data_copy->comeback_override = ast_strdup(data->comeback_override);
|
|
|
|
if (!data_copy->comeback_override) {
|
|
|
|
park_common_datastore_free(data_copy);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
if (data->parker_dial_string) {
|
|
|
|
data_copy->parker_dial_string = ast_strdup(data->parker_dial_string);
|
|
|
|
if (!data_copy->parker_dial_string) {
|
|
|
|
park_common_datastore_free(data_copy);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data_copy;
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 22:28:22 +00:00
|
|
|
struct ast_bridge *park_common_setup(struct ast_channel *parkee, struct ast_channel *parker,
|
|
|
|
const char *lot_name, const char *comeback_override,
|
|
|
|
int use_ringing, int randomize, int time_limit, int silence_announcements)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
struct ast_bridge *parking_bridge;
|
|
|
|
RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
|
|
|
|
|
2013-07-04 18:46:56 +00:00
|
|
|
if (!parker) {
|
|
|
|
parker = parkee;
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/* If the name of the parking lot isn't specified in the arguments, find it based on the channel. */
|
|
|
|
if (ast_strlen_zero(lot_name)) {
|
|
|
|
ast_channel_lock(parker);
|
|
|
|
lot_name = ast_strdupa(find_channel_parking_lot_name(parker));
|
|
|
|
ast_channel_unlock(parker);
|
|
|
|
}
|
|
|
|
|
|
|
|
lot = parking_lot_find_by_name(lot_name);
|
2013-06-28 19:22:16 +00:00
|
|
|
if (!lot) {
|
2016-03-25 23:19:22 -05:00
|
|
|
lot = parking_create_dynamic_lot(lot_name, parker);
|
2013-06-28 19:22:16 +00:00
|
|
|
}
|
2013-05-21 18:00:22 +00:00
|
|
|
if (!lot) {
|
|
|
|
ast_log(LOG_ERROR, "Could not find parking lot: '%s'\n", lot_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_lock(lot);
|
|
|
|
parking_bridge = parking_lot_get_bridge(lot);
|
|
|
|
ao2_unlock(lot);
|
|
|
|
|
2013-06-25 22:28:22 +00:00
|
|
|
if (!parking_bridge) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apply relevant bridge roles and such to the parking channel */
|
|
|
|
parking_channel_set_roles(parkee, lot, use_ringing);
|
|
|
|
setup_park_common_datastore(parkee, ast_channel_uniqueid(parker), comeback_override, randomize, time_limit,
|
|
|
|
silence_announcements);
|
|
|
|
return parking_bridge;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ast_bridge *park_application_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *app_data,
|
|
|
|
int *silence_announcements)
|
|
|
|
{
|
|
|
|
int use_ringing = 0;
|
|
|
|
int randomize = 0;
|
|
|
|
int time_limit = -1;
|
|
|
|
|
|
|
|
RAII_VAR(char *, comeback_override, NULL, ast_free);
|
|
|
|
RAII_VAR(char *, lot_name_app_arg, NULL, ast_free);
|
|
|
|
|
|
|
|
if (app_data) {
|
|
|
|
park_app_parse_data(app_data, silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name_app_arg);
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-25 22:28:22 +00:00
|
|
|
return park_common_setup(parkee, parker, lot_name_app_arg, comeback_override, use_ringing,
|
|
|
|
randomize, time_limit, silence_announcements ? *silence_announcements : 0);
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 15:01:54 +00:00
|
|
|
static int park_app_exec(struct ast_channel *chan, const char *data)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
|
|
|
|
|
|
|
|
struct ast_bridge_features chan_features;
|
|
|
|
int res;
|
|
|
|
int silence_announcements = 0;
|
2016-03-18 14:01:02 -05:00
|
|
|
int blind_transfer;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
2013-06-28 19:22:16 +00:00
|
|
|
/* Answer the channel if needed */
|
|
|
|
if (ast_channel_state(chan) != AST_STATE_UP) {
|
|
|
|
ast_answer(chan);
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_channel_lock(chan);
|
2016-03-18 14:01:02 -05:00
|
|
|
blind_transfer = !ast_strlen_zero(pbx_builtin_getvar_helper(chan, "BLINDTRANSFER"));
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
/* Handle the common parking setup stuff */
|
2013-07-04 18:46:56 +00:00
|
|
|
if (!(parking_bridge = park_application_setup(chan, NULL, data, &silence_announcements))) {
|
2016-03-18 14:01:02 -05:00
|
|
|
if (!silence_announcements && !blind_transfer) {
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_stream_and_wait(chan, "pbx-parkingfailed", "");
|
|
|
|
}
|
2014-05-22 15:52:30 +00:00
|
|
|
publish_parked_call_failure(chan);
|
2013-05-21 18:00:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize bridge features for the channel. */
|
|
|
|
res = ast_bridge_features_init(&chan_features);
|
|
|
|
if (res) {
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
2014-05-22 15:52:30 +00:00
|
|
|
publish_parked_call_failure(chan);
|
2013-05-21 18:00:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now for the fun part... park it! */
|
|
|
|
ast_bridge_join(parking_bridge, chan, NULL, &chan_features, NULL, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 only happen with AST_SOFTHANGUP_ASYNCGOTO.
|
|
|
|
*/
|
|
|
|
res = -1;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Retrieve a parked call */
|
|
|
|
|
2013-08-17 15:01:54 +00:00
|
|
|
static int parked_call_app_exec(struct ast_channel *chan, const char *data)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
RAII_VAR(struct parking_lot *, lot, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup); /* Parked user being retrieved */
|
|
|
|
struct ast_bridge *retrieval_bridge;
|
|
|
|
int res;
|
|
|
|
int target_space = -1;
|
|
|
|
struct ast_bridge_features chan_features;
|
|
|
|
char *parse;
|
2016-03-23 14:24:49 -05:00
|
|
|
const char *lot_name;
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(lot_name);
|
|
|
|
AST_APP_ARG(parking_space);
|
|
|
|
AST_APP_ARG(other); /* Any remaining unused arguments */
|
|
|
|
);
|
|
|
|
|
|
|
|
parse = ast_strdupa(data);
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
|
|
|
|
/* Answer the channel if needed */
|
|
|
|
if (ast_channel_state(chan) != AST_STATE_UP) {
|
|
|
|
ast_answer(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
lot_name = args.lot_name;
|
|
|
|
|
|
|
|
/* If the name of the parking lot isn't in the arguments, find it based on the channel. */
|
|
|
|
if (ast_strlen_zero(lot_name)) {
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
lot_name = ast_strdupa(find_channel_parking_lot_name(chan));
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
lot = parking_lot_find_by_name(lot_name);
|
|
|
|
if (!lot) {
|
|
|
|
ast_log(LOG_ERROR, "Could not find the requested parking lot\n");
|
|
|
|
ast_stream_and_wait(chan, "pbx-invalidpark", "");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(args.parking_space)) {
|
|
|
|
if (sscanf(args.parking_space, "%d", &target_space) != 1 || target_space < 0) {
|
|
|
|
ast_stream_and_wait(chan, "pbx-invalidpark", "");
|
|
|
|
ast_log(LOG_ERROR, "value '%s' for parking_space argument is invalid. Must be an integer greater than 0.\n", args.parking_space);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to get the parked user from the parking lot */
|
|
|
|
pu = parking_lot_retrieve_parked_user(lot, target_space);
|
|
|
|
if (!pu) {
|
|
|
|
ast_stream_and_wait(chan, "pbx-invalidpark", "");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The parked call needs to know who is retrieving it before we move it out of the parking bridge */
|
2015-01-23 15:21:56 +00:00
|
|
|
ast_assert(pu->retriever == NULL);
|
2013-05-21 18:00:22 +00:00
|
|
|
pu->retriever = ast_channel_snapshot_create(chan);
|
|
|
|
|
|
|
|
/* Create bridge */
|
|
|
|
retrieval_bridge = ast_bridge_basic_new();
|
|
|
|
if (!retrieval_bridge) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move the parkee into the new bridge */
|
|
|
|
if (ast_bridge_move(retrieval_bridge, lot->parking_bridge, pu->chan, NULL, 0)) {
|
2013-08-22 21:09:52 +00:00
|
|
|
ast_bridge_destroy(retrieval_bridge, 0);
|
2013-05-21 18:00:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize our bridge features */
|
|
|
|
res = ast_bridge_features_init(&chan_features);
|
|
|
|
if (res) {
|
2013-08-22 21:09:52 +00:00
|
|
|
ast_bridge_destroy(retrieval_bridge, 0);
|
2013-05-21 18:00:22 +00:00
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the features */
|
|
|
|
parked_call_retrieve_enable_features(chan, lot, AST_FEATURE_FLAG_BYCALLER);
|
|
|
|
|
|
|
|
/* If the parkedplay option is set for the caller to hear, play that tone now. */
|
|
|
|
if (lot->cfg->parkedplay & AST_FEATURE_FLAG_BYCALLER) {
|
|
|
|
ast_stream_and_wait(chan, lot->cfg->courtesytone, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now we should try to join the new bridge ourselves... */
|
2013-09-13 22:19:23 +00:00
|
|
|
ast_bridge_join(retrieval_bridge, chan, NULL, &chan_features, NULL,
|
|
|
|
AST_BRIDGE_JOIN_PASS_REFERENCE);
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
|
2015-04-06 14:51:21 +00:00
|
|
|
/* Return -1 so that call does not continue in the dialplan. This is to make
|
|
|
|
* behavior consistent with Asterisk versions prior to 12.
|
|
|
|
*/
|
|
|
|
return -1;
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct park_announce_subscription_data {
|
|
|
|
char *parkee_uuid;
|
|
|
|
char *dial_string;
|
|
|
|
char *announce_string;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void park_announce_subscription_data_destroy(void *data)
|
|
|
|
{
|
|
|
|
struct park_announce_subscription_data *pa_data = data;
|
|
|
|
ast_free(pa_data->parkee_uuid);
|
|
|
|
ast_free(pa_data->dial_string);
|
|
|
|
ast_free(pa_data->announce_string);
|
|
|
|
ast_free(pa_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct park_announce_subscription_data *park_announce_subscription_data_create(const char *parkee_uuid,
|
|
|
|
const char *dial_string,
|
|
|
|
const char *announce_string)
|
|
|
|
{
|
|
|
|
struct park_announce_subscription_data *pa_data;
|
|
|
|
|
|
|
|
if (!(pa_data = ast_calloc(1, sizeof(*pa_data)))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pa_data->parkee_uuid = ast_strdup(parkee_uuid))
|
|
|
|
|| !(pa_data->dial_string = ast_strdup(dial_string))
|
|
|
|
|| !(pa_data->announce_string = ast_strdup(announce_string))) {
|
|
|
|
park_announce_subscription_data_destroy(pa_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pa_data;
|
|
|
|
}
|
|
|
|
|
2015-09-03 14:07:35 -05:00
|
|
|
/*! \internal
|
|
|
|
* \brief Gathers inheritable channel variables from a channel by name.
|
|
|
|
*
|
|
|
|
* \param oh outgoing helper struct we are bestowing inheritable variables to
|
|
|
|
* \param channel_id name or uniqueID of the channel to inherit variables from
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void inherit_channel_vars_from_id(struct outgoing_helper *oh, const char *channel_id)
|
|
|
|
{
|
|
|
|
struct ast_channel *chan = ast_channel_get_by_name(channel_id);
|
|
|
|
struct ast_var_t *current;
|
|
|
|
struct ast_variable *newvar;
|
|
|
|
const char *varname;
|
|
|
|
int vartype;
|
|
|
|
|
|
|
|
|
|
|
|
if (!chan) {
|
|
|
|
/* Already gone */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
|
|
|
AST_LIST_TRAVERSE(ast_channel_varshead((struct ast_channel *) chan), current, entries) {
|
|
|
|
varname = ast_var_full_name(current);
|
|
|
|
if (!varname) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
vartype = 0;
|
|
|
|
if (varname[0] == '_') {
|
|
|
|
vartype = 1;
|
|
|
|
if (varname[1] == '_') {
|
|
|
|
vartype = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (vartype) {
|
|
|
|
case 1:
|
|
|
|
newvar = ast_variable_new(&varname[1], ast_var_value(current), "");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
newvar = ast_variable_new(varname, ast_var_value(current), "");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (newvar) {
|
|
|
|
ast_debug(1, "Inheriting variable %s from %s.\n",
|
|
|
|
newvar->name, ast_channel_name(chan));
|
|
|
|
if (oh->vars) {
|
|
|
|
newvar->next = oh->vars;
|
|
|
|
oh->vars = newvar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
ast_channel_cleanup(chan);
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
static void announce_to_dial(char *dial_string, char *announce_string, int parkingspace, struct ast_channel_snapshot *parkee_snapshot)
|
|
|
|
{
|
|
|
|
struct ast_channel *dchan;
|
|
|
|
struct outgoing_helper oh = { 0, };
|
|
|
|
int outstate;
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
struct ast_format_cap *cap_slin = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
|
2013-05-21 18:00:22 +00:00
|
|
|
char buf[13];
|
|
|
|
char *dial_tech;
|
|
|
|
char *cur_announce;
|
|
|
|
|
|
|
|
dial_tech = strsep(&dial_string, "/");
|
|
|
|
ast_verb(3, "Dial Tech,String: (%s,%s)\n", dial_tech, dial_string);
|
|
|
|
|
|
|
|
if (!cap_slin) {
|
|
|
|
ast_log(LOG_WARNING, "PARK: Failed to announce park.\n");
|
|
|
|
goto announce_cleanup;
|
|
|
|
}
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
ast_format_cap_append(cap_slin, ast_format_slin, 0);
|
2013-05-21 18:00:22 +00:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", parkingspace);
|
|
|
|
oh.vars = ast_variable_new("_PARKEDAT", buf, "");
|
2015-09-03 14:07:35 -05:00
|
|
|
|
2018-11-07 13:18:34 -04:00
|
|
|
inherit_channel_vars_from_id(&oh, parkee_snapshot->base->uniqueid);
|
2015-09-03 14:07:35 -05:00
|
|
|
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
dchan = __ast_request_and_dial(dial_tech, cap_slin, NULL, NULL, dial_string, 30000,
|
2013-05-21 18:00:22 +00:00
|
|
|
&outstate,
|
2018-11-07 13:18:34 -04:00
|
|
|
parkee_snapshot->caller->number,
|
|
|
|
parkee_snapshot->caller->name,
|
2013-05-21 18:00:22 +00:00
|
|
|
&oh);
|
|
|
|
|
|
|
|
ast_variables_destroy(oh.vars);
|
|
|
|
if (!dchan) {
|
|
|
|
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
|
|
|
|
goto announce_cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_verb(4, "Announce Template: %s\n", announce_string);
|
|
|
|
|
|
|
|
for (cur_announce = strsep(&announce_string, ":"); cur_announce; cur_announce = strsep(&announce_string, ":")) {
|
|
|
|
ast_verb(4, "Announce:%s\n", cur_announce);
|
|
|
|
if (!strcmp(cur_announce, "PARKED")) {
|
|
|
|
ast_say_digits(dchan, parkingspace, "", ast_channel_language(dchan));
|
|
|
|
} else {
|
|
|
|
int dres = ast_streamfile(dchan, cur_announce, ast_channel_language(dchan));
|
|
|
|
if (!dres) {
|
|
|
|
dres = ast_waitstream(dchan, "");
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", cur_announce, ast_channel_name(dchan));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_stopstream(dchan);
|
|
|
|
ast_hangup(dchan);
|
|
|
|
|
|
|
|
announce_cleanup:
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
ao2_cleanup(cap_slin);
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
Multiple revisions 399887,400138,400178,400180-400181
........
r399887 | dlee | 2013-09-26 10:41:47 -0500 (Thu, 26 Sep 2013) | 1 line
Minor performance bump by not allocate manager variable struct if we don't need it
........
r400138 | dlee | 2013-09-30 10:24:00 -0500 (Mon, 30 Sep 2013) | 23 lines
Stasis performance improvements
This patch addresses several performance problems that were found in
the initial performance testing of Asterisk 12.
The Stasis dispatch object was allocated as an AO2 object, even though
it has a very confined lifecycle. This was replaced with a straight
ast_malloc().
The Stasis message router was spending an inordinate amount of time
searching hash tables. In this case, most of our routers had 6 or
fewer routes in them to begin with. This was replaced with an array
that's searched linearly for the route.
We more heavily rely on AO2 objects in Asterisk 12, and the memset()
in ao2_ref() actually became noticeable on the profile. This was
#ifdef'ed to only run when AO2_DEBUG was enabled.
After being misled by an erroneous comment in taskprocessor.c during
profiling, the wrong comment was removed.
Review: https://reviewboard.asterisk.org/r/2873/
........
r400178 | dlee | 2013-09-30 13:26:27 -0500 (Mon, 30 Sep 2013) | 24 lines
Taskprocessor optimization; switch Stasis to use taskprocessors
This patch optimizes taskprocessor to use a semaphore for signaling,
which the OS can do a better job at managing contention and waiting
that we can with a mutex and condition.
The taskprocessor execution was also slightly optimized to reduce the
number of locks taken.
The only observable difference in the taskprocessor implementation is
that when the final reference to the taskprocessor goes away, it will
execute all tasks to completion instead of discarding the unexecuted
tasks.
For systems where unnamed semaphores are not supported, a really
simple semaphore implementation is provided. (Which gives identical
performance as the original taskprocessor implementation).
The way we ended up implementing Stasis caused the threadpool to be a
burden instead of a boost to performance. This was switched to just
use taskprocessors directly for subscriptions.
Review: https://reviewboard.asterisk.org/r/2881/
........
r400180 | dlee | 2013-09-30 13:39:34 -0500 (Mon, 30 Sep 2013) | 28 lines
Optimize how Stasis forwards are dispatched
This patch optimizes how forwards are dispatched in Stasis.
Originally, forwards were dispatched as subscriptions that are invoked
on the publishing thread. This did not account for the vast number of
forwards we would end up having in the system, and the amount of work it
would take to walk though the forward subscriptions.
This patch modifies Stasis so that rather than walking the tree of
forwards on every dispatch, when forwards and subscriptions are changed,
the subscriber list for every topic in the tree is changed.
This has a couple of benefits. First, this reduces the workload of
dispatching messages. It also reduces contention when dispatching to
different topics that happen to forward to the same aggregation topic
(as happens with all of the channel, bridge and endpoint topics).
Since forwards are no longer subscriptions, the bulk of this patch is
simply changing stasis_subscription objects to stasis_forward objects
(which, admittedly, I should have done in the first place.)
Since this required me to yet again put in a growing array, I finally
abstracted that out into a set of ast_vector macros in
asterisk/vector.h.
Review: https://reviewboard.asterisk.org/r/2883/
........
r400181 | dlee | 2013-09-30 13:48:57 -0500 (Mon, 30 Sep 2013) | 28 lines
Remove dispatch object allocation from Stasis publishing
While looking for areas for performance improvement, I realized that an
unused feature in Stasis was negatively impacting performance.
When a message is sent to a subscriber, a dispatch object is allocated
for the dispatch, containing the topic the message was published to, the
subscriber the message is being sent to, and the message itself.
The topic is actually unused by any subscriber in Asterisk today. And
the subscriber is associated with the taskprocessor the message is being
dispatched to.
First, this patch removes the unused topic parameter from Stasis
subscription callbacks.
Second, this patch introduces the concept of taskprocessor local data,
data that may be set on a taskprocessor and provided along with the data
pointer when a task is pushed using the ast_taskprocessor_push_local()
call. This allows the task to have both data specific to that
taskprocessor, in addition to data specific to that invocation.
With those two changes, the dispatch object can be removed completely,
and the message is simply refcounted and sent directly to the
taskprocessor.
Review: https://reviewboard.asterisk.org/r/2884/
........
Merged revisions 399887,400138,400178,400180-400181 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400186 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-09-30 18:55:27 +00:00
|
|
|
static void park_announce_update_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
struct park_announce_subscription_data *pa_data = data;
|
|
|
|
char *dial_string = pa_data->dial_string;
|
|
|
|
|
|
|
|
struct ast_parked_call_payload *payload = stasis_message_data(message);
|
|
|
|
|
|
|
|
if (stasis_subscription_final_message(sub, message)) {
|
|
|
|
park_announce_subscription_data_destroy(data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-23 17:50:01 -03:00
|
|
|
if (ast_parked_call_type() != stasis_message_type(message)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
if (payload->event_type != PARKED_CALL) {
|
|
|
|
/* We are only concerned with calls parked */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-07 13:18:34 -04:00
|
|
|
if (strcmp(payload->parkee->base->uniqueid, pa_data->parkee_uuid)) {
|
2013-05-21 18:00:22 +00:00
|
|
|
/* We are only concerned with the parkee we are subscribed for. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(dial_string)) {
|
|
|
|
announce_to_dial(dial_string, pa_data->announce_string, payload->parkingspace, payload->parkee);
|
|
|
|
}
|
|
|
|
|
|
|
|
*dial_string = '\0'; /* If we observe this dial string on a second pass, we don't want to do anything with it. */
|
|
|
|
}
|
|
|
|
|
2013-08-17 15:01:54 +00:00
|
|
|
static int park_and_announce_app_exec(struct ast_channel *chan, const char *data)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
struct ast_bridge_features chan_features;
|
|
|
|
char *parse;
|
|
|
|
int res;
|
|
|
|
int silence_announcements = 1;
|
|
|
|
|
|
|
|
struct stasis_subscription *parking_subscription;
|
|
|
|
struct park_announce_subscription_data *pa_data;
|
|
|
|
|
|
|
|
RAII_VAR(struct ast_bridge *, parking_bridge, NULL, ao2_cleanup);
|
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(lot_name);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
AST_APP_ARG(announce_template);
|
|
|
|
AST_APP_ARG(dial);
|
|
|
|
AST_APP_ARG(others);/* Any remaining unused arguments */
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ast_strlen_zero(data)) {
|
|
|
|
ast_log(LOG_ERROR, "ParkAndAnnounce has required arguments. No arguments were provided.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
parse = ast_strdupa(data);
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
|
|
|
|
if (ast_strlen_zero(args.announce_template)) {
|
|
|
|
/* improperly configured arguments for the application */
|
|
|
|
ast_log(LOG_ERROR, "ParkAndAnnounce requires the announce_template argument.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_strlen_zero(args.dial)) {
|
|
|
|
/* improperly configured arguments */
|
|
|
|
ast_log(LOG_ERROR, "ParkAndAnnounce requires the dial argument.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strchr(args.dial, '/')) {
|
|
|
|
ast_log(LOG_ERROR, "ParkAndAnnounce dial string '%s' is improperly formed.\n", args.dial);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the common parking setup stuff */
|
2013-07-04 18:46:56 +00:00
|
|
|
if (!(parking_bridge = park_application_setup(chan, NULL, data, &silence_announcements))) {
|
2013-05-21 18:00:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize bridge features for the channel. */
|
|
|
|
res = ast_bridge_features_init(&chan_features);
|
|
|
|
if (res) {
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* subscribe to the parking message so that we can announce once it is parked */
|
|
|
|
pa_data = park_announce_subscription_data_create(ast_channel_uniqueid(chan), args.dial, args.announce_template);
|
|
|
|
if (!pa_data) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
main/stasis: Allow subscriptions to use a threadpool for message delivery
Prior to this patch, all Stasis subscriptions would receive a dedicated
thread for servicing published messages. In contrast, prior to r400178
(see review https://reviewboard.asterisk.org/r/2881/), the subscriptions
shared a thread pool. It was discovered during some initial work on Stasis
that, for a low subscription count with high message throughput, the
threadpool was not as performant as simply having a dedicated thread per
subscriber.
For situations where a subscriber receives a substantial number of messages
and is always present, the model of having a dedicated thread per subscriber
makes sense. While we still have plenty of subscriptions that would follow
this model, e.g., AMI, CDRs, CEL, etc., there are plenty that also fall into
the following two categories:
* Large number of subscriptions, specifically those tied to endpoints/peers.
* Low number of messages. Some subscriptions exist specifically to coordinate
a single message - the subscription is created, a message is published, the
delivery is synchronized, and the subscription is destroyed.
In both of the latter two cases, creating a dedicated thread is wasteful (and
in the case of a large number of peers/endpoints, harmful). In those cases,
having shared delivery threads is far more performant.
This patch adds the ability of a subscriber to Stasis to choose whether or not
their messages are dispatched on a dedicated thread or on a threadpool. The
threadpool is configurable through stasis.conf.
Review: https://reviewboard.asterisk.org/r/4193
ASTERISK-24533 #close
Reported by: xrobau
Tested by: xrobau
........
Merged revisions 428681 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 428687 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-12-01 17:59:21 +00:00
|
|
|
if (!(parking_subscription = stasis_subscribe_pool(ast_parking_topic(), park_announce_update_cb, pa_data))) {
|
2013-05-21 18:00:22 +00:00
|
|
|
/* Failed to create subscription */
|
|
|
|
park_announce_subscription_data_destroy(pa_data);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-09-23 17:50:01 -03:00
|
|
|
stasis_subscription_accept_message_type(parking_subscription, ast_parked_call_type());
|
|
|
|
stasis_subscription_accept_message_type(parking_subscription, stasis_subscription_change_type());
|
|
|
|
stasis_subscription_set_filter(parking_subscription, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
/* Now for the fun part... park it! */
|
|
|
|
ast_bridge_join(parking_bridge, chan, NULL, &chan_features, NULL, 0);
|
|
|
|
|
|
|
|
/* Toss the subscription since we aren't bridged at this point. */
|
|
|
|
stasis_unsubscribe(parking_subscription);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 only happen with AST_SOFTHANGUP_ASYNCGOTO.
|
|
|
|
*/
|
|
|
|
res = -1;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
ast_bridge_features_cleanup(&chan_features);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2013-08-17 15:01:54 +00:00
|
|
|
|
|
|
|
int load_parking_applications(void)
|
|
|
|
{
|
|
|
|
if (ast_register_application_xml(PARK_APPLICATION, park_app_exec)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_register_application_xml(PARKED_CALL_APPLICATION, parked_call_app_exec)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_register_application_xml(PARK_AND_ANNOUNCE_APPLICATION, park_and_announce_app_exec)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unload_parking_applications(void)
|
|
|
|
{
|
|
|
|
ast_unregister_application(PARK_APPLICATION);
|
|
|
|
ast_unregister_application(PARKED_CALL_APPLICATION);
|
|
|
|
ast_unregister_application(PARK_AND_ANNOUNCE_APPLICATION);
|
|
|
|
}
|