45 #define AST_API_MODULE
248 #define LOCK_IF_NEEDED(lock, needed) do { \
250 ast_channel_lock(lock); \
253 #define UNLOCK_IF_NEEDED(lock, needed) do { \
255 ast_channel_unlock(lock); \
258 static unsigned long seq = 0;
291 const char *fname_base,
int need_lock,
int stream_action)
299 char *channel_name, *p;
304 if (!(monitor =
ast_calloc(1,
sizeof(*monitor)))) {
311 int directory = strchr(fname_base,
'/') ? 1 : 0;
313 const char *absolute_suffix = *fname_base ==
'/' ?
"" :
"/";
316 absolute, absolute_suffix, fname_base);
318 absolute, absolute_suffix, fname_base);
320 absolute, absolute_suffix, fname_base);
338 for (p = channel_name; (p = strchr(p,
'/')); ) {
402 ast_debug(1,
"Cannot start monitoring %s, already monitored\n", chan->
name);
422 if (!strcasecmp(format,
"ulaw"))
424 if (!strcasecmp(format,
"alaw"))
484 const char *execute, *execute_args;
491 execute =
"nice -n 19 soxmix";
493 execute =
"nice -n 19 sox -m";
503 snprintf(tmp,
sizeof(tmp),
"%s \"%s-in.%s\" \"%s-out.%s\" \"%s.%s\" %s &",
504 execute, fname_base, format, fname_base, format, fname_base, format,execute_args);
506 snprintf(tmp2,
sizeof(tmp2),
"( %s& rm -f \"%s-\"* ) &",tmp, fname_base);
509 ast_debug(1,
"monitor executing %s\n",tmp);
576 int directory = strchr(fname_base,
'/') ? 1 : 0;
578 const char *absolute_suffix = *fname_base ==
'/' ?
"" :
"/";
580 int i, fd[2] = { -1, -1 },
doexit = 0;
583 snprintf(tmpstring,
sizeof(tmpstring),
"%s%s%s", absolute, absolute_suffix, fname_base);
605 if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 ||
610 ast_debug(2,
"No need to rename monitor filename to itself\n");
616 for (i = 0; i < 2; i++) {
618 while (close(fd[i]) < 0 &&
errno == EINTR);
633 ast_log(
LOG_WARNING,
"Cannot change monitor filename of channel %s to %s, monitoring not started\n", chan->
name, fname_base);
658 int waitforbridge = 0;
677 if (strchr(
args.options,
'm'))
679 if (strchr(
args.options,
'b'))
681 if (strchr(
args.options,
'i'))
683 if (strchr(
args.options,
'o'))
687 arg = strchr(
args.format,
':');
694 snprintf(tmp,
sizeof(tmp),
"%s/%s.%s", urlprefix,
args.fname_base,
695 ((strcmp(
args.format,
"gsm")) ?
"wav" :
"gsm"));
710 options = strrchr(delay,
',');
712 arg = strchr(options,
'b');
725 if (stream_action &
X_JOIN) {
729 ast_log(
LOG_WARNING,
"Won't mix streams unless both input and output streams are recorded\n");
775 for (d = (
char *) fname; (d = strchr(d,
'/')); ) {
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.
int ast_safe_system(const char *s)
Safely spawn an external program while closing file descriptors.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static int ast_monitor_set_state(struct ast_channel *chan, int state)
Change state of monitored channel.
const ast_string_field uniqueid
static int load_module(void)
#define ast_channel_unref(c)
Decrease channel reference count.
static int unpause_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper for ast_monitor_unpause.
#define UNLOCK_IF_NEEDED(lock, needed)
static ast_mutex_t monitorlock
static int change_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper function.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
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)
Configuration File Parser.
int(* stop)(struct ast_channel *chan, int need_lock)
#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_MODULE_INFO(keystr, flags_to_set, desc, fields...)
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.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
void ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon)
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.
static char urlprefix[AST_MAX_BUF]
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_manager_event(chan, category, event, contents,...)
int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield)
Set CDR user field for channel (stored in CDR)
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
int ast_monitor_unpause(struct ast_channel *chan)
Unpause monitoring of channel.
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int ast_monitor_stop(struct ast_channel *chan, int need_lock)
Stop monitoring channel.
int ast_monitor_start(struct ast_channel *chan, const char *format_spec, const char *fname_base, int need_lock, int stream_action)
Start monitoring a channel.
Core PBX routines and definitions.
static int stop_monitor_action(struct mansession *s, const struct message *m)
Stop monitoring a channel by manager connection.
int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, int need_lock)
Change monitored filename of channel.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
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".
static unsigned int monitor
const ast_string_field name
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.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
struct ast_filestream * read_stream
int ast_monitor_pause(struct ast_channel *chan)
Pause monitoring of channel.
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
const char * ast_config_AST_MONITOR_DIR
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.
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...
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Options provided by main asterisk program.
int ast_filerename(const char *oldname, const char *newname, const char *fmt)
Renames a file.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_OPTIONAL_API_NAME(name)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
struct ast_channel_monitor * monitor
enum AST_MONITORING_STATE state
#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.
static snd_pcm_format_t format
static int start_monitor_exec(struct ast_channel *chan, const char *data)
Start monitor.
static int pause_monitor_exec(struct ast_channel *chan, const char *data)
Wrapper for ast_monitor_pause.
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_manager_unregister(char *action)
Unregister a registered manager command.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_mutex_unlock(a)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.