47 #define AST_API_MODULE 263 #define LOCK_IF_NEEDED(lock, needed) do { \ 265 ast_channel_lock(lock); \ 268 #define UNLOCK_IF_NEEDED(lock, needed) do { \ 270 ast_channel_unlock(lock); \ 273 static unsigned long seq = 0;
306 const char *fname_base,
int need_lock,
int stream_action,
316 char *channel_name, *p;
321 if (!(monitor =
ast_calloc(1,
sizeof(*monitor)))) {
332 int directory = strchr(fname_base,
'/') ? 1 : 0;
334 const char *absolute_suffix = *fname_base ==
'/' ?
"" :
"/";
337 absolute, absolute_suffix, fname_base);
339 absolute, absolute_suffix, fname_base);
341 absolute, absolute_suffix, fname_base);
359 for (p = channel_name; (p = strchr(p,
'/')); ) {
446 if (!strcasecmp(format,
"ulaw"))
448 if (!strcasecmp(format,
"alaw"))
503 const char *
execute, *execute_args;
510 execute =
"nice -n 19 soxmix";
512 execute =
"nice -n 19 sox -m";
524 execute, fname_base, format, fname_base, format, fname_base, format,execute_args);
600 int directory = strchr(fname_base,
'/') ? 1 : 0;
602 const char *absolute_suffix = *fname_base ==
'/' ?
"" :
"/";
604 int i, fd[2] = { -1, -1 },
doexit = 0;
607 snprintf(tmpstring,
sizeof(tmpstring),
"%s%s%s", absolute, absolute_suffix, fname_base);
629 if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 ||
630 (fd[1] = open(
ast_channel_monitor(chan)->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
634 ast_debug(2,
"No need to rename monitor filename to itself\n");
640 for (i = 0; i < 2; i++) {
642 while (close(fd[i]) < 0 &&
errno == EINTR);
698 char *urlprefix =
NULL;
706 char beep_id[64] =
"";
736 unsigned int interval = 15;
738 if (sscanf(interval_str,
"%30u", &interval) != 1) {
739 ast_log(
LOG_WARNING,
"Invalid interval '%s' for periodic beep. Using default of %u\n",
740 interval_str, interval);
744 ast_log(
LOG_WARNING,
"Unable to enable periodic beep, please ensure func_periodic_hook is loaded.\n");
750 arg = strchr(
args.format,
':');
757 snprintf(tmp,
sizeof(tmp),
"%s/%s.%s", urlprefix,
args.fname_base,
758 ((strcmp(
args.format,
"gsm")) ?
"wav" :
"gsm"));
769 options = strrchr(delay,
',');
771 arg = strchr(options,
'b');
784 if (stream_action &
X_JOIN) {
788 ast_log(
LOG_WARNING,
"Won't mix streams unless both input and output streams are recorded\n");
834 for (d = (
char *) fname; (d = strchr(d,
'/')); ) {
1014 .optional_modules =
"func_periodic_hook",
enum sip_cc_notify_state state
static int do_pause_or_unpause(struct mansession *s, const struct message *m, int action)
#define ast_channel_lock(chan)
char read_filename[FILENAME_MAX]
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static SQLHSTMT execute(struct odbc_obj *obj, void *data, int silent)
Common execution function for SQL queries.
static int ast_monitor_set_state(struct ast_channel *chan, int state)
Change state of monitored channel.
void ast_channel_insmpl_set(struct ast_channel *chan, unsigned long value)
static int load_module(void)
int(* stop)(struct ast_channel *chan, int need_lock)
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
static int unpause_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper for ast_monitor_unpause.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define UNLOCK_IF_NEEDED(lock, needed)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static ast_mutex_t monitorlock
static const struct ast_app_option monitor_opts[128]
static int change_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper function.
static int start_monitor_action(struct mansession *s, const struct message *m)
Start monitoring a channel by manager connection.
char filename_base[FILENAME_MAX]
static int unload_module(void)
static int pause_monitor_action(struct mansession *s, const struct message *m)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int AST_OPTIONAL_API_NAME() ast_beep_stop(struct ast_channel *chan, const char *beep_id)
#define LOCK_IF_NEEDED(lock, needed)
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
#define ast_mutex_lock(a)
#define ast_strdup(str)
A wrapper for strdup()
static int unpause_monitor_action(struct mansession *s, const struct message *m)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
struct stasis_message_type * ast_channel_monitor_start_type(void)
Message type for starting monitor on a channel.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
char write_filename[FILENAME_MAX]
int ast_unregister_application(const char *app)
Unregister an application.
static const char * get_soxmix_format(const char *format)
Get audio format.
Periodic beeps into the audio of a call.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Configuration File Parser.
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
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.
struct stasis_message_type * ast_channel_monitor_stop_type(void)
Message type for stopping monitor on a channel.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Core PBX routines and definitions.
int AST_OPTIONAL_API_NAME() ast_beep_start(struct ast_channel *chan, unsigned int interval, char *beep_id, size_t len)
static int stop_monitor_action(struct mansession *s, const struct message *m)
Stop monitoring a channel by manager connection.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
static int change_monitor_action(struct mansession *s, const struct message *m)
Change filename of a monitored channel by manager connection.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
static unsigned int monitor
struct ast_filestream * ast_writefile(const char *filename, const char *type, const char *comment, int flags, int check, mode_t mode)
Starts writing a file.
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.
struct ast_filestream * read_stream
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
const char * ast_config_AST_MONITOR_DIR
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_filestream * write_stream
int ast_closestream(struct ast_filestream *f)
Closes a stream.
static int stop_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper function.
void ast_cdr_setuserfield(const char *channel_name, const char *userfield)
Set CDR user field for channel (stored in CDR)
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
struct stasis_message * ast_channel_blob_create_from_cache(const char *uniqueid, struct stasis_message_type *type, struct ast_json *blob)
Create a ast_channel_blob message, pulling channel state from the cache.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
int AST_OPTIONAL_API_NAME() ast_monitor_unpause(struct ast_channel *chan)
Unpause monitoring of channel.
int AST_OPTIONAL_API_NAME() ast_monitor_stop(struct ast_channel *chan, int need_lock)
Stop monitoring channel.
Standard Command Line Interface.
void AST_OPTIONAL_API_NAME() ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
const char * ast_channel_name(const struct ast_channel *chan)
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
int AST_OPTIONAL_API_NAME() ast_monitor_pause(struct ast_channel *chan)
Pause monitoring of channel.
Options provided by main asterisk program.
int ast_filerename(const char *oldname, const char *newname, const char *fmt)
Renames a file.
#define AST_OPTIONAL_API_NAME(name)
Expands to the name of the implementation function.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
enum AST_MONITORING_STATE state
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
struct ast_channel_monitor * ast_channel_monitor(const struct ast_channel *chan)
static snd_pcm_format_t format
static int start_monitor_exec(struct ast_channel *chan, const char *data)
Start monitor.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static int pause_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper for ast_monitor_pause.
void ast_channel_outsmpl_set(struct ast_channel *chan, unsigned long value)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
void ast_channel_monitor_set(struct ast_channel *chan, struct ast_channel_monitor *value)
#define ast_mutex_unlock(a)
#define AST_APP_ARG(name)
Define an application argument.
int ast_mkdir(const char *path, int mode)
Recursively create directory path.