Asterisk - The Open Source Telephony Project GIT-master-a358458
Macros | Enumerations | Functions | Variables
app_mf.c File Reference

MF sender and receiver applications. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/pbx.h"
#include "asterisk/channel.h"
#include "asterisk/dsp.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/indications.h"
#include "asterisk/conversions.h"
Include dependency graph for app_mf.c:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   256
 
#define MF_BETWEEN_MS   50
 
#define MF_DURATION   55
 
#define MF_KP_DURATION   120
 
#define MF_ST_DURATION   65
 

Enumerations

enum  { OPT_ARG_MAXDIGITS , OPT_ARG_ARRAY_SIZE }
 
enum  read_option_flags {
  OPT_DELAY = (1 << 0) , OPT_MUTE = (1 << 1) , OPT_QUELCH = (1 << 2) , OPT_RELAXED = (1 << 3) ,
  OPT_LAX_KP = (1 << 4) , OPT_PROCESS = (1 << 5) , OPT_NO_KP = (1 << 6) , OPT_NO_ST = (1 << 7) ,
  OPT_KP_OVERRIDE = (1 << 8) , OPT_MAXDIGITS = (1 << 9) , OPT_SKIP = (1 << 0) , OPT_INDICATION = (1 << 1) ,
  OPT_NOANSWER = (1 << 2) , OPT_TERMINATOR = (1 << 3) , OPT_KEEP_TERMINATOR = (1 << 4) , OPT_ANSWER = (1 << 0) ,
  OPT_DELAY = (1 << 0) , OPT_MUTE = (1 << 1) , OPT_QUELCH = (1 << 2) , OPT_RELAXED = (1 << 3) ,
  OPT_EXTRAPULSES = (1 << 4)
}
 

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "MF Sender and Receiver Applications")
 
static int load_module (void)
 
static int manager_play_mf (struct mansession *s, const struct message *m)
 
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. More...
 
static int read_mf_exec (struct ast_channel *chan, const char *data)
 
static int sendmf_exec (struct ast_channel *chan, const char *vdata)
 
static int unload_module (void)
 

Variables

static const struct ast_app_option read_app_options [128] = { [ 'd' ] = { .flag = OPT_DELAY }, [ 'l' ] = { .flag = OPT_LAX_KP }, [ 'k' ] = { .flag = OPT_NO_KP }, [ 'm' ] = { .flag = OPT_MUTE }, [ 'n' ] = { .flag = OPT_MAXDIGITS , .arg_index = OPT_ARG_MAXDIGITS + 1 }, [ 'o' ] = { .flag = OPT_KP_OVERRIDE }, [ 'p' ] = { .flag = OPT_PROCESS }, [ 'q' ] = { .flag = OPT_QUELCH }, [ 'r' ] = { .flag = OPT_RELAXED }, [ 's' ] = { .flag = OPT_NO_ST }, }
 
static const char * readmf_name = "ReceiveMF"
 
static const char sendmf_name [] = "SendMF"
 

Detailed Description

MF sender and receiver applications.

Author
Naveen Albert aster.nosp@m.isk@.nosp@m.phrea.nosp@m.knet.nosp@m..org

Definition in file app_mf.c.

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   256

◆ MF_BETWEEN_MS

#define MF_BETWEEN_MS   50

Definition at line 225 of file app_mf.c.

◆ MF_DURATION

#define MF_DURATION   55

Definition at line 226 of file app_mf.c.

◆ MF_KP_DURATION

#define MF_KP_DURATION   120

Definition at line 227 of file app_mf.c.

◆ MF_ST_DURATION

#define MF_ST_DURATION   65

Definition at line 228 of file app_mf.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPT_ARG_MAXDIGITS 
OPT_ARG_ARRAY_SIZE 

Definition at line 203 of file app_mf.c.

203 {
205 /* Must be the last element */
207};
@ OPT_ARG_MAXDIGITS
Definition: app_mf.c:204
@ OPT_ARG_ARRAY_SIZE
Definition: app_mf.c:206

◆ read_option_flags

Enumerator
OPT_DELAY 
OPT_MUTE 
OPT_QUELCH 
OPT_RELAXED 
OPT_LAX_KP 
OPT_PROCESS 
OPT_NO_KP 
OPT_NO_ST 
OPT_KP_OVERRIDE 
OPT_MAXDIGITS 
OPT_SKIP 
OPT_INDICATION 
OPT_NOANSWER 
OPT_TERMINATOR 
OPT_KEEP_TERMINATOR 
OPT_ANSWER 
OPT_DELAY 
OPT_MUTE 
OPT_QUELCH 
OPT_RELAXED 
OPT_EXTRAPULSES 

Definition at line 190 of file app_mf.c.

190 {
191 OPT_DELAY = (1 << 0),
192 OPT_MUTE = (1 << 1),
193 OPT_QUELCH = (1 << 2),
194 OPT_RELAXED = (1 << 3),
195 OPT_LAX_KP = (1 << 4),
196 OPT_PROCESS = (1 << 5),
197 OPT_NO_KP = (1 << 6),
198 OPT_NO_ST = (1 << 7),
199 OPT_KP_OVERRIDE = (1 << 8),
200 OPT_MAXDIGITS = (1 << 9),
201};
@ OPT_PROCESS
Definition: app_mf.c:196
@ OPT_MUTE
Definition: app_mf.c:192
@ OPT_NO_KP
Definition: app_mf.c:197
@ OPT_LAX_KP
Definition: app_mf.c:195
@ OPT_RELAXED
Definition: app_mf.c:194
@ OPT_MAXDIGITS
Definition: app_mf.c:200
@ OPT_QUELCH
Definition: app_mf.c:193
@ OPT_DELAY
Definition: app_mf.c:191
@ OPT_KP_OVERRIDE
Definition: app_mf.c:199
@ OPT_NO_ST
Definition: app_mf.c:198

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"MF Sender and Receiver Applications"   
)

◆ load_module()

static int load_module ( void  )
static

Definition at line 536 of file app_mf.c.

537{
538 int res;
539
543
544 return res;
545}
static int sendmf_exec(struct ast_channel *chan, const char *vdata)
Definition: app_mf.c:424
static const char * readmf_name
Definition: app_mf.c:222
static const char sendmf_name[]
Definition: app_mf.c:223
static int manager_play_mf(struct mansession *s, const struct message *m)
Definition: app_mf.c:484
static int read_mf_exec(struct ast_channel *chan, const char *data)
Definition: app_mf.c:346
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:191
#define EVENT_FLAG_CALL
Definition: manager.h:76
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

References ast_manager_register_xml, ast_register_application_xml, EVENT_FLAG_CALL, manager_play_mf(), read_mf_exec(), readmf_name, sendmf_exec(), and sendmf_name.

◆ manager_play_mf()

static int manager_play_mf ( struct mansession s,
const struct message m 
)
static

Definition at line 484 of file app_mf.c.

485{
486 const char *channel = astman_get_header(m, "Channel");
487 const char *digit = astman_get_header(m, "Digit");
488 const char *duration = astman_get_header(m, "Duration");
489 struct ast_channel *chan;
490 unsigned int duration_ms = MF_DURATION;
491
492 if (!(chan = ast_channel_get_by_name(channel))) {
493 astman_send_error(s, m, "Channel not found");
494 return 0;
495 }
496
497 if (ast_strlen_zero(digit)) {
498 astman_send_error(s, m, "No digit specified");
499 chan = ast_channel_unref(chan);
500 return 0;
501 }
502
503 /* Override default duration with KP or ST-specific default durations */
504 if (!strcmp(digit, "*"))
505 duration_ms = MF_KP_DURATION;
506
507 if (!strcmp(digit, "#") || !strcmp(digit, "A") || !strcmp(digit, "B") || !strcmp(digit, "C"))
508 duration_ms = MF_ST_DURATION;
509
510 if (!ast_strlen_zero(duration) && (sscanf(duration, "%30u", &duration_ms) != 1)) {
511 astman_send_error(s, m, "Could not convert Duration parameter");
512 chan = ast_channel_unref(chan);
513 return 0;
514 }
515
516 ast_mf_stream(chan, NULL, NULL, digit, 0, duration_ms, duration_ms, duration_ms, 1);
517
518 chan = ast_channel_unref(chan);
519
520 astman_send_ack(s, m, "MF successfully queued");
521
522 return 0;
523}
char digit
#define MF_DURATION
Definition: app_mf.c:226
#define MF_ST_DURATION
Definition: app_mf.c:228
#define MF_KP_DURATION
Definition: app_mf.c:227
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1454
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3381
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3413
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
Definition: manager.c:3042
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.
Definition: main/app.c:1113
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Main Channel structure associated with a channel.

References ast_channel_get_by_name(), ast_channel_unref, ast_mf_stream(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), digit, MF_DURATION, MF_KP_DURATION, MF_ST_DURATION, and NULL.

Referenced by load_module().

◆ read_mf_digits()

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 
)
static

Detects MF digits on channel using DSP, terminated by ST, STP, ST2P, or ST3P.

Parameters
chanchannel on which to read digits
bufBuffer in which to store digits
buflenSize of buffer
timeoutms to wait for all digits before giving up
featuresAny additional DSP features to use
laxkpReceive digits even if KP not received
overrideStart over if we receive additional KPs
no_kpDon't include KP in the output
no_stDon't include start digits in the output
maxdigitsIf greater than 0, only read this many digits no matter what
Return values
0if successful
-1if unsuccessful (including hangup).

Definition at line 247 of file app_mf.c.

247 {
248 struct ast_dsp *dsp;
249 struct ast_frame *frame = NULL;
250 struct timeval start;
251 int remaining_time = timeout;
252 int digits_read = 0;
253 int is_start_digit = 0;
254 char *str = buf;
255 int res = 0;
256
257 if (!(dsp = ast_dsp_new())) {
258 ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
259 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "ERROR");
260 return -1;
261 }
264
265 start = ast_tvnow();
266 *str = 0; /* start with empty output buffer */
267
268 /* based on app_read and generic_fax_exec from res_fax */
269 while (timeout == 0 || remaining_time > 0) {
270 if (timeout > 0) {
271 remaining_time = ast_remaining_ms(start, timeout);
272 if (remaining_time <= 0) {
273 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "TIMEOUT");
274 break;
275 }
276 }
277 if ((maxdigits && digits_read >= maxdigits) || digits_read >= (buflen - 1)) { /* we don't have room to store any more digits (very unlikely to happen for a legitimate reason) */
278 /* This result will probably not be usable, so status should not be START */
279 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "MAXDIGITS");
280 break;
281 }
282 /* ast_waitfordigit only waits for DTMF frames, we need to do DSP on voice frames */
283 if (ast_waitfor(chan, 1000) > 0) {
284 frame = ast_read(chan);
285 if (!frame) {
286 ast_debug(1, "Channel '%s' did not return a frame; probably hung up.\n", ast_channel_name(chan));
287 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "HANGUP");
288 break;
289 } else if (frame->frametype == AST_FRAME_VOICE) {
290 frame = ast_dsp_process(chan, dsp, frame);
291 /* AST_FRAME_DTMF is used all over the DSP code for DTMF, MF, fax, etc.
292 It's used because we can use the frame to store the digit detected.
293 All this means is that we received something we care about. */
294 if (frame->frametype == AST_FRAME_DTMF) {
295 char result = frame->subclass.integer;
296 if (digits_read == 0 && !laxkp && result != '*') {
297 ast_debug(1, "Received MF digit, but no KP yet, ignoring: %c\n", result);
298 ast_frfree(frame);
299 continue;
300 }
301 ast_debug(1, "Received MF digit: %c\n", result);
302 if (result == '*') {
303 /* We received an additional KP, start over? */
304 if (override && digits_read > 0) {
305 ast_debug(1, "Received another KP, starting over\n");
306 str = buf;
307 *str = 0;
308 digits_read = 1; /* we just detected a KP */
309 } else {
310 digits_read++;
311 }
312 /* if we were told not to include the KP digit in the output string, then skip it */
313 if (no_kp) {
314 ast_frfree(frame);
315 continue;
316 }
317 } else {
318 digits_read++;
319 }
320 is_start_digit = (strchr("#", result) || strchr("A", result) || strchr("B", result) || strchr("C", result));
321 /* if we were told not to include the ST digit in the output string, then skip it */
322 if (!no_st || !is_start_digit) {
323 *str++ = result; /* won't write past allotted memory, because of buffer check at top of loop */
324 *str = 0;
325 }
326 /* we received a ST digit (ST, STP, ST2P, or ST3P), so we're done */
327 if (is_start_digit) {
328 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "START");
329 ast_frfree(frame);
330 break;
331 }
332 /* only free frame if it was a DSP match. The MF itself should not be muted. */
333 ast_frfree(frame);
334 }
335 }
336 } else {
337 pbx_builtin_setvar_helper(chan, "RECEIVEMFSTATUS", "HANGUP");
338 res = -1;
339 }
340 }
341 ast_dsp_free(dsp);
342 ast_debug(3, "channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n", ast_channel_name(chan), timeout, remaining_time);
343 return res;
344}
const char * str
Definition: app_jack.c:147
#define ast_log
Definition: astobj2.c:42
static PGresult * result
Definition: cel_pgsql.c:84
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.
Definition: channel.c:3162
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4257
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1783
#define DSP_DIGITMODE_MF
Definition: dsp.h:32
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,...
Definition: dsp.c:1499
#define DSP_FEATURE_DIGIT_DETECT
Definition: dsp.h:28
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
Definition: dsp.c:1857
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
Definition: dsp.c:1768
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
Definition: dsp.c:1758
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_FRAME_DTMF
#define ast_frfree(fr)
@ AST_FRAME_VOICE
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
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.
Definition: dsp.c:407
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.
Definition: utils.c:2281
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

References ast_channel_name(), ast_debug, ast_dsp_free(), ast_dsp_new(), ast_dsp_process(), ast_dsp_set_digitmode(), ast_dsp_set_features(), AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree, ast_log, ast_read(), ast_remaining_ms(), ast_tvnow(), ast_waitfor(), buf, DSP_DIGITMODE_MF, DSP_FEATURE_DIGIT_DETECT, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, NULL, pbx_builtin_setvar_helper(), result, str, and ast_frame::subclass.

Referenced by read_mf_exec().

◆ read_mf_exec()

static int read_mf_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 346 of file app_mf.c.

347{
348#define BUFFER_SIZE 256
349 char tmp[BUFFER_SIZE] = "";
350 int to = 0;
351 double tosec;
352 struct ast_flags flags = {0};
353 char *optargs[OPT_ARG_ARRAY_SIZE];
354 char *argcopy = NULL;
355 int res, features = 0, maxdigits = 0;
356
357 AST_DECLARE_APP_ARGS(arglist,
358 AST_APP_ARG(variable);
359 AST_APP_ARG(timeout);
361 );
362
363 if (ast_strlen_zero(data)) {
364 ast_log(LOG_WARNING, "ReceiveMF requires an argument (variable)\n");
365 return -1;
366 }
367
368 argcopy = ast_strdupa(data);
369
370 AST_STANDARD_APP_ARGS(arglist, argcopy);
371
372 if (!ast_strlen_zero(arglist.options)) {
373 ast_app_parse_options(read_app_options, &flags, optargs, arglist.options);
374 }
375
376 if (!ast_strlen_zero(arglist.timeout)) {
377 tosec = atof(arglist.timeout);
378 if (tosec <= 0) {
379 to = 0;
380 } else {
381 to = tosec * 1000.0;
382 }
383 }
384
385 if (ast_strlen_zero(arglist.variable)) {
386 ast_log(LOG_WARNING, "Invalid! Usage: ReceiveMF(variable[,timeout][,option])\n");
387 return -1;
388 }
390 maxdigits = atoi(optargs[OPT_ARG_MAXDIGITS]);
391 if (maxdigits <= 0) {
392 ast_log(LOG_WARNING, "Invalid maximum number of digits, ignoring: '%s'\n", optargs[OPT_ARG_MAXDIGITS]);
393 maxdigits = 0;
394 }
395 }
396
398 features |= DSP_DIGITMODE_MUTEMAX;
399 }
400
402 features |= DSP_DIGITMODE_MUTECONF;
403 }
404
406 features |= DSP_DIGITMODE_NOQUELCH;
407 }
408
410 features |= DSP_DIGITMODE_RELAXDTMF;
411 }
412
413 res = read_mf_digits(chan, tmp, BUFFER_SIZE, to, features, (ast_test_flag(&flags, OPT_LAX_KP)),
415 pbx_builtin_setvar_helper(chan, arglist.variable, tmp);
416 if (!ast_strlen_zero(tmp)) {
417 ast_verb(3, "MF digits received: '%s'\n", tmp);
418 } else if (!res) { /* if channel hung up, don't print anything out */
419 ast_verb(3, "No MF digits received.\n");
420 }
421 return res;
422}
#define BUFFER_SIZE
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.
Definition: app_mf.c:247
static const struct ast_app_option read_app_options[128]
Definition: app_mf.c:220
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
static int tmp()
Definition: bt_open.c:389
#define DSP_DIGITMODE_NOQUELCH
Definition: dsp.h:34
#define DSP_DIGITMODE_MUTEMAX
Definition: dsp.h:36
#define DSP_DIGITMODE_MUTECONF
Definition: dsp.h:35
#define DSP_DIGITMODE_RELAXDTMF
Definition: dsp.h:37
#define AST_APP_ARG(name)
Define an application 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.
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.
Definition: main/app.c:3056
#define ast_verb(level,...)
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
static struct test_options options
#define ast_test_flag(p, flag)
Definition: utils.h:63

References AST_APP_ARG, ast_app_parse_options(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verb, BUFFER_SIZE, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, DSP_DIGITMODE_NOQUELCH, DSP_DIGITMODE_RELAXDTMF, ast_flags::flags, LOG_WARNING, NULL, OPT_ARG_ARRAY_SIZE, OPT_ARG_MAXDIGITS, OPT_DELAY, OPT_KP_OVERRIDE, OPT_LAX_KP, OPT_MAXDIGITS, OPT_MUTE, OPT_NO_KP, OPT_NO_ST, OPT_QUELCH, OPT_RELAXED, options, pbx_builtin_setvar_helper(), read_app_options, read_mf_digits(), and tmp().

Referenced by load_module().

◆ sendmf_exec()

static int sendmf_exec ( struct ast_channel chan,
const char *  vdata 
)
static

Definition at line 424 of file app_mf.c.

425{
426 int res;
427 char *data;
428 int dinterval = 0, duration = 0, durationkp = 0, durationst = 0;
429 struct ast_channel *chan_found = NULL;
430 struct ast_channel *chan_dest = chan;
431 struct ast_channel *chan_autoservice = NULL;
433 AST_APP_ARG(digits);
434 AST_APP_ARG(dinterval);
435 AST_APP_ARG(duration);
436 AST_APP_ARG(durationkp);
437 AST_APP_ARG(durationst);
438 AST_APP_ARG(channel);
439 );
440
441 if (ast_strlen_zero(vdata)) {
442 ast_log(LOG_WARNING, "SendMF requires an argument\n");
443 return 0;
444 }
445
446 data = ast_strdupa(vdata);
448
449 if (ast_strlen_zero(args.digits)) {
450 ast_log(LOG_WARNING, "The digits argument is required (0-9,*#ABC,wf)\n");
451 return 0;
452 }
453 if (!ast_strlen_zero(args.dinterval)) {
454 ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS);
455 }
456 if (!ast_strlen_zero(args.duration)) {
457 ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
458 }
459 if (!ast_strlen_zero(args.durationkp)) {
460 ast_app_parse_timelen(args.durationkp, &durationkp, TIMELEN_MILLISECONDS);
461 }
462 if (!ast_strlen_zero(args.durationst)) {
463 ast_app_parse_timelen(args.durationst, &durationst, TIMELEN_MILLISECONDS);
464 }
465 if (!ast_strlen_zero(args.channel)) {
466 chan_found = ast_channel_get_by_name(args.channel);
467 if (!chan_found) {
468 ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
469 return 0;
470 }
471 chan_dest = chan_found;
472 if (chan_found != chan) {
473 chan_autoservice = chan;
474 }
475 }
476 res = ast_mf_stream(chan_dest, chan_autoservice, NULL, args.digits, dinterval <= 0 ? MF_BETWEEN_MS : dinterval,
477 duration <= 0 ? MF_DURATION : duration, durationkp <= 0 ? MF_KP_DURATION : durationkp,
478 durationst <= 0 ? MF_ST_DURATION : durationst, 0);
479 ast_channel_cleanup(chan_found);
480
481 return chan_autoservice ? 0 : res;
482}
#define MF_BETWEEN_MS
Definition: app_mf.c:225
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2969
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.
Definition: main/app.c:3263
@ TIMELEN_MILLISECONDS
const char * data
const char * args

References args, AST_APP_ARG, ast_app_parse_timelen(), ast_channel_cleanup, ast_channel_get_by_name(), AST_DECLARE_APP_ARGS, ast_log, ast_mf_stream(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::data, LOG_WARNING, MF_BETWEEN_MS, MF_DURATION, MF_KP_DURATION, MF_ST_DURATION, NULL, and TIMELEN_MILLISECONDS.

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 525 of file app_mf.c.

526{
527 int res;
528
531 res |= ast_manager_unregister("PlayMF");
532
533 return res;
534}
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:8041
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References ast_manager_unregister(), ast_unregister_application(), readmf_name, and sendmf_name.

Variable Documentation

◆ read_app_options

const struct ast_app_option read_app_options[128] = { [ 'd' ] = { .flag = OPT_DELAY }, [ 'l' ] = { .flag = OPT_LAX_KP }, [ 'k' ] = { .flag = OPT_NO_KP }, [ 'm' ] = { .flag = OPT_MUTE }, [ 'n' ] = { .flag = OPT_MAXDIGITS , .arg_index = OPT_ARG_MAXDIGITS + 1 }, [ 'o' ] = { .flag = OPT_KP_OVERRIDE }, [ 'p' ] = { .flag = OPT_PROCESS }, [ 'q' ] = { .flag = OPT_QUELCH }, [ 'r' ] = { .flag = OPT_RELAXED }, [ 's' ] = { .flag = OPT_NO_ST }, }
static

Definition at line 220 of file app_mf.c.

Referenced by read_mf_exec().

◆ readmf_name

const char* readmf_name = "ReceiveMF"
static

Definition at line 222 of file app_mf.c.

Referenced by load_module(), and unload_module().

◆ sendmf_name

const char sendmf_name[] = "SendMF"
static

Definition at line 223 of file app_mf.c.

Referenced by load_module(), and unload_module().