2001-12-25 21:12:07 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2001-12-25 21:12:07 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
2001-12-25 21:12:07 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2001-12-25 21:12:07 +00:00
|
|
|
*
|
|
|
|
* Includes code and algorithms from the Zapata library.
|
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2010-07-14 20:48:59 +00:00
|
|
|
* \brief ADSI support
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
2010-07-14 20:48:59 +00:00
|
|
|
* \author Mark Spencer <markster@digium.com>
|
2006-07-05 06:06:23 +00:00
|
|
|
*
|
|
|
|
* \note this module is required by app_voicemail and app_getcpeid
|
|
|
|
* \todo Move app_getcpeid into this module
|
|
|
|
* \todo Create a core layer so that app_voicemail does not require
|
|
|
|
* res_adsi to load
|
2001-12-25 21:12:07 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
2018-07-17 10:24:02 +00:00
|
|
|
<support_level>deprecated</support_level>
|
2011-07-14 20:28:54 +00:00
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <math.h>
|
2005-06-06 22:12:19 +00:00
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/ulaw.h"
|
|
|
|
#include "asterisk/alaw.h"
|
|
|
|
#include "asterisk/callerid.h"
|
|
|
|
#include "asterisk/fskmodem.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/config.h"
|
|
|
|
#include "asterisk/file.h"
|
2010-07-14 20:48:59 +00:00
|
|
|
#include "asterisk/adsi.h"
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
#include "asterisk/format_cache.h"
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
#define DEFAULT_ADSI_MAX_RETRIES 3
|
|
|
|
|
|
|
|
#define ADSI_MAX_INTRO 20
|
|
|
|
#define ADSI_MAX_SPEED_DIAL 6
|
|
|
|
|
|
|
|
#define ADSI_FLAG_DATAMODE (1 << 8)
|
|
|
|
|
|
|
|
static int maxretries = DEFAULT_ADSI_MAX_RETRIES;
|
|
|
|
|
|
|
|
/* Asterisk ADSI button definitions */
|
|
|
|
#define ADSI_SPEED_DIAL 10 /* 10-15 are reserved for speed dial */
|
|
|
|
|
|
|
|
static char intro[ADSI_MAX_INTRO][20];
|
|
|
|
static int aligns[ADSI_MAX_INTRO];
|
|
|
|
|
2007-11-14 13:18:40 +00:00
|
|
|
#define SPEEDDIAL_MAX_LEN 20
|
|
|
|
static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN];
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
static int alignment = 0;
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
|
|
|
|
static int adsi_end_download(struct ast_channel *chan);
|
|
|
|
static int adsi_channel_restore(struct ast_channel *chan);
|
|
|
|
static int adsi_print(struct ast_channel *chan, char **lines, int *align, int voice);
|
|
|
|
static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data);
|
|
|
|
static int adsi_unload_session(struct ast_channel *chan);
|
|
|
|
static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
|
|
|
|
static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
|
|
|
|
static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen);
|
|
|
|
static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver);
|
|
|
|
static int adsi_query_cpeid(unsigned char *buf);
|
|
|
|
static int adsi_query_cpeinfo(unsigned char *buf);
|
|
|
|
static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
|
|
|
|
static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
|
|
|
|
static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver);
|
|
|
|
static int adsi_disconnect_session(unsigned char *buf);
|
|
|
|
static int adsi_download_disconnect(unsigned char *buf);
|
|
|
|
static int adsi_data_mode(unsigned char *buf);
|
|
|
|
static int adsi_clear_soft_keys(unsigned char *buf);
|
|
|
|
static int adsi_clear_screen(unsigned char *buf);
|
|
|
|
static int adsi_voice_mode(unsigned char *buf, int when);
|
|
|
|
static int adsi_available(struct ast_channel *chan);
|
|
|
|
static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2);
|
|
|
|
static int adsi_set_line(unsigned char *buf, int page, int line);
|
|
|
|
static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data);
|
|
|
|
static int adsi_set_keys(unsigned char *buf, unsigned char *keys);
|
|
|
|
static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just);
|
|
|
|
static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2);
|
|
|
|
|
2011-02-03 16:22:10 +00:00
|
|
|
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, struct ast_format *codec)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int sum, x, bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Initial carrier (imaginary) */
|
2007-09-19 20:01:34 +00:00
|
|
|
float cr = 1.0, ci = 0.0, scont = 0.0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (msglen > 255) {
|
2001-12-25 21:12:07 +00:00
|
|
|
msglen = 255;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* If first message, Send 150ms of MARK's */
|
|
|
|
if (msgnum == 1) {
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < 150; x++) { /* was 150 */
|
2001-12-25 21:12:07 +00:00
|
|
|
PUT_CLID_MARKMS;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Put message type */
|
|
|
|
PUT_CLID(msgtype);
|
|
|
|
sum = msgtype;
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
/* Put message length (plus one for the message number) */
|
2001-12-25 21:12:07 +00:00
|
|
|
PUT_CLID(msglen + 1);
|
|
|
|
sum += msglen + 1;
|
|
|
|
|
|
|
|
/* Put message number */
|
|
|
|
PUT_CLID(msgnum);
|
|
|
|
sum += msgnum;
|
|
|
|
|
|
|
|
/* Put actual message */
|
2007-09-19 20:01:34 +00:00
|
|
|
for (x = 0; x < msglen; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
PUT_CLID(msg[x]);
|
|
|
|
sum += msg[x];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put 2's compliment of sum */
|
|
|
|
PUT_CLID(256-(sum & 0xff));
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (last) {
|
|
|
|
/* Put trailing marks */
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < 50; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
PUT_CLID_MARKMS;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-08-10 00:47:56 +00:00
|
|
|
static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int len, int *remain)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
|
|
|
/* Sends carefully on a full duplex channel by using reading for
|
|
|
|
timing */
|
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_frame *inf;
|
|
|
|
struct ast_frame outf = {
|
|
|
|
.frametype = AST_FRAME_VOICE,
|
|
|
|
.subclass.format = ast_format_ulaw,
|
|
|
|
.data.ptr = buf,
|
|
|
|
};
|
2001-12-25 21:12:07 +00:00
|
|
|
int amt;
|
|
|
|
|
2008-08-10 00:47:56 +00:00
|
|
|
if (remain && *remain) {
|
2001-12-25 21:12:07 +00:00
|
|
|
amt = len;
|
|
|
|
|
|
|
|
/* Send remainder if provided */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (amt > *remain) {
|
2008-08-10 00:47:56 +00:00
|
|
|
amt = *remain;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else {
|
2008-08-10 00:47:56 +00:00
|
|
|
*remain = *remain - amt;
|
2010-07-14 20:48:59 +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
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
outf.datalen = amt;
|
2003-02-04 15:48:42 +00:00
|
|
|
outf.samples = amt;
|
2001-12-25 21:12:07 +00:00
|
|
|
if (ast_write(chan, &outf)) {
|
|
|
|
ast_log(LOG_WARNING, "Failed to carefully write frame\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Update pointers and lengths */
|
|
|
|
buf += amt;
|
|
|
|
len -= amt;
|
|
|
|
}
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
while (len) {
|
2001-12-25 21:12:07 +00:00
|
|
|
amt = len;
|
|
|
|
/* If we don't get anything at all back in a second, forget
|
|
|
|
about it */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (ast_waitfor(chan, 1000) < 1) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Detect hangup */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!(inf = ast_read(chan))) {
|
2007-09-19 20:01:34 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
|
|
|
/* Drop any frames that are not voice */
|
|
|
|
if (inf->frametype != AST_FRAME_VOICE) {
|
|
|
|
ast_frfree(inf);
|
|
|
|
continue;
|
|
|
|
}
|
2010-07-14 20:48:59 +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
|
|
|
if (ast_format_cmp(inf->subclass.format, ast_format_ulaw) != AST_FORMAT_CMP_EQUAL) {
|
2007-09-19 20:01:34 +00:00
|
|
|
ast_log(LOG_WARNING, "Channel not in ulaw?\n");
|
|
|
|
ast_frfree(inf);
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
/* Send no more than they sent us */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (amt > inf->datalen) {
|
2007-09-19 20:01:34 +00:00
|
|
|
amt = inf->datalen;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else if (remain) {
|
2008-08-10 00:47:56 +00:00
|
|
|
*remain = inf->datalen - amt;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
outf.datalen = amt;
|
|
|
|
outf.samples = amt;
|
|
|
|
if (ast_write(chan, &outf)) {
|
|
|
|
ast_log(LOG_WARNING, "Failed to carefully write frame\n");
|
2007-11-24 17:07:12 +00:00
|
|
|
ast_frfree(inf);
|
2007-09-19 20:01:34 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Update pointers and lengths */
|
|
|
|
buf += amt;
|
|
|
|
len -= amt;
|
2001-12-25 21:12:07 +00:00
|
|
|
ast_frfree(inf);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
|
|
|
|
{
|
|
|
|
/* msglen must be no more than 256 bits, each */
|
|
|
|
unsigned char buf[24000 * 5];
|
2007-09-19 20:01:34 +00:00
|
|
|
int pos = 0, res, x, start = 0, retries = 0, waittime, rem = 0, def;
|
2001-12-25 21:12:07 +00:00
|
|
|
char ack[3];
|
|
|
|
struct ast_frame *f;
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_adsicpe(chan) == AST_ADSI_UNAVAILABLE) {
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Don't bother if we know they don't support ADSI */
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
while (retries < maxretries) {
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!(ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Generate CAS (no SAS) */
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
ast_gen_cas(buf, 0, 680, ast_format_ulaw);
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Send CAS */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (adsi_careful_send(chan, buf, 680, NULL)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to send CAS\n");
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Wait For DTMF result */
|
|
|
|
waittime = 500;
|
2010-07-14 20:48:59 +00:00
|
|
|
for (;;) {
|
2001-12-25 21:12:07 +00:00
|
|
|
if (((res = ast_waitfor(chan, waittime)) < 1)) {
|
|
|
|
/* Didn't get back DTMF A in time */
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "No ADSI CPE detected (%d)\n", res);
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!ast_channel_adsicpe(chan)) {
|
|
|
|
ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
waittime = res;
|
2007-09-19 20:01:34 +00:00
|
|
|
if (!(f = ast_read(chan))) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Hangup in ADSI\n");
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (f->frametype == AST_FRAME_DTMF) {
|
2009-11-04 14:05:12 +00:00
|
|
|
if (f->subclass.integer == 'A') {
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Okay, this is an ADSI CPE. Note this for future reference, too */
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!ast_channel_adsicpe(chan)) {
|
|
|
|
ast_channel_adsicpe_set(chan, AST_ADSI_AVAILABLE);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
break;
|
|
|
|
} else {
|
2010-07-14 20:48:59 +00:00
|
|
|
if (f->subclass.integer == 'D') {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
|
2010-07-14 20:48:59 +00:00
|
|
|
} else {
|
2009-11-04 14:05:12 +00:00
|
|
|
ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!ast_channel_adsicpe(chan)) {
|
|
|
|
ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
errno = ENOSYS;
|
2007-11-24 17:07:12 +00:00
|
|
|
ast_frfree(f);
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
|
|
|
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "ADSI Compatible CPE Detected\n");
|
2006-10-03 15:53:07 +00:00
|
|
|
} else {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Already in data mode\n");
|
2006-10-03 15:53:07 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
x = 0;
|
|
|
|
pos = 0;
|
2002-03-11 14:30:21 +00:00
|
|
|
#if 1
|
2001-12-25 21:12:07 +00:00
|
|
|
def= ast_channel_defer_dtmf(chan);
|
|
|
|
#endif
|
2007-09-19 20:01:34 +00:00
|
|
|
while ((x < 6) && msg[x]) {
|
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
|
|
|
if ((res = adsi_generate(buf + pos, msgtype[x], msg[x], msglen[x], x+1 - start, (x == 5) || !msg[x+1], ast_format_ulaw)) < 0) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, ast_channel_name(chan));
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
|
2010-07-14 20:48:59 +00:00
|
|
|
pos += res;
|
2001-12-25 21:12:07 +00:00
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rem = 0;
|
2010-07-14 20:48:59 +00:00
|
|
|
res = adsi_careful_send(chan, buf, pos, &rem);
|
|
|
|
if (!def) {
|
2002-03-11 14:30:21 +00:00
|
|
|
ast_channel_undefer_dtmf(chan);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (res) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Sent total spill of %d bytes\n", pos);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
memset(ack, 0, sizeof(ack));
|
2007-09-19 20:01:34 +00:00
|
|
|
/* Get real result and check for hangup */
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res = ast_readstring(chan, ack, 2, 1000, 1000, "")) < 0) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
if (ack[0] == 'D') {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
|
2010-07-14 20:48:59 +00:00
|
|
|
if (start >= x) {
|
2001-12-25 21:12:07 +00:00
|
|
|
break;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else {
|
2001-12-25 21:12:07 +00:00
|
|
|
retries++;
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Retransmitting (%d), from %d\n", retries, start + 1);
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
retries++;
|
|
|
|
ast_log(LOG_WARNING, "Unexpected response to ack: %s (retry %d)\n", ack, retries);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
if (retries >= maxretries) {
|
|
|
|
ast_log(LOG_WARNING, "Maximum ADSI Retries (%d) exceeded\n", maxretries);
|
|
|
|
errno = ETIMEDOUT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
unsigned char buf[256];
|
|
|
|
char ack[2];
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
/* Setup the resident soft key stuff, a piece at a time */
|
|
|
|
/* Upload what scripts we can for voicemail ahead of time */
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
|
|
|
|
if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (ast_readstring(chan, ack, 1, 10000, 10000, "")) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (ack[0] == 'B') {
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Download was denied by CPE\n");
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_end_download(struct ast_channel *chan)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
unsigned char buf[256];
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
/* Setup the resident soft key stuff, a piece at a time */
|
|
|
|
/* Upload what scripts we can for voicemail ahead of time */
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_download_disconnect(buf + bytes);
|
|
|
|
if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
|
|
|
unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
|
2012-02-20 23:43:27 +00:00
|
|
|
int msglens[5], msgtypes[5], newdatamode = (ast_channel_adsicpe(chan) & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
|
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
|
|
|
RAII_VAR(struct ast_format *, writeformat, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct ast_format *, readformat, NULL, ao2_cleanup);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2007-09-19 20:01:34 +00:00
|
|
|
for (x = 0; x < msglen; x += (msg[x+1]+2)) {
|
2005-04-06 05:11:48 +00:00
|
|
|
if (msg[x] == ADSI_SWITCH_TO_DATA) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Switch to data is sent!\n");
|
2005-04-06 05:11:48 +00:00
|
|
|
waitforswitch++;
|
2001-12-25 21:12:07 +00:00
|
|
|
newdatamode = ADSI_FLAG_DATAMODE;
|
2005-04-06 05:11:48 +00:00
|
|
|
}
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2005-04-06 05:11:48 +00:00
|
|
|
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Switch to voice is sent!\n");
|
2005-04-06 05:11:48 +00:00
|
|
|
waitforswitch++;
|
2001-12-25 21:12:07 +00:00
|
|
|
newdatamode = 0;
|
2005-04-06 05:11:48 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
msgs[0] = msg;
|
|
|
|
|
|
|
|
msglens[0] = msglen;
|
|
|
|
msgtypes[0] = msgtype;
|
|
|
|
|
|
|
|
if (msglen > 253) {
|
|
|
|
ast_log(LOG_WARNING, "Can't send ADSI message of %d bytes, too large\n", msglen);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_stopstream(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
|
|
|
writeformat = ao2_bump(ast_channel_writeformat(chan));
|
|
|
|
readformat = ao2_bump(ast_channel_readformat(chan));
|
|
|
|
|
|
|
|
if (ast_set_write_format(chan, ast_format_ulaw)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to set write format to ULAW\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (ast_set_read_format(chan, ast_format_ulaw)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to set read format to ULAW\n");
|
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
|
|
|
if (writeformat) {
|
|
|
|
if (ast_set_write_format(chan, writeformat)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to restore write format to %s\n", ast_format_get_name(writeformat));
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
|
2005-04-06 05:11:48 +00:00
|
|
|
|
|
|
|
if (dowait) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Wait for switch is '%d'\n", waitforswitch);
|
2010-07-14 20:48:59 +00:00
|
|
|
while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) {
|
|
|
|
res = 0;
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Waiting for 'B'...\n");
|
2006-10-03 15:53:07 +00:00
|
|
|
}
|
2005-04-06 05:11:48 +00:00
|
|
|
}
|
2010-07-14 20:48:59 +00:00
|
|
|
|
|
|
|
if (!res) {
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_adsicpe_set(chan, (ast_channel_adsicpe(chan) & ~ADSI_FLAG_DATAMODE) | newdatamode);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +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
|
|
|
if (writeformat) {
|
|
|
|
ast_set_write_format(chan, writeformat);
|
2010-07-14 20:48:59 +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
|
|
|
if (readformat) {
|
|
|
|
ast_set_read_format(chan, readformat);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!res) {
|
2005-03-20 07:32:03 +00:00
|
|
|
res = ast_safe_sleep(chan, 100 );
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
|
2005-04-06 05:11:48 +00:00
|
|
|
{
|
2012-06-25 15:55:25 +00:00
|
|
|
return adsi_transmit_message_full(chan, msg, msglen, msgtype, 1);
|
2005-04-06 05:11:48 +00:00
|
|
|
}
|
|
|
|
|
2006-04-14 22:02:19 +00:00
|
|
|
static inline int ccopy(unsigned char *dst, const unsigned char *src, int max)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int x = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Carefully copy the requested data */
|
|
|
|
while ((x < max) && src[x] && (src[x] != 0xff)) {
|
|
|
|
dst[x] = src[x];
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Abort if invalid key specified */
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((key < 2) || (key > 33)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = ADSI_LOAD_SOFTKEY;
|
|
|
|
/* Reserve for length */
|
|
|
|
bytes++;
|
|
|
|
/* Which key */
|
|
|
|
buf[bytes++] = key;
|
|
|
|
|
|
|
|
/* Carefully copy long label */
|
2006-04-14 22:02:19 +00:00
|
|
|
bytes += ccopy(buf + bytes, (const unsigned char *)llabel, 18);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Place delimiter */
|
|
|
|
buf[bytes++] = 0xff;
|
|
|
|
|
|
|
|
/* Short label */
|
2006-04-14 22:02:19 +00:00
|
|
|
bytes += ccopy(buf + bytes, (const unsigned char *)slabel, 7);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* If specified, copy return string */
|
|
|
|
if (ret) {
|
|
|
|
/* Place delimiter */
|
|
|
|
buf[bytes++] = 0xff;
|
2010-07-14 20:48:59 +00:00
|
|
|
if (data) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = ADSI_SWITCH_TO_DATA2;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Carefully copy return string */
|
2006-04-14 22:02:19 +00:00
|
|
|
bytes += ccopy(buf + bytes, (const unsigned char *)ret, 20);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
/* Replace parameter length */
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0, x;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_CONNECT_SESSION;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
if (fdn) {
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < 4; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = fdn[x];
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (ver > -1) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = ver & 0xff;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0, x;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_DOWNLOAD_CONNECT;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
/* Primary column */
|
2005-09-07 18:55:03 +00:00
|
|
|
bytes+= ccopy(buf + bytes, (unsigned char *)service, 18);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Delimiter */
|
|
|
|
buf[bytes++] = 0xff;
|
2010-07-14 20:48:59 +00:00
|
|
|
|
|
|
|
for (x = 0; x < 4; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = fdn[x];
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < 4; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = sec[x];
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2002-06-21 01:40:13 +00:00
|
|
|
buf[bytes++] = ver & 0xff;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
2002-06-21 01:40:13 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_disconnect_session(unsigned char *buf)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_DISC_SESSION;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_query_cpeid(unsigned char *buf)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
|
|
|
int bytes = 0;
|
|
|
|
buf[bytes++] = ADSI_QUERY_CPEID;
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_query_cpeinfo(unsigned char *buf)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
|
|
|
int bytes = 0;
|
|
|
|
buf[bytes++] = ADSI_QUERY_CONFIG;
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0, res, gotstar = 0, pos = 0;
|
2002-06-21 01:40:13 +00:00
|
|
|
unsigned char current = 0;
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2012-03-14 00:29:47 +00:00
|
|
|
memset(buf, 0, maxlen);
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
while (bytes <= maxlen) {
|
2002-06-21 01:40:13 +00:00
|
|
|
/* Wait up to a second for a digit */
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!(res = ast_waitfordigit(chan, 1000))) {
|
2002-06-21 01:40:13 +00:00
|
|
|
break;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
if (res == '*') {
|
2010-07-14 20:48:59 +00:00
|
|
|
gotstar = 1;
|
2002-06-21 01:40:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Ignore anything other than a digit */
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res < '0') || (res > '9')) {
|
2002-06-21 01:40:13 +00:00
|
|
|
continue;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
res -= '0';
|
2010-07-14 20:48:59 +00:00
|
|
|
if (gotstar) {
|
2002-06-21 01:40:13 +00:00
|
|
|
res += 9;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
if (pos) {
|
|
|
|
pos = 0;
|
|
|
|
buf[bytes++] = (res << 4) | current;
|
|
|
|
} else {
|
|
|
|
pos = 1;
|
|
|
|
current = res;
|
|
|
|
}
|
|
|
|
gotstar = 0;
|
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2002-06-21 01:40:13 +00:00
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
unsigned char buf[256] = "";
|
|
|
|
int bytes = 0, res;
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_data_mode(buf);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
bytes = 0;
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_query_cpeid(buf);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
/* Get response */
|
2012-06-25 15:55:25 +00:00
|
|
|
res = adsi_read_encoded_dtmf(chan, cpeid, 4);
|
2002-06-21 01:40:13 +00:00
|
|
|
if (res != 4) {
|
|
|
|
ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res);
|
|
|
|
res = 0;
|
|
|
|
} else {
|
|
|
|
res = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (voice) {
|
|
|
|
bytes = 0;
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_voice_mode(buf, 0);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
|
|
|
ast_waitfordigit(chan, 1000);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
unsigned char buf[256] = "";
|
|
|
|
int bytes = 0, res;
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_data_mode(buf);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
bytes = 0;
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_query_cpeinfo(buf);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
/* Get width */
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res = ast_readstring(chan, (char *) buf, 2, 1000, 500, "")) < 0) {
|
2002-06-21 01:40:13 +00:00
|
|
|
return res;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (strlen((char *) buf) != 2) {
|
2002-06-21 01:40:13 +00:00
|
|
|
ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res);
|
|
|
|
res = 0;
|
|
|
|
} else {
|
|
|
|
res = 1;
|
|
|
|
}
|
2010-07-14 20:48:59 +00:00
|
|
|
if (width) {
|
|
|
|
*width = atoi((char *) buf);
|
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
/* Get height */
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
if (res) {
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res = ast_readstring(chan, (char *) buf, 2, 1000, 500, "")) < 0) {
|
2002-06-21 01:40:13 +00:00
|
|
|
return res;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (strlen((char *) buf) != 2) {
|
2002-06-21 01:40:13 +00:00
|
|
|
ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res);
|
|
|
|
res = 0;
|
|
|
|
} else {
|
|
|
|
res = 1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (height) {
|
|
|
|
*height = atoi((char *) buf);
|
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
}
|
|
|
|
/* Get buttons */
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
if (res) {
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res = ast_readstring(chan, (char *) buf, 1, 1000, 500, "")) < 0) {
|
2002-06-21 01:40:13 +00:00
|
|
|
return res;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (strlen((char *) buf) != 1) {
|
2002-06-21 01:40:13 +00:00
|
|
|
ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res);
|
|
|
|
res = 0;
|
|
|
|
} else {
|
|
|
|
res = 1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
if (buttons) {
|
|
|
|
*buttons = atoi((char *) buf);
|
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
}
|
|
|
|
if (voice) {
|
|
|
|
bytes = 0;
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_voice_mode(buf, 0);
|
|
|
|
adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2002-06-21 01:40:13 +00:00
|
|
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
|
|
|
ast_waitfordigit(chan, 1000);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_data_mode(unsigned char *buf)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_SWITCH_TO_DATA;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_clear_soft_keys(unsigned char *buf)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_CLEAR_SOFTKEY;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_clear_screen(unsigned char *buf)
|
2002-06-21 01:40:13 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2002-06-21 01:40:13 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_CLEAR_SCREEN;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_voice_mode(unsigned char *buf, int when)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_SWITCH_TO_VOICE;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[bytes++] = when & 0x7f;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_available(struct ast_channel *chan)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2012-02-20 23:43:27 +00:00
|
|
|
int cpe = ast_channel_adsicpe(chan) & 0xff;
|
2001-12-25 21:12:07 +00:00
|
|
|
if ((cpe == AST_ADSI_AVAILABLE) ||
|
2010-07-14 20:48:59 +00:00
|
|
|
(cpe == AST_ADSI_UNKNOWN)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return 1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_download_disconnect(unsigned char *buf)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_DOWNLOAD_DISC;
|
|
|
|
|
|
|
|
/* Reserve space for length */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_display(unsigned char *buf, int page, int line, int just, int wrap,
|
2007-05-18 09:10:22 +00:00
|
|
|
char *col1, char *col2)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Sanity check line number */
|
|
|
|
|
|
|
|
if (page) {
|
|
|
|
if (line > 4) return -1;
|
|
|
|
} else {
|
|
|
|
if (line > 33) return -1;
|
|
|
|
}
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (line < 1) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Parameter type */
|
|
|
|
buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP;
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Reserve space for size */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
/* Page and wrap indicator */
|
|
|
|
buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
|
|
|
|
|
|
|
|
/* Justification */
|
|
|
|
buf[bytes++] = (just & 0x3) << 5;
|
|
|
|
|
|
|
|
/* Omit highlight mode definition */
|
|
|
|
buf[bytes++] = 0xff;
|
|
|
|
|
|
|
|
/* Primary column */
|
2005-09-07 18:55:03 +00:00
|
|
|
bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Delimiter */
|
|
|
|
buf[bytes++] = 0xff;
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Secondary column */
|
2005-09-07 18:55:03 +00:00
|
|
|
bytes += ccopy(buf + bytes, (unsigned char *)col2, 20);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Update length */
|
|
|
|
buf[1] = bytes - 2;
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
return bytes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
if (page) {
|
2001-12-25 21:12:07 +00:00
|
|
|
if (line > 4) return -1;
|
|
|
|
} else {
|
|
|
|
if (line > 33) return -1;
|
|
|
|
}
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (line < 1) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
buf[bytes++] = ADSI_INPUT_CONTROL;
|
|
|
|
bytes++;
|
|
|
|
buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
|
|
|
|
buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
|
|
|
int bytes = 0;
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (ast_strlen_zero((char *) format1)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
buf[bytes++] = ADSI_INPUT_FORMAT;
|
|
|
|
bytes++;
|
|
|
|
buf[bytes++] = ((dir & 1) << 7) | ((wrap & 1) << 6) | (num & 0x7);
|
2010-07-14 20:48:59 +00:00
|
|
|
bytes += ccopy(buf + bytes, (unsigned char *) format1, 20);
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = 0xff;
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!ast_strlen_zero(format2)) {
|
|
|
|
bytes += ccopy(buf + bytes, (unsigned char *) format2, 20);
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_set_keys(unsigned char *buf, unsigned char *keys)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0, x;
|
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Message type */
|
|
|
|
buf[bytes++] = ADSI_INIT_SOFTKEY_LINE;
|
|
|
|
/* Space for size */
|
|
|
|
bytes++;
|
|
|
|
/* Key definitions */
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < 6; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[bytes++] = (keys[x] & 0x3f) ? keys[x] : (keys[x] | 0x1);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_set_line(unsigned char *buf, int page, int line)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Sanity check line number */
|
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
if (page) {
|
2001-12-25 21:12:07 +00:00
|
|
|
if (line > 4) return -1;
|
|
|
|
} else {
|
|
|
|
if (line > 33) return -1;
|
|
|
|
}
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (line < 1) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Parameter type */
|
|
|
|
buf[bytes++] = ADSI_LINE_CONTROL;
|
2010-07-14 20:48:59 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
/* Reserve space for size */
|
|
|
|
bytes++;
|
|
|
|
|
|
|
|
/* Page and line */
|
|
|
|
buf[bytes++] = ((page & 0x1) << 7) | (line & 0x3f);
|
|
|
|
|
|
|
|
buf[1] = bytes - 2;
|
|
|
|
return bytes;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
static int total = 0;
|
|
|
|
static int speeds = 0;
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_channel_restore(struct ast_channel *chan)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
unsigned char dsp[256] = "", keyd[6] = "";
|
|
|
|
int bytes, x;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Start with initial display setup */
|
|
|
|
bytes = 0;
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Prepare key setup messages */
|
|
|
|
|
|
|
|
if (speeds) {
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < speeds; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
keyd[x] = ADSI_SPEED_DIAL + x;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_set_keys(dsp + bytes, keyd);
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
2012-06-25 15:55:25 +00:00
|
|
|
adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
2002-06-21 01:40:13 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_print(struct ast_channel *chan, char **lines, int *alignments, int voice)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2005-08-08 01:16:44 +00:00
|
|
|
unsigned char buf[4096];
|
2007-09-19 20:01:34 +00:00
|
|
|
int bytes = 0, res, x;
|
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; lines[x]; x++) {
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_display(buf + bytes, ADSI_INFO_PAGE, x+1, alignments[x], 0, lines[x], "");
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_set_line(buf + bytes, ADSI_INFO_PAGE, 1);
|
2010-07-14 20:48:59 +00:00
|
|
|
if (voice) {
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_voice_mode(buf + bytes, 0);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2012-06-25 15:55:25 +00:00
|
|
|
res = adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
|
2010-07-14 20:48:59 +00:00
|
|
|
if (voice) {
|
2002-06-21 01:40:13 +00:00
|
|
|
/* Ignore the resulting DTMF B announcing it's in voice mode */
|
|
|
|
ast_waitfordigit(chan, 1000);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
return res;
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
unsigned char dsp[256] = "";
|
|
|
|
int bytes = 0, res;
|
2001-12-25 21:12:07 +00:00
|
|
|
char resp[2];
|
|
|
|
|
|
|
|
/* Connect to session */
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_connect_session(dsp + bytes, app, ver);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
if (data) {
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_data_mode(dsp + bytes);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Prepare key setup messages */
|
2012-06-25 15:55:25 +00:00
|
|
|
if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
if (app) {
|
2010-07-14 20:48:59 +00:00
|
|
|
if ((res = ast_readstring(chan, resp, 1, 1200, 1200, "")) < 0) {
|
2002-06-21 01:40:13 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2002-06-21 01:40:13 +00:00
|
|
|
if (res) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "No response from CPE about version. Assuming not there.\n");
|
2002-06-21 01:40:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!strcmp(resp, "B")) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "CPE has script '%s' version %d already loaded\n", app, ver);
|
2002-06-21 01:40:13 +00:00
|
|
|
return 1;
|
|
|
|
} else if (!strcmp(resp, "A")) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
|
2002-06-21 01:40:13 +00:00
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp);
|
|
|
|
}
|
|
|
|
} else
|
2001-12-25 21:12:07 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static int adsi_unload_session(struct ast_channel *chan)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
unsigned char dsp[256] = "";
|
|
|
|
int bytes = 0;
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Connect to session */
|
2012-06-25 15:55:25 +00:00
|
|
|
bytes += adsi_disconnect_session(dsp + bytes);
|
|
|
|
bytes += adsi_voice_mode(dsp + bytes, 0);
|
2001-12-25 21:12:07 +00:00
|
|
|
|
|
|
|
/* Prepare key setup messages */
|
2012-06-25 15:55:25 +00:00
|
|
|
if (adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-14 13:18:40 +00:00
|
|
|
static int str2align(const char *s)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!strncasecmp(s, "l", 1)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return ADSI_JUST_LEFT;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else if (!strncasecmp(s, "r", 1)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return ADSI_JUST_RIGHT;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else if (!strncasecmp(s, "i", 1)) {
|
2001-12-25 21:12:07 +00:00
|
|
|
return ADSI_JUST_IND;
|
2010-07-14 20:48:59 +00:00
|
|
|
} else {
|
2001-12-25 21:12:07 +00:00
|
|
|
return ADSI_JUST_CENT;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void init_state(void)
|
|
|
|
{
|
|
|
|
int x;
|
2002-03-11 14:30:21 +00:00
|
|
|
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 0; x < ADSI_MAX_INTRO; x++) {
|
2001-12-25 21:12:07 +00:00
|
|
|
aligns[x] = ADSI_JUST_CENT;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2006-04-21 18:13:21 +00:00
|
|
|
ast_copy_string(intro[0], "Welcome to the", sizeof(intro[0]));
|
|
|
|
ast_copy_string(intro[1], "Asterisk", sizeof(intro[1]));
|
|
|
|
ast_copy_string(intro[2], "Open Source PBX", sizeof(intro[2]));
|
2001-12-25 21:12:07 +00:00
|
|
|
total = 3;
|
|
|
|
speeds = 0;
|
2010-07-14 20:48:59 +00:00
|
|
|
for (x = 3; x < ADSI_MAX_INTRO; x++) {
|
2004-07-14 13:57:15 +00:00
|
|
|
intro[x][0] = '\0';
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
memset(speeddial, 0, sizeof(speeddial));
|
|
|
|
alignment = ADSI_JUST_CENT;
|
|
|
|
}
|
|
|
|
|
2007-12-01 01:37:50 +00:00
|
|
|
static void adsi_load(int reload)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-09-19 20:01:34 +00:00
|
|
|
int x = 0;
|
|
|
|
struct ast_config *conf = NULL;
|
2001-12-25 21:12:07 +00:00
|
|
|
struct ast_variable *v;
|
2007-12-01 01:37:50 +00:00
|
|
|
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
|
2001-12-25 21:12:07 +00:00
|
|
|
char *name, *sname;
|
|
|
|
init_state();
|
2007-09-19 20:01:34 +00:00
|
|
|
|
2008-09-12 23:30:03 +00:00
|
|
|
conf = ast_config_load("adsi.conf", config_flags);
|
|
|
|
if (conf == CONFIG_STATUS_FILEMISSING || conf == CONFIG_STATUS_FILEUNCHANGED || conf == CONFIG_STATUS_FILEINVALID) {
|
2007-12-01 01:37:50 +00:00
|
|
|
return;
|
2008-09-12 23:30:03 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
for (v = ast_variable_browse(conf, "intro"); v; v = v->next) {
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!strcasecmp(v->name, "alignment")) {
|
2007-09-19 20:01:34 +00:00
|
|
|
alignment = str2align(v->value);
|
2010-07-14 20:48:59 +00:00
|
|
|
} else if (!strcasecmp(v->name, "greeting")) {
|
2007-09-19 20:01:34 +00:00
|
|
|
if (x < ADSI_MAX_INTRO) {
|
|
|
|
aligns[x] = alignment;
|
|
|
|
ast_copy_string(intro[x], v->value, sizeof(intro[x]));
|
2001-12-25 21:12:07 +00:00
|
|
|
x++;
|
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
} else if (!strcasecmp(v->name, "maxretries")) {
|
2010-07-14 20:48:59 +00:00
|
|
|
if (atoi(v->value) > 0) {
|
2007-09-19 20:01:34 +00:00
|
|
|
maxretries = atoi(v->value);
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-14 20:48:59 +00:00
|
|
|
if (x) {
|
2007-09-19 20:01:34 +00:00
|
|
|
total = x;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
|
|
|
|
2007-09-19 20:01:34 +00:00
|
|
|
x = 0;
|
|
|
|
for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) {
|
2007-11-14 13:18:40 +00:00
|
|
|
char buf[3 * SPEEDDIAL_MAX_LEN];
|
|
|
|
char *stringp = buf;
|
|
|
|
ast_copy_string(buf, v->value, sizeof(buf));
|
2007-09-19 20:01:34 +00:00
|
|
|
name = strsep(&stringp, ",");
|
|
|
|
sname = strsep(&stringp, ",");
|
2010-07-14 20:48:59 +00:00
|
|
|
if (!sname) {
|
2007-09-19 20:01:34 +00:00
|
|
|
sname = name;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
if (x < ADSI_MAX_SPEED_DIAL) {
|
|
|
|
ast_copy_string(speeddial[x][0], v->name, sizeof(speeddial[x][0]));
|
|
|
|
ast_copy_string(speeddial[x][1], name, 18);
|
|
|
|
ast_copy_string(speeddial[x][2], sname, 7);
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
}
|
2010-07-14 20:48:59 +00:00
|
|
|
if (x) {
|
2007-09-19 20:01:34 +00:00
|
|
|
speeds = x;
|
2010-07-14 20:48:59 +00:00
|
|
|
}
|
2007-09-19 20:01:34 +00:00
|
|
|
ast_config_destroy(conf);
|
|
|
|
|
|
|
|
return;
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int reload(void)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-12-01 01:37:50 +00:00
|
|
|
adsi_load(1);
|
2001-12-25 21:12:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
static struct adsi_funcs res_adsi_funcs = {
|
|
|
|
.version = AST_ADSI_VERSION,
|
|
|
|
.begin_download = adsi_begin_download,
|
|
|
|
.end_download = adsi_end_download,
|
|
|
|
.channel_restore = adsi_channel_restore,
|
|
|
|
.print = adsi_print,
|
|
|
|
.load_session = adsi_load_session,
|
|
|
|
.unload_session = adsi_unload_session,
|
|
|
|
.transmit_message = adsi_transmit_message,
|
|
|
|
.transmit_message_full = adsi_transmit_message_full,
|
|
|
|
.read_encoded_dtmf = adsi_read_encoded_dtmf,
|
|
|
|
.connect_session = adsi_connect_session,
|
|
|
|
.query_cpeid = adsi_query_cpeid,
|
|
|
|
.query_cpeinfo = adsi_query_cpeinfo,
|
|
|
|
.get_cpeid = adsi_get_cpeid,
|
|
|
|
.get_cpeinfo = adsi_get_cpeinfo,
|
|
|
|
.download_connect = adsi_download_connect,
|
|
|
|
.disconnect_session = adsi_disconnect_session,
|
|
|
|
.download_disconnect = adsi_download_disconnect,
|
|
|
|
.data_mode = adsi_data_mode,
|
|
|
|
.clear_soft_keys = adsi_clear_soft_keys,
|
|
|
|
.clear_screen = adsi_clear_screen,
|
|
|
|
.voice_mode = adsi_voice_mode,
|
|
|
|
.available = adsi_available,
|
|
|
|
.display = adsi_display,
|
|
|
|
.set_line = adsi_set_line,
|
|
|
|
.load_soft_key = adsi_load_soft_key,
|
|
|
|
.set_keys = adsi_set_keys,
|
|
|
|
.input_control = adsi_input_control,
|
|
|
|
.input_format = adsi_input_format,
|
|
|
|
};
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
2007-12-01 01:37:50 +00:00
|
|
|
adsi_load(0);
|
2012-06-25 15:55:25 +00:00
|
|
|
ast_adsi_install_funcs(&res_adsi_funcs);
|
2007-10-31 19:24:29 +00:00
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
2001-12-25 21:12:07 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2001-12-25 21:12:07 +00:00
|
|
|
{
|
|
|
|
/* Can't unload this once we're loaded */
|
2012-06-25 15:55:25 +00:00
|
|
|
ast_adsi_install_funcs(NULL);
|
2001-12-25 21:12:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-25 15:55:25 +00:00
|
|
|
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ADSI Resource",
|
2018-07-17 10:24:02 +00:00
|
|
|
.support_level = AST_MODULE_SUPPORT_DEPRECATED,
|
2015-05-06 00:49:04 +00:00
|
|
|
.load = load_module,
|
|
|
|
.unload = unload_module,
|
|
|
|
.reload = reload,
|
|
|
|
.load_pri = AST_MODPRI_APP_DEPEND,
|
|
|
|
);
|