49 #include "asterisk/file.h"
129 static int do_waiting(
struct ast_channel *chan,
int timereqd, time_t waitstart,
int timeout,
int wait_for_silence) {
177 ast_dsp_func(sildet, f, &dsptime);
182 ast_verb(6,
"Got %dms %s < %dms required\n", dsptime, wait_for_silence ?
"silence" :
"noise", timereqd);
184 if (dsptime >= timereqd) {
185 ast_verb(3,
"Exiting with %dms %s >= %dms required\n", dsptime, wait_for_silence ?
"silence" :
"noise", timereqd);
189 ast_debug(1,
"WAITSTATUS was set to %s\n", wait_for_silence ?
"SILENCE" :
"NOISE");
193 if (timeout && (difftime(time(&now), waitstart) >= timeout)) {
195 ast_debug(1,
"WAITSTATUS was set to TIMEOUT\n");
214 int iterations = 1, i;
222 if (!data || ( (sscanf(data,
"%30d,%30d,%30d", &timereqd, &iterations, &timeout) != 3) &&
223 (sscanf(data,
"%30d,%30d", &timereqd, &iterations) != 2) &&
224 (sscanf(data,
"%30d", &timereqd) != 1) ) ) {
228 ast_verb(3,
"Waiting %d time(s) for %d ms silence with %d timeout\n", iterations, timereqd, timeout);
235 for (i=0; (i<iterations) && (res == 1); i++) {
236 res =
do_waiting(chan, timereqd, waitstart, timeout, wait_for_silence);
static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart, int timeout, int wait_for_silence)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static int waitforsilence_exec(struct ast_channel *chan, const char *data)
static int unload_module(void)
void ast_dsp_free(struct ast_dsp *dsp)
Convenient Signal Processing routines.
struct ast_dsp * ast_dsp_new(void)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
#define ast_opt_transmit_silence
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_verb(level,...)
static char * app_silence
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 int waitfor_exec(struct ast_channel *chan, const char *data, int wait_for_silence)
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.
char * ast_getformatname(format_t format)
Get the name of a format.
enum ast_channel_state _state
const ast_string_field name
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.
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...
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
static int load_module(void)
static int waitfornoise_exec(struct ast_channel *chan, const char *data)
#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.
union ast_frame::@172 data
#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.
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
Return non-zero if this is noise. Updates "totalnoise" with the total number of seconds of noise...