2005-10-16 02:59:13 +00:00
|
|
|
/*
|
2005-10-28 23:01:13 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2005-10-16 02:59:13 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005, Anthony Minessale II
|
2006-01-03 22:16:23 +00:00
|
|
|
* Copyright (C) 2005 - 2006, Digium, Inc.
|
2005-10-28 23:01:13 +00:00
|
|
|
*
|
|
|
|
* Mark Spencer <markster@digium.com>
|
|
|
|
* Kevin P. Fleming <kpfleming@digium.com>
|
2005-10-16 02:59:13 +00:00
|
|
|
*
|
2005-10-28 23:01:13 +00:00
|
|
|
* Based on app_muxmon.c provided by
|
2005-10-16 02:59:13 +00:00
|
|
|
* Anthony Minessale II <anthmct@yahoo.com>
|
|
|
|
*
|
2005-10-28 23:01:13 +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.
|
|
|
|
*
|
2005-10-16 02:59:13 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-10-28 23:01:13 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
2005-10-16 02:59:13 +00:00
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
2005-10-31 15:33:27 +00:00
|
|
|
* \brief MixMonitor() - Record a call and mix the audio during the recording
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2005-12-30 21:18:06 +00:00
|
|
|
*
|
|
|
|
* \author Mark Spencer <markster@digium.com>
|
|
|
|
* \author Kevin P. Fleming <kpfleming@digium.com>
|
|
|
|
*
|
|
|
|
* \note Based on app_muxmon.c provided by
|
|
|
|
* Anthony Minessale II <anthmct@yahoo.com>
|
2005-10-24 20:12:06 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2007-11-20 23:16:15 +00:00
|
|
|
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
|
2012-06-04 20:26:12 +00:00
|
|
|
#include "asterisk/stringfields.h"
|
2005-10-28 23:01:13 +00:00
|
|
|
#include "asterisk/file.h"
|
2007-08-08 19:30:52 +00:00
|
|
|
#include "asterisk/audiohook.h"
|
2005-10-28 23:01:13 +00:00
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/cli.h"
|
|
|
|
#include "asterisk/app.h"
|
2007-11-22 03:50:04 +00:00
|
|
|
#include "asterisk/channel.h"
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
#include "asterisk/autochan.h"
|
2010-04-21 11:27:27 +00:00
|
|
|
#include "asterisk/manager.h"
|
2012-06-04 20:26:12 +00:00
|
|
|
#include "asterisk/callerid.h"
|
2011-07-13 22:10:26 +00:00
|
|
|
#include "asterisk/mod_format.h"
|
2012-01-23 18:16:20 +00:00
|
|
|
#include "asterisk/linkedlists.h"
|
2012-10-30 19:20:33 +00:00
|
|
|
#include "asterisk/test.h"
|
2013-07-01 16:01:24 +00:00
|
|
|
#include "asterisk/mixmonitor.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"
|
2014-04-15 23:21:19 +00:00
|
|
|
#include "asterisk/beep.h"
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="MixMonitor" language="en_US">
|
|
|
|
<synopsis>
|
2009-06-17 19:45:35 +00:00
|
|
|
Record a call and mix the audio during the recording. Use of StopMixMonitor is required
|
|
|
|
to guarantee the audio file is available for processing during dialplan execution.
|
2008-11-01 21:10:07 +00:00
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="file" required="true" argsep=".">
|
|
|
|
<argument name="filename" required="true">
|
|
|
|
<para>If <replaceable>filename</replaceable> is an absolute path, uses that path, otherwise
|
|
|
|
creates the file in the configured monitoring directory from <filename>asterisk.conf.</filename></para>
|
|
|
|
</argument>
|
|
|
|
<argument name="extension" required="true" />
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<optionlist>
|
|
|
|
<option name="a">
|
|
|
|
<para>Append to the file instead of overwriting it.</para>
|
|
|
|
</option>
|
|
|
|
<option name="b">
|
|
|
|
<para>Only save audio to the file while the channel is bridged.</para>
|
2009-05-28 22:04:00 +00:00
|
|
|
<note><para>If you utilize this option inside a Local channel, you must make sure the Local
|
|
|
|
channel is not optimized away. To do this, be sure to call your Local channel with the
|
|
|
|
<literal>/n</literal> option. For example: Dial(Local/start@mycontext/n)</para></note>
|
2008-11-01 21:10:07 +00:00
|
|
|
</option>
|
2014-04-15 23:21:19 +00:00
|
|
|
<option name="B">
|
|
|
|
<para>Play a periodic beep while this call is being recorded.</para>
|
|
|
|
<argument name="interval"><para>Interval, in seconds. Default is 15.</para></argument>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
<option name="v">
|
|
|
|
<para>Adjust the <emphasis>heard</emphasis> volume by a factor of <replaceable>x</replaceable>
|
|
|
|
(range <literal>-4</literal> to <literal>4</literal>)</para>
|
|
|
|
<argument name="x" required="true" />
|
|
|
|
</option>
|
|
|
|
<option name="V">
|
|
|
|
<para>Adjust the <emphasis>spoken</emphasis> volume by a factor
|
|
|
|
of <replaceable>x</replaceable> (range <literal>-4</literal> to <literal>4</literal>)</para>
|
|
|
|
<argument name="x" required="true" />
|
|
|
|
</option>
|
|
|
|
<option name="W">
|
|
|
|
<para>Adjust both, <emphasis>heard and spoken</emphasis> volumes by a factor
|
|
|
|
of <replaceable>x</replaceable> (range <literal>-4</literal> to <literal>4</literal>)</para>
|
|
|
|
<argument name="x" required="true" />
|
|
|
|
</option>
|
2011-03-11 18:54:45 +00:00
|
|
|
<option name="r">
|
|
|
|
<argument name="file" required="true" />
|
|
|
|
<para>Use the specified file to record the <emphasis>receive</emphasis> audio feed.
|
|
|
|
Like with the basic filename argument, if an absolute path isn't given, it will create
|
|
|
|
the file in the configured monitoring directory.</para>
|
|
|
|
</option>
|
|
|
|
<option name="t">
|
|
|
|
<argument name="file" required="true" />
|
|
|
|
<para>Use the specified file to record the <emphasis>transmit</emphasis> audio feed.
|
|
|
|
Like with the basic filename argument, if an absolute path isn't given, it will create
|
|
|
|
the file in the configured monitoring directory.</para>
|
|
|
|
</option>
|
2012-01-23 18:16:20 +00:00
|
|
|
<option name="i">
|
|
|
|
<argument name="chanvar" required="true" />
|
|
|
|
<para>Stores the MixMonitor's ID on this channel variable.</para>
|
|
|
|
</option>
|
2014-07-22 20:01:42 +00:00
|
|
|
<option name="p">
|
|
|
|
<para>Play a beep on the channel that starts the recording.</para>
|
|
|
|
</option>
|
|
|
|
<option name="P">
|
|
|
|
<para>Play a beep on the channel that stops the recording.</para>
|
|
|
|
</option>
|
2012-06-04 20:26:12 +00:00
|
|
|
<option name="m">
|
|
|
|
<argument name="mailbox" required="true" />
|
|
|
|
<para>Create a copy of the recording as a voicemail in the indicated <emphasis>mailbox</emphasis>(es)
|
|
|
|
separated by commas eg. m(1111@default,2222@default,...). Folders can be optionally specified using
|
|
|
|
the syntax: mailbox@context/folder</para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="command">
|
|
|
|
<para>Will be executed when the recording is over.</para>
|
|
|
|
<para>Any strings matching <literal>^{X}</literal> will be unescaped to <variable>X</variable>.</para>
|
|
|
|
<para>All variables will be evaluated at the time MixMonitor is called.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Records the audio on the current channel to the specified file.</para>
|
2011-09-19 20:23:29 +00:00
|
|
|
<para>This application does not automatically answer and should be preceeded by
|
|
|
|
an application such as Answer or Progress().</para>
|
2013-07-02 21:12:26 +00:00
|
|
|
<note><para>MixMonitor runs as an audiohook.</para></note>
|
2008-11-01 21:10:07 +00:00
|
|
|
<variablelist>
|
|
|
|
<variable name="MIXMONITOR_FILENAME">
|
|
|
|
<para>Will contain the filename used to record.</para>
|
|
|
|
</variable>
|
2013-08-30 16:27:57 +00:00
|
|
|
</variablelist>
|
2008-11-01 21:10:07 +00:00
|
|
|
</description>
|
2008-11-05 18:50:02 +00:00
|
|
|
<see-also>
|
|
|
|
<ref type="application">Monitor</ref>
|
|
|
|
<ref type="application">StopMixMonitor</ref>
|
|
|
|
<ref type="application">PauseMonitor</ref>
|
|
|
|
<ref type="application">UnpauseMonitor</ref>
|
2012-09-24 21:19:49 +00:00
|
|
|
<ref type="function">AUDIOHOOK_INHERIT</ref>
|
2008-11-05 18:50:02 +00:00
|
|
|
</see-also>
|
2008-11-01 21:10:07 +00:00
|
|
|
</application>
|
|
|
|
<application name="StopMixMonitor" language="en_US">
|
|
|
|
<synopsis>
|
2009-06-17 19:45:35 +00:00
|
|
|
Stop recording a call through MixMonitor, and free the recording's file handle.
|
2008-11-01 21:10:07 +00:00
|
|
|
</synopsis>
|
2012-01-23 18:16:20 +00:00
|
|
|
<syntax>
|
|
|
|
<parameter name="MixMonitorID" required="false">
|
|
|
|
<para>If a valid ID is provided, then this command will stop only that specific
|
|
|
|
MixMonitor.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
2008-11-01 21:10:07 +00:00
|
|
|
<description>
|
|
|
|
<para>Stops the audio recording that was started with a call to <literal>MixMonitor()</literal>
|
|
|
|
on the current channel.</para>
|
|
|
|
</description>
|
2008-11-05 18:50:02 +00:00
|
|
|
<see-also>
|
|
|
|
<ref type="application">MixMonitor</ref>
|
|
|
|
</see-also>
|
2008-11-01 21:10:07 +00:00
|
|
|
</application>
|
2010-04-21 11:27:27 +00:00
|
|
|
<manager name="MixMonitorMute" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Mute / unMute a Mixmonitor recording.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
|
|
|
|
<parameter name="Channel" required="true">
|
|
|
|
<para>Used to specify the channel to mute.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="Direction">
|
|
|
|
<para>Which part of the recording to mute: read, write or both (from channel, to channel or both channels).</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="State">
|
|
|
|
<para>Turn mute on or off : 1 to turn on, 0 to turn off.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action may be used to mute a MixMonitor recording.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
2011-12-09 21:47:28 +00:00
|
|
|
<manager name="MixMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Record a call and mix the audio during the recording. Use of StopMixMonitor is required
|
|
|
|
to guarantee the audio file is available for processing during dialplan execution.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
|
|
|
|
<parameter name="Channel" required="true">
|
|
|
|
<para>Used to specify the channel to record.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="File">
|
|
|
|
<para>Is the name of the file created in the monitor spool directory.
|
|
|
|
Defaults to the same name as the channel (with slashes replaced with dashes).
|
|
|
|
This argument is optional if you specify to record unidirectional audio with
|
|
|
|
either the r(filename) or t(filename) options in the options field. If
|
|
|
|
neither MIXMONITOR_FILENAME or this parameter is set, the mixed stream won't
|
|
|
|
be recorded.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<para>Options that apply to the MixMonitor in the same way as they
|
|
|
|
would apply if invoked from the MixMonitor application. For a list of
|
|
|
|
available options, see the documentation for the mixmonitor application. </para>
|
|
|
|
</parameter>
|
2014-04-09 21:43:23 +00:00
|
|
|
<parameter name="Command">
|
|
|
|
<para>Will be executed when the recording is over.
|
|
|
|
Any strings matching <literal>^{X}</literal> will be unescaped to <variable>X</variable>.
|
|
|
|
All variables will be evaluated at the time MixMonitor is called.</para>
|
|
|
|
</parameter>
|
2011-12-09 21:47:28 +00:00
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action records the audio on the current channel to the specified file.</para>
|
|
|
|
<variablelist>
|
|
|
|
<variable name="MIXMONITOR_FILENAME">
|
|
|
|
<para>Will contain the filename used to record the mixed stream.</para>
|
|
|
|
</variable>
|
|
|
|
</variablelist>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
<manager name="StopMixMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Stop recording a call through MixMonitor, and free the recording's file handle.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
|
|
|
|
<parameter name="Channel" required="true">
|
|
|
|
<para>The name of the channel monitored.</para>
|
|
|
|
</parameter>
|
2012-01-23 18:16:20 +00:00
|
|
|
<parameter name="MixMonitorID" required="false">
|
|
|
|
<para>If a valid ID is provided, then this command will stop only that specific
|
|
|
|
MixMonitor.</para>
|
|
|
|
</parameter>
|
2011-12-09 21:47:28 +00:00
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action stops the audio recording that was started with the <literal>MixMonitor</literal>
|
|
|
|
action on the current channel.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
2013-12-09 16:42:59 +00:00
|
|
|
<function name="MIXMONITOR" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Retrieve data pertaining to specific instances of MixMonitor on a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="id" required="true">
|
|
|
|
<para>The unique ID of the MixMonitor instance. The unique ID can be retrieved through the channel
|
|
|
|
variable used as an argument to the <replaceable>i</replaceable> option to MixMonitor.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="key" required="true">
|
|
|
|
<para>The piece of data to retrieve from the MixMonitor.</para>
|
|
|
|
<enumlist>
|
|
|
|
<enum name="filename" />
|
|
|
|
</enumlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
</function>
|
2010-04-21 11:27:27 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
***/
|
|
|
|
|
2005-10-16 02:59:13 +00:00
|
|
|
#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2009-05-12 13:59:35 +00:00
|
|
|
static const char * const app = "MixMonitor";
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2009-05-12 13:59:35 +00:00
|
|
|
static const char * const stop_app = "StopMixMonitor";
|
2006-02-16 17:37:03 +00:00
|
|
|
|
2009-05-12 13:59:35 +00:00
|
|
|
static const char * const mixmonitor_spy_type = "MixMonitor";
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief This struct is a list item holds data needed to find a vm_recipient within voicemail
|
|
|
|
*/
|
|
|
|
struct vm_recipient {
|
|
|
|
char mailbox[AST_MAX_CONTEXT];
|
|
|
|
char context[AST_MAX_EXTENSION];
|
|
|
|
char folder[80];
|
|
|
|
AST_LIST_ENTRY(vm_recipient) list;
|
|
|
|
};
|
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
struct mixmonitor {
|
2007-08-08 19:30:52 +00:00
|
|
|
struct ast_audiohook audiohook;
|
2012-03-29 20:01:20 +00:00
|
|
|
struct ast_callid *callid;
|
2007-01-22 19:22:07 +00:00
|
|
|
char *filename;
|
2011-03-11 18:54:45 +00:00
|
|
|
char *filename_read;
|
|
|
|
char *filename_write;
|
2005-10-16 02:59:13 +00:00
|
|
|
char *post_process;
|
2006-06-12 21:37:29 +00:00
|
|
|
char *name;
|
After some study, thought, comparing, etc. I've backed out the previous universal mod to make ast_flags a 64 bit thing. Instead, I added a 64-bit version of ast_flags (ast_flags64), and 64-bit versions of the test-flag, set-flag, etc. macros, and an app_parse_options64 routine, and I use these in app_dial alone, to eliminate the 30-option limit it had grown to meet. There is room now for 32 more options and flags. I was heavily tempted to implement some of the other ideas that were presented, but this solution does not intro any new versions of dial, doesn't have a different API, has a minimal/zero impact on code outside of dial, and doesn't seriously (I hope) affect the code structure of dial. It's the best I can think of right now. My goal was NOT to rewrite dial. I leave that to a future, coordinated effort.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75983 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-19 23:24:27 +00:00
|
|
|
unsigned int flags;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct ast_autochan *autochan;
|
2009-06-17 19:45:35 +00:00
|
|
|
struct mixmonitor_ds *mixmonitor_ds;
|
2012-06-04 20:26:12 +00:00
|
|
|
|
|
|
|
/* the below string fields describe data used for creating voicemails from the recording */
|
|
|
|
AST_DECLARE_STRING_FIELDS(
|
|
|
|
AST_STRING_FIELD(call_context);
|
|
|
|
AST_STRING_FIELD(call_macrocontext);
|
|
|
|
AST_STRING_FIELD(call_extension);
|
|
|
|
AST_STRING_FIELD(call_callerchan);
|
|
|
|
AST_STRING_FIELD(call_callerid);
|
|
|
|
);
|
|
|
|
int call_priority;
|
|
|
|
|
|
|
|
/* FUTURE DEVELOPMENT NOTICE
|
|
|
|
* recipient_list will need locks if we make it editable after the monitor is started */
|
|
|
|
AST_LIST_HEAD_NOLOCK(, vm_recipient) recipient_list;
|
2005-10-16 02:59:13 +00:00
|
|
|
};
|
|
|
|
|
2009-06-15 19:10:10 +00:00
|
|
|
enum mixmonitor_flags {
|
2005-11-03 21:19:11 +00:00
|
|
|
MUXFLAG_APPEND = (1 << 1),
|
|
|
|
MUXFLAG_BRIDGED = (1 << 2),
|
|
|
|
MUXFLAG_VOLUME = (1 << 3),
|
|
|
|
MUXFLAG_READVOLUME = (1 << 4),
|
|
|
|
MUXFLAG_WRITEVOLUME = (1 << 5),
|
2011-03-11 18:54:45 +00:00
|
|
|
MUXFLAG_READ = (1 << 6),
|
|
|
|
MUXFLAG_WRITE = (1 << 7),
|
|
|
|
MUXFLAG_COMBINED = (1 << 8),
|
2012-06-04 20:26:12 +00:00
|
|
|
MUXFLAG_UID = (1 << 9),
|
|
|
|
MUXFLAG_VMRECIPIENTS = (1 << 10),
|
2014-04-15 23:21:19 +00:00
|
|
|
MUXFLAG_BEEP = (1 << 11),
|
2014-07-22 20:01:42 +00:00
|
|
|
MUXFLAG_BEEP_START = (1 << 12),
|
|
|
|
MUXFLAG_BEEP_STOP = (1 << 13)
|
2009-06-15 19:10:10 +00:00
|
|
|
};
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2009-06-15 19:10:10 +00:00
|
|
|
enum mixmonitor_args {
|
2005-11-03 21:19:11 +00:00
|
|
|
OPT_ARG_READVOLUME = 0,
|
|
|
|
OPT_ARG_WRITEVOLUME,
|
|
|
|
OPT_ARG_VOLUME,
|
2011-03-11 18:54:45 +00:00
|
|
|
OPT_ARG_WRITENAME,
|
|
|
|
OPT_ARG_READNAME,
|
2012-06-04 20:26:12 +00:00
|
|
|
OPT_ARG_UID,
|
|
|
|
OPT_ARG_VMRECIPIENTS,
|
2014-04-15 23:21:19 +00:00
|
|
|
OPT_ARG_BEEP_INTERVAL,
|
2011-03-11 18:54:45 +00:00
|
|
|
OPT_ARG_ARRAY_SIZE, /* Always last element of the enum */
|
2009-06-15 19:10:10 +00:00
|
|
|
};
|
2005-11-03 21:19:11 +00:00
|
|
|
|
|
|
|
AST_APP_OPTIONS(mixmonitor_opts, {
|
|
|
|
AST_APP_OPTION('a', MUXFLAG_APPEND),
|
|
|
|
AST_APP_OPTION('b', MUXFLAG_BRIDGED),
|
2014-04-15 23:21:19 +00:00
|
|
|
AST_APP_OPTION_ARG('B', MUXFLAG_BEEP, OPT_ARG_BEEP_INTERVAL),
|
2014-07-22 20:01:42 +00:00
|
|
|
AST_APP_OPTION('p', MUXFLAG_BEEP_START),
|
|
|
|
AST_APP_OPTION('P', MUXFLAG_BEEP_STOP),
|
2005-11-03 21:19:11 +00:00
|
|
|
AST_APP_OPTION_ARG('v', MUXFLAG_READVOLUME, OPT_ARG_READVOLUME),
|
|
|
|
AST_APP_OPTION_ARG('V', MUXFLAG_WRITEVOLUME, OPT_ARG_WRITEVOLUME),
|
|
|
|
AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
|
2011-03-11 18:54:45 +00:00
|
|
|
AST_APP_OPTION_ARG('r', MUXFLAG_READ, OPT_ARG_READNAME),
|
|
|
|
AST_APP_OPTION_ARG('t', MUXFLAG_WRITE, OPT_ARG_WRITENAME),
|
2012-01-23 18:16:20 +00:00
|
|
|
AST_APP_OPTION_ARG('i', MUXFLAG_UID, OPT_ARG_UID),
|
2012-06-04 20:26:12 +00:00
|
|
|
AST_APP_OPTION_ARG('m', MUXFLAG_VMRECIPIENTS, OPT_ARG_VMRECIPIENTS),
|
2005-10-16 02:59:13 +00:00
|
|
|
});
|
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
struct mixmonitor_ds {
|
|
|
|
unsigned int destruction_ok;
|
|
|
|
ast_cond_t destruction_condition;
|
|
|
|
ast_mutex_t lock;
|
|
|
|
|
|
|
|
/* The filestream is held in the datastore so it can be stopped
|
|
|
|
* immediately during stop_mixmonitor or channel destruction. */
|
|
|
|
int fs_quit;
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
struct ast_filestream *fs;
|
2011-03-11 18:54:45 +00:00
|
|
|
struct ast_filestream *fs_read;
|
|
|
|
struct ast_filestream *fs_write;
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
struct ast_audiohook *audiohook;
|
2011-07-13 22:10:26 +00:00
|
|
|
|
|
|
|
unsigned int samp_rate;
|
2013-12-09 16:42:59 +00:00
|
|
|
char *filename;
|
2014-04-15 23:21:19 +00:00
|
|
|
char *beep_id;
|
2009-06-17 19:45:35 +00:00
|
|
|
};
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \pre mixmonitor_ds must be locked before calling this function
|
|
|
|
*/
|
2009-06-17 19:45:35 +00:00
|
|
|
static void mixmonitor_ds_close_fs(struct mixmonitor_ds *mixmonitor_ds)
|
|
|
|
{
|
2011-03-11 18:54:45 +00:00
|
|
|
unsigned char quitting = 0;
|
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
if (mixmonitor_ds->fs) {
|
2011-03-11 18:54:45 +00:00
|
|
|
quitting = 1;
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_closestream(mixmonitor_ds->fs);
|
|
|
|
mixmonitor_ds->fs = NULL;
|
2011-03-11 18:54:45 +00:00
|
|
|
ast_verb(2, "MixMonitor close filestream (mixed)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mixmonitor_ds->fs_read) {
|
|
|
|
quitting = 1;
|
|
|
|
ast_closestream(mixmonitor_ds->fs_read);
|
|
|
|
mixmonitor_ds->fs_read = NULL;
|
|
|
|
ast_verb(2, "MixMonitor close filestream (read)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mixmonitor_ds->fs_write) {
|
|
|
|
quitting = 1;
|
|
|
|
ast_closestream(mixmonitor_ds->fs_write);
|
|
|
|
mixmonitor_ds->fs_write = NULL;
|
|
|
|
ast_verb(2, "MixMonitor close filestream (write)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quitting) {
|
2009-06-17 19:45:35 +00:00
|
|
|
mixmonitor_ds->fs_quit = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mixmonitor_ds_destroy(void *data)
|
|
|
|
{
|
|
|
|
struct mixmonitor_ds *mixmonitor_ds = data;
|
|
|
|
|
|
|
|
ast_mutex_lock(&mixmonitor_ds->lock);
|
2009-11-19 21:26:21 +00:00
|
|
|
mixmonitor_ds->audiohook = NULL;
|
2009-06-17 19:45:35 +00:00
|
|
|
mixmonitor_ds->destruction_ok = 1;
|
2013-12-09 16:42:59 +00:00
|
|
|
ast_free(mixmonitor_ds->filename);
|
2014-04-15 23:21:19 +00:00
|
|
|
ast_free(mixmonitor_ds->beep_id);
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_cond_signal(&mixmonitor_ds->destruction_condition);
|
|
|
|
ast_mutex_unlock(&mixmonitor_ds->lock);
|
|
|
|
}
|
|
|
|
|
2012-07-18 17:18:20 +00:00
|
|
|
static const struct ast_datastore_info mixmonitor_ds_info = {
|
2009-06-17 19:45:35 +00:00
|
|
|
.type = "mixmonitor",
|
|
|
|
.destroy = mixmonitor_ds_destroy,
|
|
|
|
};
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
static void destroy_monitor_audiohook(struct mixmonitor *mixmonitor)
|
|
|
|
{
|
|
|
|
if (mixmonitor->mixmonitor_ds) {
|
|
|
|
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
|
|
|
|
mixmonitor->mixmonitor_ds->audiohook = NULL;
|
|
|
|
ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
|
|
|
|
}
|
|
|
|
/* kill the audiohook.*/
|
|
|
|
ast_audiohook_lock(&mixmonitor->audiohook);
|
|
|
|
ast_audiohook_detach(&mixmonitor->audiohook);
|
|
|
|
ast_audiohook_unlock(&mixmonitor->audiohook);
|
|
|
|
ast_audiohook_destroy(&mixmonitor->audiohook);
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:27:57 +00:00
|
|
|
static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
2014-10-03 19:42:54 +00:00
|
|
|
if (!chan) {
|
2005-10-28 23:01:13 +00:00
|
|
|
return -1;
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2014-10-03 19:42:54 +00:00
|
|
|
return ast_audiohook_attach(chan, audiohook);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief adds recipients to a mixmonitor's recipient list
|
|
|
|
* \param mixmonitor mixmonitor being affected
|
|
|
|
* \param vm_recipients string containing the desired recipients to add
|
|
|
|
*/
|
|
|
|
static void add_vm_recipients_from_string(struct mixmonitor *mixmonitor, const char *vm_recipients)
|
|
|
|
{
|
|
|
|
/* recipients are in a single string with a format format resembling "mailbox@context/INBOX,mailbox2@context2,mailbox3@context3/Work" */
|
|
|
|
char *cur_mailbox = ast_strdupa(vm_recipients);
|
|
|
|
char *cur_context;
|
|
|
|
char *cur_folder;
|
|
|
|
char *next;
|
|
|
|
int elements_processed = 0;
|
|
|
|
|
|
|
|
while (!ast_strlen_zero(cur_mailbox)) {
|
|
|
|
ast_debug(3, "attempting to add next element %d from %s\n", elements_processed, cur_mailbox);
|
|
|
|
if ((next = strchr(cur_mailbox, ',')) || (next = strchr(cur_mailbox, '&'))) {
|
|
|
|
*(next++) = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cur_folder = strchr(cur_mailbox, '/'))) {
|
|
|
|
*(cur_folder++) = '\0';
|
|
|
|
} else {
|
|
|
|
cur_folder = "INBOX";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cur_context = strchr(cur_mailbox, '@'))) {
|
|
|
|
*(cur_context++) = '\0';
|
|
|
|
} else {
|
|
|
|
cur_context = "default";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(cur_mailbox) && !ast_strlen_zero(cur_context)) {
|
|
|
|
struct vm_recipient *recipient;
|
|
|
|
if (!(recipient = ast_malloc(sizeof(*recipient)))) {
|
|
|
|
ast_log(LOG_ERROR, "Failed to allocate recipient. Aborting function.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ast_copy_string(recipient->context, cur_context, sizeof(recipient->context));
|
|
|
|
ast_copy_string(recipient->mailbox, cur_mailbox, sizeof(recipient->mailbox));
|
|
|
|
ast_copy_string(recipient->folder, cur_folder, sizeof(recipient->folder));
|
|
|
|
|
|
|
|
/* Add to list */
|
2014-05-28 22:54:12 +00:00
|
|
|
ast_verb(4, "Adding %s@%s to recipient list\n", recipient->mailbox, recipient->context);
|
2012-06-04 20:26:12 +00:00
|
|
|
AST_LIST_INSERT_HEAD(&mixmonitor->recipient_list, recipient, list);
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_ERROR, "Failed to properly parse extension and/or context from element %d of recipient string: %s\n", elements_processed, vm_recipients);
|
|
|
|
}
|
|
|
|
|
|
|
|
cur_mailbox = next;
|
|
|
|
elements_processed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clear_mixmonitor_recipient_list(struct mixmonitor *mixmonitor)
|
|
|
|
{
|
|
|
|
struct vm_recipient *current;
|
|
|
|
while ((current = AST_LIST_REMOVE_HEAD(&mixmonitor->recipient_list, list))) {
|
|
|
|
/* Clear list element data */
|
|
|
|
ast_free(current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
#define SAMPLES_PER_FRAME 160
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
static void mixmonitor_free(struct mixmonitor *mixmonitor)
|
|
|
|
{
|
|
|
|
if (mixmonitor) {
|
|
|
|
if (mixmonitor->mixmonitor_ds) {
|
|
|
|
ast_mutex_destroy(&mixmonitor->mixmonitor_ds->lock);
|
|
|
|
ast_cond_destroy(&mixmonitor->mixmonitor_ds->destruction_condition);
|
|
|
|
ast_free(mixmonitor->mixmonitor_ds);
|
|
|
|
}
|
2012-03-29 20:01:20 +00:00
|
|
|
|
2013-08-30 16:27:57 +00:00
|
|
|
ast_free(mixmonitor->name);
|
|
|
|
ast_free(mixmonitor->post_process);
|
|
|
|
ast_free(mixmonitor->filename);
|
|
|
|
ast_free(mixmonitor->filename_write);
|
|
|
|
ast_free(mixmonitor->filename_read);
|
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
/* Free everything in the recipient list */
|
|
|
|
clear_mixmonitor_recipient_list(mixmonitor);
|
|
|
|
|
|
|
|
/* clean stringfields */
|
|
|
|
ast_string_field_free_memory(mixmonitor);
|
|
|
|
|
2012-03-29 20:01:20 +00:00
|
|
|
if (mixmonitor->callid) {
|
|
|
|
ast_callid_unref(mixmonitor->callid);
|
|
|
|
}
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_free(mixmonitor);
|
|
|
|
}
|
|
|
|
}
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Copies the mixmonitor to all voicemail recipients
|
|
|
|
* \param mixmonitor The mixmonitor that needs to forward its file to recipients
|
|
|
|
* \param ext Format of the file that was saved
|
|
|
|
*/
|
|
|
|
static void copy_to_voicemail(struct mixmonitor *mixmonitor, const char *ext, const char *filename)
|
|
|
|
{
|
|
|
|
struct vm_recipient *recipient = NULL;
|
|
|
|
struct ast_vm_recording_data recording_data;
|
|
|
|
if (ast_string_field_init(&recording_data, 512)) {
|
|
|
|
ast_log(LOG_ERROR, "Failed to string_field_init, skipping copy_to_voicemail\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy strings to stringfields that will be used for all recipients */
|
|
|
|
ast_string_field_set(&recording_data, recording_file, filename);
|
|
|
|
ast_string_field_set(&recording_data, recording_ext, ext);
|
|
|
|
ast_string_field_set(&recording_data, call_context, mixmonitor->call_context);
|
|
|
|
ast_string_field_set(&recording_data, call_macrocontext, mixmonitor->call_macrocontext);
|
|
|
|
ast_string_field_set(&recording_data, call_extension, mixmonitor->call_extension);
|
|
|
|
ast_string_field_set(&recording_data, call_callerchan, mixmonitor->call_callerchan);
|
|
|
|
ast_string_field_set(&recording_data, call_callerid, mixmonitor->call_callerid);
|
|
|
|
/* and call_priority gets copied too */
|
|
|
|
recording_data.call_priority = mixmonitor->call_priority;
|
|
|
|
|
|
|
|
AST_LIST_TRAVERSE(&mixmonitor->recipient_list, recipient, list) {
|
|
|
|
/* context, mailbox, and folder need to be set per recipient */
|
|
|
|
ast_string_field_set(&recording_data, context, recipient->context);
|
|
|
|
ast_string_field_set(&recording_data, mailbox, recipient->mailbox);
|
|
|
|
ast_string_field_set(&recording_data, folder, recipient->folder);
|
|
|
|
|
|
|
|
ast_verb(4, "MixMonitor attempting to send voicemail copy to %s@%s\n", recording_data.mailbox,
|
|
|
|
recording_data.context);
|
|
|
|
ast_app_copy_recording_to_vm(&recording_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the string fields for recording_data before exiting the function. */
|
|
|
|
ast_string_field_free_memory(&recording_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mixmonitor_save_prep(struct mixmonitor *mixmonitor, char *filename, struct ast_filestream **fs, unsigned int *oflags, int *errflag, char **ext)
|
2011-03-11 18:54:45 +00:00
|
|
|
{
|
|
|
|
/* Initialize the file if not already done so */
|
|
|
|
char *last_slash = NULL;
|
|
|
|
if (!ast_strlen_zero(filename)) {
|
|
|
|
if (!*fs && !*errflag && !mixmonitor->mixmonitor_ds->fs_quit) {
|
|
|
|
*oflags = O_CREAT | O_WRONLY;
|
|
|
|
*oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
|
2011-07-13 22:10:26 +00:00
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
last_slash = strrchr(filename, '/');
|
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
if ((*ext = strrchr(filename, '.')) && (*ext > last_slash)) {
|
|
|
|
**ext = '\0';
|
|
|
|
*ext = *ext + 1;
|
2011-03-11 18:54:45 +00:00
|
|
|
} else {
|
2012-06-04 20:26:12 +00:00
|
|
|
*ext = "raw";
|
2011-03-11 18:54:45 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
if (!(*fs = ast_writefile(filename, *ext, NULL, *oflags, 0, 0666))) {
|
|
|
|
ast_log(LOG_ERROR, "Cannot open %s.%s\n", filename, *ext);
|
2011-03-11 18:54:45 +00:00
|
|
|
*errflag = 1;
|
2011-07-13 22:10:26 +00:00
|
|
|
} else {
|
|
|
|
struct ast_filestream *tmp = *fs;
|
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
|
|
|
mixmonitor->mixmonitor_ds->samp_rate = MAX(mixmonitor->mixmonitor_ds->samp_rate, ast_format_get_sample_rate(tmp->fmt->format));
|
2011-03-11 18:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:27:57 +00:00
|
|
|
static void *mixmonitor_thread(void *obj)
|
2005-10-28 23:01:13 +00:00
|
|
|
{
|
|
|
|
struct mixmonitor *mixmonitor = obj;
|
2012-06-04 20:26:12 +00:00
|
|
|
char *fs_ext = "";
|
|
|
|
char *fs_read_ext = "";
|
|
|
|
char *fs_write_ext = "";
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
struct ast_filestream **fs = NULL;
|
2011-03-11 18:54:45 +00:00
|
|
|
struct ast_filestream **fs_read = NULL;
|
|
|
|
struct ast_filestream **fs_write = NULL;
|
|
|
|
|
2007-01-22 19:22:07 +00:00
|
|
|
unsigned int oflags;
|
|
|
|
int errflag = 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
|
|
|
struct ast_format *format_slin;
|
2007-01-22 19:22:07 +00:00
|
|
|
|
2012-03-29 20:01:20 +00:00
|
|
|
/* Keep callid association before any log messages */
|
|
|
|
if (mixmonitor->callid) {
|
|
|
|
ast_callid_threadassoc_add(mixmonitor->callid);
|
|
|
|
}
|
|
|
|
|
2007-12-14 14:48:38 +00:00
|
|
|
ast_verb(2, "Begin MixMonitor Recording %s\n", mixmonitor->name);
|
2009-06-17 19:45:35 +00:00
|
|
|
|
|
|
|
fs = &mixmonitor->mixmonitor_ds->fs;
|
2011-03-11 18:54:45 +00:00
|
|
|
fs_read = &mixmonitor->mixmonitor_ds->fs_read;
|
|
|
|
fs_write = &mixmonitor->mixmonitor_ds->fs_write;
|
2009-06-17 19:45:35 +00:00
|
|
|
|
2011-07-13 22:10:26 +00:00
|
|
|
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
|
2012-06-04 20:26:12 +00:00
|
|
|
mixmonitor_save_prep(mixmonitor, mixmonitor->filename, fs, &oflags, &errflag, &fs_ext);
|
|
|
|
mixmonitor_save_prep(mixmonitor, mixmonitor->filename_read, fs_read, &oflags, &errflag, &fs_read_ext);
|
|
|
|
mixmonitor_save_prep(mixmonitor, mixmonitor->filename_write, fs_write, &oflags, &errflag, &fs_write_ext);
|
2011-07-13 22:10:26 +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
|
|
|
format_slin = ast_format_cache_get_slin_by_rate(mixmonitor->mixmonitor_ds->samp_rate);
|
2011-07-13 22:10:26 +00:00
|
|
|
|
|
|
|
ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/* The audiohook must enter and exit the loop locked */
|
|
|
|
ast_audiohook_lock(&mixmonitor->audiohook);
|
2009-06-17 19:45:35 +00:00
|
|
|
while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING && !mixmonitor->mixmonitor_ds->fs_quit) {
|
2007-08-08 19:30:52 +00:00
|
|
|
struct ast_frame *fr = NULL;
|
2011-03-11 18:54:45 +00:00
|
|
|
struct ast_frame *fr_read = NULL;
|
|
|
|
struct ast_frame *fr_write = NULL;
|
2005-10-28 23:01:13 +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 (!(fr = ast_audiohook_read_frame_all(&mixmonitor->audiohook, SAMPLES_PER_FRAME, format_slin,
|
2011-03-11 18:54:45 +00:00
|
|
|
&fr_read, &fr_write))) {
|
2010-04-16 21:22:30 +00:00
|
|
|
ast_audiohook_trigger_wait(&mixmonitor->audiohook);
|
2007-08-08 19:30:52 +00:00
|
|
|
|
2010-04-16 21:22:30 +00:00
|
|
|
if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
|
|
|
|
break;
|
|
|
|
}
|
2007-08-08 19:30:52 +00:00
|
|
|
continue;
|
2010-04-16 21:22:30 +00:00
|
|
|
}
|
2007-08-08 19:30:52 +00:00
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/* audiohook lock is not required for the next block.
|
|
|
|
* Unlock it, but remember to lock it before looping or exiting */
|
|
|
|
ast_audiohook_unlock(&mixmonitor->audiohook);
|
|
|
|
|
2013-07-02 20:45:47 +00:00
|
|
|
if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED)
|
|
|
|
|| (mixmonitor->autochan->chan
|
|
|
|
&& ast_channel_is_bridged(mixmonitor->autochan->chan))) {
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
|
2011-03-11 18:54:45 +00:00
|
|
|
|
|
|
|
/* Write out the frame(s) */
|
|
|
|
if ((*fs_read) && (fr_read)) {
|
|
|
|
struct ast_frame *cur;
|
|
|
|
|
|
|
|
for (cur = fr_read; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
|
|
|
|
ast_writestream(*fs_read, cur);
|
2007-10-31 17:56:21 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
2009-06-16 18:54:30 +00:00
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
if ((*fs_write) && (fr_write)) {
|
|
|
|
struct ast_frame *cur;
|
|
|
|
|
|
|
|
for (cur = fr_write; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
|
|
|
|
ast_writestream(*fs_write, cur);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*fs) && (fr)) {
|
2009-06-16 18:54:30 +00:00
|
|
|
struct ast_frame *cur;
|
|
|
|
|
|
|
|
for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_writestream(*fs, cur);
|
2009-06-16 18:54:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
2007-08-08 19:30:52 +00:00
|
|
|
/* All done! free it. */
|
2011-03-11 18:54:45 +00:00
|
|
|
if (fr) {
|
|
|
|
ast_frame_free(fr, 0);
|
|
|
|
}
|
|
|
|
if (fr_read) {
|
|
|
|
ast_frame_free(fr_read, 0);
|
|
|
|
}
|
|
|
|
if (fr_write) {
|
|
|
|
ast_frame_free(fr_write, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fr = NULL;
|
|
|
|
fr_write = NULL;
|
|
|
|
fr_read = NULL;
|
2007-08-08 19:30:52 +00:00
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
ast_audiohook_lock(&mixmonitor->audiohook);
|
2005-10-28 23:01:13 +00:00
|
|
|
}
|
2012-10-30 19:20:33 +00:00
|
|
|
|
2014-08-22 16:56:57 +00:00
|
|
|
ast_audiohook_unlock(&mixmonitor->audiohook);
|
|
|
|
|
2014-07-22 20:01:42 +00:00
|
|
|
ast_channel_lock(mixmonitor->autochan->chan);
|
|
|
|
if (ast_test_flag(mixmonitor, MUXFLAG_BEEP_STOP)) {
|
|
|
|
ast_stream_and_wait(mixmonitor->autochan->chan, "beep", "");
|
|
|
|
}
|
|
|
|
ast_channel_unlock(mixmonitor->autochan->chan);
|
2012-10-30 19:20:33 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
ast_autochan_destroy(mixmonitor->autochan);
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/* Datastore cleanup. close the filestream and wait for ds destruction */
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
|
2009-11-19 21:26:21 +00:00
|
|
|
mixmonitor_ds_close_fs(mixmonitor->mixmonitor_ds);
|
2009-06-17 19:45:35 +00:00
|
|
|
if (!mixmonitor->mixmonitor_ds->destruction_ok) {
|
|
|
|
ast_cond_wait(&mixmonitor->mixmonitor_ds->destruction_condition, &mixmonitor->mixmonitor_ds->lock);
|
|
|
|
}
|
|
|
|
ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/* kill the audiohook */
|
|
|
|
destroy_monitor_audiohook(mixmonitor);
|
|
|
|
|
|
|
|
if (mixmonitor->post_process) {
|
|
|
|
ast_verb(2, "Executing [%s]\n", mixmonitor->post_process);
|
|
|
|
ast_safe_system(mixmonitor->post_process);
|
|
|
|
}
|
2009-06-17 19:45:35 +00:00
|
|
|
|
|
|
|
ast_verb(2, "End MixMonitor Recording %s\n", mixmonitor->name);
|
2015-02-15 00:33:22 +00:00
|
|
|
ast_test_suite_event_notify("MIXMONITOR_END", "File: %s\r\n", mixmonitor->filename);
|
2012-06-04 20:26:12 +00:00
|
|
|
|
|
|
|
if (!AST_LIST_EMPTY(&mixmonitor->recipient_list)) {
|
|
|
|
if (ast_strlen_zero(fs_ext)) {
|
|
|
|
ast_log(LOG_ERROR, "No file extension set for Mixmonitor %s. Skipping copy to voicemail.\n",
|
|
|
|
mixmonitor -> name);
|
|
|
|
} else {
|
|
|
|
ast_verb(3, "Copying recordings for Mixmonitor %s to voicemail recipients\n", mixmonitor->name);
|
|
|
|
copy_to_voicemail(mixmonitor, fs_ext, mixmonitor->filename);
|
|
|
|
}
|
|
|
|
if (!ast_strlen_zero(fs_read_ext)) {
|
|
|
|
ast_verb(3, "Copying read recording for Mixmonitor %s to voicemail recipients\n", mixmonitor->name);
|
|
|
|
copy_to_voicemail(mixmonitor, fs_read_ext, mixmonitor->filename_read);
|
|
|
|
}
|
|
|
|
if (!ast_strlen_zero(fs_write_ext)) {
|
|
|
|
ast_verb(3, "Copying write recording for Mixmonitor %s to voicemail recipients\n", mixmonitor->name);
|
|
|
|
copy_to_voicemail(mixmonitor, fs_write_ext, mixmonitor->filename_write);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ast_debug(3, "No recipients to forward monitor to, moving on.\n");
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
mixmonitor_free(mixmonitor);
|
2013-06-14 16:32:43 +00:00
|
|
|
|
|
|
|
ast_module_unref(ast_module_info->self);
|
2005-10-16 02:59:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
static int setup_mixmonitor_ds(struct mixmonitor *mixmonitor, struct ast_channel *chan, char **datastore_id, const char *beep_id)
|
2009-06-17 19:45:35 +00:00
|
|
|
{
|
|
|
|
struct ast_datastore *datastore = NULL;
|
|
|
|
struct mixmonitor_ds *mixmonitor_ds;
|
|
|
|
|
|
|
|
if (!(mixmonitor_ds = ast_calloc(1, sizeof(*mixmonitor_ds)))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (ast_asprintf(datastore_id, "%p", mixmonitor_ds) == -1) {
|
|
|
|
ast_log(LOG_ERROR, "Failed to allocate memory for MixMonitor ID.\n");
|
|
|
|
}
|
|
|
|
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_mutex_init(&mixmonitor_ds->lock);
|
|
|
|
ast_cond_init(&mixmonitor_ds->destruction_condition, NULL);
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (!(datastore = ast_datastore_alloc(&mixmonitor_ds_info, *datastore_id))) {
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_mutex_destroy(&mixmonitor_ds->lock);
|
|
|
|
ast_cond_destroy(&mixmonitor_ds->destruction_condition);
|
|
|
|
ast_free(mixmonitor_ds);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-07-22 20:01:42 +00:00
|
|
|
ast_channel_lock(mixmonitor->autochan->chan);
|
|
|
|
if (ast_test_flag(mixmonitor, MUXFLAG_BEEP_START)) {
|
|
|
|
ast_stream_and_wait(mixmonitor->autochan->chan, "beep", "");
|
|
|
|
}
|
|
|
|
ast_channel_unlock(mixmonitor->autochan->chan);
|
2011-07-13 22:10:26 +00:00
|
|
|
|
|
|
|
mixmonitor_ds->samp_rate = 8000;
|
2009-11-19 21:26:21 +00:00
|
|
|
mixmonitor_ds->audiohook = &mixmonitor->audiohook;
|
2013-12-09 16:42:59 +00:00
|
|
|
mixmonitor_ds->filename = ast_strdup(mixmonitor->filename);
|
2014-04-15 23:21:19 +00:00
|
|
|
if (!ast_strlen_zero(beep_id)) {
|
|
|
|
mixmonitor_ds->beep_id = ast_strdup(beep_id);
|
|
|
|
}
|
2009-06-17 19:45:35 +00:00
|
|
|
datastore->data = mixmonitor_ds;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
ast_channel_datastore_add(chan, datastore);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
mixmonitor->mixmonitor_ds = mixmonitor_ds;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-14 16:32:43 +00:00
|
|
|
static int launch_monitor_thread(struct ast_channel *chan, const char *filename,
|
2011-03-11 18:54:45 +00:00
|
|
|
unsigned int flags, int readvol, int writevol,
|
|
|
|
const char *post_process, const char *filename_write,
|
2012-06-04 20:26:12 +00:00
|
|
|
char *filename_read, const char *uid_channel_var,
|
2014-04-15 23:21:19 +00:00
|
|
|
const char *recipients, const char *beep_id)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
|
|
|
pthread_t thread;
|
2005-10-28 23:01:13 +00:00
|
|
|
struct mixmonitor *mixmonitor;
|
2007-11-13 01:19:53 +00:00
|
|
|
char postprocess2[1024] = "";
|
2012-01-23 18:16:20 +00:00
|
|
|
char *datastore_id = NULL;
|
2006-06-13 13:40:58 +00:00
|
|
|
|
2007-11-12 18:44:36 +00:00
|
|
|
postprocess2[0] = 0;
|
2006-06-13 13:40:58 +00:00
|
|
|
/* If a post process system command is given attach it to the structure */
|
|
|
|
if (!ast_strlen_zero(post_process)) {
|
|
|
|
char *p1, *p2;
|
|
|
|
|
|
|
|
p1 = ast_strdupa(post_process);
|
2011-03-11 18:54:45 +00:00
|
|
|
for (p2 = p1; *p2; p2++) {
|
2006-06-13 13:40:58 +00:00
|
|
|
if (*p2 == '^' && *(p2+1) == '{') {
|
|
|
|
*p2 = '$';
|
|
|
|
}
|
|
|
|
}
|
2013-07-02 20:56:13 +00:00
|
|
|
ast_channel_lock(chan);
|
2006-06-13 13:40:58 +00:00
|
|
|
pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
|
2013-07-02 20:56:13 +00:00
|
|
|
ast_channel_unlock(chan);
|
2006-06-12 21:37:29 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2006-06-13 13:40:58 +00:00
|
|
|
/* Pre-allocate mixmonitor structure and spy */
|
2011-03-11 18:54:45 +00:00
|
|
|
if (!(mixmonitor = ast_calloc(1, sizeof(*mixmonitor)))) {
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2006-06-13 13:40:58 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
/* Now that the struct has been calloced, go ahead and initialize the string fields. */
|
|
|
|
if (ast_string_field_init(mixmonitor, 512)) {
|
|
|
|
mixmonitor_free(mixmonitor);
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2012-06-04 20:26:12 +00:00
|
|
|
}
|
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
/* Setup the actual spy before creating our thread */
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type, 0)) {
|
2009-11-19 21:26:21 +00:00
|
|
|
mixmonitor_free(mixmonitor);
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2009-11-19 21:26:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-12 21:37:29 +00:00
|
|
|
/* Copy over flags and channel name */
|
|
|
|
mixmonitor->flags = flags;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
if (!(mixmonitor->autochan = ast_autochan_setup(chan))) {
|
2009-06-17 19:45:35 +00:00
|
|
|
mixmonitor_free(mixmonitor);
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2009-06-17 19:45:35 +00:00
|
|
|
}
|
|
|
|
|
2013-12-09 16:42:59 +00:00
|
|
|
if (!ast_strlen_zero(filename)) {
|
|
|
|
mixmonitor->filename = ast_strdup(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(filename_write)) {
|
|
|
|
mixmonitor->filename_write = ast_strdup(filename_write);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(filename_read)) {
|
|
|
|
mixmonitor->filename_read = ast_strdup(filename_read);
|
|
|
|
}
|
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
if (setup_mixmonitor_ds(mixmonitor, chan, &datastore_id, beep_id)) {
|
2009-06-17 19:45:35 +00:00
|
|
|
ast_autochan_destroy(mixmonitor->autochan);
|
|
|
|
mixmonitor_free(mixmonitor);
|
2012-01-23 18:16:20 +00:00
|
|
|
ast_free(datastore_id);
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2009-02-05 18:34:06 +00:00
|
|
|
}
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (!ast_strlen_zero(uid_channel_var)) {
|
|
|
|
if (datastore_id) {
|
|
|
|
pbx_builtin_setvar_helper(chan, uid_channel_var, datastore_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_free(datastore_id);
|
|
|
|
|
2012-01-09 22:15:50 +00:00
|
|
|
mixmonitor->name = ast_strdup(ast_channel_name(chan));
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2006-06-13 13:40:58 +00:00
|
|
|
if (!ast_strlen_zero(postprocess2)) {
|
2011-03-11 18:54:45 +00:00
|
|
|
mixmonitor->post_process = ast_strdup(postprocess2);
|
|
|
|
}
|
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
if (!ast_strlen_zero(recipients)) {
|
|
|
|
char callerid[256];
|
|
|
|
struct ast_party_connected_line *connected;
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
|
|
|
/* We use the connected line of the invoking channel for caller ID. */
|
|
|
|
|
|
|
|
connected = ast_channel_connected(chan);
|
|
|
|
ast_debug(3, "Connected Line CID = %d - %s : %d - %s\n", connected->id.name.valid,
|
|
|
|
connected->id.name.str, connected->id.number.valid,
|
|
|
|
connected->id.number.str);
|
|
|
|
ast_callerid_merge(callerid, sizeof(callerid),
|
|
|
|
S_COR(connected->id.name.valid, connected->id.name.str, NULL),
|
|
|
|
S_COR(connected->id.number.valid, connected->id.number.str, NULL),
|
|
|
|
"Unknown");
|
|
|
|
|
|
|
|
ast_string_field_set(mixmonitor, call_context, ast_channel_context(chan));
|
|
|
|
ast_string_field_set(mixmonitor, call_macrocontext, ast_channel_macrocontext(chan));
|
|
|
|
ast_string_field_set(mixmonitor, call_extension, ast_channel_exten(chan));
|
|
|
|
ast_string_field_set(mixmonitor, call_callerchan, ast_channel_name(chan));
|
|
|
|
ast_string_field_set(mixmonitor, call_callerid, callerid);
|
|
|
|
mixmonitor->call_priority = ast_channel_priority(chan);
|
|
|
|
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
add_vm_recipients_from_string(mixmonitor, recipients);
|
|
|
|
}
|
|
|
|
|
2008-03-12 18:29:33 +00:00
|
|
|
ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_SYNC);
|
2007-08-08 19:30:52 +00:00
|
|
|
|
2007-10-31 18:03:17 +00:00
|
|
|
if (readvol)
|
|
|
|
mixmonitor->audiohook.options.read_volume = readvol;
|
|
|
|
if (writevol)
|
|
|
|
mixmonitor->audiohook.options.write_volume = writevol;
|
|
|
|
|
2007-08-08 19:30:52 +00:00
|
|
|
if (startmon(chan, &mixmonitor->audiohook)) {
|
2006-06-12 21:37:29 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
|
2012-01-09 22:15:50 +00:00
|
|
|
mixmonitor_spy_type, ast_channel_name(chan));
|
2007-08-08 19:30:52 +00:00
|
|
|
ast_audiohook_destroy(&mixmonitor->audiohook);
|
2009-08-19 21:21:00 +00:00
|
|
|
mixmonitor_free(mixmonitor);
|
2013-06-14 16:32:43 +00:00
|
|
|
return -1;
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 20:01:20 +00:00
|
|
|
/* reference be released at mixmonitor destruction */
|
|
|
|
mixmonitor->callid = ast_read_threadstorage_callid();
|
|
|
|
|
2013-06-14 16:32:43 +00:00
|
|
|
return ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
/* a note on filename_parse: creates directory structure and assigns absolute path from relative paths for filenames */
|
|
|
|
/* requires immediate copying of string from return to retain data since otherwise it will immediately lose scope */
|
|
|
|
static char *filename_parse(char *filename, char *buffer, size_t len)
|
|
|
|
{
|
|
|
|
char *slash;
|
|
|
|
if (ast_strlen_zero(filename)) {
|
|
|
|
ast_log(LOG_WARNING, "No file name was provided for a file save option.\n");
|
|
|
|
} else if (filename[0] != '/') {
|
|
|
|
char *build;
|
2012-07-31 20:21:43 +00:00
|
|
|
build = ast_alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);
|
2011-03-11 18:54:45 +00:00
|
|
|
sprintf(build, "%s/%s", ast_config_AST_MONITOR_DIR, filename);
|
|
|
|
filename = build;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_copy_string(buffer, filename, len);
|
|
|
|
|
|
|
|
if ((slash = strrchr(filename, '/'))) {
|
|
|
|
*slash = '\0';
|
|
|
|
}
|
|
|
|
ast_mkdir(filename, 0777);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2009-05-21 21:13:09 +00:00
|
|
|
static int mixmonitor_exec(struct ast_channel *chan, const char *data)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
2005-10-28 23:01:13 +00:00
|
|
|
int x, readvol = 0, writevol = 0;
|
2011-03-11 18:54:45 +00:00
|
|
|
char *filename_read = NULL;
|
|
|
|
char *filename_write = NULL;
|
|
|
|
char filename_buffer[1024] = "";
|
2013-07-02 21:19:21 +00:00
|
|
|
char *uid_channel_var = NULL;
|
2014-04-15 23:21:19 +00:00
|
|
|
char beep_id[64] = "";
|
2011-03-11 18:54:45 +00:00
|
|
|
|
|
|
|
struct ast_flags flags = { 0 };
|
2012-06-04 20:26:12 +00:00
|
|
|
char *recipients = NULL;
|
2011-03-11 18:54:45 +00:00
|
|
|
char *parse;
|
2005-10-28 23:01:13 +00:00
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(filename);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
AST_APP_ARG(post_process);
|
|
|
|
);
|
2012-01-23 18:16:20 +00:00
|
|
|
|
2005-10-26 19:48:14 +00:00
|
|
|
if (ast_strlen_zero(data)) {
|
2011-03-11 18:54:45 +00:00
|
|
|
ast_log(LOG_WARNING, "MixMonitor requires an argument (filename or ,t(filename) and/or r(filename)\n");
|
2005-10-16 02:59:13 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-05-10 13:22:15 +00:00
|
|
|
parse = ast_strdupa(data);
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2007-11-13 16:03:10 +00:00
|
|
|
if (args.options) {
|
2005-11-03 21:19:11 +00:00
|
|
|
char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2005-11-03 21:19:11 +00:00
|
|
|
ast_app_parse_options(mixmonitor_opts, &flags, opts, args.options);
|
2005-10-28 23:01:13 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_READVOLUME)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
if (ast_strlen_zero(opts[OPT_ARG_READVOLUME])) {
|
2005-10-28 23:01:13 +00:00
|
|
|
ast_log(LOG_WARNING, "No volume level was provided for the heard volume ('v') option.\n");
|
2009-08-10 19:20:57 +00:00
|
|
|
} else if ((sscanf(opts[OPT_ARG_READVOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
ast_log(LOG_NOTICE, "Heard volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_READVOLUME]);
|
2005-10-28 23:01:13 +00:00
|
|
|
} else {
|
|
|
|
readvol = get_volfactor(x);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-23 18:16:20 +00:00
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
if (ast_test_flag(&flags, MUXFLAG_WRITEVOLUME)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
if (ast_strlen_zero(opts[OPT_ARG_WRITEVOLUME])) {
|
2005-10-28 23:01:13 +00:00
|
|
|
ast_log(LOG_WARNING, "No volume level was provided for the spoken volume ('V') option.\n");
|
2009-08-10 19:20:57 +00:00
|
|
|
} else if ((sscanf(opts[OPT_ARG_WRITEVOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
ast_log(LOG_NOTICE, "Spoken volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_WRITEVOLUME]);
|
2005-10-28 23:01:13 +00:00
|
|
|
} else {
|
|
|
|
writevol = get_volfactor(x);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-23 18:16:20 +00:00
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
if (ast_test_flag(&flags, MUXFLAG_VOLUME)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
if (ast_strlen_zero(opts[OPT_ARG_VOLUME])) {
|
2005-10-28 23:01:13 +00:00
|
|
|
ast_log(LOG_WARNING, "No volume level was provided for the combined volume ('W') option.\n");
|
2009-08-10 19:20:57 +00:00
|
|
|
} else if ((sscanf(opts[OPT_ARG_VOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
|
2005-11-03 21:19:11 +00:00
|
|
|
ast_log(LOG_NOTICE, "Combined volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_VOLUME]);
|
2005-10-28 23:01:13 +00:00
|
|
|
} else {
|
|
|
|
readvol = writevol = get_volfactor(x);
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-11 18:54:45 +00:00
|
|
|
|
2012-06-04 20:26:12 +00:00
|
|
|
if (ast_test_flag(&flags, MUXFLAG_VMRECIPIENTS)) {
|
|
|
|
if (ast_strlen_zero(opts[OPT_ARG_VMRECIPIENTS])) {
|
|
|
|
ast_log(LOG_WARNING, "No voicemail recipients were specified for the vm copy ('m') option.\n");
|
|
|
|
} else {
|
|
|
|
recipients = ast_strdupa(opts[OPT_ARG_VMRECIPIENTS]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
if (ast_test_flag(&flags, MUXFLAG_WRITE)) {
|
|
|
|
filename_write = ast_strdupa(filename_parse(opts[OPT_ARG_WRITENAME], filename_buffer, sizeof(filename_buffer)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_READ)) {
|
|
|
|
filename_read = ast_strdupa(filename_parse(opts[OPT_ARG_READNAME], filename_buffer, sizeof(filename_buffer)));
|
|
|
|
}
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (ast_test_flag(&flags, MUXFLAG_UID)) {
|
|
|
|
uid_channel_var = opts[OPT_ARG_UID];
|
|
|
|
}
|
2014-04-15 23:21:19 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_BEEP)) {
|
|
|
|
const char *interval_str = S_OR(opts[OPT_ARG_BEEP_INTERVAL], "15");
|
|
|
|
unsigned int interval = 15;
|
|
|
|
|
|
|
|
if (sscanf(interval_str, "%30u", &interval) != 1) {
|
|
|
|
ast_log(LOG_WARNING, "Invalid interval '%s' for periodic beep. Using default of %u\n",
|
|
|
|
interval_str, interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_beep_start(chan, interval, beep_id, sizeof(beep_id))) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to enable periodic beep, please ensure func_periodic_hook is loaded.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2012-01-23 18:16:20 +00:00
|
|
|
}
|
2011-03-11 18:54:45 +00:00
|
|
|
/* If there are no file writing arguments/options for the mix monitor, send a warning message and return -1 */
|
2005-10-28 23:01:13 +00:00
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
if (!ast_test_flag(&flags, MUXFLAG_WRITE) && !ast_test_flag(&flags, MUXFLAG_READ) && ast_strlen_zero(args.filename)) {
|
|
|
|
ast_log(LOG_WARNING, "MixMonitor requires an argument (filename)\n");
|
|
|
|
return -1;
|
2005-10-28 23:01:13 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 18:54:45 +00:00
|
|
|
/* If filename exists, try to create directories for it */
|
|
|
|
if (!(ast_strlen_zero(args.filename))) {
|
|
|
|
args.filename = ast_strdupa(filename_parse(args.filename, filename_buffer, sizeof(filename_buffer)));
|
|
|
|
}
|
2007-06-24 16:20:18 +00:00
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
|
2013-06-14 16:32:43 +00:00
|
|
|
|
|
|
|
/* If launch_monitor_thread works, the module reference must not be released until it is finished. */
|
|
|
|
ast_module_ref(ast_module_info->self);
|
|
|
|
if (launch_monitor_thread(chan,
|
2012-06-04 20:26:12 +00:00
|
|
|
args.filename,
|
|
|
|
flags.flags,
|
|
|
|
readvol,
|
|
|
|
writevol,
|
|
|
|
args.post_process,
|
|
|
|
filename_write,
|
|
|
|
filename_read,
|
|
|
|
uid_channel_var,
|
2014-04-15 23:21:19 +00:00
|
|
|
recipients,
|
|
|
|
beep_id)) {
|
2013-06-14 16:32:43 +00:00
|
|
|
ast_module_unref(ast_module_info->self);
|
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2005-10-28 23:01:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2013-03-22 20:43:24 +00:00
|
|
|
static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
|
2006-02-16 17:37:03 +00:00
|
|
|
{
|
2009-06-17 19:45:35 +00:00
|
|
|
struct ast_datastore *datastore = NULL;
|
2012-01-23 18:16:20 +00:00
|
|
|
char *parse = "";
|
|
|
|
struct mixmonitor_ds *mixmonitor_ds;
|
2014-04-15 23:21:19 +00:00
|
|
|
const char *beep_id = NULL;
|
2012-01-23 18:16:20 +00:00
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(mixmonid);
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(data)) {
|
|
|
|
parse = ast_strdupa(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
2009-06-17 19:45:35 +00:00
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
2014-10-03 19:42:54 +00:00
|
|
|
datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info,
|
|
|
|
S_OR(args.mixmonid, NULL));
|
2013-07-02 21:19:21 +00:00
|
|
|
if (!datastore) {
|
2012-01-23 18:16:20 +00:00
|
|
|
ast_channel_unlock(chan);
|
2013-07-02 21:19:21 +00:00
|
|
|
return -1;
|
2012-01-23 18:16:20 +00:00
|
|
|
}
|
|
|
|
mixmonitor_ds = datastore->data;
|
|
|
|
|
|
|
|
ast_mutex_lock(&mixmonitor_ds->lock);
|
|
|
|
|
2013-12-17 23:38:02 +00:00
|
|
|
/* closing the filestream here guarantees the file is available to the dialplan
|
2012-01-23 18:16:20 +00:00
|
|
|
* after calling StopMixMonitor */
|
|
|
|
mixmonitor_ds_close_fs(mixmonitor_ds);
|
2009-11-19 21:26:21 +00:00
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
/* The mixmonitor thread may be waiting on the audiohook trigger.
|
|
|
|
* In order to exit from the mixmonitor loop before waiting on channel
|
|
|
|
* destruction, poke the audiohook trigger. */
|
|
|
|
if (mixmonitor_ds->audiohook) {
|
|
|
|
if (mixmonitor_ds->audiohook->status != AST_AUDIOHOOK_STATUS_DONE) {
|
|
|
|
ast_audiohook_update_status(mixmonitor_ds->audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN);
|
2009-11-19 21:26:21 +00:00
|
|
|
}
|
2012-01-23 18:16:20 +00:00
|
|
|
ast_audiohook_lock(mixmonitor_ds->audiohook);
|
|
|
|
ast_cond_signal(&mixmonitor_ds->audiohook->trigger);
|
|
|
|
ast_audiohook_unlock(mixmonitor_ds->audiohook);
|
|
|
|
mixmonitor_ds->audiohook = NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
if (!ast_strlen_zero(mixmonitor_ds->beep_id)) {
|
|
|
|
beep_id = ast_strdupa(mixmonitor_ds->beep_id);
|
|
|
|
}
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
ast_mutex_unlock(&mixmonitor_ds->lock);
|
|
|
|
|
|
|
|
/* Remove the datastore so the monitor thread can exit */
|
|
|
|
if (!ast_channel_datastore_remove(chan, datastore)) {
|
|
|
|
ast_datastore_free(datastore);
|
2009-06-17 19:45:35 +00:00
|
|
|
}
|
2014-07-22 20:01:42 +00:00
|
|
|
|
2009-11-19 21:26:21 +00:00
|
|
|
ast_channel_unlock(chan);
|
2009-06-17 19:45:35 +00:00
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
if (!ast_strlen_zero(beep_id)) {
|
|
|
|
ast_beep_stop(chan, beep_id);
|
|
|
|
}
|
|
|
|
|
2006-02-16 17:37:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-22 20:43:24 +00:00
|
|
|
static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
|
|
|
|
{
|
|
|
|
stop_mixmonitor_full(chan, data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-11 19:03:06 +00:00
|
|
|
static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *chan;
|
2012-01-23 18:16:20 +00:00
|
|
|
struct ast_datastore *datastore = NULL;
|
|
|
|
struct mixmonitor_ds *mixmonitor_ds = NULL;
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2007-10-11 19:03:06 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case CLI_INIT:
|
2012-01-23 18:16:20 +00:00
|
|
|
e->command = "mixmonitor {start|stop|list}";
|
2007-10-11 19:03:06 +00:00
|
|
|
e->usage =
|
2013-07-02 21:12:26 +00:00
|
|
|
"Usage: mixmonitor start <chan_name> [args]\n"
|
|
|
|
" The optional arguments are passed to the MixMonitor application.\n"
|
|
|
|
" mixmonitor stop <chan_name> [args]\n"
|
|
|
|
" The optional arguments are passed to the StopMixMonitor application.\n"
|
|
|
|
" mixmonitor list <chan_name>\n";
|
2007-10-11 19:03:06 +00:00
|
|
|
return NULL;
|
|
|
|
case CLI_GENERATE:
|
|
|
|
return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
|
|
|
|
}
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (a->argc < 3) {
|
2007-10-11 19:03:06 +00:00
|
|
|
return CLI_SHOWUSAGE;
|
2012-01-23 18:16:20 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
if (!(chan = ast_channel_get_by_name_prefix(a->argv[2], strlen(a->argv[2])))) {
|
2007-10-11 19:03:06 +00:00
|
|
|
ast_cli(a->fd, "No channel matching '%s' found.\n", a->argv[2]);
|
|
|
|
/* Technically this is a failure, but we don't want 2 errors printing out */
|
|
|
|
return CLI_SUCCESS;
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 19:03:06 +00:00
|
|
|
if (!strcasecmp(a->argv[1], "start")) {
|
2012-01-23 18:16:20 +00:00
|
|
|
mixmonitor_exec(chan, (a->argc >= 4) ? a->argv[3] : "");
|
|
|
|
} else if (!strcasecmp(a->argv[1], "stop")){
|
|
|
|
stop_mixmonitor_exec(chan, (a->argc >= 4) ? a->argv[3] : "");
|
|
|
|
} else if (!strcasecmp(a->argv[1], "list")) {
|
|
|
|
ast_cli(a->fd, "MixMonitor ID\tFile\tReceive File\tTransmit File\n");
|
|
|
|
ast_cli(a->fd, "=========================================================================\n");
|
2013-07-02 20:56:13 +00:00
|
|
|
ast_channel_lock(chan);
|
2012-02-29 16:52:47 +00:00
|
|
|
AST_LIST_TRAVERSE(ast_channel_datastores(chan), datastore, entry) {
|
2012-01-23 18:16:20 +00:00
|
|
|
if (datastore->info == &mixmonitor_ds_info) {
|
|
|
|
char *filename = "";
|
|
|
|
char *filename_read = "";
|
|
|
|
char *filename_write = "";
|
2013-07-02 21:13:56 +00:00
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
mixmonitor_ds = datastore->data;
|
2013-07-02 21:13:56 +00:00
|
|
|
if (mixmonitor_ds->fs) {
|
|
|
|
filename = mixmonitor_ds->fs->filename;
|
|
|
|
}
|
|
|
|
if (mixmonitor_ds->fs_read) {
|
|
|
|
filename_read = mixmonitor_ds->fs_read->filename;
|
|
|
|
}
|
|
|
|
if (mixmonitor_ds->fs_write) {
|
|
|
|
filename_write = mixmonitor_ds->fs_write->filename;
|
|
|
|
}
|
2012-01-23 18:16:20 +00:00
|
|
|
ast_cli(a->fd, "%p\t%s\t%s\t%s\n", mixmonitor_ds, filename, filename_read, filename_write);
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 19:30:52 +00:00
|
|
|
ast_channel_unlock(chan);
|
|
|
|
} else {
|
2012-01-23 18:16:20 +00:00
|
|
|
chan = ast_channel_unref(chan);
|
|
|
|
return CLI_SHOWUSAGE;
|
2007-08-08 19:30:52 +00:00
|
|
|
}
|
2005-10-28 23:01:13 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
chan = ast_channel_unref(chan);
|
|
|
|
|
2007-10-11 19:03:06 +00:00
|
|
|
return CLI_SUCCESS;
|
2006-02-16 17:37:03 +00:00
|
|
|
}
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2010-04-21 11:27:27 +00:00
|
|
|
/*! \brief Mute / unmute a MixMonitor channel */
|
|
|
|
static int manager_mute_mixmonitor(struct mansession *s, const struct message *m)
|
|
|
|
{
|
2013-07-02 21:19:21 +00:00
|
|
|
struct ast_channel *c;
|
2010-04-21 11:27:27 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
const char *id = astman_get_header(m, "ActionID");
|
|
|
|
const char *state = astman_get_header(m, "State");
|
|
|
|
const char *direction = astman_get_header(m,"Direction");
|
|
|
|
int clearmute = 1;
|
|
|
|
enum ast_audiohook_flags flag;
|
|
|
|
|
|
|
|
if (ast_strlen_zero(direction)) {
|
|
|
|
astman_send_error(s, m, "No direction specified. Must be read, write or both");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcasecmp(direction, "read")) {
|
|
|
|
flag = AST_AUDIOHOOK_MUTE_READ;
|
|
|
|
} else if (!strcasecmp(direction, "write")) {
|
|
|
|
flag = AST_AUDIOHOOK_MUTE_WRITE;
|
|
|
|
} else if (!strcasecmp(direction, "both")) {
|
|
|
|
flag = AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE;
|
|
|
|
} else {
|
|
|
|
astman_send_error(s, m, "Invalid direction specified. Must be read, write or both");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_strlen_zero(name)) {
|
|
|
|
astman_send_error(s, m, "No channel specified");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_strlen_zero(state)) {
|
|
|
|
astman_send_error(s, m, "No state specified");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
clearmute = ast_false(state);
|
|
|
|
|
2013-07-02 21:19:21 +00:00
|
|
|
c = ast_channel_get_by_name(name);
|
2010-04-21 11:27:27 +00:00
|
|
|
if (!c) {
|
|
|
|
astman_send_error(s, m, "No such channel");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_audiohook_set_mute(c, mixmonitor_spy_type, flag, clearmute)) {
|
2013-07-02 21:19:21 +00:00
|
|
|
ast_channel_unref(c);
|
2010-04-21 11:27:27 +00:00
|
|
|
astman_send_error(s, m, "Cannot set mute flag");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, "Response: Success\r\n");
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(id)) {
|
|
|
|
astman_append(s, "ActionID: %s\r\n", id);
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, "\r\n");
|
|
|
|
|
2013-07-02 21:19:21 +00:00
|
|
|
ast_channel_unref(c);
|
2010-04-21 11:27:27 +00:00
|
|
|
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-07-01 16:01:24 +00:00
|
|
|
static int start_mixmonitor_callback(struct ast_channel *chan, const char *filename, const char *options)
|
|
|
|
{
|
2013-07-02 21:16:25 +00:00
|
|
|
char args[PATH_MAX];
|
2013-07-01 16:01:24 +00:00
|
|
|
|
2013-07-02 21:16:25 +00:00
|
|
|
if (ast_strlen_zero(options)) {
|
|
|
|
snprintf(args, sizeof(args), "%s", filename);
|
|
|
|
} else {
|
|
|
|
snprintf(args, sizeof(args), "%s,%s", filename, options);
|
2013-07-01 16:01:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 20:56:13 +00:00
|
|
|
return mixmonitor_exec(chan, args);
|
2013-07-01 16:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int stop_mixmonitor_callback(struct ast_channel *chan, const char *mixmonitor_id)
|
|
|
|
{
|
|
|
|
return stop_mixmonitor_full(chan, mixmonitor_id);
|
|
|
|
}
|
|
|
|
|
2011-12-09 21:47:28 +00:00
|
|
|
static int manager_mixmonitor(struct mansession *s, const struct message *m)
|
|
|
|
{
|
2013-07-02 21:19:21 +00:00
|
|
|
struct ast_channel *c;
|
2011-12-09 21:47:28 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
const char *id = astman_get_header(m, "ActionID");
|
|
|
|
const char *file = astman_get_header(m, "File");
|
|
|
|
const char *options = astman_get_header(m, "Options");
|
2014-04-09 21:43:23 +00:00
|
|
|
const char *command = astman_get_header(m, "Command");
|
2012-01-23 18:16:20 +00:00
|
|
|
char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
|
|
|
|
struct ast_flags flags = { 0 };
|
|
|
|
char *uid_channel_var = NULL;
|
|
|
|
const char *mixmonitor_id = NULL;
|
2011-12-09 21:47:28 +00:00
|
|
|
int res;
|
2013-07-02 21:19:21 +00:00
|
|
|
char args[PATH_MAX];
|
|
|
|
|
2011-12-09 21:47:28 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
|
|
|
astman_send_error(s, m, "No channel specified");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
c = ast_channel_get_by_name(name);
|
|
|
|
if (!c) {
|
|
|
|
astman_send_error(s, m, "No such channel");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (!ast_strlen_zero(options)) {
|
|
|
|
ast_app_parse_options(mixmonitor_opts, &flags, opts, ast_strdupa(options));
|
|
|
|
}
|
|
|
|
|
2014-04-09 21:43:23 +00:00
|
|
|
snprintf(args, sizeof(args), "%s,%s,%s", file, options, command);
|
2011-12-09 21:47:28 +00:00
|
|
|
|
|
|
|
res = mixmonitor_exec(c, args);
|
2012-01-23 18:16:20 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MUXFLAG_UID)) {
|
|
|
|
uid_channel_var = opts[OPT_ARG_UID];
|
2013-07-02 20:56:13 +00:00
|
|
|
ast_channel_lock(c);
|
2012-01-23 18:16:20 +00:00
|
|
|
mixmonitor_id = pbx_builtin_getvar_helper(c, uid_channel_var);
|
2013-07-02 20:56:13 +00:00
|
|
|
mixmonitor_id = ast_strdupa(S_OR(mixmonitor_id, ""));
|
|
|
|
ast_channel_unlock(c);
|
2012-01-23 18:16:20 +00:00
|
|
|
}
|
2011-12-09 21:47:28 +00:00
|
|
|
|
|
|
|
if (res) {
|
2013-07-02 21:19:21 +00:00
|
|
|
ast_channel_unref(c);
|
2011-12-09 21:47:28 +00:00
|
|
|
astman_send_error(s, m, "Could not start monitoring channel");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, "Response: Success\r\n");
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(id)) {
|
|
|
|
astman_append(s, "ActionID: %s\r\n", id);
|
|
|
|
}
|
|
|
|
|
2012-01-23 18:16:20 +00:00
|
|
|
if (!ast_strlen_zero(mixmonitor_id)) {
|
|
|
|
astman_append(s, "MixMonitorID: %s\r\n", mixmonitor_id);
|
|
|
|
}
|
|
|
|
|
2011-12-09 21:47:28 +00:00
|
|
|
astman_append(s, "\r\n");
|
|
|
|
|
2013-07-02 21:19:21 +00:00
|
|
|
ast_channel_unref(c);
|
2011-12-09 21:47:28 +00:00
|
|
|
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int manager_stop_mixmonitor(struct mansession *s, const struct message *m)
|
|
|
|
{
|
2013-07-02 21:19:21 +00:00
|
|
|
struct ast_channel *c;
|
2011-12-09 21:47:28 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
const char *id = astman_get_header(m, "ActionID");
|
2012-01-23 18:16:20 +00:00
|
|
|
const char *mixmonitor_id = astman_get_header(m, "MixMonitorID");
|
2011-12-09 21:47:28 +00:00
|
|
|
int res;
|
2013-07-02 21:19:21 +00:00
|
|
|
|
2011-12-09 21:47:28 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
|
|
|
astman_send_error(s, m, "No channel specified");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
c = ast_channel_get_by_name(name);
|
|
|
|
if (!c) {
|
|
|
|
astman_send_error(s, m, "No such channel");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-03-22 20:43:24 +00:00
|
|
|
res = stop_mixmonitor_full(c, mixmonitor_id);
|
2011-12-09 21:47:28 +00:00
|
|
|
if (res) {
|
2013-07-02 21:01:23 +00:00
|
|
|
ast_channel_unref(c);
|
2011-12-09 21:47:28 +00:00
|
|
|
astman_send_error(s, m, "Could not stop monitoring channel");
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, "Response: Success\r\n");
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(id)) {
|
|
|
|
astman_append(s, "ActionID: %s\r\n", id);
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, "\r\n");
|
|
|
|
|
2013-07-02 21:19:21 +00:00
|
|
|
ast_channel_unref(c);
|
2011-12-09 21:47:28 +00:00
|
|
|
|
|
|
|
return AMI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-12-09 16:42:59 +00:00
|
|
|
static int func_mixmonitor_read(struct ast_channel *chan, const char *cmd, char *data,
|
|
|
|
char *buf, size_t len)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore;
|
|
|
|
struct mixmonitor_ds *ds_data;
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(id);
|
|
|
|
AST_APP_ARG(key);
|
|
|
|
);
|
|
|
|
|
|
|
|
AST_STANDARD_APP_ARGS(args, data);
|
|
|
|
|
|
|
|
if (ast_strlen_zero(args.id) || ast_strlen_zero(args.key)) {
|
|
|
|
ast_log(LOG_WARNING, "Not enough arguments provided to %s. "
|
|
|
|
"An ID and key must be provided\n", cmd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info, args.id);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
if (!datastore) {
|
|
|
|
ast_log(LOG_WARNING, "Could not find MixMonitor with ID %s\n", args.id);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ds_data = datastore->data;
|
|
|
|
|
|
|
|
if (!strcasecmp(args.key, "filename")) {
|
|
|
|
ast_copy_string(buf, ds_data->filename, len);
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_WARNING, "Unrecognized %s option %s\n", cmd, args.key);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_custom_function mixmonitor_function = {
|
|
|
|
.name = "MIXMONITOR",
|
|
|
|
.read = func_mixmonitor_read,
|
|
|
|
};
|
|
|
|
|
2006-09-18 19:54:18 +00:00
|
|
|
static struct ast_cli_entry cli_mixmonitor[] = {
|
2007-10-22 20:05:18 +00:00
|
|
|
AST_CLI_DEFINE(handle_cli_mixmonitor, "Execute a MixMonitor command")
|
2005-10-28 23:01:13 +00:00
|
|
|
};
|
2005-10-16 02:59:13 +00:00
|
|
|
|
2013-07-01 16:01:24 +00:00
|
|
|
static int set_mixmonitor_methods(void)
|
|
|
|
{
|
|
|
|
struct ast_mixmonitor_methods mixmonitor_methods = {
|
|
|
|
.start = start_mixmonitor_callback,
|
|
|
|
.stop = stop_mixmonitor_callback,
|
|
|
|
};
|
|
|
|
|
|
|
|
return ast_set_mixmonitor_methods(&mixmonitor_methods);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clear_mixmonitor_methods(void)
|
|
|
|
{
|
|
|
|
return ast_clear_mixmonitor_methods();
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
2005-10-18 22:52:21 +00:00
|
|
|
int res;
|
|
|
|
|
2008-12-05 10:31:25 +00:00
|
|
|
ast_cli_unregister_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
|
2006-09-18 19:54:18 +00:00
|
|
|
res = ast_unregister_application(stop_app);
|
2005-10-18 22:52:21 +00:00
|
|
|
res |= ast_unregister_application(app);
|
2010-04-21 11:27:27 +00:00
|
|
|
res |= ast_manager_unregister("MixMonitorMute");
|
2011-12-09 21:47:28 +00:00
|
|
|
res |= ast_manager_unregister("MixMonitor");
|
|
|
|
res |= ast_manager_unregister("StopMixMonitor");
|
2013-12-09 16:42:59 +00:00
|
|
|
res |= ast_custom_function_unregister(&mixmonitor_function);
|
2013-07-01 16:01:24 +00:00
|
|
|
res |= clear_mixmonitor_methods();
|
2011-12-09 21:47:28 +00:00
|
|
|
|
2005-10-18 22:52:21 +00:00
|
|
|
return res;
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2005-10-16 02:59:13 +00:00
|
|
|
{
|
2005-10-18 22:52:21 +00:00
|
|
|
int res;
|
|
|
|
|
2008-12-05 10:31:25 +00:00
|
|
|
ast_cli_register_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
|
2008-11-01 21:10:07 +00:00
|
|
|
res = ast_register_application_xml(app, mixmonitor_exec);
|
|
|
|
res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec);
|
2014-06-12 15:39:52 +00:00
|
|
|
res |= ast_manager_register_xml("MixMonitorMute", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, manager_mute_mixmonitor);
|
|
|
|
res |= ast_manager_register_xml("MixMonitor", EVENT_FLAG_SYSTEM, manager_mixmonitor);
|
|
|
|
res |= ast_manager_register_xml("StopMixMonitor", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, manager_stop_mixmonitor);
|
2013-12-09 16:42:59 +00:00
|
|
|
res |= ast_custom_function_register(&mixmonitor_function);
|
2013-07-01 16:01:24 +00:00
|
|
|
res |= set_mixmonitor_methods();
|
2005-10-18 22:52:21 +00:00
|
|
|
|
|
|
|
return res;
|
2005-10-16 02:59:13 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mixed Audio Monitoring Application");
|