167 unsigned short int tx;
168 unsigned short int rx;
237 di = datastore->
data;
253 ast_debug(1,
"TONE_DETECT just got a hit\n");
282 data = datastore->
data;
341 context =
strsep(&parse,
",");
342 exten =
strsep(&parse,
",");
343 pri =
strsep(&parse,
",");
363 size =
sizeof(
context) +
sizeof(exten) +
sizeof(pri) + 2;
365 snprintf(dest, size,
"%s,%s,%s", context, exten, pri);
385 di = datastore->
data;
388 if (strchr(data,
't')) {
389 snprintf(buffer, buflen,
"%d", di->
txcount);
390 }
else if (strchr(data,
'r')) {
391 snprintf(buffer, buflen,
"%d", di->
rxcount);
437 di = datastore->
data;
494 ast_debug(1,
"Keeping our ears open for %s Hz, %d db\n",
args.freqs,
db);
533 struct timeval start;
534 int remaining_time = 0;
587 while (
timeout == 0 || remaining_time > 0) {
590 if (remaining_time <= 0) {
606 ast_debug(1,
"We just detected %s Hz (hit #%d)\n",
args.freqs, hits);
626 .
name =
"TONE_DETECT",
#define ast_channel_lock(chan)
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_test_flag(p, flag)
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
void ast_dsp_free(struct ast_dsp *dsp)
static char * goto_parser(struct ast_channel *chan, char *loc)
Convenient Signal Processing routines.
static void destroy_callback(void *data)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Structure for a data store type.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
static const struct ast_app_option wait_exec_options[128]
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int detect_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
Structure for a data store object.
static const struct ast_datastore_info detect_datastore
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.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
static int unload_module(void)
static int remove_detect(struct ast_channel *chan)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
struct ast_frame_subclass subclass
#define ast_strlen_zero(foo)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
ast_audiohook_manipulate_callback manipulate_callback
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags)
Initialize an audiohook structure.
static int detect_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
#define ast_debug(level,...)
Log a DEBUG message.
static int detect_read(struct ast_channel *chan, const char *cmd, char *data, char *buffer, size_t buflen)
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
Asterisk internal frame definitions.
Conversion utility functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_malloc(len)
A wrapper for malloc()
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.
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Tone detection module")
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
Structure used to handle boolean flags.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
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 int load_module(void)
char * strsep(char **str, const char *delims)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
const char * ast_channel_name(const struct ast_channel *chan)
Data structure associated with a single frame of data.
int ast_dsp_set_freqmode(struct ast_dsp *dsp, int freq1, int dur, int db, int squelch)
Set arbitrary frequency detection mode.
const char * ast_channel_context(const struct ast_channel *chan)
enum ast_audiohook_status status
#define ast_datastore_alloc(info, uid)
enum ast_frame_type frametype
static char context[AST_MAX_CONTEXT]
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define DSP_FEATURE_FREQ_DETECT
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_audiohook_lock(ah)
Lock an audiohook.
Asterisk module definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
static int freq_parser(char *freqs, int *freq1, int *freq2)
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int wait_exec(struct ast_channel *chan, const char *data)
static struct ast_custom_function detect_function
#define AST_APP_ARG(name)
Define an application argument.