From 772b59034ff25b2e943d9e32fdc42e99e7a98609 Mon Sep 17 00:00:00 2001
From: lvl <digium@lvlconsultancy.nl>
Date: Thu, 7 Nov 2019 17:05:39 +0000
Subject: [PATCH] app_senddtmf: Add receive mode to AMI Action PlayDTMF

ASTERISK-28614

Change-Id: I183501297ae1dc294ae56b34acac9b0343eb2664
---
 apps/app_senddtmf.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index e0362e7d30..ea75a9e5fb 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -80,6 +80,9 @@
 			<parameter name="Duration" required="false">
 				<para>The duration, in milliseconds, of the digit to be played.</para>
 			</parameter>
+			<parameter name="Receive" required="false">
+				<para>Emulate receiving DTMF on this channel instead of sending it out.</para>
+			</parameter>
 		</syntax>
 		<description>
 			<para>Plays a dtmf digit on the specified channel.</para>
@@ -147,6 +150,7 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
 	const char *channel = astman_get_header(m, "Channel");
 	const char *digit = astman_get_header(m, "Digit");
 	const char *duration = astman_get_header(m, "Duration");
+	const char *receive_s = astman_get_header(m, "Receive");
 	struct ast_channel *chan;
 	unsigned int duration_ms = 0;
 
@@ -167,7 +171,14 @@ static int manager_play_dtmf(struct mansession *s, const struct message *m)
 		return 0;
 	}
 
-	ast_senddigit_external(chan, *digit, duration_ms);
+	if (ast_true(receive_s)) {
+		struct ast_frame f = { AST_FRAME_DTMF, };
+		f.len = duration_ms;
+		f.subclass.integer = *digit;
+		ast_queue_frame(chan, &f);
+	} else {
+		ast_senddigit_external(chan, *digit, duration_ms);
+	}
 
 	chan = ast_channel_unref(chan);
 
-- 
GitLab