diff mgw/mdcx.c @ 127:f062c32a5116

mgw: implement DTMF
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 01 Oct 2022 20:31:15 -0800
parents 3b3f07b112f3
children a6eb2de277f6
line wrap: on
line diff
--- a/mgw/mdcx.c	Sat Oct 01 17:09:51 2022 -0800
+++ b/mgw/mdcx.c	Sat Oct 01 20:31:15 2022 -0800
@@ -4,6 +4,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -87,14 +88,13 @@
 		    ep->rtp_gsm.remote_addr.sin_family != AF_INET ||
 		    ep->rtp_pstn.remote_addr.sin_family != AF_INET)
 			return TMGW_RESP_ERR_PROT;
-		if ((req->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN) &&
-		    !(ep->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN)) {
+		if (req->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN) {
 			rc = gsm2pstn_init(ep);
 			if (rc != TMGW_RESP_OK)
 				return rc;
-		}
-		if ((req->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM) &&
-		    !(ep->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM)) {
+		} else if (ep->dtmf_pp)
+			dtmf_stop_immediate(ep);
+		if (req->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM) {
 			rc = pstn2gsm_init(ep);
 			if (rc != TMGW_RESP_OK)
 				return rc;
@@ -111,7 +111,6 @@
 	struct tmgw_ctrl_resp *resp;
 {
 	struct endpoint *ep;
-	int rc;
 
 	ep = find_ep_by_id(conn, req->ep_id);
 	if (!ep) {