[Asterisk-code-review] res_tonedetect: Add ringback support to TONE_DETECT. (asterisk[20])

Friendly Automation asteriskteam at digium.com
Mon Oct 10 12:04:37 CDT 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19441 )

Change subject: res_tonedetect: Add ringback support to TONE_DETECT.
......................................................................

res_tonedetect: Add ringback support to TONE_DETECT.

Adds support for detecting audible ringback tone
to the TONE_DETECT function using the p option.

ASTERISK-30254 #close

Change-Id: Ie2329ff245248768367d26749c285fbe823f6414
---
A doc/CHANGES-staging/res_tonedetect_ring.txt
M res/res_tonedetect.c
2 files changed, 43 insertions(+), 1 deletion(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit




diff --git a/doc/CHANGES-staging/res_tonedetect_ring.txt b/doc/CHANGES-staging/res_tonedetect_ring.txt
new file mode 100644
index 0000000..e5e4c2e
--- /dev/null
+++ b/doc/CHANGES-staging/res_tonedetect_ring.txt
@@ -0,0 +1,5 @@
+Subject: res_tonedetect
+
+The TONE_DETECT function now supports
+detection of audible ringback tone
+using the p option.
diff --git a/res/res_tonedetect.c b/res/res_tonedetect.c
index c02eeeb..c81e80c 100644
--- a/res/res_tonedetect.c
+++ b/res/res_tonedetect.c
@@ -228,6 +228,10 @@
 						provided timeout) before going to the destination provided in the <literal>g</literal>
 						or <literal>h</literal> option. Default is 1.</para>
 					</option>
+					<option name="p">
+						<para>Match immediately on audible ringback tone, instead of or in addition to
+						a particular frequency.</para>
+					</option>
 					<option name="r">
 						<para>Apply to received frames only. Default is both directions.</para>
 					</option>
@@ -297,6 +301,7 @@
 	OPT_SIT = (1 << 9),
 	OPT_BUSY = (1 << 10),
 	OPT_DIALTONE = (1 << 11),
+	OPT_RINGING = (1 << 12),
 };
 
 enum {
@@ -316,6 +321,7 @@
 	AST_APP_OPTION_ARG('g', OPT_GOTO_RX, OPT_ARG_GOTO_RX),
 	AST_APP_OPTION_ARG('h', OPT_GOTO_TX, OPT_ARG_GOTO_TX),
 	AST_APP_OPTION_ARG('n', OPT_HITS_REQ, OPT_ARG_HITS_REQ),
+	AST_APP_OPTION('p', OPT_RINGING),
 	AST_APP_OPTION('s', OPT_SQUELCH),
 	AST_APP_OPTION('t', OPT_TX),
 	AST_APP_OPTION('r', OPT_RX),
@@ -403,18 +409,31 @@
 		if (tstate > 0) {
 			ast_debug(3, "tcount: %d, tstate: %d\n", tcount, tstate);
 			switch (tstate) {
+			case DSP_TONE_STATE_RINGING:
+				if (di->signalfeatures & DSP_PROGRESS_RINGING) {
+					ast_debug(1, "Detected ringing on %s in %s direction\n", ast_channel_name(chan),
+						direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
+					match = 1;
+				}
+				break;
 			case DSP_TONE_STATE_DIALTONE:
 				if (di->signalfeatures & DSP_FEATURE_WAITDIALTONE) {
+					ast_debug(1, "Detected dial tone on %s in %s direction\n", ast_channel_name(chan),
+						direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
 					match = 1;
 				}
 				break;
 			case DSP_TONE_STATE_BUSY:
 				if (di->signalfeatures & DSP_PROGRESS_BUSY) {
+					ast_debug(1, "Detected busy tone on %s in %s direction\n", ast_channel_name(chan),
+						direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
 					match = 1;
 				}
 				break;
 			case DSP_TONE_STATE_SPECIAL3:
 				if (di->signalfeatures & DSP_PROGRESS_CONGESTION) {
+					ast_debug(1, "Detected SIT on %s in %s direction\n", ast_channel_name(chan),
+						direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
 					match = 1;
 				}
 				break;
@@ -427,7 +446,8 @@
 				} else if (di->gototx) {
 					ast_async_parseable_goto(chan, di->gototx);
 				} else {
-					ast_debug(3, "Detected call progress signal, but don't know where to go\n");
+					ast_debug(3, "Detected call progress signal in %s direction, but don't know where to go\n",
+						direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write");
 				}
 			}
 		}
@@ -583,6 +603,9 @@
 	if (ast_test_flag(flags, OPT_DIALTONE)) {
 		features |= DSP_FEATURE_WAITDIALTONE;
 	}
+	if (ast_test_flag(flags, OPT_RINGING)) {
+		features |= DSP_PROGRESS_RINGING;
+	}
 
 	return features;
 }

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19441
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: Ie2329ff245248768367d26749c285fbe823f6414
Gerrit-Change-Number: 19441
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221010/2032f787/attachment.html>


More information about the asterisk-code-review mailing list