Asterisk - The Open Source Telephony Project GIT-master-f36a736
res_tonedetect.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2021, Naveen Albert
5 *
6 * Naveen Albert <asterisk@phreaknet.org>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*! \file
20 *
21 * \brief Tone detection module
22 *
23 * \author Naveen Albert <asterisk@phreaknet.org>
24 *
25 * \ingroup resources
26 */
27
28/*** MODULEINFO
29 <support_level>extended</support_level>
30 ***/
31
32#include "asterisk.h"
33
34#include <math.h>
35
36#include "asterisk/module.h"
37#include "asterisk/frame.h"
39#include "asterisk/channel.h"
40#include "asterisk/dsp.h"
41#include "asterisk/pbx.h"
43#include "asterisk/audiohook.h"
44#include "asterisk/app.h"
47
48/*** DOCUMENTATION
49 <application name="WaitForTone" language="en_US">
50 <since>
51 <version>16.21.0</version>
52 <version>18.7.0</version>
53 <version>19.0.0</version>
54 </since>
55 <synopsis>
56 Wait for tone
57 </synopsis>
58 <syntax>
59 <parameter name="freq" required="true">
60 <para>Frequency of the tone to wait for.</para>
61 </parameter>
62 <parameter name="duration_ms" required="false">
63 <para>Minimum duration of tone, in ms. Default is 500ms.
64 Using a minimum duration under 50ms is unlikely to produce
65 accurate results.</para>
66 </parameter>
67 <parameter name="timeout" required="false">
68 <para>Maximum amount of time, in seconds, to wait for specified tone.
69 Default is forever.</para>
70 </parameter>
71 <parameter name="times" required="false">
72 <para>Number of times the tone should be detected (subject to the
73 provided timeout) before returning. Default is 1.</para>
74 </parameter>
75 <parameter name="options" required="false">
76 <optionlist>
77 <option name="d">
78 <para>Custom decibel threshold to use. Default is 16.</para>
79 </option>
80 <option name="s">
81 <para>Squelch tone.</para>
82 </option>
83 </optionlist>
84 </parameter>
85 </syntax>
86 <description>
87 <para>Waits for a single-frequency tone to be detected before dialplan execution continues.</para>
88 <variablelist>
89 <variable name="WAITFORTONESTATUS">
90 <para>This indicates the result of the wait.</para>
91 <value name="SUCCESS"/>
92 <value name="ERROR"/>
93 <value name="TIMEOUT"/>
94 <value name="HANGUP"/>
95 </variable>
96 </variablelist>
97 </description>
98 <see-also>
99 <ref type="application">PlayTones</ref>
100 </see-also>
101 </application>
102 <application name="ToneScan" language="en_US">
103 <since>
104 <version>16.23.0</version>
105 <version>18.9.0</version>
106 <version>19.1.0</version>
107 </since>
108 <synopsis>
109 Wait for period of time while scanning for call progress tones
110 </synopsis>
111 <syntax>
112 <parameter name="zone" required="false">
113 <para>Call progress zone. Default is the system default.</para>
114 </parameter>
115 <parameter name="timeout" required="false">
116 <para>Maximum amount of time, in seconds, to wait for call progress
117 or signal tones. Default is forever.</para>
118 </parameter>
119 <parameter name="threshold" required="false">
120 <para>DSP threshold required for a match. A higher number will
121 require a longer match and may reduce false positives, at the
122 expense of false negatives. Default is 1.</para>
123 </parameter>
124 <parameter name="options" required="false">
125 <optionlist>
126 <option name="f">
127 <para>Enable fax machine detection. By default, this is disabled.</para>
128 </option>
129 <option name="v">
130 <para>Enable voice detection. By default, this is disabled.</para>
131 </option>
132 </optionlist>
133 </parameter>
134 </syntax>
135 <description>
136 <para>Waits for a a distinguishable call progress tone and then exits.
137 Unlike a conventional scanner, this is not currently capable of
138 scanning for modem carriers.</para>
139 <variablelist>
140 <variable name="TONESCANSTATUS">
141 This indicates the result of the scan.
142 <value name="RINGING">
143 Audible ringback tone
144 </value>
145 <value name="BUSY">
146 Busy tone
147 </value>
148 <value name="SIT">
149 Special Information Tones
150 </value>
151 <value name="VOICE">
152 Human voice detected
153 </value>
154 <value name="DTMF">
155 DTMF digit
156 </value>
157 <value name="FAX">
158 Fax (answering)
159 </value>
160 <value name="MODEM">
161 Modem (answering)
162 </value>
163 <value name="DIALTONE">
164 Dial tone
165 </value>
166 <value name="NUT">
167 UK Number Unobtainable tone
168 </value>
169 <value name="TIMEOUT">
170 Timeout reached before any positive detection
171 </value>
172 <value name="HANGUP">
173 Caller hung up before any positive detection
174 </value>
175 </variable>
176 </variablelist>
177 </description>
178 <see-also>
179 <ref type="application">WaitForTone</ref>
180 </see-also>
181 </application>
182 <function name="TONE_DETECT" language="en_US">
183 <since>
184 <version>16.21.0</version>
185 <version>18.7.0</version>
186 <version>19.0.0</version>
187 </since>
188 <synopsis>
189 Asynchronously detects a tone
190 </synopsis>
191 <syntax>
192 <parameter name="freq" required="true">
193 <para>Frequency of the tone to detect. To disable frequency
194 detection completely (e.g. for signal detection only),
195 specify 0 for the frequency.</para>
196 </parameter>
197 <parameter name="duration_ms" required="false">
198 <para>Minimum duration of tone, in ms. Default is 500ms.
199 Using a minimum duration under 50ms is unlikely to produce
200 accurate results.</para>
201 </parameter>
202 <parameter name="options">
203 <optionlist>
204 <option name="a">
205 <para>Match immediately on Special Information Tones, instead of or in addition
206 to a particular frequency.</para>
207 </option>
208 <option name="b">
209 <para>Match immediately on a busy signal, instead of or in addition to
210 a particular frequency.</para>
211 </option>
212 <option name="c">
213 <para>Match immediately on a dial tone, instead of or in addition to
214 a particular frequency.</para>
215 </option>
216 <option name="d">
217 <para>Custom decibel threshold to use. Default is 16.</para>
218 </option>
219 <option name="g">
220 <para>Go to the specified context,exten,priority if tone is received on this channel.
221 Detection will not end automatically.</para>
222 </option>
223 <option name="h">
224 <para>Go to the specified context,exten,priority if tone is transmitted on this channel.
225 Detection will not end automatically.</para>
226 </option>
227 <option name="n">
228 <para>Number of times the tone should be detected (subject to the
229 provided timeout) before going to the destination provided in the <literal>g</literal>
230 or <literal>h</literal> option. Default is 1.</para>
231 </option>
232 <option name="p">
233 <para>Match immediately on audible ringback tone, instead of or in addition to
234 a particular frequency.</para>
235 </option>
236 <option name="r">
237 <para>Apply to received frames only. Default is both directions.</para>
238 </option>
239 <option name="s">
240 <para>Squelch tone.</para>
241 </option>
242 <option name="t">
243 <para>Apply to transmitted frames only. Default is both directions.</para>
244 </option>
245 <option name="x">
246 <para>Destroy the detector (stop detection).</para>
247 </option>
248 </optionlist>
249 </parameter>
250 </syntax>
251 <description>
252 <para>The TONE_DETECT function detects a single-frequency tone and keeps
253 track of how many times the tone has been detected.</para>
254 <para>When reading this function (instead of writing), supply <literal>tx</literal>
255 to get the number of times a tone has been detected in the TX direction and
256 <literal>rx</literal> to get the number of times a tone has been detected in the
257 RX direction.</para>
258 <example title="intercept2600">
259 same => n,Set(TONE_DETECT(2600,1000,g(got-2600,s,1))=) ; detect 2600 Hz
260 same => n,Wait(15)
261 same => n,NoOp(${TONE_DETECT(rx)})
262 </example>
263 <example title="dropondialtone">
264 same => n,Set(TONE_DETECT(0,,bg(my-hangup,s,1))=) ; disconnect a call if we hear a busy signal
265 same => n,Goto(somewhere-else)
266 same => n(myhangup),Hangup()
267 </example>
268 <example title="removedetector">
269 same => n,Set(TONE_DETECT(0,,x)=) ; remove the detector from the channel
270 </example>
271 </description>
272 </function>
273 ***/
274
276 struct ast_dsp *dsp;
278 int freq1;
279 int freq2;
281 int db;
282 char *gototx;
283 char *gotorx;
284 unsigned short int squelch;
285 unsigned short int tx;
286 unsigned short int rx;
291};
292
294 OPT_TX = (1 << 1),
295 OPT_RX = (1 << 2),
296 OPT_END_FILTER = (1 << 3),
297 OPT_GOTO_RX = (1 << 4),
298 OPT_GOTO_TX = (1 << 5),
299 OPT_DECIBEL = (1 << 6),
300 OPT_SQUELCH = (1 << 7),
301 OPT_HITS_REQ = (1 << 8),
302 OPT_SIT = (1 << 9),
303 OPT_BUSY = (1 << 10),
304 OPT_DIALTONE = (1 << 11),
305 OPT_RINGING = (1 << 12),
306};
307
308enum {
313 /* note: this entry _MUST_ be the last one in the enum */
315};
316
330});
331
332static void destroy_callback(void *data)
333{
334 struct detect_information *di = data;
335 ast_dsp_free(di->dsp);
336 if (di->gotorx) {
337 ast_free(di->gotorx);
338 }
339 if (di->gototx) {
340 ast_free(di->gototx);
341 }
342 ast_audiohook_lock(&di->audiohook);
343 ast_audiohook_detach(&di->audiohook);
344 ast_audiohook_unlock(&di->audiohook);
345 ast_audiohook_destroy(&di->audiohook);
346 ast_free(di);
347 return;
348}
349
351 .type = "detect",
352 .destroy = destroy_callback
353};
354
355static int detect_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
356{
357 struct ast_datastore *datastore = NULL;
358 struct detect_information *di = NULL;
359 struct stasis_message *message;
360 int match = 0;
361
362 /* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
363 if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
364 return 0;
365 }
366
367 /* Grab datastore which contains our gain information */
368 if (!(datastore = ast_channel_datastore_find(chan, &detect_datastore, NULL))) {
369 return 0;
370 }
371
372 di = datastore->data;
373
374 if (!frame || frame->frametype != AST_FRAME_VOICE) {
375 return 0;
376 }
377
378 if (!(direction == AST_AUDIOHOOK_DIRECTION_READ ? di->rx : di->tx)) {
379 return 0;
380 }
381
382 /* ast_dsp_process may free the frame and return a new one */
383 frame = ast_frdup(frame);
384 frame = ast_dsp_process(chan, di->dsp, frame);
385 if (frame->frametype == AST_FRAME_DTMF) {
386 char result = frame->subclass.integer;
387 if (result == 'q') {
388 int now;
389 match = 1;
391 di->rxcount = di->rxcount + 1;
392 now = di->rxcount;
393 } else {
394 di->txcount = di->txcount + 1;
395 now = di->txcount;
396 }
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) {
400
401 if (!message) {
402 ast_log(LOG_ERROR, "Unable to publish tone detected event for ARI on channel '%s'", ast_channel_name(chan));
403 return 1;
404 } else {
406 ao2_ref(message, -1);
407 }
408
409 if (direction == AST_AUDIOHOOK_DIRECTION_READ && di->gotorx) {
410 ast_async_parseable_goto(chan, di->gotorx);
411 } else if (di->gototx) {
412 ast_async_parseable_goto(chan, di->gototx);
413 }
414 }
415 }
416 }
417 if (di->signalfeatures && !match) { /* skip unless there are call progress/signal options */
418 int tstate, tcount;
419 tcount = ast_dsp_get_tcount(di->dsp);
420 tstate = ast_dsp_get_tstate(di->dsp);
421 if (tstate > 0) {
422 ast_debug(3, "tcount: %d, tstate: %d\n", tcount, tstate);
423 switch (tstate) {
425 if (di->signalfeatures & DSP_PROGRESS_RINGING) {
426 ast_debug(1, "Detected ringing on %s in %s direction\n", ast_channel_name(chan),
427 direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
428 match = 1;
429 }
430 break;
432 if (di->signalfeatures & DSP_FEATURE_WAITDIALTONE) {
433 ast_debug(1, "Detected dial tone on %s in %s direction\n", ast_channel_name(chan),
434 direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
435 match = 1;
436 }
437 break;
439 if (di->signalfeatures & DSP_PROGRESS_BUSY) {
440 ast_debug(1, "Detected busy tone on %s in %s direction\n", ast_channel_name(chan),
441 direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
442 match = 1;
443 }
444 break;
446 if (di->signalfeatures & DSP_PROGRESS_CONGESTION) {
447 ast_debug(1, "Detected SIT on %s in %s direction\n", ast_channel_name(chan),
448 direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
449 match = 1;
450 }
451 break;
452 default: /* ignore */
453 break;
454 }
455 if (match) {
456 if (direction == AST_AUDIOHOOK_DIRECTION_READ && di->gotorx) {
457 ast_async_parseable_goto(chan, di->gotorx);
458 } else if (di->gototx) {
459 ast_async_parseable_goto(chan, di->gototx);
460 } else {
461 ast_debug(3, "Detected call progress signal in %s direction, but don't know where to go\n",
462 direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
463 }
464 }
465 }
466 }
467 /* this could be the duplicated frame or a new one, doesn't matter */
468 ast_frfree(frame);
469 return 0;
470}
471
472static int remove_detect(struct ast_channel *chan)
473{
474 struct ast_datastore *datastore = NULL;
475 struct detect_information *data;
476 SCOPED_CHANNELLOCK(chan_lock, chan);
477
479 if (!datastore) {
480 ast_log(AST_LOG_WARNING, "Cannot remove TONE_DETECT from %s: TONE_DETECT not currently enabled\n",
481 ast_channel_name(chan));
482 return -1;
483 }
484 data = datastore->data;
485
486 if (ast_audiohook_remove(chan, &data->audiohook)) {
487 ast_log(AST_LOG_WARNING, "Failed to remove TONE_DETECT audiohook from channel %s\n", ast_channel_name(chan));
488 return -1;
489 }
490
491 if (ast_channel_datastore_remove(chan, datastore)) {
492 ast_log(AST_LOG_WARNING, "Failed to remove TONE_DETECT datastore from channel %s\n",
493 ast_channel_name(chan));
494 return -1;
495 }
496 ast_datastore_free(datastore);
497
498 return 0;
499}
500
501static int freq_parser(char *freqs, int *freq1, int *freq2) {
502 char *f1, *f2, *f3;
503 if (ast_strlen_zero(freqs)) {
504 ast_log(LOG_ERROR, "No frequency specified\n");
505 return -1;
506 }
507 f3 = ast_strdupa(freqs);
508 f1 = strsep(&f3, "+");
509 f2 = strsep(&f3, "+");
510 if (!ast_strlen_zero(f3)) {
511 ast_log(LOG_WARNING, "Only up to 2 frequencies may be specified: %s\n", freqs);
512 return -1;
513 }
514 if (ast_str_to_int(f1, freq1)) {
515 ast_log(LOG_WARNING, "Frequency must be an integer: %s\n", f1);
516 return -1;
517 }
518 if (*freq1 < 0) {
519 ast_log(LOG_WARNING, "Sorry, no negative frequencies: %d\n", *freq1);
520 return -1;
521 }
522 if (!ast_strlen_zero(f2)) {
523 ast_log(LOG_WARNING, "Sorry, currently only 1 frequency is supported\n");
524 return -1;
525 /* not supported just yet, but possibly will be in the future */
526 if (ast_str_to_int(f2, freq2)) {
527 ast_log(LOG_WARNING, "Frequency must be an integer: %s\n", f2);
528 return -1;
529 }
530 if (*freq2 < 1) {
531 ast_log(LOG_WARNING, "Sorry, positive frequencies only: %d\n", *freq2);
532 return -1;
533 }
534 }
535 return 0;
536}
537
538static char* goto_parser(struct ast_channel *chan, char *loc) {
539 char *exten, *pri, *context, *parse;
540 char *dest;
541 int size;
542 parse = ast_strdupa(loc);
543 context = strsep(&parse, ",");
544 exten = strsep(&parse, ",");
545 pri = strsep(&parse, ",");
546 if (!exten) {
547 pri = context;
548 exten = NULL;
549 context = NULL;
550 } else if (!pri) {
551 pri = exten;
552 exten = context;
553 context = NULL;
554 }
555 ast_channel_lock(chan);
556 if (ast_strlen_zero(exten)) {
557 exten = ast_strdupa(ast_channel_exten(chan));
558 }
561 }
562 ast_channel_unlock(chan);
563
564 /* size + 3: for 1 null terminator + 2 commas */
565 size = strlen(context) + strlen(exten) + strlen(pri) + 3;
566 dest = ast_malloc(size + 1);
567 if (!dest) {
568 ast_log(LOG_ERROR, "Failed to parse goto: %s,%s,%s\n", context, exten, pri);
569 return NULL;
570 }
571 snprintf(dest, size, "%s,%s,%s", context, exten, pri);
572 return dest;
573}
574
575static int detect_read(struct ast_channel *chan, const char *cmd, char *data, char *buffer, size_t buflen)
576{
577 struct ast_datastore *datastore = NULL;
578 struct detect_information *di = NULL;
579
580 if (!chan) {
581 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
582 return -1;
583 }
584
585 ast_channel_lock(chan);
586 if (!(datastore = ast_channel_datastore_find(chan, &detect_datastore, NULL))) {
587 ast_channel_unlock(chan);
588 return -1; /* function not initiated yet, so nothing to read */
589 } else {
590 ast_channel_unlock(chan);
591 di = datastore->data;
592 }
593
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);
598 } else {
599 ast_log(LOG_WARNING, "Invalid direction: %s\n", data);
600 }
601
602 return 0;
603}
604
605static int parse_signal_features(struct ast_flags *flags)
606{
607 int features = 0;
608
609 if (ast_test_flag(flags, OPT_SIT)) {
610 features |= DSP_PROGRESS_CONGESTION;
611 }
612 if (ast_test_flag(flags, OPT_BUSY)) {
613 features |= DSP_PROGRESS_BUSY;
614 }
615 if (ast_test_flag(flags, OPT_DIALTONE)) {
616 features |= DSP_FEATURE_WAITDIALTONE;
617 }
618 if (ast_test_flag(flags, OPT_RINGING)) {
619 features |= DSP_PROGRESS_RINGING;
620 }
621
622 return features;
623}
624
625static int detect_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
626{
627 char *parse;
628 struct ast_datastore *datastore = NULL;
629 struct detect_information *di = NULL;
630 struct ast_flags flags = { 0 };
631 char *opt_args[OPT_ARG_ARRAY_SIZE];
632 struct ast_dsp *dsp;
633 int freq1 = 0, freq2 = 0, duration = 500, db = 16, squelch = 0, hitsrequired = 1;
634 int signalfeatures = 0;
635
638 AST_APP_ARG(duration);
640 );
641
642 if (!chan) {
643 ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
644 return -1;
645 }
646 parse = ast_strdupa(data);
648
649 if (!ast_strlen_zero(args.options)) {
650 ast_app_parse_options(td_opts, &flags, opt_args, args.options);
651 }
652 if (ast_test_flag(&flags, OPT_END_FILTER)) {
653 return remove_detect(chan);
654 }
655 if (freq_parser(args.freqs, &freq1, &freq2)) {
656 return -1;
657 }
658 if (!ast_strlen_zero(args.duration) && (ast_str_to_int(args.duration, &duration) || duration < 1)) {
659 ast_log(LOG_WARNING, "Invalid duration: %s\n", args.duration);
660 return -1;
661 }
662 if (ast_test_flag(&flags, OPT_HITS_REQ) && !ast_strlen_zero(opt_args[OPT_ARG_HITS_REQ])) {
663 if ((ast_str_to_int(opt_args[OPT_ARG_HITS_REQ], &hitsrequired) || hitsrequired < 1)) {
664 ast_log(LOG_WARNING, "Invalid number hits required: %s\n", opt_args[OPT_ARG_HITS_REQ]);
665 return -1;
666 }
667 }
668 if (ast_test_flag(&flags, OPT_DECIBEL) && !ast_strlen_zero(opt_args[OPT_ARG_DECIBEL])) {
669 if ((ast_str_to_int(opt_args[OPT_ARG_DECIBEL], &db) || db < 1)) {
670 ast_log(LOG_WARNING, "Invalid decibel level: %s\n", opt_args[OPT_ARG_DECIBEL]);
671 return -1;
672 }
673 }
674 signalfeatures = parse_signal_features(&flags);
675
676 ast_channel_lock(chan);
677 if (!(datastore = ast_channel_datastore_find(chan, &detect_datastore, NULL))) {
678 if (!(datastore = ast_datastore_alloc(&detect_datastore, NULL))) {
679 ast_channel_unlock(chan);
680 return 0;
681 }
682 if (!(di = ast_calloc(1, sizeof(*di)))) {
683 ast_datastore_free(datastore);
684 ast_channel_unlock(chan);
685 return 0;
686 }
688 di->audiohook.manipulate_callback = detect_callback;
689 if (!(dsp = ast_dsp_new())) {
690 ast_datastore_free(datastore);
691 ast_channel_unlock(chan);
692 ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
693 return -1;
694 }
695 di->signalfeatures = signalfeatures; /* we're not including freq detect */
696 if (freq1 > 0) {
697 signalfeatures |= DSP_FEATURE_FREQ_DETECT;
698 ast_dsp_set_freqmode(dsp, freq1, duration, db, squelch);
699 }
700 ast_dsp_set_features(dsp, signalfeatures);
701 di->dsp = dsp;
702 di->txcount = 0;
703 di->rxcount = 0;
704 ast_debug(1, "Keeping our ears open for %s Hz, %d db\n", args.freqs, db);
705 datastore->data = di;
706 ast_channel_datastore_add(chan, datastore);
707 ast_audiohook_attach(chan, &di->audiohook);
708 } else {
709 di = datastore->data;
710 dsp = di->dsp;
711 di->signalfeatures = signalfeatures; /* we're not including freq detect */
712 if (freq1 > 0) {
713 signalfeatures |= DSP_FEATURE_FREQ_DETECT;
714 ast_dsp_set_freqmode(dsp, freq1, duration, db, squelch);
715 }
716 ast_dsp_set_features(dsp, signalfeatures);
717 }
718 di->duration = duration;
719 di->gotorx = NULL;
720 di->gototx = NULL;
721 /* resolve gotos now, in case a full context,exten,pri wasn't specified */
722 if (ast_test_flag(&flags, OPT_GOTO_RX) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO_RX])) {
723 di->gotorx = goto_parser(chan, opt_args[OPT_ARG_GOTO_RX]);
724 }
725 if (ast_test_flag(&flags, OPT_GOTO_TX) && !ast_strlen_zero(opt_args[OPT_ARG_GOTO_TX])) {
726 di->gototx = goto_parser(chan, opt_args[OPT_ARG_GOTO_TX]);
727 }
728 di->db = db;
729 di->hitsrequired = hitsrequired;
730 di->squelch = ast_test_flag(&flags, OPT_SQUELCH);
731 di->tx = 1;
732 di->rx = 1;
733 if (ast_strlen_zero(args.options) || ast_test_flag(&flags, OPT_TX)) {
734 di->tx = 1;
735 di->rx = 0;
736 }
737 if (ast_strlen_zero(args.options) || ast_test_flag(&flags, OPT_RX)) {
738 di->rx = 1;
739 di->tx = 0;
740 }
741 ast_channel_unlock(chan);
742
743 return 0;
744}
745
746enum {
747 OPT_APP_DECIBEL = (1 << 0),
748 OPT_APP_SQUELCH = (1 << 1),
749};
750
751enum {
753 /* note: this entry _MUST_ be the last one in the enum */
755};
756
761
762static int wait_exec(struct ast_channel *chan, const char *data)
763{
764 char *appdata;
765 struct ast_flags flags = {0};
766 char *opt_args[OPT_APP_ARG_ARRAY_SIZE];
767 double timeoutf = 0;
768 int freq1 = 0, freq2 = 0, timeout = 0, duration = 500, times = 1, db = 16, squelch = 0;
769 struct ast_frame *frame = NULL;
770 struct ast_dsp *dsp;
771 struct timeval start;
772 int remaining_time = 0;
773 int hits = 0;
775 AST_APP_ARG(freqs);
776 AST_APP_ARG(duration);
777 AST_APP_ARG(timeout);
778 AST_APP_ARG(times);
780 );
781
782 appdata = ast_strdupa(data);
783 AST_STANDARD_APP_ARGS(args, appdata);
784
785 if (!ast_strlen_zero(args.options)) {
786 ast_app_parse_options(wait_exec_options, &flags, opt_args, args.options);
787 }
788 if (freq_parser(args.freqs, &freq1, &freq2)) {
789 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
790 return -1;
791 }
792 if (!ast_strlen_zero(args.timeout) && (sscanf(args.timeout, "%30lf", &timeoutf) != 1 || timeoutf < 0)) {
793 ast_log(LOG_WARNING, "Invalid timeout: %s\n", args.timeout);
794 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
795 return -1;
796 }
797 timeout = 1000 * timeoutf;
798 if (!ast_strlen_zero(args.duration) && (ast_str_to_int(args.duration, &duration) || duration < 1)) {
799 ast_log(LOG_WARNING, "Invalid duration: %s\n", args.duration);
800 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
801 return -1;
802 }
803 if (!ast_strlen_zero(args.times) && (ast_str_to_int(args.times, &times) || times < 1)) {
804 ast_log(LOG_WARNING, "Invalid number of times: %s\n", args.times);
805 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
806 return -1;
807 }
809 if ((ast_str_to_int(opt_args[OPT_APP_ARG_DECIBEL], &db) || db < 1)) {
810 ast_log(LOG_WARNING, "Invalid decibel level: %s\n", opt_args[OPT_APP_ARG_DECIBEL]);
811 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
812 return -1;
813 }
814 }
815 squelch = ast_test_flag(&flags, OPT_APP_SQUELCH);
816 if (!(dsp = ast_dsp_new())) {
817 ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
818 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
819 return -1;
820 }
822 ast_dsp_set_freqmode(dsp, freq1, duration, db, squelch);
823 ast_debug(1, "Waiting for %s Hz, %d time(s), timeout %d ms, %d db\n", args.freqs, times, timeout, db);
824 start = ast_tvnow();
825 do {
826 if (timeout > 0) {
827 remaining_time = ast_remaining_ms(start, timeout);
828 if (remaining_time <= 0) {
829 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "TIMEOUT");
830 break;
831 }
832 }
833 if (ast_waitfor(chan, 1000) > 0) {
834 if (!(frame = ast_read(chan))) {
835 ast_debug(1, "Channel '%s' did not return a frame; probably hung up.\n", ast_channel_name(chan));
836 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "HANGUP");
837 break;
838 } else if (frame->frametype == AST_FRAME_VOICE) {
839 frame = ast_dsp_process(chan, dsp, frame);
840 if (frame->frametype == AST_FRAME_DTMF) {
841 char result = frame->subclass.integer;
842 if (result == 'q') {
843 hits++;
844 ast_debug(1, "We just detected %s Hz (hit #%d)\n", args.freqs, hits);
845 if (hits >= times) {
846 ast_frfree(frame);
847 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "SUCCESS");
848 break;
849 }
850 }
851 }
852 }
853 ast_frfree(frame);
854 } else {
855 pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "HANGUP");
856 }
857 } while (timeout == 0 || remaining_time > 0);
858 ast_dsp_free(dsp);
859
860 return 0;
861}
862
863static char *waitapp = "WaitForTone";
864static char *scanapp = "ToneScan";
865
866static int scan_exec(struct ast_channel *chan, const char *data)
867{
868 char *appdata;
869 double timeoutf = 0;
870 int timeout = 0;
871 struct ast_frame *frame = NULL, *frame2 = NULL;
872 struct ast_dsp *dsp = NULL, *dsp2 = NULL;
873 struct timeval start;
874 int remaining_time = 0;
875 int features, match = 0, fax = 0, voice = 0, threshold = 1;
877 AST_APP_ARG(zone);
878 AST_APP_ARG(timeout);
881 );
882
883 appdata = ast_strdupa(data);
884 AST_STANDARD_APP_ARGS(args, appdata);
885
886 if (!ast_strlen_zero(args.timeout) && (sscanf(args.timeout, "%30lf", &timeoutf) != 1 || timeout < 0)) {
887 ast_log(LOG_WARNING, "Invalid timeout: %s\n", args.timeout);
888 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "ERROR");
889 return -1;
890 }
891 if (!ast_strlen_zero(args.threshold) && (ast_str_to_int(args.threshold, &threshold) || threshold < 1)) {
892 ast_log(LOG_WARNING, "Invalid threshold: %s\n", args.threshold);
893 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "ERROR");
894 return -1;
895 }
896 timeout = 1000 * timeoutf;
897
898 if (!ast_strlen_zero(args.options) && strchr(args.options, 'f')) {
899 fax = 1;
900 }
901 if (!ast_strlen_zero(args.options) && strchr(args.options, 'v')) {
902 voice = 1;
903 }
904
905 if (!(dsp = ast_dsp_new())) {
906 ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
907 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "ERROR");
908 return -1;
909 }
910
911 if (!ast_strlen_zero(args.zone)) {
912 if (ast_dsp_set_call_progress_zone(dsp, args.zone)) {
913 ast_log(LOG_WARNING, "Invalid call progress zone: %s\n", args.zone);
914 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "ERROR");
915 ast_dsp_free(dsp);
916 return -1;
917 }
918 }
919
920 if (fax) {
921 if (!(dsp2 = ast_dsp_new())) {
922 ast_dsp_free(dsp);
923 ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
924 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "ERROR");
925 return -1;
926 }
927 }
928
929 features = DSP_PROGRESS_RINGING; /* audible ringback tone */
930 features |= DSP_PROGRESS_BUSY; /* busy signal */
931 features |= DSP_PROGRESS_CONGESTION; /* SIT tones (not reorder!) */
932 features |= DSP_PROGRESS_TALK; /* voice. */
933 features |= DSP_FEATURE_WAITDIALTONE; /* dial tone */
934 features |= DSP_FEATURE_FREQ_DETECT; /* modem answer */
935 if (voice) {
936 features |= DSP_TONE_STATE_TALKING; /* voice */
937 }
938 ast_dsp_set_features(dsp, features);
939 /* all modems begin negotiating with Bell 103. An answering modem just sends mark tone, or 2225 Hz */
940 ast_dsp_set_freqmode(dsp, 2225, 400, 16, 0); /* this needs to be pretty short, or the progress tones code will think this is voice */
941
942 if (fax) { /* fax detect uses same tone detect internals as modem and causes things to not work as intended, so use a separate DSP if needed. */
943 ast_dsp_set_features(dsp2, DSP_FEATURE_FAX_DETECT); /* fax tone */
944 ast_dsp_set_faxmode(dsp2, DSP_FAXMODE_DETECT_CED); /* we only care about the answering side (CED), not originating (CNG) */
945 }
946
947 ast_debug(1, "Starting tone scan, timeout: %d ms, threshold: %d\n", timeout, threshold);
948 start = ast_tvnow();
949 do {
950 if (timeout > 0) {
951 remaining_time = ast_remaining_ms(start, timeout);
952 if (remaining_time <= 0) {
953 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "TIMEOUT");
954 break;
955 }
956 }
957 if (ast_waitfor(chan, 1000) > 0) {
958 if (!(frame = ast_read(chan))) {
959 ast_debug(1, "Channel '%s' did not return a frame; probably hung up.\n", ast_channel_name(chan));
960 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "HANGUP");
961 break;
962 } else if (frame->frametype == AST_FRAME_VOICE) {
963 if (fax) {
964 frame2 = ast_frdup(frame);
965 }
966 frame = ast_dsp_process(chan, dsp, frame);
967 if (frame->frametype == AST_FRAME_DTMF) {
968 char result = frame->subclass.integer;
969 match = 1;
970 if (result == 'q') {
971 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "MODEM");
972 } else {
973 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "DTMF");
974 }
975 } else if (fax) {
976 char result;
977 frame2 = ast_dsp_process(chan, dsp2, frame2);
978 result = frame2->subclass.integer;
979 if (frame2->frametype == AST_FRAME_DTMF) {
980 if (result == 'e') {
981 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "FAX");
982 match = 1;
983 } else {
984 ast_debug(1, "Ignoring inactionable event\n"); /* shouldn't happen */
985 }
986 }
987 ast_frfree(frame2);
988 }
989 if (!match) {
990 int tstate, tcount;
991 tcount = ast_dsp_get_tcount(dsp);
992 tstate = ast_dsp_get_tstate(dsp);
993 if (tstate > 0) {
994 ast_debug(3, "tcount: %d, tstate: %d\n", tcount, tstate);
995 if (tcount >= threshold) {
996 match = 1;
997 switch (tstate) {
999 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "RINGING");
1000 break;
1002 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "DIALTONE");
1003 break;
1005 /* even if we don't specify this feature, it's still checked, so we always need to handle it.
1006 Even if we are looking for it, we need to wait a while or tones will be interpreted
1007 as voice, because this will match first (and this should match last). */
1008 if (voice && tcount > 15 && tcount >= threshold) {
1009 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "VOICE");
1010 } else {
1011 match = 0;
1012 }
1013 break;
1015 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "BUSY");
1016 break;
1018 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "SIT");
1019 break;
1020 case DSP_TONE_STATE_HUNGUP: /* UK only */
1021 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "NUT");
1022 break;
1023 default:
1024 match = 0;
1025 ast_debug(1, "Something else we weren't expecting? tstate: %d, #%d\n", tstate, tcount);
1026 }
1027 }
1028 }
1029 }
1030 }
1031 ast_frfree(frame);
1032 } else {
1033 pbx_builtin_setvar_helper(chan, "TONESCANSTATUS", "HANGUP");
1034 }
1035 } while (!match && (timeout == 0 || remaining_time > 0));
1036 ast_dsp_free(dsp);
1037 if (dsp2) {
1038 ast_dsp_free(dsp2);
1039 }
1040
1041 return 0;
1042}
1043
1045 .name = "TONE_DETECT",
1046 .read = detect_read,
1047 .write = detect_write,
1048};
1049
1050static int unload_module(void)
1051{
1052 int res;
1053
1057
1058 return res;
1059}
1060
1061static int load_module(void)
1062{
1063 int res;
1064
1068
1069 return res;
1070}
1071
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ast_log
Definition: astobj2.c:42
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
Audiohooks Architecture.
@ AST_AUDIOHOOK_MANIPULATE_ALL_RATES
Definition: audiohook.h:75
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.
Definition: audiohook.c:100
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
Definition: audiohook.c:749
ast_audiohook_direction
Definition: audiohook.h:48
@ AST_AUDIOHOOK_DIRECTION_READ
Definition: audiohook.h:49
#define ast_audiohook_lock(ah)
Lock an audiohook.
Definition: audiohook.h:313
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
Definition: audiohook.c:578
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
Definition: audiohook.c:512
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
Definition: audiohook.c:124
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
Definition: audiohook.h:318
@ AST_AUDIOHOOK_TYPE_MANIPULATE
Definition: audiohook.h:38
@ AST_AUDIOHOOK_STATUS_DONE
Definition: audiohook.h:45
static sqlite3 * db
static PGresult * result
Definition: cel_pgsql.c:84
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
Definition: chan_iax2.c:2362
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.
Definition: channel.c:2404
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2413
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)
Definition: channel.h:2968
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3181
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.
Definition: channel.c:4276
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2969
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.
Definition: channel.c:2418
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
Definition: conversions.c:44
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:85
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
Convenient Signal Processing routines.
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1783
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
Definition: dsp.c:1916
threshold
Definition: dsp.h:71
#define DSP_PROGRESS_RINGING
Definition: dsp.h:40
#define DSP_TONE_STATE_SPECIAL3
Definition: dsp.h:59
#define DSP_FEATURE_WAITDIALTONE
Definition: dsp.h:44
#define DSP_TONE_STATE_DIALTONE
Definition: dsp.h:54
#define DSP_PROGRESS_TALK
Definition: dsp.h:39
#define DSP_TONE_STATE_BUSY
Definition: dsp.h:56
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_PROGRESS_BUSY
Definition: dsp.h:41
#define DSP_FEATURE_FAX_DETECT
Definition: dsp.h:29
#define DSP_FAXMODE_DETECT_CED
Definition: dsp.h:48
#define DSP_PROGRESS_CONGESTION
Definition: dsp.h:42
#define DSP_TONE_STATE_HUNGUP
Definition: dsp.h:60
#define DSP_FEATURE_FREQ_DETECT
Definition: dsp.h:45
#define DSP_TONE_STATE_TALKING
Definition: dsp.h:55
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
Definition: dsp.c:1911
#define DSP_TONE_STATE_RINGING
Definition: dsp.h:53
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
Definition: dsp.c:1883
int ast_dsp_set_freqmode(struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
Set arbitrary frequency detection mode.
Definition: dsp.c:1872
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
int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
Definition: dsp.c:1892
Media Format Cache API.
direction
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 END_OPTIONS
#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 BEGIN_OPTIONS
#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.
Definition: main/app.c:3066
char * strsep(char **str, const char *delims)
Asterisk internal frame definitions.
#define AST_FRAME_DTMF
#define ast_frdup(fr)
Copies a frame.
#define ast_frfree(fr)
@ AST_FRAME_VOICE
#define AST_LOG_WARNING
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_ERROR
#define LOG_WARNING
Tone Indication Support.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:619
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
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.
Definition: pbx.h:1558
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)
Definition: pbx.c:8871
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)
@ OPT_ARG_GOTO_TX
@ OPT_ARG_DECIBEL
@ OPT_ARG_HITS_REQ
@ OPT_ARG_GOTO_RX
@ OPT_ARG_ARRAY_SIZE
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
@ OPT_APP_DECIBEL
@ OPT_APP_SQUELCH
static struct ast_custom_function detect_function
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Tone detection module")
static char * waitapp
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)
@ OPT_APP_ARG_DECIBEL
@ OPT_APP_ARG_ARRAY_SIZE
td_opts
@ OPT_GOTO_RX
@ OPT_SIT
@ OPT_END_FILTER
@ OPT_DIALTONE
@ OPT_SQUELCH
@ OPT_DECIBEL
@ OPT_RX
@ OPT_GOTO_TX
@ OPT_TX
@ OPT_BUSY
@ OPT_RINGING
@ OPT_HITS_REQ
static const struct ast_app_option wait_exec_options[128]
static char * scanapp
static int detect_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
#define NULL
Definition: resample.c:96
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1512
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
enum ast_audiohook_status status
Definition: audiohook.h:108
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Definition: pbx.h:118
const char * name
Definition: pbx.h:119
Structure for a data store type.
Definition: datastore.h:31
const char * type
Definition: datastore.h:32
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66
Definition: dsp.c:407
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
Definition: dsp.c:421
Structure used to handle boolean flags.
Definition: utils.h:199
unsigned int flags
Definition: utils.h:200
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
unsigned short int tx
struct ast_audiohook audiohook
unsigned short int squelch
struct ast_dsp * dsp
unsigned short int rx
int value
Definition: syslog.c:37
static float di[4]
Definition: tdd.c:58
const char * args
static struct test_options options
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
#define ast_test_flag(p, flag)
Definition: utils.h:63