36 #include "asterisk/file.h"
116 static char *
app =
"Record";
145 char *
ext = NULL, *opts[0];
146 char *
parse, *dir, *file;
160 int terminator =
'#';
172 struct timeval start;
187 if (strstr(
args.filename,
"%d"))
189 ext = strrchr(
args.filename,
'.');
191 ext = strchr(
args.filename,
':');
203 if ((sscanf(
args.silence,
"%30d", &i) == 1) && (i > -1)) {
210 if (
args.maxduration) {
211 if ((sscanf(
args.maxduration,
"%30d", &i) == 1) && (i > -1))
213 maxduration = i * 1000;
232 char countstring[15];
241 tmplen = strlen(tmp);
242 for (idx = 1; idx < fname.argc; idx++) {
243 if (fname.piece[idx][0] ==
'd') {
245 snprintf(countstring,
sizeof(countstring),
"%d", count);
247 tmplen += strlen(countstring);
248 }
else if (tmplen + 2 <
sizeof(tmp)) {
251 tmp[tmplen++] = fname.piece[idx][0];
254 ast_copy_string(tmp + tmplen, &(fname.piece[idx][1]),
sizeof(tmp) - tmplen);
312 if ((file = strrchr(dir,
'/')))
331 if (maxduration <= 0)
341 if (maxduration > 0 && ms == 0) {
364 totalsilence = dspsilence;
368 if (totalsilence > silence) {
395 if (maxduration > 0 && !ms) {
412 }
else if (!gottimeout) {
423 if ((silence > 0) && rfmt) {
union ast_frame_subclass subclass
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define ast_test_flag(p, flag)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
void ast_dsp_free(struct ast_dsp *dsp)
Convenient Signal Processing routines.
#define ast_set_flag(p, flag)
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.
struct ast_dsp * ast_dsp_new(void)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_opt_transmit_silence
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Core PBX routines and definitions.
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set threshold value for silence.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
int ast_stream_rewind(struct ast_filestream *fs, off_t ms)
Rewind stream ms.
enum ast_channel_state _state
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...
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
static void parse(struct mgcp_request *req)
static int unload_module(void)
int ast_closestream(struct ast_filestream *f)
Closes a stream.
Structure used to handle boolean flags.
int ast_truncstream(struct ast_filestream *fs)
Trunc stream at current location.
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_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Return non-zero if this is silence. Updates "totalsilence" with the total number of seconds of silenc...
static int load_module(void)
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
static int record_exec(struct ast_channel *chan, const char *data)
#define AST_APP_ARG(name)
Define an application argument.
enum ast_frame_type frametype
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static struct ast_app_option app_opts[128]
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
Asterisk module definitions.
const ast_string_field language
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_mkdir(const char *path, int mode)
Recursively create directory path.