150#define OPERATOR_KEY '0' 
  152static char *
app = 
"Record";
 
  199    struct ast_flags *flags, 
int dtmf_integer, 
int terminator)
 
  206    if ((dtmf_integer == terminator) ||
 
 
  217    char directory[
PATH_MAX], *file_sep;
 
  219    if (!(file_sep = strrchr(path, 
'/'))) {
 
  228    if (path[0] == 
'/') {
 
  235    res = snprintf(directory, 
sizeof(directory), 
"%s/sounds/%s",
 
  240    if (res >= 
sizeof(directory)) {
 
 
  258    .
type = 
"RECORDING_INFO",
 
 
  288    if (!strcasecmp(data, 
"duration")) {
 
 
  316    int truncate_silence = 1;   
 
  319    int terminator = 
'#';
 
  331    struct timeval start;
 
  332    const char *status_response = 
"ERROR";
 
  343        if (!(recdata = 
ast_calloc(1, 
sizeof(*recdata)))) {
 
  372        ext = strrchr(
args.filename, 
'.'); 
 
  374            ext = strchr(
args.filename, 
':');
 
  386        if ((sscanf(
args.silence, 
"%30d", &i) == 1) && (i > -1)) {
 
  394        truncate_silence = 0;
 
  396    if (
args.maxduration) {
 
  397        if ((sscanf(
args.maxduration, 
"%30d", &i) == 1) && (i > -1))
 
  399            maxduration = i * 1000;
 
  413    if (strchr(
args.filename, 
'%')) {
 
  414        size_t src, dst, count = 0;
 
  415        size_t src_len = strlen(
args.filename);
 
  416        size_t dst_len = 
sizeof(tmp) - 1;
 
  419            for (src = 0, dst = 0; src < src_len && dst < dst_len; src++) {
 
  420                if (!strncmp(&
args.filename[src], 
"%d", 2)) {
 
  421                    int s = snprintf(&tmp[dst], 
PATH_MAX - dst, 
"%zu", count);
 
  431                    tmp[dst] = 
args.filename[src];
 
  455        status_response = 
"ERROR";
 
  492        status_response = 
"ERROR";
 
  501        status_response = 
"ERROR";
 
  511    if (maxduration <= 0)
 
  521        if (maxduration > 0 && ms == 0) {
 
  536                status_response = 
"ERROR";
 
  544                    totalsilence = dspsilence;
 
  548                if (totalsilence > silence) {
 
  552                    status_response = 
"SILENCE";
 
  561                status_response = 
"ERROR";
 
  572                status_response = 
"OPERATOR";
 
  576                status_response = 
"DTMF";
 
  588    if (maxduration > 0 && !ms) {
 
  590        status_response = 
"TIMEOUT";
 
  596        status_response = 
"HANGUP";
 
  602    if (gotsilence && truncate_silence) {
 
  605    } 
else if (!gottimeout && f) {
 
  623    if ((silence > 0) && rfmt) {
 
 
  640    .
name = 
"RECORDING_INFO",
 
 
static int record_exec(struct ast_channel *chan, const char *data)
@ OPTION_IGNORE_TERMINATE
static enum dtmf_response record_dtmf_response(struct ast_channel *chan, struct ast_flags *flags, int dtmf_integer, int terminator)
static struct ast_custom_function acf_recording_info
static int create_destination_directory(const char *path)
static int recording_info_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static const struct ast_app_option app_opts[128]
static const struct ast_datastore_info recording_data_info
static int load_module(void)
static int unload_module(void)
static void recording_data_free(void *data)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#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)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define ast_channel_lock(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.
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
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.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
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.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
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.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
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.