285 unsigned short int tx;
286 unsigned short int rx;
391 di->rxcount =
di->rxcount + 1;
394 di->txcount =
di->txcount + 1;
397 ast_debug(1,
"TONE_DETECT just got a hit (#%d in this direction, waiting for %d total)\n", now,
di->hitsrequired);
398 if (now >=
di->hitsrequired) {
411 }
else if (
di->gototx) {
417 if (
di->signalfeatures && !
match) {
422 ast_debug(3,
"tcount: %d, tstate: %d\n", tcount, tstate);
458 }
else if (
di->gototx) {
461 ast_debug(3,
"Detected call progress signal in %s direction, but don't know where to go\n",
484 data = datastore->
data;
539 char *exten, *pri, *
context, *parse;
544 exten =
strsep(&parse,
",");
545 pri =
strsep(&parse,
",");
565 size = strlen(
context) + strlen(exten) + strlen(pri) + 3;
571 snprintf(dest, size,
"%s,%s,%s",
context, exten, pri);
594 if (strchr(data,
't')) {
595 snprintf(buffer, buflen,
"%d",
di->txcount);
596 }
else if (strchr(data,
'r')) {
597 snprintf(buffer, buflen,
"%d",
di->rxcount);
633 int freq1 = 0, freq2 = 0, duration = 500,
db = 16, squelch = 0, hitsrequired = 1;
634 int signalfeatures = 0;
695 di->signalfeatures = signalfeatures;
704 ast_debug(1,
"Keeping our ears open for %s Hz, %d db\n",
args.freqs,
db);
711 di->signalfeatures = signalfeatures;
718 di->duration = duration;
729 di->hitsrequired = hitsrequired;
768 int freq1 = 0, freq2 = 0, timeout = 0, duration = 500, times = 1,
db = 16, squelch = 0;
771 struct timeval start;
772 int remaining_time = 0;
797 timeout = 1000 * timeoutf;
823 ast_debug(1,
"Waiting for %s Hz, %d time(s), timeout %d ms, %d db\n",
args.freqs, times, timeout,
db);
828 if (remaining_time <= 0) {
844 ast_debug(1,
"We just detected %s Hz (hit #%d)\n",
args.freqs, hits);
857 }
while (timeout == 0 || remaining_time > 0);
873 struct timeval start;
874 int remaining_time = 0;
896 timeout = 1000 * timeoutf;
947 ast_debug(1,
"Starting tone scan, timeout: %d ms, threshold: %d\n", timeout,
threshold);
952 if (remaining_time <= 0) {
978 result = frame2->subclass.integer;
984 ast_debug(1,
"Ignoring inactionable event\n");
994 ast_debug(3,
"tcount: %d, tstate: %d\n", tcount, tstate);
1008 if (voice && tcount > 15 && tcount >=
threshold) {
1025 ast_debug(1,
"Something else we weren't expecting? tstate: %d, #%d\n", tstate, tcount);
1035 }
while (!
match && (timeout == 0 || remaining_time > 0));
1045 .
name =
"TONE_DETECT",
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 ast_malloc(len)
A wrapper for malloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
@ AST_AUDIOHOOK_MANIPULATE_ALL_RATES
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.
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
@ AST_AUDIOHOOK_DIRECTION_READ
#define ast_audiohook_lock(ah)
Lock an audiohook.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
@ AST_AUDIOHOOK_TYPE_MANIPULATE
@ AST_AUDIOHOOK_STATUS_DONE
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
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.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
#define ast_channel_lock(chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
const char * ast_channel_exten(const struct ast_channel *chan)
#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.
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
#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_free(struct ast_dsp *dsp)
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
#define DSP_PROGRESS_RINGING
#define DSP_TONE_STATE_SPECIAL3
#define DSP_FEATURE_WAITDIALTONE
#define DSP_TONE_STATE_DIALTONE
#define DSP_PROGRESS_TALK
#define DSP_TONE_STATE_BUSY
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,...
#define DSP_PROGRESS_BUSY
#define DSP_FEATURE_FAX_DETECT
#define DSP_FAXMODE_DETECT_CED
#define DSP_PROGRESS_CONGESTION
#define DSP_TONE_STATE_HUNGUP
#define DSP_FEATURE_FREQ_DETECT
#define DSP_TONE_STATE_TALKING
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
#define DSP_TONE_STATE_RINGING
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
int ast_dsp_set_freqmode(struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
Set arbitrary frequency detection mode.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
struct stasis_message_type * ast_channel_tone_detect(void)
Message type for a channel tone detection.
struct stasis_message * ast_channel_blob_create_from_cache(const char *uniqueid, struct stasis_message_type *type, struct ast_json *blob)
Create a ast_channel_blob message, pulling channel state from the cache.
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_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#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.
char * strsep(char **str, const char *delims)
Asterisk internal frame definitions.
#define ast_frdup(fr)
Copies a frame.
#define ast_debug(level,...)
Log a DEBUG message.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Asterisk module definitions.
#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.
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.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
static int detect_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
static int wait_exec(struct ast_channel *chan, const char *data)
static int detect_read(struct ast_channel *chan, const char *cmd, char *data, char *buffer, size_t buflen)
static int remove_detect(struct ast_channel *chan)
static int scan_exec(struct ast_channel *chan, const char *data)
static const struct ast_datastore_info detect_datastore
static struct ast_custom_function detect_function
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Tone detection module")
static int parse_signal_features(struct ast_flags *flags)
static void destroy_callback(void *data)
static int load_module(void)
static char * goto_parser(struct ast_channel *chan, char *loc)
static int freq_parser(char *freqs, int *freq1, int *freq2)
static int unload_module(void)
static const struct ast_app_option wait_exec_options[128]
static int detect_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
enum ast_audiohook_status status
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.
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
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)