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