Browse code

rtpengine: add block_dtmf and unblock_dtmf

Richard Fuchs authored on 06/09/2018 08:16:35
Showing 4 changed files
... ...
@@ -91,7 +91,7 @@
91 91
 		<holder><ulink url='http://www.voipembedded.com'>VoIPEmbedded Inc.</ulink></holder>
92 92
 	</copyright>
93 93
 	<copyright>
94
-		<year>2013-2017</year>
94
+		<year>2013-2018</year>
95 95
 		<holder>Sipwise GmbH</holder>
96 96
 	</copyright>
97 97
 	</bookinfo>
... ...
@@ -2582,6 +2582,47 @@ stop_recording();
2582 2582
 		</example>
2583 2583
 	</section>
2584 2584
 
2585
+	<section id="rtpengine.f.block_dtmf">
2586
+		<title>
2587
+		<function moreinfo="none">block_dtmf([flags])</function>
2588
+		</title>
2589
+		<para>
2590
+		This function will instruct the &rtp; proxy to start blocking DTMF
2591
+		event packets (RFC 4733). DTMF events will still be processed by the
2592
+		&rtp; proxy, but they won't be forwarded to the receiving peer.
2593
+		</para>
2594
+		<para>
2595
+		The call-id flag can be used to stop recording for a different call.
2596
+		</para>
2597
+		<para>
2598
+		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
2599
+		</para>
2600
+		<example>
2601
+		<title><function>block_dtmf</function> usage</title>
2602
+		<programlisting format="linespecific">
2603
+...
2604
+block_dtmf();
2605
+...
2606
+		</programlisting>
2607
+		</example>
2608
+	</section>
2609
+
2610
+	<section id="rtpengine.f.unblock_dtmf">
2611
+		<title>
2612
+		<function moreinfo="none">unblock_dtmf([flags])</function>
2613
+		</title>
2614
+		<para>
2615
+		Reverses the effects of a previously issued <function>block_dtmf</function> call.
2616
+		<example>
2617
+		<title><function>unblock_dtmf</function> usage</title>
2618
+		<programlisting format="linespecific">
2619
+...
2620
+unblock_dtmf();
2621
+...
2622
+		</programlisting>
2623
+		</example>
2624
+	</section>
2625
+
2585 2626
 
2586 2627
 	</section>
2587 2628
 
... ...
@@ -128,6 +128,8 @@ static const char *command_strings[] = {
128 128
 	[OP_QUERY]		= "query",
129 129
 	[OP_PING]		= "ping",
130 130
 	[OP_STOP_RECORDING]	= "stop recording",
131
+	[OP_BLOCK_DTMF]		= "block DTMF",
132
+	[OP_UNBLOCK_DTMF]	= "unblock DTMF",
131 133
 };
132 134
 
133 135
 struct minmax_mos_stats {
... ...
@@ -169,6 +171,8 @@ static char *gencookie();
169 171
 static int rtpp_test(struct rtpp_node*, int, int);
170 172
 static int start_recording_f(struct sip_msg *, char *, char *);
171 173
 static int stop_recording_f(struct sip_msg *, char *, char *);
174
+static int block_dtmf_f(struct sip_msg *, char *, char *);
175
+static int unblock_dtmf_f(struct sip_msg *, char *, char *);
172 176
 static int rtpengine_answer1_f(struct sip_msg *, char *, char *);
173 177
 static int rtpengine_offer1_f(struct sip_msg *, char *, char *);
174 178
 static int rtpengine_delete1_f(struct sip_msg *, char *, char *);
... ...
@@ -295,6 +299,12 @@ static cmd_export_t cmds[] = {
295 299
 	{"stop_recording",	(cmd_function)stop_recording_f, 	1,
296 300
 		fixup_spve_null, 0,
297 301
 		ANY_ROUTE},
302
+	{"block_dtmf",		(cmd_function)block_dtmf_f,	 	0,
303
+		0, 0,
304
+		ANY_ROUTE },
305
+	{"unblock_dtmf",	(cmd_function)unblock_dtmf_f, 		0,
306
+		0, 0,
307
+		ANY_ROUTE},
298 308
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
299 309
 		0, 0,
300 310
 		ANY_ROUTE},
... ...
@@ -3526,6 +3536,27 @@ stop_recording_f(struct sip_msg* msg, char *str1, char *str2)
3526 3536
 	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, flags.s, 1);
3527 3537
 }
3528 3538
 
3539
+
3540
+static int rtpengine_block_dtmf_wrap(struct sip_msg *msg, void *d, int more) {
3541
+	return rtpp_function_call_simple(msg, OP_BLOCK_DTMF, d);
3542
+}
3543
+
3544
+static int rtpengine_unblock_dtmf_wrap(struct sip_msg *msg, void *d, int more) {
3545
+	return rtpp_function_call_simple(msg, OP_UNBLOCK_DTMF, d);
3546
+}
3547
+
3548
+static int
3549
+block_dtmf_f(struct sip_msg* msg, char *str1, char *str2)
3550
+{
3551
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_block_dtmf_wrap, NULL, 1);
3552
+}
3553
+
3554
+static int
3555
+unblock_dtmf_f(struct sip_msg* msg, char *str1, char *str2)
3556
+{
3557
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_unblock_dtmf_wrap, NULL, 1);
3558
+}
3559
+
3529 3560
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {
3530 3561
 	void **parms;
3531 3562
 	pv_param_t *param;
... ...
@@ -38,6 +38,8 @@ enum rtpe_operation {
38 38
         OP_STOP_RECORDING,
39 39
         OP_QUERY,
40 40
         OP_PING,
41
+        OP_BLOCK_DTMF,
42
+        OP_UNBLOCK_DTMF,
41 43
 };
42 44
 
43 45
 struct rtpp_node {