Files
asterisk/apps/app_mixmonitor.c

1087 lines
34 KiB
C
Raw Normal View History

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2005, Anthony Minessale II
* Copyright (C) 2005 - 2006, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
* Kevin P. Fleming <kpfleming@digium.com>
*
* Based on app_muxmon.c provided by
* Anthony Minessale II <anthmct@yahoo.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief MixMonitor() - Record a call and mix the audio during the recording
* \ingroup applications
*
* \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>
*/
/*** MODULEINFO
<support_level>core</support_level>
***/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
#include "asterisk/stringfields.h"
#include "asterisk/file.h"
#include "asterisk/audiohook.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#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"
#include "asterisk/manager.h"
#include "asterisk/callerid.h"
/*** DOCUMENTATION
<application 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>
<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>
<note><para>Does not include conferences or sounds played to each bridged party</para></note>
<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>
</option>
<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>
<option name="m">
<argument name="mailbox" required="true" />
<para>Create a copy of the recording as a voicemail in each indicated <emphasis>mailbox</emphasis>
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
separated by commas eg. m(1111@default,2222@default,...). Folders can be optionally specified using
the syntax: mailbox@context/folder</para>
<note><para>The recording will be deleted once all the copies are made.</para></note>
</option>
</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>
<para>This application does not automatically answer and should be preceeded by
an application such as Answer or Progress().</para>
<variablelist>
<variable name="MIXMONITOR_FILENAME">
<para>Will contain the filename used to record.</para>
</variable>
</variablelist>
</description>
<see-also>
<ref type="application">Monitor</ref>
<ref type="application">StopMixMonitor</ref>
<ref type="application">PauseMonitor</ref>
<ref type="application">UnpauseMonitor</ref>
</see-also>
</application>
<application name="StopMixMonitor" language="en_US">
<synopsis>
Stop recording a call through MixMonitor, and free the recording's file handle.
</synopsis>
<syntax />
<description>
<para>Stops the audio recording that was started with a call to <literal>MixMonitor()</literal>
on the current channel.</para>
</description>
<see-also>
<ref type="application">MixMonitor</ref>
</see-also>
</application>
<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>
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +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>
</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>
</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>
***/
#define get_volfactor(x) x ? ((x > 0) ? (1 << x) : ((1 << abs(x)) * -1)) : 0
static const char * const app = "MixMonitor";
static const char * const stop_app = "StopMixMonitor";
static const char * const mixmonitor_spy_type = "MixMonitor";
/*!
* \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];
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
char folder[80];
AST_LIST_ENTRY(vm_recipient) list;
};
struct mixmonitor {
struct ast_audiohook audiohook;
char *filename;
char *post_process;
char *name;
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;
struct mixmonitor_ds *mixmonitor_ds;
/* 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;
};
enum mixmonitor_flags {
MUXFLAG_APPEND = (1 << 1),
MUXFLAG_BRIDGED = (1 << 2),
MUXFLAG_VOLUME = (1 << 3),
MUXFLAG_READVOLUME = (1 << 4),
MUXFLAG_WRITEVOLUME = (1 << 5),
MUXFLAG_VMRECIPIENTS = (1 << 6),
};
enum mixmonitor_args {
OPT_ARG_READVOLUME = 0,
OPT_ARG_WRITEVOLUME,
OPT_ARG_VOLUME,
OPT_ARG_VMRECIPIENTS,
OPT_ARG_ARRAY_SIZE,
};
AST_APP_OPTIONS(mixmonitor_opts, {
AST_APP_OPTION('a', MUXFLAG_APPEND),
AST_APP_OPTION('b', MUXFLAG_BRIDGED),
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),
AST_APP_OPTION_ARG('m', MUXFLAG_VMRECIPIENTS, OPT_ARG_VMRECIPIENTS),
});
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;
struct ast_filestream *fs;
struct ast_audiohook *audiohook;
};
/*!
* \internal
* \pre mixmonitor_ds must be locked before calling this function
*/
static void mixmonitor_ds_close_fs(struct mixmonitor_ds *mixmonitor_ds)
{
if (mixmonitor_ds->fs) {
ast_closestream(mixmonitor_ds->fs);
mixmonitor_ds->fs = NULL;
mixmonitor_ds->fs_quit = 1;
ast_verb(2, "MixMonitor close filestream\n");
}
}
static void mixmonitor_ds_destroy(void *data)
{
struct mixmonitor_ds *mixmonitor_ds = data;
ast_mutex_lock(&mixmonitor_ds->lock);
mixmonitor_ds->audiohook = NULL;
mixmonitor_ds->destruction_ok = 1;
ast_cond_signal(&mixmonitor_ds->destruction_condition);
ast_mutex_unlock(&mixmonitor_ds->lock);
}
static struct ast_datastore_info mixmonitor_ds_info = {
.type = "mixmonitor",
.destroy = mixmonitor_ds_destroy,
};
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);
}
static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook)
{
struct ast_channel *peer = NULL;
int res = 0;
if (!chan)
return -1;
ast_audiohook_attach(chan, audiohook);
if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
return res;
}
/*!
* \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)
{
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
/* 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;
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
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';
}
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
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));
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
ast_copy_string(recipient->folder, cur_folder, sizeof(recipient->folder));
/* Add to list */
ast_verb(5, "Adding %s@%s to recipient list\n", recipient->mailbox, recipient->context);
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);
}
}
#define SAMPLES_PER_FRAME 160
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);
}
/* Free everything in the recipient list */
clear_mixmonitor_recipient_list(mixmonitor);
/* clean stringfields */
ast_string_field_free_memory(mixmonitor);
ast_free(mixmonitor);
}
}
/*!
* \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, char *ext)
{
struct vm_recipient *recipient = NULL;
struct ast_vm_recording_data recording_data;
char filename[PATH_MAX];
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, mixmonitor->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) {
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
/* 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);
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
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);
}
/* Delete the source file */
snprintf(filename, sizeof(filename), "%s.%s", mixmonitor->filename, ext);
if (remove(filename)) {
ast_log(LOG_ERROR, "Failed to delete recording source file %s\n", filename);
}
/* Free the string fields for recording_data before exiting the function. */
ast_string_field_free_memory(&recording_data);
}
static void *mixmonitor_thread(void *obj)
{
struct mixmonitor *mixmonitor = obj;
struct ast_filestream **fs = NULL;
unsigned int oflags;
char *ext = "";
char *last_slash;
int errflag = 0;
ast_verb(2, "Begin MixMonitor Recording %s\n", mixmonitor->name);
fs = &mixmonitor->mixmonitor_ds->fs;
/* The audiohook must enter and exit the loop locked */
ast_audiohook_lock(&mixmonitor->audiohook);
while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING && !mixmonitor->mixmonitor_ds->fs_quit) {
struct ast_frame *fr = NULL;
if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR))) {
ast_audiohook_trigger_wait(&mixmonitor->audiohook);
if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
break;
}
continue;
}
/* 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);
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 (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) || (mixmonitor->autochan->chan && ast_bridged_channel(mixmonitor->autochan->chan))) {
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
/* Initialize the file if not already done so */
if (!*fs && !errflag && !mixmonitor->mixmonitor_ds->fs_quit) {
oflags = O_CREAT | O_WRONLY;
oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
last_slash = strrchr(mixmonitor->filename, '/');
if ((ext = strrchr(mixmonitor->filename, '.')) && (ext > last_slash))
*(ext++) = '\0';
else
ext = "raw";
if (!(*fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0666))) {
ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
errflag = 1;
}
}
/* Write out the frame(s) */
if (*fs) {
struct ast_frame *cur;
for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
ast_writestream(*fs, cur);
}
}
ast_mutex_unlock(&mixmonitor->mixmonitor_ds->lock);
}
/* All done! free it. */
ast_frame_free(fr, 0);
ast_audiohook_lock(&mixmonitor->audiohook);
}
ast_audiohook_unlock(&mixmonitor->audiohook);
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);
/* Datastore cleanup. close the filestream and wait for ds destruction */
ast_mutex_lock(&mixmonitor->mixmonitor_ds->lock);
mixmonitor_ds_close_fs(mixmonitor->mixmonitor_ds);
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);
/* 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);
}
ast_verb(2, "End MixMonitor Recording %s\n", mixmonitor->name);
if (!AST_LIST_EMPTY(&mixmonitor->recipient_list)) {
if (ast_strlen_zero(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, ext);
}
} else {
ast_debug(3, "No recipients to forward monitor to, moving on.\n");
}
mixmonitor_free(mixmonitor);
return NULL;
}
static int setup_mixmonitor_ds(struct mixmonitor *mixmonitor, struct ast_channel *chan)
{
struct ast_datastore *datastore = NULL;
struct mixmonitor_ds *mixmonitor_ds;
if (!(mixmonitor_ds = ast_calloc(1, sizeof(*mixmonitor_ds)))) {
return -1;
}
ast_mutex_init(&mixmonitor_ds->lock);
ast_cond_init(&mixmonitor_ds->destruction_condition, NULL);
if (!(datastore = ast_datastore_alloc(&mixmonitor_ds_info, NULL))) {
ast_mutex_destroy(&mixmonitor_ds->lock);
ast_cond_destroy(&mixmonitor_ds->destruction_condition);
ast_free(mixmonitor_ds);
return -1;
}
mixmonitor_ds->audiohook = &mixmonitor->audiohook;
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;
}
static void launch_monitor_thread(struct ast_channel *chan, const char *filename, unsigned int flags,
int readvol, int writevol, const char *post_process, const char *recipients)
{
pthread_t thread;
struct mixmonitor *mixmonitor;
char postprocess2[1024] = "";
size_t len;
len = sizeof(*mixmonitor) + strlen(chan->name) + strlen(filename) + 2;
postprocess2[0] = 0;
/* 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);
for (p2 = p1; *p2 ; p2++) {
if (*p2 == '^' && *(p2+1) == '{') {
*p2 = '$';
}
}
pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
if (!ast_strlen_zero(postprocess2))
len += strlen(postprocess2) + 1;
}
/* Pre-allocate mixmonitor structure and spy */
if (!(mixmonitor = ast_calloc(1, len))) {
return;
}
/* Now that the struct has been calloced, go ahead and initialize the string fields. */
if (ast_string_field_init(mixmonitor, 512)) {
mixmonitor_free(mixmonitor);
return;
}
/* Setup the actual spy before creating our thread */
if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
mixmonitor_free(mixmonitor);
return;
}
/* 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))) {
mixmonitor_free(mixmonitor);
return;
}
if (setup_mixmonitor_ds(mixmonitor, chan)) {
ast_autochan_destroy(mixmonitor->autochan);
mixmonitor_free(mixmonitor);
Merged revisions 173559 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r173559 | mmichelson | 2009-02-05 11:34:33 -0600 (Thu, 05 Feb 2009) | 25 lines Fix a problem where a channel pointer becomes invalid due to masquerading or hanging up. app_mixmonitor runs its own thread to monitor the channel's activity and write the mixed audio to a file. Since this thread runs independently of the channel, it is possible that the mixmonitor thread's channel pointer will point to freed memory when the channel either is masqueraded or hangs up (technically, both cases are hangups, but we need to handle the cases slightly differently). The solution for this is to employ a datastore, which has the nice benefit of allowing us to hook into channel masquerades and hangups and update our pointer as necessary. If this looks familiar, this same technique is employed in app_chanspy. app_chanspy is a bit more involved since it does a lot more operations on the channel that is being spied upon. app_mixmonitor does have an extra touch that app_chanspy doesn't have, though. Since there is a thread race between the channel's thread and the mixmonitor thread on a hangup, we em- ploy a condition-and-boolean combination to ensure that the channel thread finishes with our structure before the mixmonitor thread attempts to free it. No crashes! (closes issue #14374) Reported by: aragon Patches: 14374.patch uploaded by putnopvut (license 60) Tested by: aragon, putnopvut ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@173589 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-05 18:34:06 +00:00
return;
}
mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor);
strcpy(mixmonitor->name, chan->name);
if (!ast_strlen_zero(postprocess2)) {
mixmonitor->post_process = mixmonitor->name + strlen(mixmonitor->name) + strlen(filename) + 2;
strcpy(mixmonitor->post_process, postprocess2);
}
if (!ast_strlen_zero(recipients)) {
char callerid[256];
ast_channel_lock(chan);
/* We use the connected line of the invoking channel for caller ID. */
ast_debug(3, "Connected Line CID = %d - %s : %d - %s\n", chan->connected.id.name.valid,
chan->connected.id.name.str, chan->connected.id.number.valid,
chan->connected.id.number.str);
ast_callerid_merge(callerid, sizeof(callerid),
S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, NULL),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, NULL),
"Unknown");
ast_string_field_set(mixmonitor, call_context, chan->context);
ast_string_field_set(mixmonitor, call_macrocontext, chan->macrocontext);
ast_string_field_set(mixmonitor, call_extension, chan->exten);
ast_string_field_set(mixmonitor, call_callerchan, chan->name);
ast_string_field_set(mixmonitor, call_callerid, callerid);
mixmonitor->call_priority = chan->priority;
ast_channel_unlock(chan);
add_vm_recipients_from_string(mixmonitor, recipients);
}
mixmonitor->filename = (char *) mixmonitor + sizeof(*mixmonitor) + strlen(chan->name) + 1;
strcpy(mixmonitor->filename, filename);
ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_SYNC);
if (readvol)
mixmonitor->audiohook.options.read_volume = readvol;
if (writevol)
mixmonitor->audiohook.options.write_volume = writevol;
if (startmon(chan, &mixmonitor->audiohook)) {
ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
mixmonitor_spy_type, chan->name);
ast_audiohook_destroy(&mixmonitor->audiohook);
mixmonitor_free(mixmonitor);
return;
}
ast_pthread_create_detached_background(&thread, NULL, mixmonitor_thread, mixmonitor);
}
static int mixmonitor_exec(struct ast_channel *chan, const char *data)
{
int x, readvol = 0, writevol = 0;
struct ast_flags flags = {0};
char *recipients = NULL;
char *parse, *tmp, *slash;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
AST_APP_ARG(options);
AST_APP_ARG(post_process);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "MixMonitor requires an argument (filename)\n");
return -1;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.filename)) {
ast_log(LOG_WARNING, "MixMonitor requires an argument (filename)\n");
return -1;
}
if (args.options) {
char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
ast_app_parse_options(mixmonitor_opts, &flags, opts, args.options);
if (ast_test_flag(&flags, MUXFLAG_READVOLUME)) {
if (ast_strlen_zero(opts[OPT_ARG_READVOLUME])) {
ast_log(LOG_WARNING, "No volume level was provided for the heard volume ('v') option.\n");
} else if ((sscanf(opts[OPT_ARG_READVOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
ast_log(LOG_NOTICE, "Heard volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_READVOLUME]);
} else {
readvol = get_volfactor(x);
}
}
if (ast_test_flag(&flags, MUXFLAG_WRITEVOLUME)) {
if (ast_strlen_zero(opts[OPT_ARG_WRITEVOLUME])) {
ast_log(LOG_WARNING, "No volume level was provided for the spoken volume ('V') option.\n");
} else if ((sscanf(opts[OPT_ARG_WRITEVOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
ast_log(LOG_NOTICE, "Spoken volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_WRITEVOLUME]);
} else {
writevol = get_volfactor(x);
}
}
if (ast_test_flag(&flags, MUXFLAG_VOLUME)) {
if (ast_strlen_zero(opts[OPT_ARG_VOLUME])) {
ast_log(LOG_WARNING, "No volume level was provided for the combined volume ('W') option.\n");
} else if ((sscanf(opts[OPT_ARG_VOLUME], "%2d", &x) != 1) || (x < -4) || (x > 4)) {
ast_log(LOG_NOTICE, "Combined volume must be a number between -4 and 4, not '%s'\n", opts[OPT_ARG_VOLUME]);
} else {
readvol = writevol = get_volfactor(x);
}
}
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]);
}
}
}
/* if not provided an absolute path, use the system-configured monitoring directory */
if (args.filename[0] != '/') {
char *build;
build = alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(args.filename) + 3);
sprintf(build, "%s/%s", ast_config_AST_MONITOR_DIR, args.filename);
args.filename = build;
}
tmp = ast_strdupa(args.filename);
if ((slash = strrchr(tmp, '/')))
*slash = '\0';
ast_mkdir(tmp, 0777);
pbx_builtin_setvar_helper(chan, "MIXMONITOR_FILENAME", args.filename);
launch_monitor_thread(chan, args.filename, flags.flags, readvol, writevol, args.post_process, recipients);
return 0;
}
static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
{
struct ast_datastore *datastore = NULL;
ast_channel_lock(chan);
ast_audiohook_detach_source(chan, mixmonitor_spy_type);
if ((datastore = ast_channel_datastore_find(chan, &mixmonitor_ds_info, NULL))) {
struct mixmonitor_ds *mixmonitor_ds = datastore->data;
ast_mutex_lock(&mixmonitor_ds->lock);
/* closing the filestream here guarantees the file is avaliable to the dialplan
* after calling StopMixMonitor */
mixmonitor_ds_close_fs(mixmonitor_ds);
/* 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) {
ast_audiohook_lock(mixmonitor_ds->audiohook);
ast_cond_signal(&mixmonitor_ds->audiohook->trigger);
ast_audiohook_unlock(mixmonitor_ds->audiohook);
mixmonitor_ds->audiohook = NULL;
}
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);
}
}
ast_channel_unlock(chan);
return 0;
}
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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)
{
struct ast_channel *chan;
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-11 19:03:06 +00:00
switch (cmd) {
case CLI_INIT:
e->command = "mixmonitor {start|stop}";
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-11 19:03:06 +00:00
e->usage =
"Usage: mixmonitor <start|stop> <chan_name> [args]\n"
" The optional arguments are passed to the MixMonitor\n"
" application when the 'start' command is used.\n";
return NULL;
case CLI_GENERATE:
return ast_complete_channels(a->line, a->word, a->pos, a->n, 2);
}
if (a->argc < 3)
return CLI_SHOWUSAGE;
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])))) {
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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;
}
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_channel_lock(chan);
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-11 19:03:06 +00:00
if (!strcasecmp(a->argv[1], "start")) {
mixmonitor_exec(chan, a->argv[3]);
ast_channel_unlock(chan);
} else {
ast_channel_unlock(chan);
ast_audiohook_detach_source(chan, mixmonitor_spy_type);
}
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);
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85460 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-11 19:03:06 +00:00
return CLI_SUCCESS;
}
/*! \brief Mute / unmute a MixMonitor channel */
static int manager_mute_mixmonitor(struct mansession *s, const struct message *m)
{
struct ast_channel *c = NULL;
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);
c = ast_channel_get_by_name(name);
if (!c) {
astman_send_error(s, m, "No such channel");
return AMI_SUCCESS;
}
if (ast_audiohook_set_mute(c, mixmonitor_spy_type, flag, clearmute)) {
c = ast_channel_unref(c);
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");
c = ast_channel_unref(c);
return AMI_SUCCESS;
}
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
static int manager_mixmonitor(struct mansession *s, const struct message *m)
{
struct ast_channel *c = NULL;
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");
int res;
char args[PATH_MAX] = "";
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;
}
strcpy(args, file);
strcat(args, ",");
strcat(args, options);
ast_channel_lock(c);
res = mixmonitor_exec(c, args);
ast_channel_unlock(c);
if (res) {
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);
}
astman_append(s, "\r\n");
c = ast_channel_unref(c);
return AMI_SUCCESS;
}
static int manager_stop_mixmonitor(struct mansession *s, const struct message *m)
{
struct ast_channel *c = NULL;
const char *name = astman_get_header(m, "Channel");
const char *id = astman_get_header(m, "ActionID");
int res;
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;
}
res = stop_mixmonitor_exec(c, NULL);
if (res) {
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");
c = ast_channel_unref(c);
return AMI_SUCCESS;
}
static struct ast_cli_entry cli_mixmonitor[] = {
AST_CLI_DEFINE(handle_cli_mixmonitor, "Execute a MixMonitor command")
};
static int unload_module(void)
{
int res;
ast_cli_unregister_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
res = ast_unregister_application(stop_app);
res |= ast_unregister_application(app);
res |= ast_manager_unregister("MixMonitorMute");
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
res |= ast_manager_unregister("MixMonitor");
res |= ast_manager_unregister("StopMixMonitor");
return res;
}
static int load_module(void)
{
int res;
ast_cli_register_multiple(cli_mixmonitor, ARRAY_LEN(cli_mixmonitor));
res = ast_register_application_xml(app, mixmonitor_exec);
res |= ast_register_application_xml(stop_app, stop_mixmonitor_exec);
res |= ast_manager_register_xml("MixMonitorMute", 0, manager_mute_mixmonitor);
Re-merge changes that were reverted. ------------------------------------------------------------------------ r365395 | qwell | 2012-05-04 16:17:08 -0500 (Fri, 04 May 2012) | 7 lines Add support for folders in MixMonitor 'm' option. Backport manager actions. The manager actions are needed, so MixMonitor can be executed on existing channels. (issue DPMA-68) ------------------------------------------------------------------------ r364761 | qwell | 2012-05-01 12:25:14 -0500 (Tue, 01 May 2012) | 6 lines Remove folder_dir from voicemail snapshots API. It was both unused (except in tests, where it was fudged) and unnecessary. (closes issue AST-842) ------------------------------------------------------------------------ r367161 | mmichelson | 2012-05-21 14:05:52 -0500 (Mon, 21 May 2012) | 21 lines Add "send to voicemail" Digium phone functionality to Asterisk. This change accommodates two methods by which calls can be directed to a user's voicemail. * Incoming calls can be redirected to any user's voicemail. * Established calls can be blind transferred to any user's voicemail. Digium phones indicate the desire to direct a call to voicemail by using a Diversion header with a reason parameter of "send_to_vm". This patch adds the "send_to_vm" reason as a valid redirecting reason. In addition, chan_sip.c has been modified to update redirecting information on the transferred channel by reading a Diversion header on a REFER request. (closes issue AST-871) Reported by Malcolm Davenport Review: https://reviewboard.asterisk.org/r/1925 ------------------------------------------------------------------------ r368790 | mjordan | 2012-06-12 08:44:36 -0500 (Tue, 12 Jun 2012) | 18 lines Fix deadlock in SIP transfers that involve a REFER request In r367163, "send to voicemail" functionality was added to the SIP channel driver. This required updating the party redirecting information for the channel based on the headers provided in the REFER request. When the redirecting party information is updated on the channel, a call to ast_indicate_data occurs. Because handle_request_refer still had the sip_pvt locked, a deadlock could occur between the pbx_thread and the do_monitor thread servicing the REFER request. This patch preserves the proper locking order between the channel and the sip_pvt by ensuring that the sip_pvt is unlocked prior to updating the party redirecting information on the channel. (closes issue AST-903) Reported by: Matt Jordan patches: jira_ast_903_trunk.patch by rmudgett (license 5621) ------------------------------------------------------------------------ r368962 | qwell | 2012-06-14 13:38:48 -0500 (Thu, 14 Jun 2012) | 11 lines Remove global symbol requirement from app_voicemail. This uses the existing "function installation" stuff that already existed for other functions, like getting message counts. (closes issue AST-807) (issue AST-901) (issue AST-908) Review: https://reviewboard.asterisk.org/r/1965/ ------------------------------------------------------------------------ r368964 | qwell | 2012-06-14 14:03:24 -0500 (Thu, 14 Jun 2012) | 8 lines These functions that were moved need to be static. Also wrap test functions in a #ifdef. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r368998 | qwell | 2012-06-15 10:31:43 -0500 (Fri, 15 Jun 2012) | 6 lines Remove some symbol exports that got missed in the removal of global symbols. (issue AST-807) (issue AST-901) (issue AST-908) ------------------------------------------------------------------------ r369024 | qwell | 2012-06-15 11:29:40 -0500 (Fri, 15 Jun 2012) | 2 lines Fix voicemail API tests by using the correct argument order for create/destroy. ------------------------------------------------------------------------ git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369839 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-07-09 19:05:54 +00:00
res |= ast_manager_register_xml("MixMonitor", 0, manager_mixmonitor);
res |= ast_manager_register_xml("StopMixMonitor", 0, manager_stop_mixmonitor);
return res;
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Mixed Audio Monitoring Application");