2012-01-09 22:15:50 +00:00
|
|
|
/*
|
2012-02-23 00:56:31 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* Copyright (C) 2012, Digium, Inc.
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +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.
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* 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.
|
2012-01-09 22:15:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* \brief Channel Accessor API
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* This file is intended to be the only file that ever accesses the
|
|
|
|
* internals of an ast_channel. All other files should use the
|
|
|
|
* accessor functions defined here.
|
2012-01-09 22:15:50 +00:00
|
|
|
*
|
2012-02-23 00:56:31 +00:00
|
|
|
* \author Terry Wilson
|
2012-01-09 22:15:50 +00:00
|
|
|
*/
|
|
|
|
|
2012-06-15 16:20:16 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2012-01-09 22:15:50 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2012-03-01 22:09:18 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2017-04-18 00:06:10 +00:00
|
|
|
#include "asterisk/alertpipe.h"
|
2013-06-17 03:00:38 +00:00
|
|
|
#include "asterisk/paths.h"
|
2012-01-09 22:15:50 +00:00
|
|
|
#include "asterisk/channel.h"
|
2013-05-08 13:39:08 +00:00
|
|
|
#include "asterisk/channel_internal.h"
|
|
|
|
#include "asterisk/endpoints.h"
|
2012-01-09 22:15:50 +00:00
|
|
|
#include "asterisk/indications.h"
|
2013-04-08 14:26:37 +00:00
|
|
|
#include "asterisk/stasis_channels.h"
|
2013-05-08 13:39:08 +00:00
|
|
|
#include "asterisk/stasis_endpoints.h"
|
|
|
|
#include "asterisk/stringfields.h"
|
2017-02-13 17:50:47 +00:00
|
|
|
#include "asterisk/stream.h"
|
2012-07-18 19:48:09 +00:00
|
|
|
#include "asterisk/test.h"
|
2017-03-08 13:24:46 +00:00
|
|
|
#include "asterisk/vector.h"
|
2012-03-13 18:20:34 +00: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
|
|
|
/*!
|
|
|
|
* \brief Channel UniqueId structure
|
|
|
|
* \note channel creation time used for determining LinkedId Propagation
|
|
|
|
*/
|
|
|
|
struct ast_channel_id {
|
|
|
|
time_t creation_time; /*!< Creation time */
|
|
|
|
int creation_unique; /*!< sub-second unique value */
|
2014-06-15 22:12:49 +00:00
|
|
|
char unique_id[AST_MAX_UNIQUEID]; /*!< Unique Identifier */
|
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
|
|
|
};
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
/*!
|
|
|
|
* \brief Main Channel structure associated with a channel.
|
|
|
|
*
|
|
|
|
* \note When adding fields to this structure, it is important to add the field
|
|
|
|
* 'in position' with like-aligned fields, so as to keep the compiler from
|
|
|
|
* having to add padding to align fields. The structure's fields are sorted
|
|
|
|
* in this order: pointers, structures, long, int/enum, short, char. This
|
|
|
|
* is especially important on 64-bit architectures, where mixing 4-byte
|
|
|
|
* and 8-byte fields causes 4 bytes of padding to be added before many
|
|
|
|
* 8-byte fields.
|
|
|
|
*/
|
|
|
|
struct ast_channel {
|
|
|
|
const struct ast_channel_tech *tech; /*!< Technology (point to channel driver) */
|
|
|
|
void *tech_pvt; /*!< Private data used by the technology driver */
|
|
|
|
void *music_state; /*!< Music State*/
|
|
|
|
void *generatordata; /*!< Current generator data if there is any */
|
|
|
|
struct ast_generator *generator; /*!< Current active data generator */
|
|
|
|
struct ast_channel *masq; /*!< Channel that will masquerade as us */
|
|
|
|
struct ast_channel *masqr; /*!< Who we are masquerading as */
|
|
|
|
const char *blockproc; /*!< Procedure causing blocking */
|
|
|
|
const char *appl; /*!< Current application */
|
|
|
|
const char *data; /*!< Data passed to current application */
|
|
|
|
struct ast_sched_context *sched; /*!< Schedule context */
|
|
|
|
struct ast_filestream *stream; /*!< Stream itself. */
|
|
|
|
struct ast_filestream *vstream; /*!< Video Stream itself. */
|
|
|
|
ast_timing_func_t timingfunc;
|
|
|
|
void *timingdata;
|
|
|
|
struct ast_pbx *pbx; /*!< PBX private structure for this channel */
|
|
|
|
struct ast_trans_pvt *writetrans; /*!< Write translation path */
|
|
|
|
struct ast_trans_pvt *readtrans; /*!< Read translation path */
|
|
|
|
struct ast_audiohook_list *audiohooks;
|
|
|
|
struct ast_framehook_list *framehooks;
|
|
|
|
struct ast_cdr *cdr; /*!< Call Detail Record */
|
|
|
|
struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or
|
|
|
|
* in the CHANNEL dialplan function */
|
|
|
|
struct ast_channel_monitor *monitor; /*!< Channel monitoring */
|
2015-03-13 01:12:35 +00:00
|
|
|
ast_callid callid; /*!< Bound call identifier pointer */
|
2012-07-20 15:48:55 +00:00
|
|
|
struct ao2_container *dialed_causes; /*!< Contains tech-specific and Asterisk cause data from dialed channels */
|
2012-03-13 18:20:34 +00:00
|
|
|
|
|
|
|
AST_DECLARE_STRING_FIELDS(
|
|
|
|
AST_STRING_FIELD(name); /*!< ASCII unique channel name */
|
|
|
|
AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
|
|
|
|
AST_STRING_FIELD(musicclass); /*!< Default music class */
|
2013-08-23 18:33:36 +00:00
|
|
|
AST_STRING_FIELD(latest_musicclass); /*!< Latest active music class */
|
2012-03-13 18:20:34 +00:00
|
|
|
AST_STRING_FIELD(accountcode); /*!< Account code for billing */
|
|
|
|
AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
|
|
|
|
AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
|
|
|
|
AST_STRING_FIELD(call_forward); /*!< Where to forward to if asked to dial on this interface */
|
|
|
|
AST_STRING_FIELD(parkinglot); /*! Default parking lot, if empty, default parking lot */
|
|
|
|
AST_STRING_FIELD(hangupsource); /*! Who is responsible for hanging up this channel */
|
|
|
|
AST_STRING_FIELD(dialcontext); /*!< Dial: Extension context that we were called from */
|
|
|
|
);
|
|
|
|
|
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
|
|
|
struct ast_channel_id uniqueid; /*!< Unique Channel Identifier - can be specified on creation */
|
|
|
|
struct ast_channel_id linkedid; /*!< Linked Channel Identifier - oldest propagated when bridged */
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
struct timeval whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */
|
|
|
|
pthread_t blocker; /*!< If anyone is blocking, this is them */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Dialed/Called information.
|
|
|
|
* \note Set on incoming channels to indicate the originally dialed party.
|
|
|
|
* \note Dialed Number Identifier (DNID)
|
|
|
|
*/
|
|
|
|
struct ast_party_dialed dialed;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Channel Caller ID information.
|
|
|
|
* \note The caller id information is the caller id of this
|
|
|
|
* channel when it is used to initiate a call.
|
|
|
|
*/
|
|
|
|
struct ast_party_caller caller;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Channel Connected Line ID information.
|
|
|
|
* \note The connected line information identifies the channel
|
|
|
|
* connected/bridged to this channel.
|
|
|
|
*/
|
|
|
|
struct ast_party_connected_line connected;
|
|
|
|
|
2013-07-12 21:42:53 +00:00
|
|
|
/*!
|
|
|
|
* \brief Channel Connected Line ID information that was last indicated.
|
|
|
|
*/
|
|
|
|
struct ast_party_connected_line connected_indicated;
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
/*! \brief Redirecting/Diversion information */
|
|
|
|
struct ast_party_redirecting redirecting;
|
|
|
|
|
|
|
|
struct ast_frame dtmff; /*!< DTMF frame */
|
|
|
|
struct varshead varshead; /*!< A linked list for channel variables. See \ref AstChanVar */
|
|
|
|
ast_group_t callgroup; /*!< Call group for call pickups */
|
|
|
|
ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
|
2012-08-07 12:46:36 +00:00
|
|
|
struct ast_namedgroups *named_callgroups; /*!< Named call group for call pickups */
|
|
|
|
struct ast_namedgroups *named_pickupgroups; /*!< Named pickup group - which call groups can be picked up? */
|
|
|
|
struct timeval creationtime; /*!< The time of channel creation */
|
2013-06-17 03:00:38 +00:00
|
|
|
struct timeval answertime; /*!< The time the channel was answered */
|
2012-03-13 18:20:34 +00:00
|
|
|
struct ast_readq_list readq;
|
|
|
|
struct ast_jb jb; /*!< The jitterbuffer state */
|
|
|
|
struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */
|
2012-06-29 17:02:32 +00:00
|
|
|
struct ast_hangup_handler_list hangup_handlers;/*!< Hangup handlers on the channel. */
|
2012-03-13 18:20:34 +00:00
|
|
|
struct ast_datastore_list datastores; /*!< Data stores on the channel */
|
|
|
|
struct ast_autochan_list autochans; /*!< Autochans on the channel */
|
|
|
|
unsigned long insmpl; /*!< Track the read/written samples for monitor use */
|
|
|
|
unsigned long outsmpl; /*!< Track the read/written samples for monitor use */
|
|
|
|
|
2018-06-13 16:33:44 +00:00
|
|
|
int blocker_tid; /*!< If anyone is blocking, this is their thread id */
|
2017-03-08 13:24:46 +00:00
|
|
|
AST_VECTOR(, int) fds; /*!< File descriptors for channel -- Drivers will poll on
|
2012-03-13 18:20:34 +00:00
|
|
|
* these file descriptors, so at least one must be non -1.
|
|
|
|
* See \arg \ref AstFileDesc */
|
|
|
|
int softhangup; /*!< Whether or not we have been hung up... Do not set this value
|
|
|
|
* directly, use ast_softhangup() */
|
|
|
|
int fdno; /*!< Which fd had an event detected on */
|
|
|
|
int streamid; /*!< For streaming playback, the schedule ID */
|
|
|
|
int vstreamid; /*!< For streaming video playback, the schedule ID */
|
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 *oldwriteformat; /*!< Original writer format */
|
2012-03-13 18:20:34 +00:00
|
|
|
int timingfd; /*!< Timing fd */
|
|
|
|
enum ast_channel_state state; /*!< State of line -- Don't write directly, use ast_setstate() */
|
|
|
|
int rings; /*!< Number of rings so far */
|
|
|
|
int priority; /*!< Dialplan: Current extension priority */
|
|
|
|
int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */
|
|
|
|
int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */
|
|
|
|
enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */
|
|
|
|
unsigned int fin; /*!< Frames in counters. The high bit is a debug mask, so
|
|
|
|
* the counter is only in the remaining bits */
|
|
|
|
unsigned int fout; /*!< Frames out counters. The high bit is a debug mask, so
|
|
|
|
* the counter is only in the remaining bits */
|
|
|
|
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
|
|
|
|
unsigned int finalized:1; /*!< Whether or not the channel has been successfully allocated */
|
|
|
|
struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
|
|
|
|
int alertpipe[2];
|
|
|
|
struct ast_format_cap *nativeformats; /*!< Kinds of data this channel can natively handle */
|
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 *readformat; /*!< Requested read format (after translation) */
|
2014-08-14 16:01:39 +00:00
|
|
|
struct ast_format *writeformat; /*!< Requested write format (before translation) */
|
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 *rawreadformat; /*!< Raw read format (before translation) */
|
2014-08-14 16:01:39 +00:00
|
|
|
struct ast_format *rawwriteformat; /*!< Raw write format (after translation) */
|
2012-03-13 18:20:34 +00:00
|
|
|
unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */
|
|
|
|
int visible_indication; /*!< Indication currently playing on the channel */
|
2013-08-23 18:33:36 +00:00
|
|
|
int hold_state; /*!< Current Hold/Unhold state */
|
2012-03-13 18:20:34 +00:00
|
|
|
|
|
|
|
unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
|
|
|
|
|
|
|
|
struct ast_bridge *bridge; /*!< Bridge this channel is participating in */
|
2013-05-21 18:00:22 +00:00
|
|
|
struct ast_bridge_channel *bridge_channel;/*!< The bridge_channel this channel is linked with. */
|
2012-03-13 18:20:34 +00:00
|
|
|
struct ast_timer *timer; /*!< timer object that provided timingfd */
|
|
|
|
|
|
|
|
char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */
|
|
|
|
char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */
|
|
|
|
char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */
|
|
|
|
char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */
|
2016-02-19 22:01:17 +00:00
|
|
|
char unbridged; /*!< non-zero if the bridge core needs to re-evaluate the current
|
|
|
|
bridging technology which is in use by this channel's bridge. */
|
|
|
|
char is_t38_active; /*!< non-zero if T.38 is active on this channel. */
|
2012-03-13 18:20:34 +00:00
|
|
|
char dtmf_digit_to_emulate; /*!< Digit being emulated */
|
2012-11-06 19:05:11 +00:00
|
|
|
char sending_dtmf_digit; /*!< Digit this channel is currently sending out. (zero if not sending) */
|
|
|
|
struct timeval sending_dtmf_tv; /*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
|
2018-10-10 14:28:18 +00:00
|
|
|
struct stasis_topic *topic; /*!< Topic for trhis channel */
|
|
|
|
struct stasis_forward *channel_forward; /*!< Subscription for event forwarding to all channel topic */
|
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
|
|
|
struct stasis_forward *endpoint_forward; /*!< Subscription for event forwarding to endpoint's topic */
|
2017-02-13 17:50:47 +00:00
|
|
|
struct ast_stream_topology *stream_topology; /*!< Stream topology */
|
2017-04-25 16:49:16 +00:00
|
|
|
void *stream_topology_change_source; /*!< Source that initiated a stream topology change */
|
2017-02-13 17:50:47 +00:00
|
|
|
struct ast_stream *default_streams[AST_MEDIA_TYPE_END]; /*!< Default streams indexed by media type */
|
2018-10-10 14:28:18 +00:00
|
|
|
struct ast_channel_snapshot *snapshot; /*!< The current up to date snapshot of the channel */
|
2018-11-07 17:18:34 +00:00
|
|
|
struct ast_flags snapshot_segment_flags; /*!< Flags regarding the segments of the snapshot */
|
2012-03-13 18:20:34 +00:00
|
|
|
};
|
2012-01-09 22:15:50 +00:00
|
|
|
|
2013-06-17 03:00:38 +00:00
|
|
|
/*! \brief The monotonically increasing integer counter for channel uniqueids */
|
|
|
|
static int uniqueint;
|
|
|
|
|
2012-01-09 22:15:50 +00:00
|
|
|
/* ACCESSORS */
|
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
#define DEFINE_STRINGFIELD_SETTERS_FOR(field, assert_on_null) \
|
2012-01-24 20:12:09 +00:00
|
|
|
void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
|
|
|
|
{ \
|
2013-06-17 03:00:38 +00:00
|
|
|
if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
|
|
|
|
if (!strcmp(value, chan->field)) return; \
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_string_field_set(chan, field, value); \
|
2018-11-07 17:18:34 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
|
|
|
|
{ \
|
|
|
|
ast_string_field_build_va(chan, field, fmt, ap); \
|
|
|
|
} \
|
|
|
|
void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
|
|
|
|
{ \
|
|
|
|
va_list ap; \
|
|
|
|
va_start(ap, fmt); \
|
|
|
|
ast_channel_##field##_build_va(chan, fmt, ap); \
|
|
|
|
va_end(ap); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(field, publish, assert_on_null, invalidate) \
|
|
|
|
void ast_channel_##field##_set(struct ast_channel *chan, const char *value) \
|
|
|
|
{ \
|
|
|
|
if ((assert_on_null)) ast_assert(!ast_strlen_zero(value)); \
|
|
|
|
if (!strcmp(value, chan->field)) return; \
|
|
|
|
ast_string_field_set(chan, field, value); \
|
|
|
|
ast_channel_snapshot_invalidate_segment(chan, invalidate); \
|
2013-08-08 14:13:05 +00:00
|
|
|
if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
|
2012-01-24 20:12:09 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
void ast_channel_##field##_build_va(struct ast_channel *chan, const char *fmt, va_list ap) \
|
|
|
|
{ \
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_string_field_build_va(chan, field, fmt, ap); \
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, invalidate); \
|
2013-08-08 14:13:05 +00:00
|
|
|
if (publish && ast_channel_internal_is_finalized(chan)) ast_channel_publish_snapshot(chan); \
|
2012-01-24 20:12:09 +00:00
|
|
|
} \
|
|
|
|
void ast_channel_##field##_build(struct ast_channel *chan, const char *fmt, ...) \
|
|
|
|
{ \
|
|
|
|
va_list ap; \
|
|
|
|
va_start(ap, fmt); \
|
|
|
|
ast_channel_##field##_build_va(chan, fmt, ap); \
|
|
|
|
va_end(ap); \
|
2012-01-09 22:15:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(name, 0, 1, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(language, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_FOR(musicclass, 0);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_FOR(latest_musicclass, 0);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(accountcode, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(peeraccount, 1, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(userfield, 0, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_FOR(call_forward, 0);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_FOR(parkinglot, 0);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_AND_INVALIDATE_FOR(hangupsource, 0, 0, AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP);
|
|
|
|
DEFINE_STRINGFIELD_SETTERS_FOR(dialcontext, 0);
|
2012-01-24 20:12:09 +00:00
|
|
|
|
|
|
|
#define DEFINE_STRINGFIELD_GETTER_FOR(field) const char *ast_channel_##field(const struct ast_channel *chan) \
|
|
|
|
{ \
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->field; \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(name);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(language);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(musicclass);
|
2013-08-23 18:33:36 +00:00
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(latest_musicclass);
|
2012-03-13 18:20:34 +00:00
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(accountcode);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(peeraccount);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(userfield);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(call_forward);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(parkinglot);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(hangupsource);
|
|
|
|
DEFINE_STRINGFIELD_GETTER_FOR(dialcontext);
|
2012-02-13 17:27:06 +00: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
|
|
|
const char *ast_channel_uniqueid(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
ast_assert(chan->uniqueid.unique_id[0] != '\0');
|
|
|
|
return chan->uniqueid.unique_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *ast_channel_linkedid(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
ast_assert(chan->linkedid.unique_id[0] != '\0');
|
|
|
|
return chan->linkedid.unique_id;
|
|
|
|
}
|
|
|
|
|
2012-02-13 17:27:06 +00:00
|
|
|
const char *ast_channel_appl(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->appl;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->appl = value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN);
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
const char *ast_channel_blockproc(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->blockproc;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_blockproc_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->blockproc = value;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
const char *ast_channel_data(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->data;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_data_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->data = value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN);
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *ast_channel_context(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->context;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_context_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_copy_string(chan->context, value, sizeof(chan->context));
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN);
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
const char *ast_channel_exten(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->exten;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_copy_string(chan->exten, value, sizeof(chan->exten));
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN);
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
const char *ast_channel_macrocontext(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->macrocontext;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_macrocontext_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_copy_string(chan->macrocontext, value, sizeof(chan->macrocontext));
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
const char *ast_channel_macroexten(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->macroexten;
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
|
|
|
void ast_channel_macroexten_set(struct ast_channel *chan, const char *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_copy_string(chan->macroexten, value, sizeof(chan->macroexten));
|
2012-02-13 17:27:06 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
|
2012-02-22 00:35:54 +00:00
|
|
|
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
|
2012-02-20 23:43:27 +00:00
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->dtmf_digit_to_emulate;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2012-02-22 00:35:54 +00:00
|
|
|
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
|
2012-02-20 23:43:27 +00:00
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->dtmf_digit_to_emulate = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2012-11-06 19:05:11 +00:00
|
|
|
|
|
|
|
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->sending_dtmf_digit;
|
|
|
|
}
|
|
|
|
void ast_channel_sending_dtmf_digit_set(struct ast_channel *chan, char value)
|
|
|
|
{
|
|
|
|
chan->sending_dtmf_digit = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->sending_dtmf_tv;
|
|
|
|
}
|
|
|
|
void ast_channel_sending_dtmf_tv_set(struct ast_channel *chan, struct timeval value)
|
|
|
|
{
|
|
|
|
chan->sending_dtmf_tv = value;
|
|
|
|
}
|
|
|
|
|
2013-06-17 03:00:38 +00:00
|
|
|
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
|
2012-02-20 23:43:27 +00:00
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->amaflags;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2013-06-17 03:00:38 +00:00
|
|
|
|
|
|
|
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
|
2012-02-20 23:43:27 +00:00
|
|
|
{
|
2013-06-17 03:00:38 +00:00
|
|
|
if (chan->amaflags == value) {
|
|
|
|
return;
|
|
|
|
}
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->amaflags = value;
|
2013-06-17 03:00:38 +00:00
|
|
|
ast_channel_publish_snapshot(chan);
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_fdno(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->fdno;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_fdno_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->fdno = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_hangupcause(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->hangupcause;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->hangupcause = value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_HANGUP);
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_macropriority(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->macropriority;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_macropriority_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->macropriority = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_priority(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->priority;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_priority_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->priority = value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_DIALPLAN);
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_rings(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->rings;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_rings_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->rings = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_streamid(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->streamid;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_streamid_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->streamid = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_timingfd(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->timingfd;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->timingfd = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
int ast_channel_visible_indication(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->visible_indication;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->visible_indication = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2013-08-23 18:33:36 +00:00
|
|
|
int ast_channel_hold_state(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->hold_state;
|
|
|
|
}
|
|
|
|
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
|
|
|
chan->hold_state = value;
|
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
int ast_channel_vstreamid(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->vstreamid;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->vstreamid = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->transfercapability;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->transfercapability = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->emulate_dtmf_duration;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->emulate_dtmf_duration = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned int ast_channel_fin(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->fin;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->fin = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned int ast_channel_fout(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->fout;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->fout = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned long ast_channel_insmpl(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->insmpl;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->insmpl = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
unsigned long ast_channel_outsmpl(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->outsmpl;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->outsmpl = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void *ast_channel_generatordata(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->generatordata;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->generatordata = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void *ast_channel_music_state(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->music_state;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_music_state_set(struct ast_channel *chan, void *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->music_state = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void *ast_channel_tech_pvt(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->tech_pvt;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->tech_pvt = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void *ast_channel_timingdata(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->timingdata;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_timingdata_set(struct ast_channel *chan, void *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->timingdata = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_audiohook_list *ast_channel_audiohooks(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->audiohooks;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->audiohooks = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_cdr *ast_channel_cdr(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->cdr;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_cdr_set(struct ast_channel *chan, struct ast_cdr *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->cdr = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_channel *ast_channel_masq(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->masq;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_masq_set(struct ast_channel *chan, struct ast_channel *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->masq = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_channel *ast_channel_masqr(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->masqr;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_masqr_set(struct ast_channel *chan, struct ast_channel *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->masqr = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_channel_monitor *ast_channel_monitor(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->monitor;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->monitor = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_filestream *ast_channel_stream(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->stream;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_stream_set(struct ast_channel *chan, struct ast_filestream *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->stream = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_filestream *ast_channel_vstream(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->vstream;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_vstream_set(struct ast_channel *chan, struct ast_filestream *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->vstream = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_format_cap *ast_channel_nativeformats(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->nativeformats;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2017-02-13 17:50:47 +00:00
|
|
|
|
|
|
|
static void channel_set_default_streams(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
enum ast_media_type type;
|
|
|
|
|
|
|
|
ast_assert(chan != NULL);
|
|
|
|
|
|
|
|
for (type = AST_MEDIA_TYPE_UNKNOWN; type < AST_MEDIA_TYPE_END; type++) {
|
|
|
|
if (chan->stream_topology) {
|
|
|
|
chan->default_streams[type] =
|
|
|
|
ast_stream_topology_get_first_stream_by_type(chan->stream_topology, type);
|
|
|
|
} else {
|
|
|
|
chan->default_streams[type] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_set_stream_topology(struct ast_channel *chan,
|
|
|
|
struct ast_stream_topology *topology)
|
|
|
|
{
|
2017-02-16 14:28:33 +00:00
|
|
|
ast_stream_topology_free(chan->stream_topology);
|
2017-02-13 17:50:47 +00:00
|
|
|
chan->stream_topology = topology;
|
|
|
|
channel_set_default_streams(chan);
|
|
|
|
}
|
|
|
|
|
2017-04-25 16:49:16 +00:00
|
|
|
void ast_channel_internal_set_stream_topology_change_source(
|
|
|
|
struct ast_channel *chan, void *change_source)
|
|
|
|
{
|
|
|
|
chan->stream_topology_change_source = change_source;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->stream_topology_change_source;
|
|
|
|
}
|
|
|
|
|
2017-02-13 17:50:47 +00:00
|
|
|
void ast_channel_nativeformats_set(struct ast_channel *chan,
|
|
|
|
struct ast_format_cap *value)
|
2012-02-20 23:43:27 +00:00
|
|
|
{
|
2017-02-13 17:50:47 +00:00
|
|
|
ast_assert(chan != NULL);
|
|
|
|
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->nativeformats, value);
|
2017-02-13 17:50:47 +00:00
|
|
|
|
|
|
|
/* If chan->stream_topology is NULL, the channel is being destroyed
|
|
|
|
* and topology is destroyed.
|
|
|
|
*/
|
|
|
|
if (!chan->stream_topology) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-21 00:25:10 +00:00
|
|
|
if (!ast_channel_is_multistream(chan) || !value) {
|
2017-02-13 17:50:47 +00:00
|
|
|
struct ast_stream_topology *new_topology;
|
|
|
|
|
2017-04-21 00:25:10 +00:00
|
|
|
new_topology = ast_stream_topology_create_from_format_cap(value);
|
2017-02-13 17:50:47 +00:00
|
|
|
ast_channel_internal_set_stream_topology(chan, new_topology);
|
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2017-02-13 17:50:47 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
struct ast_framehook_list *ast_channel_framehooks(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->framehooks;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_framehooks_set(struct ast_channel *chan, struct ast_framehook_list *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->framehooks = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_generator *ast_channel_generator(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->generator;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->generator = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_pbx *ast_channel_pbx(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->pbx;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->pbx = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_sched_context *ast_channel_sched(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->sched;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->sched = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_timer *ast_channel_timer(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->timer;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->timer = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_tone_zone *ast_channel_zone(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->zone;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_zone_set(struct ast_channel *chan, struct ast_tone_zone *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->zone = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_trans_pvt *ast_channel_readtrans(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->readtrans;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_readtrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->readtrans = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
struct ast_trans_pvt *ast_channel_writetrans(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->writetrans;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_writetrans_set(struct ast_channel *chan, struct ast_trans_pvt *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->writetrans = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->tech;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
|
|
|
|
{
|
2017-02-24 21:30:33 +00:00
|
|
|
if (value->read_stream || value->write_stream) {
|
|
|
|
ast_assert(value->read_stream && value->write_stream);
|
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->tech = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->adsicpe;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->adsicpe = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
|
|
|
enum ast_channel_state ast_channel_state(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->state;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
2015-03-13 01:12:35 +00:00
|
|
|
ast_callid ast_channel_callid(const struct ast_channel *chan)
|
2012-05-17 16:28:20 +00:00
|
|
|
{
|
2015-03-13 01:12:35 +00:00
|
|
|
return chan->callid;
|
2012-05-17 16:28:20 +00:00
|
|
|
}
|
2015-03-13 01:12:35 +00:00
|
|
|
void ast_channel_callid_set(struct ast_channel *chan, ast_callid callid)
|
2012-05-17 16:28:20 +00:00
|
|
|
{
|
2012-07-18 19:48:09 +00:00
|
|
|
char call_identifier_from[AST_CALLID_BUFFER_LENGTH];
|
|
|
|
char call_identifier_to[AST_CALLID_BUFFER_LENGTH];
|
|
|
|
call_identifier_from[0] = '\0';
|
|
|
|
ast_callid_strnprint(call_identifier_to, sizeof(call_identifier_to), callid);
|
2012-05-17 16:28:20 +00:00
|
|
|
if (chan->callid) {
|
2012-07-18 19:48:09 +00:00
|
|
|
ast_callid_strnprint(call_identifier_from, sizeof(call_identifier_from), chan->callid);
|
|
|
|
ast_debug(3, "Channel Call ID changing from %s to %s\n", call_identifier_from, call_identifier_to);
|
2012-05-17 16:28:20 +00:00
|
|
|
}
|
2012-07-18 19:48:09 +00:00
|
|
|
|
2015-03-13 01:12:35 +00:00
|
|
|
chan->callid = callid;
|
2012-07-18 19:48:09 +00:00
|
|
|
|
|
|
|
ast_test_suite_event_notify("CallIDChange",
|
|
|
|
"State: CallIDChange\r\n"
|
|
|
|
"Channel: %s\r\n"
|
|
|
|
"CallID: %s\r\n"
|
2012-07-19 19:07:25 +00:00
|
|
|
"PriorCallID: %s",
|
2012-07-18 19:48:09 +00:00
|
|
|
ast_channel_name(chan),
|
|
|
|
call_identifier_to,
|
|
|
|
call_identifier_from);
|
2012-05-17 16:28:20 +00:00
|
|
|
}
|
stasis: Reduce creation of channel snapshots to improve performance
During some performance testing of Asterisk with AGI, ARI, and lots of Local
channels, we noticed that there's quite a hit in performance during channel
creation and releasing to the dialplan (ARI continue). After investigating
the performance spike that occurs during channel creation, we discovered
that we create a lot of channel snapshots that are technically unnecessary.
This includes creating snapshots during:
* AGI execution
* Returning objects for ARI commands
* During some Local channel operations
* During some dialling operations
* During variable setting
* During some bridging operations
And more.
This patch does the following:
- It removes a number of fields from channel snapshots. These fields were
rarely used, were expensive to have on the snapshot, and hurt performance.
This included formats, translation paths, Log Call ID, callgroup, pickup
group, and all channel variables. As a result, AMI Status,
"core show channel", "core show channelvar", and "pjsip show channel" were
modified to either hit the live channel or not show certain pieces of data.
While this is unfortunate, the performance gain from this patch is worth
the loss in behaviour.
- It adds a mechanism to publish a cached snapshot + blob. A large number of
publications were changed to use this, including:
- During Dial begin
- During Variable assignment (if no AMI variables are emitted - if AMI
variables are set, we have to make snapshots when a variable is changed)
- During channel pickup
- When a channel is put on hold/unhold
- When a DTMF digit is begun/ended
- When creating a bridge snapshot
- When an AOC event is raised
- During Local channel optimization/Local bridging
- When endpoint snapshots are generated
- All AGI events
- All ARI responses that return a channel
- Events in the AgentPool, MeetMe, and some in Queue
- Additionally, some extraneous channel snapshots were being made that were
unnecessary. These were removed.
- The result of ast_hashtab_hash_string is now cached in stasis_cache. This
reduces a large number of calls to ast_hashtab_hash_string, which reduced
the amount of time spent in this function in gprof by around 50%.
#ASTERISK-23811 #close
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/3568/
........
Merged revisions 416211 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416216 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-13 18:24:49 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->state = value;
|
2012-02-20 23:43:27 +00:00
|
|
|
}
|
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
|
|
|
void ast_channel_set_oldwriteformat(struct ast_channel *chan, struct ast_format *format)
|
|
|
|
{
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->oldwriteformat, format);
|
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
|
|
|
}
|
|
|
|
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
|
|
|
|
{
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->rawreadformat, format);
|
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
|
|
|
}
|
|
|
|
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
|
|
|
|
{
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->rawwriteformat, format);
|
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
|
|
|
}
|
|
|
|
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
|
|
|
|
{
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->readformat, format);
|
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
|
|
|
}
|
|
|
|
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
|
|
|
|
{
|
2014-08-14 16:01:39 +00:00
|
|
|
ao2_replace(chan->writeformat, format);
|
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
|
|
|
}
|
2012-02-24 00:32:20 +00:00
|
|
|
struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan)
|
|
|
|
{
|
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
|
|
|
return chan->oldwriteformat;
|
2012-02-24 00:32:20 +00:00
|
|
|
}
|
|
|
|
struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan)
|
|
|
|
{
|
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
|
|
|
return chan->rawreadformat;
|
2012-02-24 00:32:20 +00:00
|
|
|
}
|
|
|
|
struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan)
|
|
|
|
{
|
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
|
|
|
return chan->rawwriteformat;
|
2012-02-24 00:32:20 +00:00
|
|
|
}
|
|
|
|
struct ast_format *ast_channel_readformat(struct ast_channel *chan)
|
|
|
|
{
|
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
|
|
|
return chan->readformat;
|
2012-02-24 00:32:20 +00:00
|
|
|
}
|
|
|
|
struct ast_format *ast_channel_writeformat(struct ast_channel *chan)
|
|
|
|
{
|
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
|
|
|
return chan->writeformat;
|
2012-02-24 00:32:20 +00:00
|
|
|
}
|
2012-06-29 17:02:32 +00:00
|
|
|
struct ast_hangup_handler_list *ast_channel_hangup_handlers(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return &chan->hangup_handlers;
|
|
|
|
}
|
2012-02-29 16:52:47 +00:00
|
|
|
struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->datastores;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->autochans;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_readq_list *ast_channel_readq(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->readq;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_frame *ast_channel_dtmff(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->dtmff;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_jb *ast_channel_jb(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->jb;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_party_caller *ast_channel_caller(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->caller;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_party_connected_line *ast_channel_connected(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->connected;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
2013-07-12 21:42:53 +00:00
|
|
|
struct ast_party_connected_line *ast_channel_connected_indicated(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return &chan->connected_indicated;
|
|
|
|
}
|
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
|
|
|
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return ast_party_id_merge(&chan->connected.id, &chan->connected.priv);
|
|
|
|
}
|
2012-02-29 16:52:47 +00:00
|
|
|
struct ast_party_dialed *ast_channel_dialed(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->dialed;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct ast_party_redirecting *ast_channel_redirecting(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->redirecting;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
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
|
|
|
struct ast_party_id ast_channel_redirecting_effective_orig(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return ast_party_id_merge(&chan->redirecting.orig, &chan->redirecting.priv_orig);
|
|
|
|
}
|
|
|
|
struct ast_party_id ast_channel_redirecting_effective_from(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return ast_party_id_merge(&chan->redirecting.from, &chan->redirecting.priv_from);
|
|
|
|
}
|
|
|
|
struct ast_party_id ast_channel_redirecting_effective_to(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return ast_party_id_merge(&chan->redirecting.to, &chan->redirecting.priv_to);
|
|
|
|
}
|
2012-02-29 16:52:47 +00:00
|
|
|
struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->dtmf_tv;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct timeval *ast_channel_whentohangup(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->whentohangup;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
struct varshead *ast_channel_varshead(struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return &chan->varshead;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
2012-03-01 22:09:18 +00:00
|
|
|
void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->dtmff = *value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->jb = *value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
2012-02-29 16:52:47 +00:00
|
|
|
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->caller = *value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->connected = *value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED);
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->dialed = *value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->redirecting = *value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->dtmf_tv = *value;
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
|
|
|
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->whentohangup = *value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->varshead = *value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
2012-08-07 12:46:36 +00:00
|
|
|
struct timeval ast_channel_creationtime(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->creationtime;
|
|
|
|
}
|
|
|
|
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
|
|
|
|
{
|
|
|
|
chan->creationtime = *value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BASE);
|
2012-08-07 12:46:36 +00:00
|
|
|
}
|
2012-03-01 22:09:18 +00:00
|
|
|
|
2013-06-17 03:00:38 +00:00
|
|
|
struct timeval ast_channel_answertime(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->answertime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_answertime_set(struct ast_channel *chan, struct timeval *value)
|
|
|
|
{
|
|
|
|
chan->answertime = *value;
|
|
|
|
}
|
|
|
|
|
2012-03-01 22:09:18 +00:00
|
|
|
/* Evil softhangup accessors */
|
2012-03-13 18:20:34 +00:00
|
|
|
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
|
2012-03-01 22:09:18 +00:00
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->softhangup;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->softhangup = value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->softhangup |= value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan ->softhangup &= ~value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 16:24:37 +00:00
|
|
|
int ast_channel_unbridged_nolock(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->unbridged;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_unbridged(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
res = ast_channel_unbridged_nolock(chan);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
|
|
|
|
{
|
2016-02-19 22:01:17 +00:00
|
|
|
chan->unbridged = !!value;
|
2014-08-13 16:24:37 +00:00
|
|
|
ast_queue_frame(chan, &ast_null_frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_set_unbridged(struct ast_channel *chan, int value)
|
|
|
|
{
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
ast_channel_set_unbridged_nolock(chan, value);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
}
|
|
|
|
|
2016-02-19 22:01:17 +00:00
|
|
|
int ast_channel_is_t38_active_nolock(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->is_t38_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_is_t38_active(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
res = ast_channel_is_t38_active_nolock(chan);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
|
|
|
|
{
|
|
|
|
chan->is_t38_active = !!is_t38_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_set_is_t38_active(struct ast_channel *chan, int is_t38_active)
|
|
|
|
{
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
ast_channel_set_is_t38_active_nolock(chan, is_t38_active);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
}
|
|
|
|
|
2012-05-17 16:28:20 +00:00
|
|
|
void ast_channel_callid_cleanup(struct ast_channel *chan)
|
|
|
|
{
|
2015-03-13 01:12:35 +00:00
|
|
|
chan->callid = 0;
|
2012-05-17 16:28:20 +00:00
|
|
|
}
|
|
|
|
|
2012-03-01 22:09:18 +00:00
|
|
|
/* Typedef accessors */
|
|
|
|
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->callgroup;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->callgroup = value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
return chan->pickupgroup;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
|
|
|
|
{
|
2012-03-13 18:20:34 +00:00
|
|
|
chan->pickupgroup = value;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
2012-08-07 12:46:36 +00:00
|
|
|
struct ast_namedgroups *ast_channel_named_callgroups(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->named_callgroups;
|
|
|
|
}
|
|
|
|
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
|
|
|
|
{
|
|
|
|
ast_unref_namedgroups(chan->named_callgroups);
|
|
|
|
chan->named_callgroups = ast_ref_namedgroups(value);
|
|
|
|
}
|
|
|
|
struct ast_namedgroups *ast_channel_named_pickupgroups(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->named_pickupgroups;
|
|
|
|
}
|
|
|
|
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
|
|
|
|
{
|
|
|
|
ast_unref_namedgroups(chan->named_pickupgroups);
|
|
|
|
chan->named_pickupgroups = ast_ref_namedgroups(value);
|
|
|
|
}
|
2012-03-01 22:09:18 +00:00
|
|
|
|
|
|
|
/* Alertpipe functions */
|
|
|
|
int ast_channel_alert_write(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_write(chan->alertpipe);
|
2016-12-13 00:38:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ast_alert_status_t ast_channel_internal_alert_flush(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_flush(chan->alertpipe);
|
2016-12-13 00:38:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_read(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_alert_writable(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_writable(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_internal_alert_readable(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_readable(chan->alertpipe);
|
2012-02-29 16:52:47 +00:00
|
|
|
}
|
2012-03-01 22:09:18 +00:00
|
|
|
|
|
|
|
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
ast_alertpipe_clear(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
ast_alertpipe_close(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_init(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
return ast_alertpipe_readfd(chan->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
|
|
|
|
{
|
2017-04-18 00:06:10 +00:00
|
|
|
ast_alertpipe_swap(chan1->alertpipe, chan2->alertpipe);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* file descriptor array accessors */
|
|
|
|
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
|
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
int pos;
|
|
|
|
|
|
|
|
/* This ensures that if the vector has to grow with unused positions they will be
|
|
|
|
* initialized to -1.
|
|
|
|
*/
|
|
|
|
for (pos = AST_VECTOR_SIZE(&chan->fds); pos < which; pos++) {
|
|
|
|
AST_VECTOR_REPLACE(&chan->fds, pos, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_VECTOR_REPLACE(&chan->fds, which, value);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
|
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
if (which >= AST_VECTOR_SIZE(&chan->fds)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_VECTOR_REPLACE(&chan->fds, which, -1);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
|
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
AST_VECTOR_RESET(&chan->fds, AST_VECTOR_ELEM_CLEANUP_NOOP);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
int ast_channel_fd(const struct ast_channel *chan, int which)
|
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
return (which >= AST_VECTOR_SIZE(&chan->fds)) ? -1 : AST_VECTOR_GET(&chan->fds, which);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
|
|
|
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
|
|
|
|
{
|
|
|
|
return ast_channel_fd(chan, which) > -1;
|
|
|
|
}
|
|
|
|
|
2017-03-08 13:24:46 +00:00
|
|
|
int ast_channel_fd_count(const struct ast_channel *chan)
|
2012-03-01 22:09:18 +00:00
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
return AST_VECTOR_SIZE(&chan->fds);
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
2017-03-08 13:24:46 +00:00
|
|
|
|
|
|
|
int ast_channel_fd_add(struct ast_channel *chan, int value)
|
2012-03-01 22:09:18 +00:00
|
|
|
{
|
2017-03-08 13:24:46 +00:00
|
|
|
int pos = AST_EXTENDED_FDS;
|
|
|
|
|
|
|
|
while (ast_channel_fd_isset(chan, pos)) {
|
|
|
|
pos += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_VECTOR_REPLACE(&chan->fds, pos, value);
|
|
|
|
|
|
|
|
return pos;
|
2012-03-01 22:09:18 +00:00
|
|
|
}
|
2012-03-13 18:20:34 +00:00
|
|
|
|
|
|
|
pthread_t ast_channel_blocker(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->blocker;
|
|
|
|
}
|
|
|
|
void ast_channel_blocker_set(struct ast_channel *chan, pthread_t value)
|
|
|
|
{
|
|
|
|
chan->blocker = value;
|
|
|
|
}
|
|
|
|
|
2018-06-13 16:33:44 +00:00
|
|
|
int ast_channel_blocker_tid(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->blocker_tid;
|
|
|
|
}
|
|
|
|
void ast_channel_blocker_tid_set(struct ast_channel *chan, int value)
|
|
|
|
{
|
|
|
|
chan->blocker_tid = value;
|
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->timingfunc;
|
|
|
|
}
|
|
|
|
void ast_channel_timingfunc_set(struct ast_channel *chan, ast_timing_func_t value)
|
|
|
|
{
|
|
|
|
chan->timingfunc = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ast_bridge *ast_channel_internal_bridge(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->bridge;
|
|
|
|
}
|
|
|
|
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
|
|
|
|
{
|
|
|
|
chan->bridge = value;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_BRIDGE);
|
2013-07-08 19:19:55 +00:00
|
|
|
ast_channel_publish_snapshot(chan);
|
2012-03-13 18:20:34 +00:00
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
struct ast_bridge_channel *ast_channel_internal_bridge_channel(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->bridge_channel;
|
|
|
|
}
|
|
|
|
void ast_channel_internal_bridge_channel_set(struct ast_channel *chan, struct ast_bridge_channel *value)
|
|
|
|
{
|
|
|
|
chan->bridge_channel = value;
|
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
struct ast_flags *ast_channel_flags(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return &chan->flags;
|
|
|
|
}
|
|
|
|
|
2012-07-20 15:48:55 +00:00
|
|
|
static int collect_names_cb(void *obj, void *arg, int flags) {
|
|
|
|
struct ast_control_pvt_cause_code *cause_code = obj;
|
|
|
|
struct ast_str **str = arg;
|
|
|
|
|
|
|
|
ast_str_append(str, 0, "%s%s", (ast_str_strlen(*str) ? "," : ""), cause_code->chan_name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
struct ast_str *chanlist = ast_str_create(128);
|
|
|
|
|
|
|
|
if (!chanlist) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_callback(chan->dialed_causes, 0, collect_names_cb, &chanlist);
|
|
|
|
|
|
|
|
return chanlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ast_control_pvt_cause_code *ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name)
|
|
|
|
{
|
|
|
|
return ao2_find(chan->dialed_causes, chan_name, OBJ_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
|
|
|
|
{
|
|
|
|
struct ast_control_pvt_cause_code *ao2_cause_code;
|
|
|
|
ao2_find(chan->dialed_causes, cause_code->chan_name, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA);
|
|
|
|
ao2_cause_code = ao2_alloc(datalen, NULL);
|
|
|
|
|
|
|
|
if (ao2_cause_code) {
|
|
|
|
memcpy(ao2_cause_code, cause_code, datalen);
|
|
|
|
ao2_link(chan->dialed_causes, ao2_cause_code);
|
|
|
|
ao2_ref(ao2_cause_code, -1);
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_dialed_causes_clear(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
ao2_callback(chan->dialed_causes, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* \brief Hash function for pvt cause code frames */
|
|
|
|
static int pvt_cause_hash_fn(const void *vpc, const int flags)
|
|
|
|
{
|
|
|
|
const struct ast_control_pvt_cause_code *pc = vpc;
|
|
|
|
return ast_str_hash(ast_tech_to_upper(ast_strdupa(pc->chan_name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* \brief Comparison function for pvt cause code frames */
|
|
|
|
static int pvt_cause_cmp_fn(void *obj, void *vstr, int flags)
|
|
|
|
{
|
|
|
|
struct ast_control_pvt_cause_code *pc = obj;
|
|
|
|
char *str = ast_tech_to_upper(ast_strdupa(vstr));
|
|
|
|
char *pc_str = ast_tech_to_upper(ast_strdupa(pc->chan_name));
|
|
|
|
return !strcmp(pc_str, str) ? CMP_MATCH | CMP_STOP : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DIALED_CAUSES_BUCKETS 37
|
|
|
|
|
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
|
|
|
struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)
|
2012-03-13 18:20:34 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *tmp;
|
2015-04-17 07:16:59 +00:00
|
|
|
|
|
|
|
tmp = __ao2_alloc(sizeof(*tmp), destructor,
|
|
|
|
AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function);
|
2012-03-13 18:20:34 +00:00
|
|
|
|
2015-04-21 20:17:33 +00:00
|
|
|
if (!tmp) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
if ((ast_string_field_init(tmp, 128))) {
|
|
|
|
return ast_channel_unref(tmp);
|
|
|
|
}
|
|
|
|
|
2018-11-19 20:10:02 +00:00
|
|
|
tmp->dialed_causes = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
|
|
|
|
DIALED_CAUSES_BUCKETS, pvt_cause_hash_fn, NULL, pvt_cause_cmp_fn);
|
|
|
|
if (!tmp->dialed_causes) {
|
2013-06-17 03:00:38 +00:00
|
|
|
return ast_channel_unref(tmp);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* set the creation time in the uniqueid */
|
|
|
|
tmp->uniqueid.creation_time = time(NULL);
|
|
|
|
tmp->uniqueid.creation_unique = ast_atomic_fetchadd_int(&uniqueint, 1);
|
|
|
|
|
|
|
|
/* use provided id or default to historical {system-}time.# format */
|
|
|
|
if (assignedids && !ast_strlen_zero(assignedids->uniqueid)) {
|
|
|
|
ast_copy_string(tmp->uniqueid.unique_id, assignedids->uniqueid, sizeof(tmp->uniqueid.unique_id));
|
|
|
|
} else if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
|
|
|
|
snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%li.%d",
|
|
|
|
(long)(tmp->uniqueid.creation_time),
|
|
|
|
tmp->uniqueid.creation_unique);
|
2013-06-17 03:00:38 +00:00
|
|
|
} else {
|
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
|
|
|
snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%s-%li.%d",
|
|
|
|
ast_config_AST_SYSTEM_NAME,
|
|
|
|
(long)(tmp->uniqueid.creation_time),
|
|
|
|
tmp->uniqueid.creation_unique);
|
2013-06-17 03:00:38 +00: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
|
|
|
/* copy linked id from parent channel if known */
|
|
|
|
if (requestor) {
|
|
|
|
tmp->linkedid = requestor->linkedid;
|
2013-06-17 03:00:38 +00:00
|
|
|
} else {
|
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
|
|
|
tmp->linkedid = tmp->uniqueid;
|
2012-07-20 15:48:55 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 13:24:46 +00:00
|
|
|
AST_VECTOR_INIT(&tmp->fds, AST_MAX_FDS);
|
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
/* Force all channel snapshot segments to be created on first use, so we don't have to check if
|
|
|
|
* an old snapshot exists.
|
|
|
|
*/
|
|
|
|
ast_set_flag(&tmp->snapshot_segment_flags, AST_FLAGS_ALL);
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
struct ast_channel *ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
|
|
|
|
{
|
|
|
|
ast_assert(a->linkedid.creation_time != 0);
|
|
|
|
ast_assert(b->linkedid.creation_time != 0);
|
|
|
|
|
|
|
|
if (a->linkedid.creation_time < b->linkedid.creation_time) {
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
if (b->linkedid.creation_time < a->linkedid.creation_time) {
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
if (a->linkedid.creation_unique < b->linkedid.creation_unique) {
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source)
|
|
|
|
{
|
2014-06-15 22:12:49 +00:00
|
|
|
if (dest->linkedid.creation_time == source->linkedid.creation_time
|
|
|
|
&& dest->linkedid.creation_unique == source->linkedid.creation_unique
|
|
|
|
&& !strcmp(dest->linkedid.unique_id, source->linkedid.unique_id)) {
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
dest->linkedid = source->linkedid;
|
2018-11-07 17:18:34 +00:00
|
|
|
ast_channel_snapshot_invalidate_segment(dest, AST_CHANNEL_SNAPSHOT_INVALIDATE_PEER);
|
2014-06-15 22:12:49 +00:00
|
|
|
ast_channel_publish_snapshot(dest);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
|
|
|
|
{
|
|
|
|
struct ast_channel_id temp;
|
|
|
|
|
2018-11-07 17:18:34 +00:00
|
|
|
/* This operation is used as part of masquerading and so does not invalidate the peer
|
|
|
|
* segment. This is due to the masquerade process invalidating all segments.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
temp = a->uniqueid;
|
|
|
|
a->uniqueid = b->uniqueid;
|
|
|
|
b->uniqueid = temp;
|
|
|
|
|
|
|
|
temp = a->linkedid;
|
|
|
|
a->linkedid = b->linkedid;
|
|
|
|
b->linkedid = temp;
|
|
|
|
}
|
|
|
|
|
2014-12-08 15:45:46 +00:00
|
|
|
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
|
|
|
|
{
|
2018-10-10 14:28:18 +00:00
|
|
|
struct stasis_topic *topic;
|
|
|
|
struct stasis_forward *forward;
|
2014-12-08 15:45:46 +00:00
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
topic = a->topic;
|
|
|
|
a->topic = b->topic;
|
|
|
|
b->topic = topic;
|
|
|
|
|
|
|
|
forward = a->channel_forward;
|
|
|
|
a->channel_forward = b->channel_forward;
|
|
|
|
b->channel_forward = forward;
|
|
|
|
}
|
|
|
|
|
2019-01-12 08:29:12 +00:00
|
|
|
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
|
|
|
|
{
|
|
|
|
struct stasis_forward *temp;
|
|
|
|
|
|
|
|
temp = a->endpoint_forward;
|
|
|
|
a->endpoint_forward = b->endpoint_forward;
|
|
|
|
b->endpoint_forward = temp;
|
|
|
|
}
|
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
|
|
|
|
{
|
|
|
|
struct ast_channel_snapshot *snapshot;
|
|
|
|
|
|
|
|
snapshot = a->snapshot;
|
|
|
|
a->snapshot = b->snapshot;
|
|
|
|
b->snapshot = snapshot;
|
2014-12-08 15:45:46 +00: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
|
|
|
void ast_channel_internal_set_fake_ids(struct ast_channel *chan, const char *uniqueid, const char *linkedid)
|
|
|
|
{
|
2014-03-20 16:35:57 +00:00
|
|
|
ast_copy_string(chan->uniqueid.unique_id, uniqueid, sizeof(chan->uniqueid.unique_id));
|
|
|
|
ast_copy_string(chan->linkedid.unique_id, linkedid, sizeof(chan->linkedid.unique_id));
|
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
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
void ast_channel_internal_cleanup(struct ast_channel *chan)
|
|
|
|
{
|
2012-07-20 15:48:55 +00:00
|
|
|
if (chan->dialed_causes) {
|
|
|
|
ao2_t_ref(chan->dialed_causes, -1,
|
|
|
|
"done with dialed causes since the channel is going away");
|
|
|
|
chan->dialed_causes = NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-13 18:20:34 +00:00
|
|
|
ast_string_field_free_memory(chan);
|
2013-03-08 15:15:13 +00:00
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
chan->channel_forward = stasis_forward_cancel(chan->channel_forward);
|
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
|
|
|
chan->endpoint_forward = stasis_forward_cancel(chan->endpoint_forward);
|
2013-03-08 15:15:13 +00:00
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
ao2_cleanup(chan->topic);
|
|
|
|
chan->topic = NULL;
|
2017-02-13 17:50:47 +00:00
|
|
|
|
|
|
|
ast_channel_internal_set_stream_topology(chan, NULL);
|
2017-03-08 13:24:46 +00:00
|
|
|
|
|
|
|
AST_VECTOR_FREE(&chan->fds);
|
2012-03-13 18:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_internal_finalize(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
chan->finalized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_internal_is_finalized(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->finalized;
|
|
|
|
}
|
2013-03-08 15:15:13 +00:00
|
|
|
|
|
|
|
struct stasis_topic *ast_channel_topic(struct ast_channel *chan)
|
|
|
|
{
|
2013-08-01 13:49:34 +00:00
|
|
|
if (!chan) {
|
|
|
|
return ast_channel_topic_all();
|
|
|
|
}
|
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
return chan->topic;
|
2013-08-01 13:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ast_channel_forward_endpoint(struct ast_channel *chan,
|
|
|
|
struct ast_endpoint *endpoint)
|
2013-05-08 13:39:08 +00:00
|
|
|
{
|
|
|
|
ast_assert(chan != NULL);
|
|
|
|
ast_assert(endpoint != NULL);
|
|
|
|
|
|
|
|
chan->endpoint_forward =
|
2013-08-01 13:49:34 +00:00
|
|
|
stasis_forward_all(ast_channel_topic(chan),
|
|
|
|
ast_endpoint_topic(endpoint));
|
ARI: Fix endpoint/channel subscription issues; allow for subscriptions to tech
This patch serves two purposes:
(1) It fixes some bugs with endpoint subscriptions not reporting all of the
channel events
(2) It serves as the preliminary work needed for ASTERISK-23692, which allows
for sending/receiving arbitrary out of call text messages through ARI in a
technology agnostic fashion.
The messaging functionality described on ASTERISK-23692 requires two things:
(1) The ability to send/receive messages associated with an endpoint. This is
relatively straight forwards with the endpoint core in Asterisk now.
(2) The ability to send/receive messages associated with a technology and an
arbitrary technology defined URI. This is less straight forward, as
endpoints are formed from a tech + resource pair. We don't have a
mechanism to note that a technology that *may* have endpoints exists.
This patch provides such a mechanism, and fixes a few bugs along the way.
The first major bug this patch fixes is the forwarding of channel messages
to their respective endpoints. Prior to this patch, there were two problems:
(1) Channel caching messages weren't forwarded. Thus, the endpoints missed
most of the interesting bits (such as channel creation, destruction, state
changes, etc.)
(2) Channels weren't associated with their endpoint until after creation.
This resulted in endpoints missing the channel creation message, which
limited the usefulness of the subscription in the first place (a major use
case being 'tell me when this endpoint has a channel'). Unfortunately,
this meant another parameter to ast_channel_alloc. Since not all channel
technologies support an ast_endpoint, this patch makes such a call
optional and opts for a new function, ast_channel_alloc_with_endpoint.
When endpoints are created, they will implicitly create a technology endpoint
for their technology (if one does not already exist). A technology endpoint is
special in that it has no state, cannot have channels created for it, cannot
be created explicitly, and cannot be destroyed except on shutdown. It does,
however, have all messages from other endpoints in its technology forwarded to
it.
Combined with the bug fixes, we now have Stasis messages being properly
forwarded. Consider the following scenario: two PJSIP endpoints (foo and bar),
where bar has a single channel associated with it and foo has two channels
associated with it. The messages would be forwarded as follows:
channel PJSIP/foo-1 --
\
--> endpoint PJSIP/foo --
/ \
channel PJSIP/foo-2 -- \
---- > endpoint PJSIP
/
channel PJSIP/bar-1 -----> endpoint PJSIP/bar --
ARI, through the applications resource, can:
- subscribe to endpoint:PJSIP/foo and get notifications for channels
PJSIP/foo-1,PJSIP/foo-2 and endpoint PJSIP/foo
- subscribe to endpoint:PJSIP/bar and get notifications for channels
PJSIP/bar-1 and endpoint PJSIP/bar
- subscribe to endpoint:PJSIP and get notifications for channels
PJSIP/foo-1,PJSIP/foo-2,PJSIP/bar-1 and endpoints PJSIP/foo,PJSIP/bar
Note that since endpoint PJSIP never changes, it never has events itself. It
merely provides an aggregation point for all other endpoints in its technology
(which in turn aggregate all channel messages associated with that endpoint).
This patch also adds endpoints to res_xmpp and chan_motif, because the actual
messaging work will need it (messaging without XMPP is just sad).
Review: https://reviewboard.asterisk.org/r/3760/
ASTERISK-23692
........
Merged revisions 419196 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419203 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-22 16:20:58 +00:00
|
|
|
if (!chan->endpoint_forward) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-05-08 13:39:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-01 13:49:34 +00:00
|
|
|
int ast_channel_internal_setup_topics(struct ast_channel *chan)
|
2013-03-08 15:15:13 +00: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
|
|
|
const char *topic_name = chan->uniqueid.unique_id;
|
2018-10-10 14:28:18 +00:00
|
|
|
ast_assert(chan->topic == NULL);
|
2013-03-08 16:25:58 +00:00
|
|
|
|
|
|
|
if (ast_strlen_zero(topic_name)) {
|
|
|
|
topic_name = "<dummy-channel>";
|
|
|
|
}
|
|
|
|
|
2018-10-10 14:28:18 +00:00
|
|
|
chan->topic = stasis_topic_create(topic_name);
|
|
|
|
if (!chan->topic) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
chan->channel_forward = stasis_forward_all(ast_channel_topic(chan),
|
|
|
|
ast_channel_topic_all());
|
|
|
|
if (!chan->channel_forward) {
|
|
|
|
ao2_ref(chan->topic, -1);
|
|
|
|
chan->topic = NULL;
|
2013-08-01 13:49:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2013-03-08 15:15:13 +00:00
|
|
|
}
|
2016-10-17 19:18:57 +00:00
|
|
|
|
|
|
|
AST_THREADSTORAGE(channel_errno);
|
|
|
|
|
|
|
|
void ast_channel_internal_errno_set(enum ast_channel_error error)
|
|
|
|
{
|
|
|
|
enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
|
|
|
|
if (!error_code) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*error_code = error;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum ast_channel_error ast_channel_internal_errno(void)
|
|
|
|
{
|
|
|
|
enum ast_channel_error *error_code = ast_threadstorage_get(&channel_errno, sizeof(*error_code));
|
|
|
|
if (!error_code) {
|
|
|
|
return AST_CHANNEL_ERROR_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *error_code;
|
|
|
|
}
|
2017-02-13 17:50:47 +00:00
|
|
|
|
|
|
|
struct ast_stream_topology *ast_channel_get_stream_topology(
|
|
|
|
const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
ast_assert(chan != NULL);
|
|
|
|
|
|
|
|
return chan->stream_topology;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ast_stream_topology *ast_channel_set_stream_topology(struct ast_channel *chan,
|
|
|
|
struct ast_stream_topology *topology)
|
|
|
|
{
|
|
|
|
struct ast_stream_topology *new_topology;
|
|
|
|
|
|
|
|
ast_assert(chan != NULL);
|
|
|
|
|
|
|
|
/* A non-MULTISTREAM channel can't manipulate topology directly */
|
2017-02-24 21:30:33 +00:00
|
|
|
ast_assert(ast_channel_is_multistream(chan));
|
2017-02-13 17:50:47 +00:00
|
|
|
|
|
|
|
/* Unless the channel is being destroyed, we always want a topology on
|
|
|
|
* it even if its empty.
|
|
|
|
*/
|
|
|
|
if (!topology) {
|
2017-02-16 14:28:33 +00:00
|
|
|
new_topology = ast_stream_topology_alloc();
|
2017-02-13 17:50:47 +00:00
|
|
|
} else {
|
|
|
|
new_topology = topology;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_topology) {
|
|
|
|
ast_channel_internal_set_stream_topology(chan, new_topology);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_topology;
|
|
|
|
}
|
|
|
|
|
2017-02-22 11:00:57 +00:00
|
|
|
struct ast_stream *ast_channel_get_default_stream(struct ast_channel *chan,
|
|
|
|
enum ast_media_type type)
|
|
|
|
{
|
|
|
|
ast_assert(chan != NULL);
|
|
|
|
ast_assert(type < AST_MEDIA_TYPE_END);
|
|
|
|
|
|
|
|
return chan->default_streams[type];
|
|
|
|
}
|
|
|
|
|
2017-02-13 17:50:47 +00:00
|
|
|
void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1,
|
|
|
|
struct ast_channel *chan2)
|
|
|
|
{
|
|
|
|
struct ast_stream_topology *tmp_topology;
|
|
|
|
|
|
|
|
ast_assert(chan1 != NULL && chan2 != NULL);
|
|
|
|
|
|
|
|
tmp_topology = chan1->stream_topology;
|
|
|
|
chan1->stream_topology = chan2->stream_topology;
|
|
|
|
chan2->stream_topology = tmp_topology;
|
|
|
|
|
|
|
|
channel_set_default_streams(chan1);
|
|
|
|
channel_set_default_streams(chan2);
|
|
|
|
}
|
2017-02-24 21:30:33 +00:00
|
|
|
|
|
|
|
int ast_channel_is_multistream(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return (chan->tech && chan->tech->read_stream && chan->tech->write_stream);
|
|
|
|
}
|
2018-10-10 14:28:18 +00:00
|
|
|
|
|
|
|
struct ast_channel_snapshot *ast_channel_snapshot(const struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return chan->snapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ast_channel_snapshot_set(struct ast_channel *chan, struct ast_channel_snapshot *snapshot)
|
|
|
|
{
|
|
|
|
ao2_cleanup(chan->snapshot);
|
|
|
|
chan->snapshot = ao2_bump(snapshot);
|
|
|
|
}
|
2018-11-07 17:18:34 +00:00
|
|
|
|
|
|
|
struct ast_flags *ast_channel_snapshot_segment_flags(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
return &chan->snapshot_segment_flags;
|
|
|
|
}
|