2001-04-13 02:12:18 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2001-04-13 02:12:18 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Matthew Fredrickson <creslin@digium.com>
|
2001-04-13 02:12:18 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2001-04-13 02:12:18 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Trivial application to record a sound file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-12-30 21:18:06 +00:00
|
|
|
* \author Matthew Fredrickson <creslin@digium.com>
|
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2001-04-13 02:12:18 +00:00
|
|
|
*/
|
2011-07-14 20:28:54 +00:00
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2005-06-06 22:39:32 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
2006-09-07 23:15:43 +00:00
|
|
|
#include "asterisk/app.h"
|
2007-11-22 03:50:04 +00:00
|
|
|
#include "asterisk/channel.h"
|
2007-11-22 01:39:06 +00:00
|
|
|
#include "asterisk/dsp.h" /* use dsp routines for silence detection */
|
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"
|
2017-08-25 17:20:16 +00:00
|
|
|
#include "asterisk/paths.h"
|
2001-04-13 02:12:18 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Record" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Record to a file.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="filename" required="true" argsep=".">
|
|
|
|
<argument name="filename" required="true" />
|
|
|
|
<argument name="format" required="true">
|
|
|
|
<para>Is the format of the file type to be recorded (wav, gsm, etc).</para>
|
|
|
|
</argument>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="silence">
|
|
|
|
<para>Is the number of seconds of silence to allow before returning.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="maxduration">
|
|
|
|
<para>Is the maximum recording duration in seconds. If missing
|
|
|
|
or 0 there is no maximum.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<optionlist>
|
|
|
|
<option name="a">
|
|
|
|
<para>Append to existing recording rather than replacing.</para>
|
|
|
|
</option>
|
|
|
|
<option name="n">
|
|
|
|
<para>Do not answer, but record anyway if line not yet answered.</para>
|
|
|
|
</option>
|
2013-12-05 23:40:38 +00:00
|
|
|
<option name="o">
|
|
|
|
<para>Exit when 0 is pressed, setting the variable <variable>RECORD_STATUS</variable>
|
|
|
|
to <literal>OPERATOR</literal> instead of <literal>DTMF</literal></para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
<option name="q">
|
|
|
|
<para>quiet (do not play a beep tone).</para>
|
|
|
|
</option>
|
|
|
|
<option name="s">
|
|
|
|
<para>skip recording if the line is not yet answered.</para>
|
|
|
|
</option>
|
|
|
|
<option name="t">
|
|
|
|
<para>use alternate '*' terminator key (DTMF) instead of default '#'</para>
|
|
|
|
</option>
|
2017-02-14 14:12:31 +00:00
|
|
|
<option name="u">
|
|
|
|
<para>Don't truncate recorded silence.</para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
<option name="x">
|
|
|
|
<para>Ignore all terminator keys (DTMF) and keep recording until hangup.</para>
|
|
|
|
</option>
|
2009-02-13 16:41:15 +00:00
|
|
|
<option name="k">
|
2010-03-10 20:53:43 +00:00
|
|
|
<para>Keep recorded file upon hangup.</para>
|
2009-12-02 18:35:47 +00:00
|
|
|
</option>
|
|
|
|
<option name="y">
|
|
|
|
<para>Terminate recording if *any* DTMF digit is received.</para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>If filename contains <literal>%d</literal>, these characters will be replaced with a number
|
|
|
|
incremented by one each time the file is recorded.
|
|
|
|
Use <astcli>core show file formats</astcli> to see the available formats on your system
|
|
|
|
User can press <literal>#</literal> to terminate the recording and continue to the next priority.
|
2008-11-02 02:57:27 +00:00
|
|
|
If the user hangs up during a recording, all data will be lost and the application will terminate.</para>
|
2008-11-01 21:10:07 +00:00
|
|
|
<variablelist>
|
|
|
|
<variable name="RECORDED_FILE">
|
2017-08-25 17:20:16 +00:00
|
|
|
<para>Will be set to the final filename of the recording, without an extension.</para>
|
2008-11-01 21:10:07 +00:00
|
|
|
</variable>
|
2008-12-17 23:39:48 +00:00
|
|
|
<variable name="RECORD_STATUS">
|
|
|
|
<para>This is the final status of the command</para>
|
2008-12-19 18:20:46 +00:00
|
|
|
<value name="DTMF">A terminating DTMF was received ('#' or '*', depending upon option 't')</value>
|
|
|
|
<value name="SILENCE">The maximum silence occurred in the recording.</value>
|
|
|
|
<value name="SKIP">The line was not yet answered and the 's' option was specified.</value>
|
|
|
|
<value name="TIMEOUT">The maximum length was reached.</value>
|
|
|
|
<value name="HANGUP">The channel was hung up.</value>
|
|
|
|
<value name="ERROR">An unrecoverable error occurred, which resulted in a WARNING to the logs.</value>
|
2008-12-17 23:39:48 +00:00
|
|
|
</variable>
|
2008-11-01 21:10:07 +00:00
|
|
|
</variablelist>
|
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
|
|
|
|
***/
|
2001-04-13 02:12:18 +00:00
|
|
|
|
2013-12-05 23:40:38 +00:00
|
|
|
#define OPERATOR_KEY '0'
|
|
|
|
|
2001-04-13 02:12:18 +00:00
|
|
|
static char *app = "Record";
|
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
enum {
|
|
|
|
OPTION_APPEND = (1 << 0),
|
|
|
|
OPTION_NOANSWER = (1 << 1),
|
|
|
|
OPTION_QUIET = (1 << 2),
|
|
|
|
OPTION_SKIP = (1 << 3),
|
|
|
|
OPTION_STAR_TERMINATE = (1 << 4),
|
|
|
|
OPTION_IGNORE_TERMINATE = (1 << 5),
|
2009-02-13 16:41:15 +00:00
|
|
|
OPTION_KEEP = (1 << 6),
|
2017-08-25 17:20:16 +00:00
|
|
|
OPTION_ANY_TERMINATE = (1 << 7),
|
|
|
|
OPTION_OPERATOR_EXIT = (1 << 8),
|
|
|
|
OPTION_NO_TRUNCATE = (1 << 9),
|
2007-07-23 19:51:41 +00:00
|
|
|
};
|
|
|
|
|
2017-11-15 18:10:16 +00:00
|
|
|
enum dtmf_response {
|
|
|
|
RESPONSE_NO_MATCH = 0,
|
|
|
|
RESPONSE_OPERATOR,
|
|
|
|
RESPONSE_DTMF,
|
|
|
|
};
|
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
AST_APP_OPTIONS(app_opts,{
|
|
|
|
AST_APP_OPTION('a', OPTION_APPEND),
|
2013-12-05 23:40:38 +00:00
|
|
|
AST_APP_OPTION('k', OPTION_KEEP),
|
2007-07-23 19:51:41 +00:00
|
|
|
AST_APP_OPTION('n', OPTION_NOANSWER),
|
2013-12-05 23:40:38 +00:00
|
|
|
AST_APP_OPTION('o', OPTION_OPERATOR_EXIT),
|
2007-07-23 19:51:41 +00:00
|
|
|
AST_APP_OPTION('q', OPTION_QUIET),
|
|
|
|
AST_APP_OPTION('s', OPTION_SKIP),
|
|
|
|
AST_APP_OPTION('t', OPTION_STAR_TERMINATE),
|
2017-02-14 14:12:31 +00:00
|
|
|
AST_APP_OPTION('u', OPTION_NO_TRUNCATE),
|
2009-12-02 18:35:47 +00:00
|
|
|
AST_APP_OPTION('y', OPTION_ANY_TERMINATE),
|
2007-07-23 19:51:41 +00:00
|
|
|
AST_APP_OPTION('x', OPTION_IGNORE_TERMINATE),
|
|
|
|
});
|
2001-04-13 02:12:18 +00:00
|
|
|
|
2013-12-05 23:40:38 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Used to determine what action to take when DTMF is received while recording
|
|
|
|
* \since 13.0.0
|
|
|
|
*
|
|
|
|
* \param chan channel being recorded
|
|
|
|
* \param flags option flags in use by the record application
|
|
|
|
* \param dtmf_integer the integer value of the DTMF key received
|
|
|
|
* \param terminator key currently set to be pressed for normal termination
|
|
|
|
*
|
2017-11-15 18:10:16 +00:00
|
|
|
* \returns One of enum dtmf_response
|
2013-12-05 23:40:38 +00:00
|
|
|
*/
|
2017-11-15 18:10:16 +00:00
|
|
|
static enum dtmf_response record_dtmf_response(struct ast_channel *chan,
|
|
|
|
struct ast_flags *flags, int dtmf_integer, int terminator)
|
2013-12-05 23:40:38 +00:00
|
|
|
{
|
|
|
|
if ((dtmf_integer == OPERATOR_KEY) &&
|
|
|
|
(ast_test_flag(flags, OPTION_OPERATOR_EXIT))) {
|
2017-11-15 18:10:16 +00:00
|
|
|
return RESPONSE_OPERATOR;
|
2013-12-05 23:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((dtmf_integer == terminator) ||
|
|
|
|
(ast_test_flag(flags, OPTION_ANY_TERMINATE))) {
|
2017-11-15 18:10:16 +00:00
|
|
|
return RESPONSE_DTMF;
|
2013-12-05 23:40:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-15 18:10:16 +00:00
|
|
|
return RESPONSE_NO_MATCH;
|
2013-12-05 23:40:38 +00:00
|
|
|
}
|
|
|
|
|
2017-08-25 17:20:16 +00:00
|
|
|
static int create_destination_directory(const char *path)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
char directory[PATH_MAX], *file_sep;
|
|
|
|
|
|
|
|
if (!(file_sep = strrchr(path, '/'))) {
|
|
|
|
/* No directory to create */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overwrite temporarily */
|
|
|
|
*file_sep = '\0';
|
|
|
|
|
|
|
|
/* Absolute path? */
|
|
|
|
if (path[0] == '/') {
|
|
|
|
res = ast_mkdir(path, 0777);
|
|
|
|
*file_sep = '/';
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Relative path */
|
|
|
|
res = snprintf(directory, sizeof(directory), "%s/sounds/%s",
|
|
|
|
ast_config_AST_DATA_DIR, path);
|
|
|
|
|
|
|
|
*file_sep = '/';
|
|
|
|
|
|
|
|
if (res >= sizeof(directory)) {
|
|
|
|
/* We truncated, so we fail */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ast_mkdir(directory, 0777);
|
|
|
|
}
|
|
|
|
|
2009-05-21 21:13:09 +00:00
|
|
|
static int record_exec(struct ast_channel *chan, const char *data)
|
2001-04-13 02:12:18 +00:00
|
|
|
{
|
|
|
|
int res = 0;
|
2007-07-23 19:51:41 +00:00
|
|
|
char *ext = NULL, *opts[0];
|
2017-08-25 17:20:16 +00:00
|
|
|
char *parse;
|
2001-04-13 02:12:18 +00:00
|
|
|
int i = 0;
|
2017-08-25 17:20:16 +00:00
|
|
|
char tmp[PATH_MAX];
|
2003-04-28 05:07:52 +00:00
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
struct ast_filestream *s = NULL;
|
2002-06-19 02:35:40 +00:00
|
|
|
struct ast_frame *f = NULL;
|
2017-12-22 14:23:22 +00:00
|
|
|
|
2003-10-28 14:07:19 +00:00
|
|
|
struct ast_dsp *sildet = NULL; /* silence detector dsp */
|
2003-04-28 05:07:52 +00:00
|
|
|
int totalsilence = 0;
|
|
|
|
int dspsilence = 0;
|
|
|
|
int silence = 0; /* amount of silence to allow */
|
|
|
|
int gotsilence = 0; /* did we timeout for silence? */
|
2017-02-14 14:12:31 +00:00
|
|
|
int truncate_silence = 1; /* truncate on complete silence recording */
|
2005-09-15 01:17:51 +00:00
|
|
|
int maxduration = 0; /* max duration of recording in milliseconds */
|
2004-06-30 16:04:28 +00:00
|
|
|
int gottimeout = 0; /* did we timeout for maxduration exceeded? */
|
2004-10-28 19:08:02 +00:00
|
|
|
int terminator = '#';
|
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 *, rfmt, NULL, ao2_cleanup);
|
2007-07-23 19:51:41 +00:00
|
|
|
int ioflags;
|
2005-11-01 17:22:25 +00:00
|
|
|
struct ast_silence_generator *silgen = NULL;
|
2007-10-29 19:56:50 +00:00
|
|
|
struct ast_flags flags = { 0, };
|
2007-07-23 19:51:41 +00:00
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(filename);
|
|
|
|
AST_APP_ARG(silence);
|
|
|
|
AST_APP_ARG(maxduration);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
);
|
2012-11-07 19:15:26 +00:00
|
|
|
int ms;
|
|
|
|
struct timeval start;
|
2017-11-15 18:10:16 +00:00
|
|
|
const char *status_response = "ERROR";
|
2011-02-03 16:22:10 +00:00
|
|
|
|
2001-04-13 02:12:18 +00:00
|
|
|
/* The next few lines of code parse out the filename and header from the input string */
|
2005-10-26 19:48:14 +00:00
|
|
|
if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
|
2001-04-13 02:12:18 +00:00
|
|
|
ast_log(LOG_WARNING, "Record requires an argument (filename)\n");
|
2008-12-17 23:39:48 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
|
2001-04-13 02:12:18 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2005-10-19 18:19:02 +00:00
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
parse = ast_strdupa(data);
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
if (args.argc == 4)
|
|
|
|
ast_app_parse_options(app_opts, &flags, opts, args.options);
|
2005-10-19 18:19:02 +00:00
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
if (!ast_strlen_zero(args.filename)) {
|
|
|
|
ext = strrchr(args.filename, '.'); /* to support filename with a . in the filename, not format */
|
2004-10-28 19:08:02 +00:00
|
|
|
if (!ext)
|
2007-07-23 19:51:41 +00:00
|
|
|
ext = strchr(args.filename, ':');
|
2004-10-28 22:14:08 +00:00
|
|
|
if (ext) {
|
|
|
|
*ext = '\0';
|
|
|
|
ext++;
|
|
|
|
}
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
2004-10-28 21:37:18 +00:00
|
|
|
if (!ext) {
|
|
|
|
ast_log(LOG_WARNING, "No extension specified to filename!\n");
|
2008-12-17 23:39:48 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
|
2004-10-28 21:37:18 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
if (args.silence) {
|
2009-08-10 19:20:57 +00:00
|
|
|
if ((sscanf(args.silence, "%30d", &i) == 1) && (i > -1)) {
|
2004-11-17 03:34:56 +00:00
|
|
|
silence = i * 1000;
|
2007-07-23 19:51:41 +00:00
|
|
|
} else if (!ast_strlen_zero(args.silence)) {
|
|
|
|
ast_log(LOG_WARNING, "'%s' is not a valid silence duration\n", args.silence);
|
2004-11-17 03:34:56 +00:00
|
|
|
}
|
2004-06-30 16:04:28 +00:00
|
|
|
}
|
2017-02-14 14:12:31 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, OPTION_NO_TRUNCATE))
|
|
|
|
truncate_silence = 0;
|
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
if (args.maxduration) {
|
2009-08-10 19:20:57 +00:00
|
|
|
if ((sscanf(args.maxduration, "%30d", &i) == 1) && (i > -1))
|
2005-09-15 01:17:51 +00:00
|
|
|
/* Convert duration to milliseconds */
|
|
|
|
maxduration = i * 1000;
|
2007-07-23 19:51:41 +00:00
|
|
|
else if (!ast_strlen_zero(args.maxduration))
|
|
|
|
ast_log(LOG_WARNING, "'%s' is not a valid maximum duration\n", args.maxduration);
|
2004-10-28 19:08:02 +00:00
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, OPTION_STAR_TERMINATE))
|
|
|
|
terminator = '*';
|
|
|
|
if (ast_test_flag(&flags, OPTION_IGNORE_TERMINATE))
|
|
|
|
terminator = '\0';
|
|
|
|
|
2017-08-25 17:20:16 +00:00
|
|
|
/*
|
|
|
|
If a '%d' is specified as part of the filename, we replace that token with
|
|
|
|
sequentially incrementing numbers until we find a unique filename.
|
|
|
|
*/
|
|
|
|
if (strchr(args.filename, '%')) {
|
|
|
|
size_t src, dst, count = 0;
|
|
|
|
size_t src_len = strlen(args.filename);
|
|
|
|
size_t dst_len = sizeof(tmp) - 1;
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2001-04-13 02:12:18 +00:00
|
|
|
do {
|
2017-08-25 17:20:16 +00:00
|
|
|
for (src = 0, dst = 0; src < src_len && dst < dst_len; src++) {
|
|
|
|
if (!strncmp(&args.filename[src], "%d", 2)) {
|
|
|
|
int s = snprintf(&tmp[dst], PATH_MAX - dst, "%zu", count);
|
|
|
|
if (s >= PATH_MAX - dst) {
|
|
|
|
/* We truncated, so we need to bail */
|
|
|
|
ast_log(LOG_WARNING, "Failed to create unique filename from template: %s\n", args.filename);
|
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
dst += s;
|
|
|
|
src++;
|
|
|
|
} else {
|
|
|
|
tmp[dst] = args.filename[src];
|
|
|
|
tmp[++dst] = '\0';
|
2006-09-07 23:15:43 +00:00
|
|
|
}
|
|
|
|
}
|
2001-04-13 02:12:18 +00:00
|
|
|
count++;
|
2012-01-24 20:12:09 +00:00
|
|
|
} while (ast_fileexists(tmp, ext, ast_channel_language(chan)) > 0);
|
2001-04-13 02:12:18 +00:00
|
|
|
} else
|
2007-07-23 19:51:41 +00:00
|
|
|
ast_copy_string(tmp, args.filename, sizeof(tmp));
|
2015-09-21 23:06:15 +00:00
|
|
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "RECORDED_FILE", tmp);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_state(chan) != AST_STATE_UP) {
|
2007-07-23 19:51:41 +00:00
|
|
|
if (ast_test_flag(&flags, OPTION_SKIP)) {
|
2004-06-30 16:04:28 +00:00
|
|
|
/* At the user's option, skip if the line is not up */
|
2008-12-17 23:39:48 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "SKIP");
|
2004-06-30 16:04:28 +00:00
|
|
|
return 0;
|
2007-07-23 19:51:41 +00:00
|
|
|
} else if (!ast_test_flag(&flags, OPTION_NOANSWER)) {
|
2004-06-30 16:04:28 +00:00
|
|
|
/* Otherwise answer unless we're supposed to record while on-hook */
|
|
|
|
res = ast_answer(chan);
|
|
|
|
}
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (res) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "Could not answer channel '%s'\n", ast_channel_name(chan));
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "ERROR";
|
2005-11-01 17:22:25 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
|
|
|
if (!ast_test_flag(&flags, OPTION_QUIET)) {
|
2005-11-01 17:22:25 +00:00
|
|
|
/* Some code to play a nice little beep to signify the start of the record operation */
|
2012-01-24 20:12:09 +00:00
|
|
|
res = ast_streamfile(chan, "beep", ast_channel_language(chan));
|
2005-11-01 17:22:25 +00:00
|
|
|
if (!res) {
|
|
|
|
res = ast_waitstream(chan, "");
|
|
|
|
} else {
|
2020-01-09 10:37:08 +00:00
|
|
|
ast_log(LOG_WARNING, "ast_streamfile(beep) failed on %s\n", ast_channel_name(chan));
|
|
|
|
res = 0;
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
2005-11-01 17:22:25 +00:00
|
|
|
ast_stopstream(chan);
|
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
/* The end of beep code. Now the recording starts */
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (silence > 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
|
|
|
rfmt = ao2_bump(ast_channel_readformat(chan));
|
|
|
|
res = ast_set_read_format(chan, ast_format_slin);
|
2005-11-01 17:22:25 +00:00
|
|
|
if (res < 0) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
|
2008-12-17 23:39:48 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
|
2005-11-01 17:22:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
sildet = ast_dsp_new();
|
|
|
|
if (!sildet) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
|
2008-12-17 23:39:48 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", "ERROR");
|
2005-11-01 17:22:25 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-03-05 16:23:44 +00:00
|
|
|
ast_dsp_set_threshold(sildet, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
|
2017-12-22 14:23:22 +00:00
|
|
|
}
|
2007-06-26 20:34:46 +00:00
|
|
|
|
2017-08-25 17:20:16 +00:00
|
|
|
if (create_destination_directory(tmp)) {
|
|
|
|
ast_log(LOG_WARNING, "Could not create directory for file %s\n", args.filename);
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "ERROR";
|
2017-08-25 17:20:16 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2007-06-26 20:34:46 +00:00
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
ioflags = ast_test_flag(&flags, OPTION_APPEND) ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
|
|
|
|
s = ast_writefile(tmp, ext, NULL, ioflags, 0, AST_FILE_MODE);
|
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (!s) {
|
2007-07-23 19:51:41 +00:00
|
|
|
ast_log(LOG_WARNING, "Could not create file %s\n", args.filename);
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "ERROR";
|
2005-11-01 17:22:25 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2005-08-30 02:12:09 +00:00
|
|
|
|
2005-12-04 20:40:46 +00:00
|
|
|
if (ast_opt_transmit_silence)
|
2005-11-01 17:22:25 +00:00
|
|
|
silgen = ast_channel_start_silence_generator(chan);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
/* Request a video update */
|
|
|
|
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (maxduration <= 0)
|
|
|
|
maxduration = -1;
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2012-11-07 19:15:26 +00:00
|
|
|
start = ast_tvnow();
|
|
|
|
while ((ms = ast_remaining_ms(start, maxduration))) {
|
|
|
|
ms = ast_waitfor(chan, ms);
|
|
|
|
if (ms < 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxduration > 0 && ms == 0) {
|
|
|
|
break;
|
2005-11-01 17:22:25 +00:00
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
f = ast_read(chan);
|
|
|
|
if (!f) {
|
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (f->frametype == AST_FRAME_VOICE) {
|
|
|
|
res = ast_writestream(s, f);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (res) {
|
|
|
|
ast_log(LOG_WARNING, "Problem writing frame\n");
|
2005-11-21 02:01:36 +00:00
|
|
|
ast_frfree(f);
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "ERROR";
|
2005-11-01 17:22:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (silence > 0) {
|
|
|
|
dspsilence = 0;
|
|
|
|
ast_dsp_silence(sildet, f, &dspsilence);
|
|
|
|
if (dspsilence) {
|
|
|
|
totalsilence = dspsilence;
|
|
|
|
} else {
|
|
|
|
totalsilence = 0;
|
2003-06-29 03:24:39 +00:00
|
|
|
}
|
2005-11-01 17:22:25 +00:00
|
|
|
if (totalsilence > silence) {
|
|
|
|
/* Ended happily with silence */
|
2001-07-26 16:36:23 +00:00
|
|
|
ast_frfree(f);
|
2005-11-01 17:22:25 +00:00
|
|
|
gotsilence = 1;
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "SILENCE";
|
2001-07-26 16:36:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
2005-11-21 02:01:36 +00:00
|
|
|
} else if (f->frametype == AST_FRAME_VIDEO) {
|
2005-11-01 17:22:25 +00:00
|
|
|
res = ast_writestream(s, f);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (res) {
|
|
|
|
ast_log(LOG_WARNING, "Problem writing frame\n");
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "ERROR";
|
2005-11-21 02:01:36 +00:00
|
|
|
ast_frfree(f);
|
2005-11-01 17:22:25 +00:00
|
|
|
break;
|
2003-04-28 05:07:52 +00:00
|
|
|
}
|
2013-12-05 23:40:38 +00:00
|
|
|
} else if (f->frametype == AST_FRAME_DTMF) {
|
2017-11-15 18:10:16 +00:00
|
|
|
enum dtmf_response rc =
|
|
|
|
record_dtmf_response(chan, &flags, f->subclass.integer, terminator);
|
|
|
|
switch(rc) {
|
|
|
|
case RESPONSE_NO_MATCH:
|
|
|
|
break;
|
|
|
|
case RESPONSE_OPERATOR:
|
|
|
|
status_response = "OPERATOR";
|
|
|
|
ast_debug(1, "Got OPERATOR\n");
|
|
|
|
break;
|
|
|
|
case RESPONSE_DTMF:
|
|
|
|
status_response = "DTMF";
|
|
|
|
ast_debug(1, "Got DTMF\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rc != RESPONSE_NO_MATCH) {
|
2013-12-05 23:40:38 +00:00
|
|
|
ast_frfree(f);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-01 17:22:25 +00:00
|
|
|
}
|
|
|
|
ast_frfree(f);
|
|
|
|
}
|
2012-11-07 19:15:26 +00:00
|
|
|
|
|
|
|
if (maxduration > 0 && !ms) {
|
|
|
|
gottimeout = 1;
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "TIMEOUT";
|
2012-11-07 19:15:26 +00:00
|
|
|
}
|
|
|
|
|
2005-11-01 17:22:25 +00:00
|
|
|
if (!f) {
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1, "Got hangup\n");
|
2005-11-01 17:22:25 +00:00
|
|
|
res = -1;
|
2017-11-15 18:10:16 +00:00
|
|
|
status_response = "HANGUP";
|
2009-02-13 16:41:15 +00:00
|
|
|
if (!ast_test_flag(&flags, OPTION_KEEP)) {
|
|
|
|
ast_filedelete(args.filename, NULL);
|
|
|
|
}
|
2005-11-01 17:22:25 +00:00
|
|
|
}
|
2007-07-23 19:51:41 +00:00
|
|
|
|
2017-02-14 14:12:31 +00:00
|
|
|
if (gotsilence && truncate_silence) {
|
2007-07-23 19:51:41 +00:00
|
|
|
ast_stream_rewind(s, silence - 1000);
|
2005-11-01 17:22:25 +00:00
|
|
|
ast_truncstream(s);
|
2014-12-01 13:41:43 +00:00
|
|
|
} else if (!gottimeout && f) {
|
|
|
|
/*
|
|
|
|
* Strip off the last 1/4 second of it, if we didn't end because of a timeout,
|
|
|
|
* or a hangup. This must mean we ended because of a DTMF tone and while this
|
|
|
|
* 1/4 second stripping is very old code the most likely explanation is that it
|
|
|
|
* relates to stripping a partial DTMF tone.
|
|
|
|
*/
|
2005-11-01 17:22:25 +00:00
|
|
|
ast_stream_rewind(s, 250);
|
|
|
|
ast_truncstream(s);
|
|
|
|
}
|
|
|
|
ast_closestream(s);
|
|
|
|
|
|
|
|
if (silgen)
|
|
|
|
ast_channel_stop_silence_generator(chan, silgen);
|
2007-07-23 19:51:41 +00:00
|
|
|
|
|
|
|
out:
|
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 ((silence > 0) && rfmt) {
|
|
|
|
res = ast_set_read_format(chan, rfmt);
|
2012-05-18 14:43:44 +00:00
|
|
|
if (res) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", ast_channel_name(chan));
|
2012-05-18 14:43:44 +00:00
|
|
|
}
|
2003-04-28 05:07:52 +00:00
|
|
|
}
|
2005-10-19 18:19:02 +00:00
|
|
|
|
2012-05-18 14:43:44 +00:00
|
|
|
if (sildet) {
|
|
|
|
ast_dsp_free(sildet);
|
|
|
|
}
|
2017-11-15 18:10:16 +00:00
|
|
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "RECORD_STATUS", status_response);
|
|
|
|
|
2001-04-13 02:12:18 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2001-04-13 02:12:18 +00:00
|
|
|
{
|
2007-07-16 13:35:20 +00:00
|
|
|
return ast_unregister_application(app);
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2001-04-13 02:12:18 +00:00
|
|
|
{
|
2008-11-01 21:10:07 +00:00
|
|
|
return ast_register_application_xml(app, record_exec);
|
2001-04-13 02:12:18 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Trivial Record Application");
|