123#define OPERATOR_KEY '0'
125static char *
app =
"Record";
172 struct ast_flags *flags,
int dtmf_integer,
int terminator)
179 if ((dtmf_integer == terminator) ||
190 char directory[
PATH_MAX], *file_sep;
192 if (!(file_sep = strrchr(path,
'/'))) {
201 if (path[0] ==
'/') {
208 res = snprintf(directory,
sizeof(directory),
"%s/sounds/%s",
213 if (res >=
sizeof(directory)) {
237 int truncate_silence = 1;
240 int terminator =
'#';
252 struct timeval start;
253 const char *status_response =
"ERROR";
268 ext = strrchr(
args.filename,
'.');
270 ext = strchr(
args.filename,
':');
282 if ((sscanf(
args.silence,
"%30d", &i) == 1) && (i > -1)) {
290 truncate_silence = 0;
292 if (
args.maxduration) {
293 if ((sscanf(
args.maxduration,
"%30d", &i) == 1) && (i > -1))
295 maxduration = i * 1000;
309 if (strchr(
args.filename,
'%')) {
310 size_t src, dst, count = 0;
311 size_t src_len = strlen(
args.filename);
312 size_t dst_len =
sizeof(
tmp) - 1;
315 for (src = 0, dst = 0; src < src_len && dst < dst_len; src++) {
316 if (!strncmp(&
args.filename[src],
"%d", 2)) {
317 int s = snprintf(&
tmp[dst],
PATH_MAX - dst,
"%zu", count);
351 status_response =
"ERROR";
388 status_response =
"ERROR";
397 status_response =
"ERROR";
407 if (maxduration <= 0)
417 if (maxduration > 0 && ms == 0) {
432 status_response =
"ERROR";
440 totalsilence = dspsilence;
444 if (totalsilence > silence) {
448 status_response =
"SILENCE";
457 status_response =
"ERROR";
468 status_response =
"OPERATOR";
472 status_response =
"DTMF";
484 if (maxduration > 0 && !ms) {
486 status_response =
"TIMEOUT";
492 status_response =
"HANGUP";
498 if (gotsilence && truncate_silence) {
501 }
else if (!gottimeout && f) {
517 if ((silence > 0) && rfmt) {
static int record_exec(struct ast_channel *chan, const char *data)
static enum dtmf_response record_dtmf_response(struct ast_channel *chan, struct ast_flags *flags, int dtmf_integer, int terminator)
static int create_destination_directory(const char *path)
static const struct ast_app_option app_opts[128]
static int load_module(void)
static int unload_module(void)
@ OPTION_IGNORE_TERMINATE
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
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.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
const char * ast_channel_language(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
Convenient Signal Processing routines.
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Generic File Format Support. Should be included by clients of the file handling routines....
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
Writes a frame to a stream.
int ast_stream_rewind(struct ast_filestream *fs, off_t ms)
Rewind stream ms.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
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_truncstream(struct ast_filestream *fs)
Trunc stream at current location.
int ast_closestream(struct ast_filestream *f)
Closes a stream.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
int ast_filedelete(const char *filename, const char *fmt)
Deletes a file.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
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.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ast_opt_transmit_silence
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_DATA_DIR
Core PBX routines and definitions.
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.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_mkdir(const char *path, int mode)
Recursively create directory path.