185 #define SF_MIN_OFF 25
187 #define SF_BETWEEN 600
188 #define SF_MIN_DETECT 50
192 struct timeval start, pulsetimer, digittimer;
193 int remaining_time = timeout;
195 int hits = 0, digits_read = 0;
196 unsigned short int sf_on = 0;
211 while (timeout == 0 || remaining_time > 0) {
214 if (remaining_time <= 0) {
219 if (digits_read >= (buflen - 1)) {
245 if (timeleft > -30) {
248 ast_debug(5,
"Detected SF pulse (pulse #%d)\n", hits);
259 ast_debug(5,
"SF noise, ignoring, time elapsed was %d ms\n", timeleft);
264 ast_debug(2,
"Received SF digit: %d\n", hits);
271 }
else if (hits == 12) {
273 }
else if (hits == 13) {
275 }
else if (hits == 14) {
277 }
else if (hits == 15) {
279 }
else if (hits == 16) {
282 ast_debug(3,
"Got %d SF pulses, is someone playing with the phone?\n", hits);
287 ast_debug(2,
"Got more than 10 pulses, truncating to 10\n");
299 if (maxdigits > 0 && digits_read >= maxdigits) {
316 ast_debug(3,
"channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n",
ast_channel_name(chan), timeout, remaining_time);
322#define BUFFER_SIZE 256
326 char *argcopy =
NULL;
327 int res, features = 0, digits = 0, to = 0, freq = 2600;
351 tosec = atof(arglist.timeout);
395 ast_verb(3,
"No SF digits received.\n");
404 int frequency = 2600;
436 chan_dest = chan_found;
437 if (chan_found != chan) {
438 chan_autoservice = chan;
444 return chan_autoservice ? 0 : res;
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "SF Sender and Receiver Applications")
static const char sendsf_name[]
static const char * readsf_name
static int read_sf_exec(struct ast_channel *chan, const char *data)
static int sendsf_exec(struct ast_channel *chan, const char *vdata)
static int load_module(void)
static int unload_module(void)
static int read_sf_digits(struct ast_channel *chan, char *buf, int buflen, int timeout, int maxdigits, int freq, int features, int extrapulses)
Detects SF digits on channel using DSP.
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_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.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
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_DIGITMODE_MUTECONF
#define DSP_FEATURE_FREQ_DETECT
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.
#define DSP_DIGITMODE_RELAXDTMF
Generic File Format Support. Should be included by clients of the file handling routines....
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
int ast_sf_stream(struct ast_channel *chan, struct ast_channel *peer, struct ast_channel *chan2, const char *digits, int frequency, int is_external)
Send a string of SF digits to a channel.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#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.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
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
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)