262 #define MF_BETWEEN_MS 50 263 #define MF_DURATION 55 264 #define MF_KP_DURATION 120 265 #define MF_ST_DURATION 65 277 struct timeval start;
280 int is_start_digit = 0;
295 while (timeout == 0 || remaining_time > 0) {
298 if (remaining_time <= 0) {
317 if (digits_read == 0 && !laxkp && result !=
'*') {
318 ast_debug(1,
"Received MF digit, but no KP yet, ignoring: %c\n", result);
321 ast_debug(1,
"Received MF digit: %c\n", result);
325 if (
override && digits_read > 0) {
326 ast_debug(1,
"Received another KP, starting over\n");
336 is_start_digit = (strchr(
"#", result) || strchr(
"A", result) || strchr(
"B", result) || strchr(
"C", result));
338 if (!no_st || !is_start_digit) {
343 if (is_start_digit) {
354 ast_debug(3,
"channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n",
ast_channel_name(chan), timeout, remaining_time);
361 struct timeval start, pulsetimer, digittimer;
364 int hits = 0, digits_read = 0;
365 unsigned short int sf_on = 0;
378 while (timeout == 0 || remaining_time > 0) {
381 if (remaining_time <= 0) {
407 if (timeleft > -75) {
410 ast_debug(5,
"Detected SF pulse (pulse #%d)\n", hits);
412 ast_debug(5,
"SF noise, ignoring, time elapsed was %d ms\n", timeleft);
417 ast_debug(2,
"Received SF digit: %d\n", hits);
435 ast_debug(3,
"Got SF pulse digit %d, is someone playing with the phone?\n", hits);
440 ast_debug(2,
"Got more than 10 pulses, truncating to 10\n");
452 if (maxdigits > 0 && digits_read >= maxdigits) {
464 ast_debug(3,
"channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n",
ast_channel_name(chan), timeout, remaining_time);
477 char *argcopy =
NULL;
478 int features = 0, digits = 0, to = 0, freq = 2600;
502 tosec = atof(arglist.timeout);
544 ast_verb(3,
"MF digits received: '%s'\n", tmp);
546 ast_verb(3,
"No MF digits received.\n");
557 char *argcopy =
NULL;
580 tosec = atof(arglist.timeout);
613 ast_verb(3,
"MF digits received: '%s'\n", tmp);
615 ast_verb(3,
"No MF digits received.\n");
624 int dinterval = 0, duration = 0, durationkp = 0, durationst = 0;
667 chan_dest = chan_found;
668 if (chan_found != chan) {
669 chan_autoservice = chan;
679 return chan_autoservice ? 0 : res;
702 if (!strcmp(digit,
"*"))
705 if (!strcmp(digit,
"#") || !strcmp(digit,
"A") || !strcmp(digit,
"B") || !strcmp(digit,
"C"))
708 if (!
ast_strlen_zero(duration) && (sscanf(duration,
"%30u", &duration_ms) != 1)) {
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...
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
Convenient Signal Processing routines.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define DSP_DIGITMODE_MUTECONF
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
static int load_module(void)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_verb(level,...)
struct ast_frame_subclass subclass
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
static const struct ast_app_option read_app_options[128]
#define DSP_DIGITMODE_RELAXDTMF
#define ast_debug(level,...)
Log a DEBUG message.
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "MF Sender and Receiver Applications")
static char * readmf_name
General Asterisk PBX channel definitions.
static int read_mf_digits(struct ast_channel *chan, char *buf, int timeout, int features, int laxkp, int override, int no_kp, int no_st)
Detects MF digits on channel using DSP, terminated by ST, STP, ST2P, or ST3P.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
Conversion utility functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
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.
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_manager_unregister(const char *action)
Unregister a registered manager command.
#define DSP_DIGITMODE_MUTEMAX
static char * readsf_name
static int read_mf_exec(struct ast_channel *chan, const char *data)
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static int read_sf_digits(struct ast_channel *chan, char *buf, int timeout, int maxdigits, int freq, int features, int extrapulses)
static int sendmf_exec(struct ast_channel *chan, const char *vdata)
static int read_sf_exec(struct ast_channel *chan, const char *data)
Structure used to handle boolean flags.
static int manager_play_mf(struct mansession *s, const struct message *m)
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_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.
static const char sendmf_name[]
enum ast_frame_type frametype
#define DSP_DIGITMODE_NOQUELCH
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define DSP_FEATURE_FREQ_DETECT
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
#define AST_APP_ARG(name)
Define an application argument.