Asterisk - The Open Source Telephony Project
18.5.0
|
PBX channel monitoring. More...
#include "asterisk.h"
#include <sys/stat.h>
#include <libgen.h>
#include "asterisk/paths.h"
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/cli.h"
#include "asterisk/manager.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/monitor.h"
#include "asterisk/app.h"
#include "asterisk/utils.h"
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/beep.h"
Go to the source code of this file.
Macros | |
#define | AST_API_MODULE |
#define | LOCK_IF_NEEDED(lock, needed) |
#define | UNLOCK_IF_NEEDED(lock, needed) |
Enumerations | |
enum | { MON_FLAG_BRIDGED = (1 << 0), MON_FLAG_MIX = (1 << 1), MON_FLAG_DROP_IN = (1 << 2), MON_FLAG_DROP_OUT = (1 << 3), MON_FLAG_BEEP = (1 << 4) } |
enum | { OPT_ARG_BEEP_INTERVAL, OPT_ARG_ARRAY_SIZE } |
enum | MONITOR_PAUSING_ACTION { MONITOR_ACTION_PAUSE, MONITOR_ACTION_UNPAUSE } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
int AST_OPTIONAL_API_NAME() | ast_monitor_change_fname (struct ast_channel *chan, const char *fname_base, int need_lock) |
Change monitored filename of channel. More... | |
int AST_OPTIONAL_API_NAME() | ast_monitor_pause (struct ast_channel *chan) |
Pause monitoring of channel. More... | |
static int | ast_monitor_set_state (struct ast_channel *chan, int state) |
Change state of monitored channel. More... | |
void AST_OPTIONAL_API_NAME() | ast_monitor_setjoinfiles (struct ast_channel *chan, int turnon) |
int AST_OPTIONAL_API_NAME() | ast_monitor_start (struct ast_channel *chan, const char *format_spec, const char *fname_base, int need_lock, int stream_action, const char *beep_id) |
Start monitoring a channel. More... | |
int AST_OPTIONAL_API_NAME() | ast_monitor_stop (struct ast_channel *chan, int need_lock) |
Stop monitoring channel. More... | |
int AST_OPTIONAL_API_NAME() | ast_monitor_unpause (struct ast_channel *chan) |
Unpause monitoring of channel. More... | |
static int | change_monitor_action (struct mansession *s, const struct message *m) |
Change filename of a monitored channel by manager connection. More... | |
static int | change_monitor_exec (struct ast_channel *chan, const char *data) |
Wrapper function. More... | |
static int | do_pause_or_unpause (struct mansession *s, const struct message *m, int action) |
static const char * | get_soxmix_format (const char *format) |
Get audio format. More... | |
static int | load_module (void) |
static int | pause_monitor_action (struct mansession *s, const struct message *m) |
static int | pause_monitor_exec (struct ast_channel *chan, const char *data) |
Wrapper for ast_monitor_pause. More... | |
static int | start_monitor_action (struct mansession *s, const struct message *m) |
Start monitoring a channel by manager connection. More... | |
static int | start_monitor_exec (struct ast_channel *chan, const char *data) |
Start monitor. More... | |
static int | stop_monitor_action (struct mansession *s, const struct message *m) |
Stop monitoring a channel by manager connection. More... | |
static int | stop_monitor_exec (struct ast_channel *chan, const char *data) |
Wrapper function. More... | |
static int | unload_module (void) |
static int | unpause_monitor_action (struct mansession *s, const struct message *m) |
static int | unpause_monitor_exec (struct ast_channel *chan, const char *data) |
Wrapper for ast_monitor_unpause. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Call Monitoring Resource" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, .optional_modules = "func_periodic_hook", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static const struct ast_app_option | monitor_opts [128] = { [ 'b' ] = { .flag = MON_FLAG_BRIDGED }, [ 'm' ] = { .flag = MON_FLAG_MIX }, [ 'i' ] = { .flag = MON_FLAG_DROP_IN }, [ 'o' ] = { .flag = MON_FLAG_DROP_OUT }, [ 'B' ] = { .flag = MON_FLAG_BEEP , .arg_index = OPT_ARG_BEEP_INTERVAL + 1 }, } |
static ast_mutex_t | monitorlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static unsigned long | seq = 0 |
PBX channel monitoring.
Definition in file res_monitor.c.
#define AST_API_MODULE |
Definition at line 47 of file res_monitor.c.
#define LOCK_IF_NEEDED | ( | lock, | |
needed | |||
) |
Definition at line 263 of file res_monitor.c.
Referenced by ast_monitor_change_fname(), ast_monitor_set_state(), ast_monitor_start(), and ast_monitor_stop().
#define UNLOCK_IF_NEEDED | ( | lock, | |
needed | |||
) |
Definition at line 268 of file res_monitor.c.
Referenced by ast_monitor_change_fname(), ast_monitor_set_state(), ast_monitor_start(), and ast_monitor_stop().
anonymous enum |
Enumerator | |
---|---|
MON_FLAG_BRIDGED | |
MON_FLAG_MIX | |
MON_FLAG_DROP_IN | |
MON_FLAG_DROP_OUT | |
MON_FLAG_BEEP |
Definition at line 665 of file res_monitor.c.
anonymous enum |
Enumerator | |
---|---|
OPT_ARG_BEEP_INTERVAL | |
OPT_ARG_ARRAY_SIZE |
Definition at line 673 of file res_monitor.c.
Enumerator | |
---|---|
MONITOR_ACTION_PAUSE | |
MONITOR_ACTION_UNPAUSE |
Definition at line 932 of file res_monitor.c.
|
static |
Definition at line 1015 of file res_monitor.c.
|
static |
Definition at line 1015 of file res_monitor.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1015 of file res_monitor.c.
int AST_OPTIONAL_API_NAME() ast_monitor_change_fname | ( | struct ast_channel * | chan, |
const char * | fname_base, | ||
int | need_lock | ||
) |
Change monitored filename of channel.
chan | |
fname_base | new filename |
need_lock |
0 | on success. |
-1 | on failure. |
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.
Definition at line 590 of file res_monitor.c.
References ast_channel_monitor(), ast_channel_name(), ast_config_AST_MONITOR_DIR, ast_copy_string(), ast_debug, ast_log, ast_mkdir(), ast_strdupa, ast_strlen_zero, doexit, errno, ast_channel_monitor::filename_base, ast_channel_monitor::filename_changed, LOCK_IF_NEEDED, LOG_ERROR, LOG_WARNING, name, and UNLOCK_IF_NEEDED.
Referenced by __stub__ast_monitor_stop(), change_monitor_action(), change_monitor_exec(), start_monitor_action(), and start_monitor_exec().
int AST_OPTIONAL_API_NAME() ast_monitor_pause | ( | struct ast_channel * | chan | ) |
Pause monitoring of channel.
Definition at line 559 of file res_monitor.c.
References AST_MONITOR_PAUSED, and ast_monitor_set_state().
Referenced by __stub__ast_monitor_setjoinfiles(), do_pause_or_unpause(), and pause_monitor_exec().
|
static |
Change state of monitored channel.
chan | |
state | monitor state |
0 | on success. |
-1 | on failure. |
Definition at line 282 of file res_monitor.c.
References ast_channel_monitor(), LOCK_IF_NEEDED, state, ast_channel_monitor::state, and UNLOCK_IF_NEEDED.
Referenced by ast_monitor_pause(), ast_monitor_start(), and ast_monitor_unpause().
void AST_OPTIONAL_API_NAME() ast_monitor_setjoinfiles | ( | struct ast_channel * | chan, |
int | turnon | ||
) |
Definition at line 926 of file res_monitor.c.
References ast_channel_monitor(), and ast_channel_monitor::joinfiles.
Referenced by __stub__ast_monitor_change_fname(), start_automonitor(), start_monitor_action(), start_monitor_exec(), and try_calling().
int AST_OPTIONAL_API_NAME() ast_monitor_start | ( | struct ast_channel * | chan, |
const char * | format_spec, | ||
const char * | fname_base, | ||
int | need_lock, | ||
int | stream_action, | ||
const char * | beep_id | ||
) |
Start monitoring a channel.
chan | ast_channel struct to record |
format_spec | file format to use for recording |
fname_base | filename base to record to |
need_lock | whether to lock the channel mutex |
stream_action | whether to record the input and/or output streams. X_REC_IN | X_REC_OUT is most often used Creates the file to record, if no format is specified it assumes WAV It also sets channel variable __MONITORED=yes |
0 | on success |
-1 | on failure |
Definition at line 305 of file res_monitor.c.
References ao2_cleanup, ast_calloc, ast_channel_blob_create_from_cache(), ast_channel_insmpl_set(), ast_channel_monitor(), ast_channel_monitor_set(), ast_channel_monitor_start_type(), ast_channel_name(), ast_channel_outsmpl_set(), ast_channel_topic(), ast_channel_uniqueid(), ast_closestream(), ast_config_AST_MONITOR_DIR, ast_copy_string(), ast_debug, AST_FILE_MODE, ast_filedelete(), ast_fileexists(), ast_free, ast_log, ast_mkdir(), AST_MONITOR_RUNNING, ast_monitor_set_state(), ast_monitor_stop(), ast_mutex_lock, ast_mutex_unlock, ast_strdup, ast_strdupa, ast_strlen_zero, ast_writefile(), ast_channel_monitor::beep_id, ast_channel_monitor::filename_base, ast_channel_monitor::filename_changed, FILENAME_MAX, ast_channel_monitor::format, LOCK_IF_NEEDED, LOG_WARNING, monitor, monitorlock, name, NULL, pbx_builtin_setvar_helper(), RAII_VAR, ast_channel_monitor::read_filename, ast_channel_monitor::read_stream, seq, stasis_publish(), ast_channel_monitor::stop, UNLOCK_IF_NEEDED, ast_channel_monitor::write_filename, ast_channel_monitor::write_stream, X_REC_IN, and X_REC_OUT.
Referenced by start_automonitor(), start_monitor_action(), start_monitor_exec(), and try_calling().
int AST_OPTIONAL_API_NAME() ast_monitor_stop | ( | struct ast_channel * | chan, |
int | need_lock | ||
) |
Stop monitoring channel.
chan | |
need_lock | Stop the recording, close any open streams, mix in/out channels if required |
Definition at line 461 of file res_monitor.c.
References ao2_cleanup, ast_beep_stop(), ast_channel_blob_create_from_cache(), ast_channel_monitor(), ast_channel_monitor_set(), ast_channel_monitor_stop_type(), ast_channel_topic(), ast_channel_uniqueid(), ast_closestream(), ast_debug, ast_filedelete(), ast_fileexists(), ast_filerename(), ast_free, ast_log, ast_safe_system(), ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_strlen_zero, execute(), ast_channel_monitor::filename_base, format, ast_channel_monitor::format, get_soxmix_format(), LOCK_IF_NEEDED, LOG_WARNING, NULL, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), RAII_VAR, stasis_publish(), tmp(), UNLOCK_IF_NEEDED, and write_stream().
Referenced by __stub__ast_monitor_start(), ast_monitor_start(), stop_monitor_action(), and stop_monitor_exec().
int AST_OPTIONAL_API_NAME() ast_monitor_unpause | ( | struct ast_channel * | chan | ) |
Unpause monitoring of channel.
Definition at line 565 of file res_monitor.c.
References AST_MONITOR_RUNNING, and ast_monitor_set_state().
Referenced by __stub__ast_monitor_pause(), do_pause_or_unpause(), and unpause_monitor_exec().
|
static |
Change filename of a monitored channel by manager connection.
Definition at line 892 of file res_monitor.c.
References AMI_SUCCESS, ast_channel_get_by_name(), ast_channel_unref, ast_monitor_change_fname(), ast_strlen_zero, astman_get_header(), astman_send_ack(), astman_send_error(), c, name, and NULL.
Referenced by load_module().
|
static |
Wrapper function.
Definition at line 802 of file res_monitor.c.
References ast_monitor_change_fname().
Referenced by load_module().
|
static |
Definition at line 938 of file res_monitor.c.
References AMI_SUCCESS, ast_channel_get_by_name(), ast_channel_unref, ast_monitor_pause(), ast_monitor_unpause(), ast_strlen_zero, astman_get_header(), astman_send_ack(), astman_send_error(), c, MONITOR_ACTION_PAUSE, name, and NULL.
Referenced by pause_monitor_action(), and unpause_monitor_action().
|
static |
Get audio format.
format | recording format. 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. |
Definition at line 442 of file res_monitor.c.
References format.
Referenced by ast_monitor_stop().
|
static |
Definition at line 976 of file res_monitor.c.
References ast_manager_register_xml, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, change_monitor_action(), change_monitor_exec(), EVENT_FLAG_CALL, pause_monitor_action(), pause_monitor_exec(), start_monitor_action(), start_monitor_exec(), stop_monitor_action(), stop_monitor_exec(), unpause_monitor_action(), and unpause_monitor_exec().
Referenced by unload_module().
|
static |
Definition at line 966 of file res_monitor.c.
References do_pause_or_unpause(), and MONITOR_ACTION_PAUSE.
Referenced by load_module().
|
static |
Wrapper for ast_monitor_pause.
Definition at line 571 of file res_monitor.c.
References ast_monitor_pause().
Referenced by load_module().
|
static |
Start monitoring a channel by manager connection.
Definition at line 808 of file res_monitor.c.
References AMI_SUCCESS, ast_channel_get_by_name(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_channel_unref, ast_monitor_change_fname(), ast_monitor_setjoinfiles(), ast_monitor_start(), ast_strdupa, ast_strlen_zero, ast_true(), astman_get_header(), astman_send_ack(), astman_send_error(), c, d, format, name, NULL, X_REC_IN, and X_REC_OUT.
Referenced by load_module().
|
static |
Start monitor.
chan | |
data | arguments passed fname|options |
0 | on success. |
-1 | on failure. |
Definition at line 693 of file res_monitor.c.
References args, AST_APP_ARG, ast_app_parse_options(), ast_beep_start(), ast_cdr_setuserfield(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_log, ast_monitor_change_fname(), ast_monitor_setjoinfiles(), ast_monitor_start(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, ast_test_flag, format, LOG_ERROR, LOG_WARNING, MON_FLAG_BEEP, MON_FLAG_BRIDGED, MON_FLAG_DROP_IN, MON_FLAG_DROP_OUT, MON_FLAG_MIX, monitor_opts, NULL, OPT_ARG_ARRAY_SIZE, OPT_ARG_BEEP_INTERVAL, options, parse(), pbx_builtin_setvar_helper(), S_OR, tmp(), X_JOIN, X_REC_IN, and X_REC_OUT.
Referenced by load_module().
|
static |
Stop monitoring a channel by manager connection.
Definition at line 861 of file res_monitor.c.
References AMI_SUCCESS, ast_channel_get_by_name(), ast_channel_unref, ast_monitor_stop(), ast_strlen_zero, astman_get_header(), astman_send_ack(), astman_send_error(), c, name, and NULL.
Referenced by load_module().
|
static |
Wrapper function.
Definition at line 796 of file res_monitor.c.
References ast_monitor_stop().
Referenced by load_module().
|
static |
Definition at line 992 of file res_monitor.c.
References ast_manager_unregister(), AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_DEPRECATED, ast_unregister_application(), ASTERISK_GPL_KEY, and load_module().
|
static |
Definition at line 971 of file res_monitor.c.
References do_pause_or_unpause(), and MONITOR_ACTION_UNPAUSE.
Referenced by load_module().
|
static |
Wrapper for ast_monitor_unpause.
Definition at line 577 of file res_monitor.c.
References ast_monitor_unpause().
Referenced by load_module().
|
static |
Definition at line 1015 of file res_monitor.c.
|
static |
Definition at line 1015 of file res_monitor.c.
|
static |
Definition at line 684 of file res_monitor.c.
Referenced by start_monitor_exec().
|
static |
Definition at line 261 of file res_monitor.c.
Referenced by ast_monitor_start().
|
static |
Definition at line 273 of file res_monitor.c.
Referenced by ast_monitor_start().