2005-09-14 20:46:50 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2005-06-06 22:12:19 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
2005-06-06 22:12:19 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2005-06-06 22:12:19 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2005-06-06 22:12:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief PBX channel monitoring
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-12-30 21:18:06 +00:00
|
|
|
* \author Mark Spencer <markster@digium.com>
|
2005-06-06 22:12:19 +00:00
|
|
|
*/
|
2011-07-14 20:28:54 +00:00
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
2005-06-06 22:12:19 +00:00
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2003-09-10 05:24:49 +00:00
|
|
|
#include <sys/stat.h>
|
2006-06-07 18:54:56 +00:00
|
|
|
#include <libgen.h>
|
2005-06-06 22:12:19 +00:00
|
|
|
|
2007-11-20 23:16:15 +00:00
|
|
|
#include "asterisk/paths.h" /* use ast_config_AST_MONITOR_DIR */
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/cli.h"
|
2013-05-24 20:44:07 +00:00
|
|
|
#include "asterisk/manager.h"
|
|
|
|
#include "asterisk/stasis.h"
|
|
|
|
#include "asterisk/stasis_channels.h"
|
2009-05-18 20:52:33 +00:00
|
|
|
#define AST_API_MODULE
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/monitor.h"
|
2014-04-23 15:02:39 +00:00
|
|
|
#undef AST_API_MODULE
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/app.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/config.h"
|
2008-01-31 21:02:12 +00:00
|
|
|
#include "asterisk/options.h"
|
2014-04-15 23:21:19 +00:00
|
|
|
#include "asterisk/beep.h"
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2009-06-01 19:37:30 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Monitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Monitor a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="file_format" argsep=":">
|
|
|
|
<argument name="file_format" required="true">
|
|
|
|
<para>optional, if not set, defaults to <literal>wav</literal></para>
|
|
|
|
</argument>
|
|
|
|
<argument name="urlbase" />
|
|
|
|
</parameter>
|
|
|
|
<parameter name="fname_base">
|
|
|
|
<para>if set, changes the filename used to the one specified.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<optionlist>
|
|
|
|
<option name="m">
|
|
|
|
<para>when the recording ends mix the two leg files into one and
|
|
|
|
delete the two leg files. If the variable <variable>MONITOR_EXEC</variable>
|
|
|
|
is set, the application referenced in it will be executed instead of
|
|
|
|
soxmix/sox and the raw leg files will NOT be deleted automatically.
|
|
|
|
soxmix/sox or <variable>MONITOR_EXEC</variable> is handed 3 arguments,
|
|
|
|
the two leg files and a target mixed file name which is the same as
|
|
|
|
the leg file names only without the in/out designator.</para>
|
|
|
|
<para>If <variable>MONITOR_EXEC_ARGS</variable> is set, the contents
|
|
|
|
will be passed on as additional arguments to <variable>MONITOR_EXEC</variable>.
|
|
|
|
Both <variable>MONITOR_EXEC</variable> and the Mix flag can be set from the
|
|
|
|
administrator interface.</para>
|
|
|
|
</option>
|
|
|
|
<option name="b">
|
|
|
|
<para>Don't begin recording unless a call is bridged to another channel.</para>
|
|
|
|
</option>
|
2014-04-15 23:21:19 +00:00
|
|
|
<option name="B">
|
|
|
|
<para>Play a periodic beep while this call is being recorded.</para>
|
|
|
|
<argument name="interval"><para>Interval, in seconds. Default is 15.</para></argument>
|
|
|
|
</option>
|
2009-06-01 19:37:30 +00:00
|
|
|
<option name="i">
|
|
|
|
<para>Skip recording of input stream (disables <literal>m</literal> option).</para>
|
|
|
|
</option>
|
|
|
|
<option name="o">
|
|
|
|
<para>Skip recording of output stream (disables <literal>m</literal> option).</para>
|
|
|
|
</option>
|
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Used to start monitoring a channel. The channel's input and output
|
|
|
|
voice packets are logged to files until the channel hangs up or
|
|
|
|
monitoring is stopped by the StopMonitor application.</para>
|
|
|
|
<para>By default, files are stored to <filename>/var/spool/asterisk/monitor/</filename>.
|
|
|
|
Returns <literal>-1</literal> if monitor files can't be opened or if the channel is
|
|
|
|
already monitored, otherwise <literal>0</literal>.</para>
|
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">StopMonitor</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
<application name="StopMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Stop monitoring a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax />
|
|
|
|
<description>
|
|
|
|
<para>Stops monitoring a channel. Has no effect if the channel is not monitored.</para>
|
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
<application name="ChangeMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Change monitoring filename of a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="filename_base" required="true">
|
|
|
|
<para>The new filename base to use for monitoring this channel.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Changes monitoring filename of a channel. Has no effect if the
|
|
|
|
channel is not monitored.</para>
|
|
|
|
</description>
|
|
|
|
</application>
|
|
|
|
<application name="PauseMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Pause monitoring of a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax />
|
|
|
|
<description>
|
|
|
|
<para>Pauses monitoring of a channel until it is re-enabled by a call to UnpauseMonitor.</para>
|
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">UnpauseMonitor</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
<application name="UnpauseMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Unpause monitoring of a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax />
|
|
|
|
<description>
|
|
|
|
<para>Unpauses monitoring of a channel on which monitoring had
|
|
|
|
previously been paused with PauseMonitor.</para>
|
|
|
|
</description>
|
|
|
|
<see-also>
|
|
|
|
<ref type="application">PauseMonitor</ref>
|
|
|
|
</see-also>
|
|
|
|
</application>
|
|
|
|
<manager name="Monitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Monitor a channel.
|
|
|
|
</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).</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="Format">
|
|
|
|
<para>Is the audio recording format. Defaults to <literal>wav</literal>.</para>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="Mix">
|
|
|
|
<para>Boolean parameter as to whether to mix the input and output channels
|
|
|
|
together after the recording is finished.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action may be used to record the audio on a
|
|
|
|
specified channel.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
<manager name="StopMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Stop monitoring a channel.
|
|
|
|
</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 may be used to end a previously started 'Monitor' action.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
<manager name="ChangeMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Change monitoring filename of a channel.
|
|
|
|
</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" required="true">
|
|
|
|
<para>Is the new name of the file created in the
|
|
|
|
monitor spool directory.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action may be used to change the file
|
|
|
|
started by a previous 'Monitor' action.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
<manager name="PauseMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Pause monitoring of a channel.
|
|
|
|
</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>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action may be used to temporarily stop the
|
|
|
|
recording of a channel.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
<manager name="UnpauseMonitor" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Unpause monitoring of a channel.
|
|
|
|
</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>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>This action may be used to re-enable recording
|
|
|
|
of a channel after calling PauseMonitor.</para>
|
|
|
|
</description>
|
|
|
|
</manager>
|
|
|
|
|
|
|
|
***/
|
|
|
|
|
2004-06-09 01:45:08 +00:00
|
|
|
AST_MUTEX_DEFINE_STATIC(monitorlock);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2006-05-09 07:28:01 +00:00
|
|
|
#define LOCK_IF_NEEDED(lock, needed) do { \
|
|
|
|
if (needed) \
|
2006-05-10 15:17:58 +00:00
|
|
|
ast_channel_lock(lock); \
|
2006-01-14 00:32:30 +00:00
|
|
|
} while(0)
|
|
|
|
|
2006-05-09 07:28:01 +00:00
|
|
|
#define UNLOCK_IF_NEEDED(lock, needed) do { \
|
|
|
|
if (needed) \
|
2006-05-10 15:17:58 +00:00
|
|
|
ast_channel_unlock(lock); \
|
2006-05-09 07:28:01 +00:00
|
|
|
} while (0)
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
static unsigned long seq = 0;
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \brief Change state of monitored channel
|
|
|
|
* \param chan
|
|
|
|
* \param state monitor state
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on failure.
|
|
|
|
*/
|
2006-01-14 00:32:30 +00:00
|
|
|
static int ast_monitor_set_state(struct ast_channel *chan, int state)
|
|
|
|
{
|
2006-05-10 15:17:58 +00:00
|
|
|
LOCK_IF_NEEDED(chan, 1);
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!ast_channel_monitor(chan)) {
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, 1);
|
2006-01-14 00:32:30 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_monitor(chan)->state = state;
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, 1);
|
2006-01-14 00:32:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-10 15:07:25 +00:00
|
|
|
/*! \brief Start monitoring a channel
|
|
|
|
* \param chan ast_channel struct to record
|
|
|
|
* \param format_spec file format to use for recording
|
|
|
|
* \param fname_base filename base to record to
|
|
|
|
* \param need_lock whether to lock the channel mutex
|
|
|
|
* \param stream_action whether to record the input and/or output streams. X_REC_IN | X_REC_OUT is most often used
|
2007-07-23 14:32:04 +00:00
|
|
|
* Creates the file to record, if no format is specified it assumes WAV
|
|
|
|
* It also sets channel variable __MONITORED=yes
|
|
|
|
* \retval 0 on success
|
|
|
|
* \retval -1 on failure
|
2007-07-10 15:07:25 +00:00
|
|
|
*/
|
2009-06-15 16:07:23 +00:00
|
|
|
int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const char *format_spec,
|
2014-04-15 23:21:19 +00:00
|
|
|
const char *fname_base, int need_lock, int stream_action,
|
|
|
|
const char *beep_id)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
|
|
|
int res = 0;
|
2013-05-24 20:44:07 +00:00
|
|
|
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
LOCK_IF_NEEDED(chan, need_lock);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (!(ast_channel_monitor(chan))) {
|
2003-03-25 19:30:06 +00:00
|
|
|
struct ast_channel_monitor *monitor;
|
|
|
|
char *channel_name, *p;
|
|
|
|
|
|
|
|
/* Create monitoring directory if needed */
|
2007-06-22 04:35:12 +00:00
|
|
|
ast_mkdir(ast_config_AST_MONITOR_DIR, 0777);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2006-01-21 22:09:06 +00:00
|
|
|
if (!(monitor = ast_calloc(1, sizeof(*monitor)))) {
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
2004-10-23 07:03:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
if (!ast_strlen_zero(beep_id)) {
|
|
|
|
ast_copy_string(monitor->beep_id, beep_id, sizeof(monitor->beep_id));
|
|
|
|
}
|
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
/* Determine file names */
|
2005-11-08 01:55:31 +00:00
|
|
|
if (!ast_strlen_zero(fname_base)) {
|
2004-02-03 16:57:00 +00:00
|
|
|
int directory = strchr(fname_base, '/') ? 1 : 0;
|
Merged revisions 248757 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r248757 | jpeeler | 2010-02-25 12:06:54 -0600 (Thu, 25 Feb 2010) | 15 lines
Ensure that monitor recordings are written to the correct location.
Recordings should be placed in the monitor directory when a non-absolute path
is used.
Exact dialplan used for testing:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)
ABE-2101
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-25 18:37:56 +00:00
|
|
|
const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
const char *absolute_suffix = *fname_base == '/' ? "" : "/";
|
Merged revisions 248757 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r248757 | jpeeler | 2010-02-25 12:06:54 -0600 (Thu, 25 Feb 2010) | 15 lines
Ensure that monitor recordings are written to the correct location.
Recordings should be placed in the monitor directory when a non-absolute path
is used.
Exact dialplan used for testing:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)
ABE-2101
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-25 18:37:56 +00:00
|
|
|
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
snprintf(monitor->read_filename, FILENAME_MAX, "%s%s%s-in",
|
|
|
|
absolute, absolute_suffix, fname_base);
|
|
|
|
snprintf(monitor->write_filename, FILENAME_MAX, "%s%s%s-out",
|
|
|
|
absolute, absolute_suffix, fname_base);
|
|
|
|
snprintf(monitor->filename_base, FILENAME_MAX, "%s%s%s",
|
|
|
|
absolute, absolute_suffix, fname_base);
|
Merged revisions 248757 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r248757 | jpeeler | 2010-02-25 12:06:54 -0600 (Thu, 25 Feb 2010) | 15 lines
Ensure that monitor recordings are written to the correct location.
Recordings should be placed in the monitor directory when a non-absolute path
is used.
Exact dialplan used for testing:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)
ABE-2101
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248793 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-25 18:37:56 +00:00
|
|
|
|
2004-02-03 16:57:00 +00:00
|
|
|
/* try creating the directory just in case it doesn't exist */
|
|
|
|
if (directory) {
|
Merged revisions 248860 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r248860 | jpeeler | 2010-02-25 15:22:06 -0600 (Thu, 25 Feb 2010) | 18 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248757. As such the dialplan test has been extended:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test3,m)
exten => 5043, n, changemonitor(monitor_test4)
exten => 5043, n, dial(sip/5001)
exten => 5044, 1, monitor(wav,monitor_test4,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test5) ; this looks to fail by design and emits a warning
exten => 5044, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248952 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-25 23:09:54 +00:00
|
|
|
char *name = ast_strdupa(monitor->filename_base);
|
|
|
|
ast_mkdir(dirname(name), 0777);
|
2004-02-03 16:57:00 +00:00
|
|
|
}
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2004-09-17 14:15:11 +00:00
|
|
|
ast_mutex_lock(&monitorlock);
|
2014-05-09 22:49:26 +00:00
|
|
|
snprintf(monitor->read_filename, FILENAME_MAX, "%s/audio-in-%lu",
|
2005-06-06 03:04:58 +00:00
|
|
|
ast_config_AST_MONITOR_DIR, seq);
|
2014-05-09 22:49:26 +00:00
|
|
|
snprintf(monitor->write_filename, FILENAME_MAX, "%s/audio-out-%lu",
|
2005-06-06 03:04:58 +00:00
|
|
|
ast_config_AST_MONITOR_DIR, seq);
|
2003-03-25 19:30:06 +00:00
|
|
|
seq++;
|
2004-09-17 14:15:11 +00:00
|
|
|
ast_mutex_unlock(&monitorlock);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2012-02-16 18:39:46 +00:00
|
|
|
/* Replace all '/' chars from the channel name with '-' chars. */
|
2012-01-09 22:15:50 +00:00
|
|
|
channel_name = ast_strdupa(ast_channel_name(chan));
|
2012-02-16 18:39:46 +00:00
|
|
|
for (p = channel_name; (p = strchr(p, '/')); ) {
|
2006-05-10 13:22:15 +00:00
|
|
|
*p = '-';
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2012-02-16 18:39:46 +00:00
|
|
|
|
2006-05-10 13:22:15 +00:00
|
|
|
snprintf(monitor->filename_base, FILENAME_MAX, "%s/%d-%s",
|
|
|
|
ast_config_AST_MONITOR_DIR, (int)time(NULL), channel_name);
|
|
|
|
monitor->filename_changed = 1;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
monitor->stop = ast_monitor_stop;
|
|
|
|
|
2004-12-18 22:04:07 +00:00
|
|
|
/* Determine file format */
|
2005-11-08 01:55:31 +00:00
|
|
|
if (!ast_strlen_zero(format_spec)) {
|
2007-06-14 23:01:01 +00:00
|
|
|
monitor->format = ast_strdup(format_spec);
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2007-06-14 23:01:01 +00:00
|
|
|
monitor->format = ast_strdup("wav");
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2004-12-18 22:04:07 +00:00
|
|
|
/* open files */
|
2007-07-09 20:58:22 +00:00
|
|
|
if (stream_action & X_REC_IN) {
|
|
|
|
if (ast_fileexists(monitor->read_filename, NULL, NULL) > 0)
|
|
|
|
ast_filedelete(monitor->read_filename, NULL);
|
|
|
|
if (!(monitor->read_stream = ast_writefile(monitor->read_filename,
|
|
|
|
monitor->format, NULL,
|
|
|
|
O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
|
|
|
|
ast_log(LOG_WARNING, "Could not create file %s\n",
|
|
|
|
monitor->read_filename);
|
|
|
|
ast_free(monitor);
|
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
monitor->read_stream = NULL;
|
|
|
|
|
|
|
|
if (stream_action & X_REC_OUT) {
|
|
|
|
if (ast_fileexists(monitor->write_filename, NULL, NULL) > 0) {
|
|
|
|
ast_filedelete(monitor->write_filename, NULL);
|
|
|
|
}
|
|
|
|
if (!(monitor->write_stream = ast_writefile(monitor->write_filename,
|
|
|
|
monitor->format, NULL,
|
|
|
|
O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
|
|
|
|
ast_log(LOG_WARNING, "Could not create file %s\n",
|
|
|
|
monitor->write_filename);
|
Resolve FORWARD_NULL static analysis warnings
This resolves core findings from ASTERISK-19650 numbers 0-2, 6, 7, 9-11, 14-20,
22-24, 28, 30-32, 34-36, 42-56, 82-84, 87, 89-90, 93-102, 104, 105, 109-111,
and 115. Finding numbers 26, 33, and 29 were already resolved. Those skipped
were either extended/deprecated or in areas of code that shouldn't be
disturbed.
(Closes issue ASTERISK-19650)
........
Merged revisions 366167 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 366168 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-05-10 20:56:09 +00:00
|
|
|
if (monitor->read_stream) {
|
|
|
|
ast_closestream(monitor->read_stream);
|
|
|
|
}
|
2007-07-09 20:58:22 +00:00
|
|
|
ast_free(monitor);
|
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
monitor->write_stream = NULL;
|
|
|
|
|
2014-12-06 18:16:49 +00:00
|
|
|
ast_channel_insmpl_set(chan, 0);
|
|
|
|
ast_channel_outsmpl_set(chan, 0);
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_channel_monitor_set(chan, monitor);
|
2006-01-14 00:32:30 +00:00
|
|
|
ast_monitor_set_state(chan, AST_MONITOR_RUNNING);
|
2005-01-10 04:29:33 +00:00
|
|
|
/* so we know this call has been monitored in case we need to bill for it or something */
|
|
|
|
pbx_builtin_setvar_helper(chan, "__MONITORED","true");
|
2007-12-03 23:48:04 +00:00
|
|
|
|
2013-05-29 02:26:17 +00:00
|
|
|
message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
|
2013-05-24 20:44:07 +00:00
|
|
|
ast_channel_monitor_start_type(),
|
|
|
|
NULL);
|
|
|
|
if (message) {
|
|
|
|
stasis_publish(ast_channel_topic(chan), message);
|
|
|
|
}
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_debug(1,"Cannot start monitoring %s, already monitored\n", ast_channel_name(chan));
|
2003-03-25 19:30:06 +00:00
|
|
|
res = -1;
|
|
|
|
}
|
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \brief Get audio format.
|
|
|
|
* \param format recording format.
|
2006-11-01 18:29:05 +00:00
|
|
|
* The file format extensions that Asterisk uses are not all the same as that
|
|
|
|
* which soxmix expects. This function ensures that the format used as the
|
|
|
|
* extension on the filename is something soxmix will understand.
|
|
|
|
*/
|
|
|
|
static const char *get_soxmix_format(const char *format)
|
|
|
|
{
|
|
|
|
const char *res = format;
|
|
|
|
|
|
|
|
if (!strcasecmp(format,"ulaw"))
|
|
|
|
res = "ul";
|
|
|
|
if (!strcasecmp(format,"alaw"))
|
|
|
|
res = "al";
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \brief Stop monitoring channel
|
|
|
|
* \param chan
|
|
|
|
* \param need_lock
|
|
|
|
* Stop the recording, close any open streams, mix in/out channels if required
|
|
|
|
* \return Always 0
|
|
|
|
*/
|
2009-06-15 16:07:23 +00:00
|
|
|
int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_lock)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2004-09-17 14:15:11 +00:00
|
|
|
int delfiles = 0;
|
2013-05-24 20:44:07 +00:00
|
|
|
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
|
2004-06-29 04:42:19 +00:00
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
LOCK_IF_NEEDED(chan, need_lock);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)) {
|
2003-03-25 19:30:06 +00:00
|
|
|
char filename[ FILENAME_MAX ];
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)->read_stream) {
|
|
|
|
ast_closestream(ast_channel_monitor(chan)->read_stream);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)->write_stream) {
|
|
|
|
ast_closestream(ast_channel_monitor(chan)->write_stream);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)->filename_changed && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) {
|
|
|
|
if (ast_fileexists(ast_channel_monitor(chan)->read_filename,NULL,NULL) > 0) {
|
|
|
|
snprintf(filename, FILENAME_MAX, "%s-in", ast_channel_monitor(chan)->filename_base);
|
2004-09-17 14:15:11 +00:00
|
|
|
if (ast_fileexists(filename, NULL, NULL) > 0) {
|
|
|
|
ast_filedelete(filename, NULL);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_filerename(ast_channel_monitor(chan)->read_filename, filename, ast_channel_monitor(chan)->format);
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->read_filename);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_fileexists(ast_channel_monitor(chan)->write_filename,NULL,NULL) > 0) {
|
|
|
|
snprintf(filename, FILENAME_MAX, "%s-out", ast_channel_monitor(chan)->filename_base);
|
2004-09-17 14:15:11 +00:00
|
|
|
if (ast_fileexists(filename, NULL, NULL) > 0) {
|
2004-06-29 04:42:19 +00:00
|
|
|
ast_filedelete(filename, NULL);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_filerename(ast_channel_monitor(chan)->write_filename, filename, ast_channel_monitor(chan)->format);
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_log(LOG_WARNING, "File %s not found\n", ast_channel_monitor(chan)->write_filename);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-03 15:42:36 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)->joinfiles && !ast_strlen_zero(ast_channel_monitor(chan)->filename_base)) {
|
2004-02-06 05:52:03 +00:00
|
|
|
char tmp[1024];
|
2004-06-03 15:42:36 +00:00
|
|
|
char tmp2[1024];
|
2012-02-20 23:43:27 +00:00
|
|
|
const char *format = !strcasecmp(ast_channel_monitor(chan)->format,"wav49") ? "WAV" : ast_channel_monitor(chan)->format;
|
|
|
|
char *fname_base = ast_channel_monitor(chan)->filename_base;
|
2005-12-03 19:25:33 +00:00
|
|
|
const char *execute, *execute_args;
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
/* at this point, fname_base really is the full path */
|
2004-06-03 15:42:36 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
/* Set the execute application */
|
2004-09-17 14:15:11 +00:00
|
|
|
execute = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC");
|
2007-12-19 23:04:32 +00:00
|
|
|
if (ast_strlen_zero(execute)) {
|
|
|
|
#ifdef HAVE_SOXMIX
|
2005-01-21 03:56:22 +00:00
|
|
|
execute = "nice -n 19 soxmix";
|
2007-12-19 23:04:32 +00:00
|
|
|
#else
|
|
|
|
execute = "nice -n 19 sox -m";
|
|
|
|
#endif
|
2006-11-01 18:29:05 +00:00
|
|
|
format = get_soxmix_format(format);
|
2004-09-17 03:49:57 +00:00
|
|
|
delfiles = 1;
|
|
|
|
}
|
2004-09-17 14:15:11 +00:00
|
|
|
execute_args = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC_ARGS");
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(execute_args)) {
|
2004-09-17 03:49:57 +00:00
|
|
|
execute_args = "";
|
|
|
|
}
|
|
|
|
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &",
|
|
|
|
execute, fname_base, format, fname_base, format, fname_base, format,execute_args);
|
2004-09-17 03:49:57 +00:00
|
|
|
if (delfiles) {
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s-\"* ) &",tmp, fname_base); /* remove legs when done mixing */
|
2005-07-10 23:21:39 +00:00
|
|
|
ast_copy_string(tmp, tmp2, sizeof(tmp));
|
2004-06-03 23:16:55 +00:00
|
|
|
}
|
2007-06-14 19:39:12 +00:00
|
|
|
ast_debug(1,"monitor executing %s\n",tmp);
|
2004-06-03 15:42:36 +00:00
|
|
|
if (ast_safe_system(tmp) == -1)
|
2004-06-29 04:42:19 +00:00
|
|
|
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
|
2004-02-03 16:57:00 +00:00
|
|
|
}
|
2014-04-15 23:21:19 +00:00
|
|
|
|
|
|
|
if (!ast_strlen_zero(ast_channel_monitor(chan)->beep_id)) {
|
|
|
|
ast_beep_stop(chan, ast_channel_monitor(chan)->beep_id);
|
|
|
|
}
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_free(ast_channel_monitor(chan)->format);
|
|
|
|
ast_free(ast_channel_monitor(chan));
|
|
|
|
ast_channel_monitor_set(chan, NULL);
|
2007-12-03 23:48:04 +00:00
|
|
|
|
2013-05-29 02:26:17 +00:00
|
|
|
message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(chan),
|
2013-05-24 20:44:07 +00:00
|
|
|
ast_channel_monitor_stop_type(),
|
|
|
|
NULL);
|
|
|
|
if (message) {
|
|
|
|
stasis_publish(ast_channel_topic(chan), message);
|
|
|
|
}
|
2010-04-25 18:12:14 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "MONITORED", NULL);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2010-04-25 18:12:14 +00:00
|
|
|
pbx_builtin_setvar_helper(chan, "AUTO_MONITOR", NULL);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Pause monitoring of channel */
|
2009-06-15 16:07:23 +00:00
|
|
|
int AST_OPTIONAL_API_NAME(ast_monitor_pause)(struct ast_channel *chan)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return ast_monitor_set_state(chan, AST_MONITOR_PAUSED);
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Unpause monitoring of channel */
|
2009-06-15 16:07:23 +00:00
|
|
|
int AST_OPTIONAL_API_NAME(ast_monitor_unpause)(struct ast_channel *chan)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return ast_monitor_set_state(chan, AST_MONITOR_RUNNING);
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Wrapper for ast_monitor_pause */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int pause_monitor_exec(struct ast_channel *chan, const char *data)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return ast_monitor_pause(chan);
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Wrapper for ast_monitor_unpause */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int unpause_monitor_exec(struct ast_channel *chan, const char *data)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return ast_monitor_unpause(chan);
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \brief Change monitored filename of channel
|
|
|
|
* \param chan
|
|
|
|
* \param fname_base new filename
|
|
|
|
* \param need_lock
|
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on failure.
|
|
|
|
*/
|
2009-06-15 16:07:23 +00:00
|
|
|
int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, const char *fname_base, int need_lock)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(fname_base)) {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to null\n", ast_channel_name(chan));
|
2003-03-25 19:30:06 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
LOCK_IF_NEEDED(chan, need_lock);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan)) {
|
2004-02-03 16:57:00 +00:00
|
|
|
int directory = strchr(fname_base, '/') ? 1 : 0;
|
Merged revisions 248860 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r248860 | jpeeler | 2010-02-25 15:22:06 -0600 (Thu, 25 Feb 2010) | 18 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248757. As such the dialplan test has been extended:
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test,b)
exten => 5040, n, dial(sip/5001)
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2,b)
exten => 5041, n, dial(sip/5001)
exten => 5042, 1, monitor(wav,monitor_test3,b)
exten => 5042, n, dial(sip/5001)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test3,m)
exten => 5043, n, changemonitor(monitor_test4)
exten => 5043, n, dial(sip/5001)
exten => 5044, 1, monitor(wav,monitor_test4,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test5) ; this looks to fail by design and emits a warning
exten => 5044, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@248952 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-02-25 23:09:54 +00:00
|
|
|
const char *absolute = *fname_base == '/' ? "" : ast_config_AST_MONITOR_DIR;
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
const char *absolute_suffix = *fname_base == '/' ? "" : "/";
|
2012-02-20 23:43:27 +00:00
|
|
|
char tmpstring[sizeof(ast_channel_monitor(chan)->filename_base)] = "";
|
2009-11-04 23:50:59 +00:00
|
|
|
int i, fd[2] = { -1, -1 }, doexit = 0;
|
2008-01-31 21:02:12 +00:00
|
|
|
|
|
|
|
/* before continuing, see if we're trying to rename the file to itself... */
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
snprintf(tmpstring, sizeof(tmpstring), "%s%s%s", absolute, absolute_suffix, fname_base);
|
|
|
|
|
|
|
|
/* try creating the directory just in case it doesn't exist */
|
|
|
|
if (directory) {
|
|
|
|
char *name = ast_strdupa(tmpstring);
|
|
|
|
ast_mkdir(dirname(name), 0777);
|
|
|
|
}
|
2009-11-04 23:50:59 +00:00
|
|
|
|
2012-02-16 18:39:46 +00:00
|
|
|
/*!
|
|
|
|
* \note We cannot just compare filenames, due to symlinks, relative
|
2009-11-04 23:50:59 +00:00
|
|
|
* paths, and other possible filesystem issues. We could use
|
|
|
|
* realpath(3), but its use is discouraged. However, if we try to
|
|
|
|
* create the same file from two different paths, the second will
|
|
|
|
* fail, and so we have our notification that the filenames point to
|
|
|
|
* the same path.
|
|
|
|
*
|
|
|
|
* Remember, also, that we're using the basename of the file (i.e.
|
|
|
|
* the file without the format suffix), so it does not already exist
|
|
|
|
* and we aren't interfering with the recording itself.
|
|
|
|
*/
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, ast_channel_monitor(chan)->filename_base);
|
2009-11-04 23:50:59 +00:00
|
|
|
|
|
|
|
if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 ||
|
2012-02-20 23:43:27 +00:00
|
|
|
(fd[1] = open(ast_channel_monitor(chan)->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
|
2009-11-04 23:50:59 +00:00
|
|
|
if (fd[0] < 0) {
|
|
|
|
ast_log(LOG_ERROR, "Unable to compare filenames: %s\n", strerror(errno));
|
|
|
|
} else {
|
|
|
|
ast_debug(2, "No need to rename monitor filename to itself\n");
|
|
|
|
}
|
|
|
|
doexit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup temporary files */
|
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
if (fd[i] >= 0) {
|
|
|
|
while (close(fd[i]) < 0 && errno == EINTR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unlink(tmpstring);
|
Merged revisions 254235 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r254235 | jpeeler | 2010-03-23 19:37:23 -0500 (Tue, 23 Mar 2010) | 72 lines
Ensure that monitor recordings are written to the correct location (again)
This is an extension to 248860. As such the dialplan test has been extended:
; non absolute path, not combined
exten => 5040, 1, monitor(wav,tmp/jeff/monitor_test)
exten => 5040, n, dial(sip/5001)
; absolute path, not combined
exten => 5041, 1, monitor(wav,/tmp/jeff/monitor_test2)
exten => 5041, n, dial(sip/5001)
; no path, not combined
exten => 5042, 1, monitor(wav,monitor_test3)
exten => 5042, n, dial(sip/5001)
; combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5043, 1, monitor(wav,tmp/jeff/monitor_test4,m)
exten => 5043, n, changemonitor(monitor_test5)
exten => 5043, n, dial(sip/5001)
; combined: changemonitor from no path to non absolute path
exten => 5044, 1, monitor(wav,monitor_test6,m)
exten => 5044, n, changemonitor(tmp/jeff/monitor_test7) ; this wasn't possible before
exten => 5044, n, dial(sip/5001)
; non absolute path, combined
exten => 5045, 1, monitor(wav,tmp/jeff/monitor_test8,m)
exten => 5045, n, dial(sip/5001)
; absolute path, combined
exten => 5046, 1, monitor(wav,/tmp/jeff/monitor_test9,m)
exten => 5046, n, dial(sip/5001)
; no path, combined
exten => 5047, 1, monitor(wav,monitor_test10,m)
exten => 5047, n, dial(sip/5001)
; combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5048, 1, monitor(wav,tmp/jeff/monitor_test11,m)
exten => 5048, n, changemonitor(/tmp/jeff/monitor_test12)
exten => 5048, n, dial(sip/5001)
; combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5049, 1, monitor(wav,/tmp/jeff/monitor_test13,m)
exten => 5049, n, changemonitor(tmp/jeff/monitor_test14)
exten => 5049, n, dial(sip/5001)
; combined: changemonitor from no path to absolute
exten => 5050, 1, monitor(wav,monitor_test15,m)
exten => 5050, n, changemonitor(/tmp/jeff/monitor_test16)
exten => 5050, n, dial(sip/5001)
; combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5051, 1, monitor(wav,/tmp/jeff/monitor_test17,m)
exten => 5051, n, changemonitor(monitor_test18)
exten => 5051, n, dial(sip/5001)
; not combined: changemonitor from non absolute to no path (leaves tmp/jeff)
exten => 5052, 1, monitor(wav,tmp/jeff/monitor_test19)
exten => 5052, n, changemonitor(monitor_test20)
exten => 5052, n, dial(sip/5001)
; not combined: changemonitor from no path to non absolute
exten => 5053, 1, monitor(wav,monitor_test21)
exten => 5053, n, changemonitor(tmp/jeff/monitor_test22)
exten => 5053, n, dial(sip/5001)
; not combined: changemonitor from non absolute to absolute (leaves tmp/jeff)
exten => 5054, 1, monitor(wav,tmp/jeff/monitor_test23)
exten => 5054, n, changemonitor(/tmp/jeff/monitor_test24)
exten => 5054, n, dial(sip/5001)
; not combined: changemonitor from absolute to non absolute (leaves /tmp/jeff)
exten => 5055, 1, monitor(wav,/tmp/jeff/monitor_test24)
exten => 5055, n, changemonitor(tmp/jeff/monitor_test25)
exten => 5055, n, dial(sip/5001)
; not combined: changemonitor from no path to absolute
exten => 5056, 1, monitor(wav,monitor_test26)
exten => 5056, n, changemonitor(/tmp/jeff/monitor_test27)
exten => 5056, n, dial(sip/5001)
; not combined: changemonitor from absolute to no path (leaves /tmp/jeff)
exten => 5057, 1, monitor(wav,/tmp/jeff/monitor_test28)
exten => 5057, n, changemonitor(monitor_test29)
exten => 5057, n, dial(sip/5001)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254277 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-03-24 17:15:05 +00:00
|
|
|
/* if previous monitor file existed in a subdirectory, the directory will not be removed */
|
2012-02-20 23:43:27 +00:00
|
|
|
unlink(ast_channel_monitor(chan)->filename_base);
|
2009-11-04 23:50:59 +00:00
|
|
|
|
|
|
|
if (doexit) {
|
2008-01-31 21:02:12 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-20 23:43:27 +00:00
|
|
|
ast_copy_string(ast_channel_monitor(chan)->filename_base, tmpstring, sizeof(ast_channel_monitor(chan)->filename_base));
|
|
|
|
ast_channel_monitor(chan)->filename_changed = 1;
|
2003-03-25 19:30:06 +00:00
|
|
|
} else {
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_log(LOG_WARNING, "Cannot change monitor filename of channel %s to %s, monitoring not started\n", ast_channel_name(chan), fname_base);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2006-05-10 15:17:58 +00:00
|
|
|
UNLOCK_IF_NEEDED(chan, need_lock);
|
2004-06-29 04:42:19 +00:00
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-11 01:12:54 +00:00
|
|
|
enum {
|
|
|
|
MON_FLAG_BRIDGED = (1 << 0),
|
|
|
|
MON_FLAG_MIX = (1 << 1),
|
|
|
|
MON_FLAG_DROP_IN = (1 << 2),
|
|
|
|
MON_FLAG_DROP_OUT = (1 << 3),
|
2014-04-15 23:21:19 +00:00
|
|
|
MON_FLAG_BEEP = (1 << 4),
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OPT_ARG_BEEP_INTERVAL,
|
|
|
|
OPT_ARG_ARRAY_SIZE, /* Always last element of the enum */
|
2014-04-11 01:12:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AST_APP_OPTIONS(monitor_opts, {
|
|
|
|
AST_APP_OPTION('b', MON_FLAG_BRIDGED),
|
|
|
|
AST_APP_OPTION('m', MON_FLAG_MIX),
|
|
|
|
AST_APP_OPTION('i', MON_FLAG_DROP_IN),
|
|
|
|
AST_APP_OPTION('o', MON_FLAG_DROP_OUT),
|
2014-04-15 23:21:19 +00:00
|
|
|
AST_APP_OPTION_ARG('B', MON_FLAG_BEEP, OPT_ARG_BEEP_INTERVAL),
|
2014-04-11 01:12:54 +00:00
|
|
|
});
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*!
|
|
|
|
* \brief Start monitor
|
|
|
|
* \param chan
|
2007-11-12 23:44:20 +00:00
|
|
|
* \param data arguments passed fname|options
|
2007-07-23 14:32:04 +00:00
|
|
|
* \retval 0 on success.
|
|
|
|
* \retval -1 on failure.
|
|
|
|
*/
|
2009-05-21 21:13:09 +00:00
|
|
|
static int start_monitor_exec(struct ast_channel *chan, const char *data)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2012-02-16 18:39:46 +00:00
|
|
|
char *arg;
|
|
|
|
char *options;
|
|
|
|
char *delay;
|
2004-12-09 22:39:14 +00:00
|
|
|
char *urlprefix = NULL;
|
|
|
|
char tmp[256];
|
2007-07-09 20:58:22 +00:00
|
|
|
int stream_action = X_REC_IN | X_REC_OUT;
|
2004-02-05 22:10:19 +00:00
|
|
|
int joinfiles = 0;
|
2004-09-17 03:49:57 +00:00
|
|
|
int res = 0;
|
2007-07-31 01:10:47 +00:00
|
|
|
char *parse;
|
2014-04-11 01:12:54 +00:00
|
|
|
struct ast_flags flags = { 0 };
|
2014-04-15 23:21:19 +00:00
|
|
|
char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
|
|
|
|
char beep_id[64] = "";
|
2007-07-31 01:10:47 +00:00
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(format);
|
|
|
|
AST_APP_ARG(fname_base);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
);
|
2011-07-14 20:28:54 +00:00
|
|
|
|
|
|
|
/* Parse arguments. */
|
|
|
|
if (ast_strlen_zero(data)) {
|
|
|
|
ast_log(LOG_ERROR, "Monitor requires an argument\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
|
2009-05-22 16:10:33 +00:00
|
|
|
parse = ast_strdupa(data);
|
2007-07-31 01:10:47 +00:00
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
|
|
|
|
2007-12-11 20:06:43 +00:00
|
|
|
if (!ast_strlen_zero(args.options)) {
|
2014-04-15 23:21:19 +00:00
|
|
|
ast_app_parse_options(monitor_opts, &flags, opts, args.options);
|
2014-04-11 01:12:54 +00:00
|
|
|
|
|
|
|
if (ast_test_flag(&flags, MON_FLAG_MIX)) {
|
2007-12-11 20:06:43 +00:00
|
|
|
stream_action |= X_JOIN;
|
2014-04-11 01:12:54 +00:00
|
|
|
}
|
|
|
|
if (ast_test_flag(&flags, MON_FLAG_DROP_IN)) {
|
2007-12-11 20:06:43 +00:00
|
|
|
stream_action &= ~X_REC_IN;
|
2014-04-11 01:12:54 +00:00
|
|
|
}
|
|
|
|
if (ast_test_flag(&flags, MON_FLAG_DROP_OUT)) {
|
2007-12-11 20:06:43 +00:00
|
|
|
stream_action &= ~X_REC_OUT;
|
2014-04-11 01:12:54 +00:00
|
|
|
}
|
2014-04-15 23:21:19 +00:00
|
|
|
if (ast_test_flag(&flags, MON_FLAG_BEEP)) {
|
|
|
|
const char *interval_str = S_OR(opts[OPT_ARG_BEEP_INTERVAL], "15");
|
|
|
|
unsigned int interval = 15;
|
|
|
|
|
|
|
|
if (sscanf(interval_str, "%30u", &interval) != 1) {
|
|
|
|
ast_log(LOG_WARNING, "Invalid interval '%s' for periodic beep. Using default of %u\n",
|
|
|
|
interval_str, interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_beep_start(chan, interval, beep_id, sizeof(beep_id))) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to enable periodic beep, please ensure func_periodic_hook is loaded.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2007-12-11 20:06:43 +00:00
|
|
|
}
|
2007-07-31 01:10:47 +00:00
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
arg = strchr(args.format, ':');
|
2007-07-31 01:10:47 +00:00
|
|
|
if (arg) {
|
|
|
|
*arg++ = 0;
|
|
|
|
urlprefix = arg;
|
|
|
|
}
|
|
|
|
|
2012-02-16 18:39:46 +00:00
|
|
|
if (!ast_strlen_zero(urlprefix) && !ast_strlen_zero(args.fname_base)) {
|
2007-07-31 01:10:47 +00:00
|
|
|
snprintf(tmp, sizeof(tmp), "%s/%s.%s", urlprefix, args.fname_base,
|
|
|
|
((strcmp(args.format, "gsm")) ? "wav" : "gsm"));
|
2011-12-16 21:10:19 +00:00
|
|
|
ast_channel_lock(chan);
|
2013-06-17 03:00:38 +00:00
|
|
|
ast_cdr_setuserfield(ast_channel_name(chan), tmp);
|
2011-12-16 21:10:19 +00:00
|
|
|
ast_channel_unlock(chan);
|
2004-12-09 22:39:14 +00:00
|
|
|
}
|
2014-04-11 01:12:54 +00:00
|
|
|
if (ast_test_flag(&flags, MON_FLAG_BRIDGED)) {
|
2004-09-17 03:49:57 +00:00
|
|
|
/* We must remove the "b" option if listed. In principle none of
|
|
|
|
the following could give NULL results, but we check just to
|
|
|
|
be pedantic. Reconstructing with checks for 'm' option does not
|
|
|
|
work if we end up adding more options than 'm' in the future. */
|
2006-05-10 13:22:15 +00:00
|
|
|
delay = ast_strdupa(data);
|
2008-02-20 15:21:51 +00:00
|
|
|
options = strrchr(delay, ',');
|
2006-05-10 13:22:15 +00:00
|
|
|
if (options) {
|
|
|
|
arg = strchr(options, 'b');
|
|
|
|
if (arg) {
|
|
|
|
*arg = 'X';
|
2007-07-31 01:10:47 +00:00
|
|
|
pbx_builtin_setvar_helper(chan,"AUTO_MONITOR", delay);
|
2004-09-17 03:49:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
res = ast_monitor_start(chan, args.format, args.fname_base, 1, stream_action, beep_id);
|
2004-06-29 04:42:19 +00:00
|
|
|
if (res < 0)
|
2007-07-31 01:10:47 +00:00
|
|
|
res = ast_monitor_change_fname(chan, args.fname_base, 1);
|
2007-07-09 20:58:22 +00:00
|
|
|
|
|
|
|
if (stream_action & X_JOIN) {
|
|
|
|
if ((stream_action & X_REC_IN) && (stream_action & X_REC_OUT))
|
|
|
|
joinfiles = 1;
|
|
|
|
else
|
|
|
|
ast_log(LOG_WARNING, "Won't mix streams unless both input and output streams are recorded\n");
|
|
|
|
}
|
2004-02-05 22:10:19 +00:00
|
|
|
ast_monitor_setjoinfiles(chan, joinfiles);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Wrapper function \see ast_monitor_stop */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int stop_monitor_exec(struct ast_channel *chan, const char *data)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2004-06-29 04:42:19 +00:00
|
|
|
return ast_monitor_stop(chan, 1);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Wrapper function \see ast_monitor_change_fname */
|
2009-05-21 21:13:09 +00:00
|
|
|
static int change_monitor_exec(struct ast_channel *chan, const char *data)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2009-05-21 21:13:09 +00:00
|
|
|
return ast_monitor_change_fname(chan, data, 1);
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Start monitoring a channel by manager connection */
|
2007-01-05 22:43:18 +00:00
|
|
|
static int start_monitor_action(struct mansession *s, const struct message *m)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *c = NULL;
|
2007-01-05 22:43:18 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
const char *fname = astman_get_header(m, "File");
|
|
|
|
const char *format = astman_get_header(m, "Format");
|
|
|
|
const char *mix = astman_get_header(m, "Mix");
|
2004-01-11 05:58:10 +00:00
|
|
|
char *d;
|
2007-07-09 20:58:22 +00:00
|
|
|
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No channel specified");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
if (!(c = ast_channel_get_by_name(name))) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No such channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
2004-06-29 04:42:19 +00:00
|
|
|
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(fname)) {
|
2012-02-16 18:39:46 +00:00
|
|
|
/* No filename specified, default to the channel name. */
|
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(c);
|
2012-01-09 22:15:50 +00:00
|
|
|
fname = ast_strdupa(ast_channel_name(c));
|
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_unlock(c);
|
2012-02-16 18:39:46 +00:00
|
|
|
|
|
|
|
/* Replace all '/' chars from the channel name with '-' chars. */
|
|
|
|
for (d = (char *) fname; (d = strchr(d, '/')); ) {
|
2006-01-21 22:09:06 +00:00
|
|
|
*d = '-';
|
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
|
|
|
}
|
2004-01-11 05:58:10 +00:00
|
|
|
}
|
2007-07-09 20:58:22 +00:00
|
|
|
|
2014-04-15 23:21:19 +00:00
|
|
|
if (ast_monitor_start(c, format, fname, 1, X_REC_IN | X_REC_OUT, NULL)) {
|
2004-06-29 04:42:19 +00:00
|
|
|
if (ast_monitor_change_fname(c, fname, 1)) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "Could not start monitoring channel");
|
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
|
|
|
c = ast_channel_unref(c);
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-03 15:42:36 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
if (ast_true(mix)) {
|
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(c);
|
2004-09-17 14:15:11 +00:00
|
|
|
ast_monitor_setjoinfiles(c, 1);
|
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_unlock(c);
|
2004-06-03 15:42:36 +00:00
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
c = ast_channel_unref(c);
|
|
|
|
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_ack(s, m, "Started monitoring channel");
|
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
|
|
|
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Stop monitoring a channel by manager connection */
|
2007-01-05 22:43:18 +00:00
|
|
|
static int stop_monitor_action(struct mansession *s, const struct message *m)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *c = NULL;
|
2007-01-05 22:43:18 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
2004-05-20 16:30:10 +00:00
|
|
|
int res;
|
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
|
|
|
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No channel specified");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
if (!(c = ast_channel_get_by_name(name))) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No such channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
res = ast_monitor_stop(c, 1);
|
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
|
|
|
|
|
|
|
c = ast_channel_unref(c);
|
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
if (res) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "Could not stop monitoring channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_ack(s, m, "Stopped monitoring channel");
|
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
|
|
|
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 14:32:04 +00:00
|
|
|
/*! \brief Change filename of a monitored channel by manager connection */
|
2007-01-05 22:43:18 +00:00
|
|
|
static int change_monitor_action(struct mansession *s, const struct message *m)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *c = NULL;
|
2007-01-05 22:43:18 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
|
|
|
const char *fname = astman_get_header(m, "File");
|
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
|
|
|
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No channel specified");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2005-11-08 01:55:31 +00:00
|
|
|
if (ast_strlen_zero(fname)) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No filename specified");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
if (!(c = ast_channel_get_by_name(name))) {
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "No such channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2004-06-29 04:42:19 +00:00
|
|
|
if (ast_monitor_change_fname(c, fname, 1)) {
|
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
|
|
|
c = ast_channel_unref(c);
|
2003-09-08 16:44:36 +00:00
|
|
|
astman_send_error(s, m, "Could not change monitored filename of channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
c = ast_channel_unref(c);
|
|
|
|
|
2006-03-02 19:07:17 +00:00
|
|
|
astman_send_ack(s, m, "Changed monitor filename");
|
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
|
|
|
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 16:07:23 +00:00
|
|
|
void AST_OPTIONAL_API_NAME(ast_monitor_setjoinfiles)(struct ast_channel *chan, int turnon)
|
2004-02-03 16:57:00 +00:00
|
|
|
{
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_monitor(chan))
|
|
|
|
ast_channel_monitor(chan)->joinfiles = turnon;
|
2004-02-03 16:57:00 +00:00
|
|
|
}
|
|
|
|
|
2006-01-14 00:32:30 +00:00
|
|
|
enum MONITOR_PAUSING_ACTION
|
|
|
|
{
|
|
|
|
MONITOR_ACTION_PAUSE,
|
|
|
|
MONITOR_ACTION_UNPAUSE
|
|
|
|
};
|
2012-01-27 19:26:53 +00:00
|
|
|
|
2007-01-05 22:43:18 +00:00
|
|
|
static int do_pause_or_unpause(struct mansession *s, const struct message *m, int action)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *c = NULL;
|
2007-01-05 22:43:18 +00:00
|
|
|
const char *name = astman_get_header(m, "Channel");
|
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
|
|
|
|
2006-10-02 16:56:15 +00:00
|
|
|
if (ast_strlen_zero(name)) {
|
2006-01-14 00:32:30 +00:00
|
|
|
astman_send_error(s, m, "No channel specified");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2006-01-14 00:32:30 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
if (!(c = ast_channel_get_by_name(name))) {
|
2006-01-14 00:32:30 +00:00
|
|
|
astman_send_error(s, m, "No such channel");
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2006-01-14 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
if (action == MONITOR_ACTION_PAUSE) {
|
2006-01-14 00:32:30 +00:00
|
|
|
ast_monitor_pause(c);
|
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
|
|
|
} else {
|
2006-01-14 00:32:30 +00:00
|
|
|
ast_monitor_unpause(c);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
c = ast_channel_unref(c);
|
|
|
|
|
2007-04-26 01:50:02 +00:00
|
|
|
astman_send_ack(s, m, (action == MONITOR_ACTION_PAUSE ? "Paused monitoring of the channel" : "Unpaused monitoring of the channel"));
|
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
|
|
|
|
2012-01-27 19:26:53 +00:00
|
|
|
return AMI_SUCCESS;
|
2006-01-14 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2007-01-05 22:43:18 +00:00
|
|
|
static int pause_monitor_action(struct mansession *s, const struct message *m)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return do_pause_or_unpause(s, m, MONITOR_ACTION_PAUSE);
|
|
|
|
}
|
|
|
|
|
2007-01-05 22:43:18 +00:00
|
|
|
static int unpause_monitor_action(struct mansession *s, const struct message *m)
|
2006-01-14 00:32:30 +00:00
|
|
|
{
|
|
|
|
return do_pause_or_unpause(s, m, MONITOR_ACTION_UNPAUSE);
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2009-06-01 19:37:30 +00:00
|
|
|
ast_register_application_xml("Monitor", start_monitor_exec);
|
|
|
|
ast_register_application_xml("StopMonitor", stop_monitor_exec);
|
|
|
|
ast_register_application_xml("ChangeMonitor", change_monitor_exec);
|
|
|
|
ast_register_application_xml("PauseMonitor", pause_monitor_exec);
|
|
|
|
ast_register_application_xml("UnpauseMonitor", unpause_monitor_exec);
|
|
|
|
ast_manager_register_xml("Monitor", EVENT_FLAG_CALL, start_monitor_action);
|
|
|
|
ast_manager_register_xml("StopMonitor", EVENT_FLAG_CALL, stop_monitor_action);
|
|
|
|
ast_manager_register_xml("ChangeMonitor", EVENT_FLAG_CALL, change_monitor_action);
|
|
|
|
ast_manager_register_xml("PauseMonitor", EVENT_FLAG_CALL, pause_monitor_action);
|
|
|
|
ast_manager_register_xml("UnpauseMonitor", EVENT_FLAG_CALL, unpause_monitor_action);
|
2003-03-25 19:30:06 +00:00
|
|
|
|
2007-10-26 21:37:02 +00:00
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
2003-03-25 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2003-03-25 19:30:06 +00:00
|
|
|
{
|
2004-09-17 14:15:11 +00:00
|
|
|
ast_unregister_application("Monitor");
|
|
|
|
ast_unregister_application("StopMonitor");
|
2004-12-28 23:49:46 +00:00
|
|
|
ast_unregister_application("ChangeMonitor");
|
2006-01-14 00:32:30 +00:00
|
|
|
ast_unregister_application("PauseMonitor");
|
|
|
|
ast_unregister_application("UnpauseMonitor");
|
2004-12-28 23:49:46 +00:00
|
|
|
ast_manager_unregister("Monitor");
|
|
|
|
ast_manager_unregister("StopMonitor");
|
|
|
|
ast_manager_unregister("ChangeMonitor");
|
2006-10-21 18:50:38 +00:00
|
|
|
ast_manager_unregister("PauseMonitor");
|
|
|
|
ast_manager_unregister("UnpauseMonitor");
|
2006-01-14 00:32:30 +00:00
|
|
|
|
2003-03-25 19:30:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
/* usecount semantics need to be defined */
|
2010-07-20 19:35:02 +00:00
|
|
|
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Monitoring Resource",
|
2015-05-06 00:49:04 +00:00
|
|
|
.support_level = AST_MODULE_SUPPORT_CORE,
|
|
|
|
.load = load_module,
|
|
|
|
.unload = unload_module,
|
|
|
|
.load_pri = AST_MODPRI_CHANNEL_DEPEND,
|
|
|
|
);
|