225#define MF_BETWEEN_MS 50
226#define MF_DURATION 55
227#define MF_KP_DURATION 120
228#define MF_ST_DURATION 65
247static int read_mf_digits(
struct ast_channel *chan,
char *
buf,
int buflen,
int timeout,
int features,
int laxkp,
int override,
int no_kp,
int no_st,
int maxdigits) {
250 struct timeval start;
251 int remaining_time = timeout;
253 int is_start_digit = 0;
269 while (timeout == 0 || remaining_time > 0) {
272 if (remaining_time <= 0) {
277 if ((maxdigits && digits_read >= maxdigits) || digits_read >= (buflen - 1)) {
296 if (digits_read == 0 && !laxkp &&
result !=
'*') {
297 ast_debug(1,
"Received MF digit, but no KP yet, ignoring: %c\n",
result);
304 if (
override && digits_read > 0) {
305 ast_debug(1,
"Received another KP, starting over\n");
322 if (!no_st || !is_start_digit) {
327 if (is_start_digit) {
342 ast_debug(3,
"channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n",
ast_channel_name(chan), timeout, remaining_time);
348#define BUFFER_SIZE 256
354 char *argcopy =
NULL;
355 int res, features = 0, maxdigits = 0;
377 tosec = atof(arglist.timeout);
391 if (maxdigits <= 0) {
419 ast_verb(3,
"No MF digits received.\n");
428 int dinterval = 0, duration = 0, durationkp = 0, durationst = 0;
471 chan_dest = chan_found;
472 if (chan_found != chan) {
473 chan_autoservice = chan;
481 return chan_autoservice ? 0 : res;
504 if (!strcmp(
digit,
"*"))
510 if (!
ast_strlen_zero(duration) && (sscanf(duration,
"%30u", &duration_ms) != 1)) {
static int sendmf_exec(struct ast_channel *chan, const char *vdata)
static const char * readmf_name
static const char sendmf_name[]
static int read_mf_digits(struct ast_channel *chan, char *buf, int buflen, int timeout, int features, int laxkp, int override, int no_kp, int no_st, int maxdigits)
Detects MF digits on channel using DSP, terminated by ST, STP, ST2P, or ST3P.
static int manager_play_mf(struct mansession *s, const struct message *m)
static int load_module(void)
static int unload_module(void)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "MF Sender and Receiver Applications")
static int read_mf_exec(struct ast_channel *chan, const char *data)
static const struct ast_app_option read_app_options[128]
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Conversion utility functions.
Convenient Signal Processing routines.
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_DIGITMODE_NOQUELCH
#define DSP_DIGITMODE_MUTEMAX
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_FEATURE_DIGIT_DETECT
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
#define DSP_DIGITMODE_MUTECONF
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.
#define DSP_DIGITMODE_RELAXDTMF
Generic File Format Support. Should be included by clients of the file handling routines....
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
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_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_mf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, 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.
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.
#define ast_verb(level,...)
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
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.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Main Channel structure associated with a channel.
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
In case you didn't read that giant block of text above the mansession_session struct,...
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)