From 845639025ccf57889276793e8775642a7dfb92de Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Fri, 20 Apr 2012 08:03:03 -0500
Subject: [PATCH] FS-4122

---
 src/mod/endpoints/mod_sofia/sofia.c | 14 +++++++-------
 src/switch_rtp.c                    | 10 ++--------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index 44afd6242d..9614b1cba0 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -2957,7 +2957,7 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
 						} else {
 							sofia_clear_pflag(profile, PFLAG_PASS_CALLEE_ID);
 						}
-					} else if (!strcasecmp(var, "rtp-digit-timeout")) {
+					} else if (!strcasecmp(var, "rtp-digit-delay")) {
 						int delay = val ? atoi(val) : 0;
 						
 						if (delay < 0) delay = 0;
@@ -3747,6 +3747,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
 				switch_thread_rwlock_create(&profile->rwlock, profile->pool);
 				switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
 				profile->dtmf_duration = 100;
+				profile->rtp_digit_delay = 40;
 				profile->sip_force_expires = 0;
 				profile->sip_expires_max_deviation = 0;
 				profile->tls_version = 0;
@@ -3845,13 +3846,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
 						} else {
 							sofia_clear_pflag(profile, PFLAG_LIBERAL_DTMF);
 						}
-					} else if (!strcasecmp(var, "rtp-digit-timeout")) {
-						int delay = val ? atoi(val) : 0;
-						
-						if (delay < 0) delay = 0;
-
+					} else if (!strcasecmp(var, "rtp-digit-delay")) {
+						int delay = atoi(val);
+						if (delay < 0) {
+							delay = 0;
+						}
 						profile->rtp_digit_delay = (uint32_t) delay;
-						
 					} else if (!strcasecmp(var, "watchdog-enabled")) {
 						profile->watchdog_enabled = switch_true(val);
 					} else if (!strcasecmp(var, "watchdog-step-timeout")) {
diff --git a/src/switch_rtp.c b/src/switch_rtp.c
index 193520000f..72d7a8e71c 100644
--- a/src/switch_rtp.c
+++ b/src/switch_rtp.c
@@ -2310,11 +2310,6 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session)
 	switch_frame_flag_t flags = 0;
 	uint32_t samples = rtp_session->samples_per_interval;
 
-	if (rtp_session->sending_dtmf > 1) {
-		rtp_session->sending_dtmf--;
-		return;
-	}
-
 	if (!rtp_session->last_write_ts) {
 		return;
 	}
@@ -2409,8 +2404,7 @@ static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session)
 
 
 		if (!rtp_session->sending_dtmf) {
-			rtp_session->sending_dtmf = 2;
-			return;
+			rtp_session->sending_dtmf = 1;
 		}
 
 		if (switch_queue_trypop(rtp_session->dtmf_data.dtmf_queue, &pop) == SWITCH_STATUS_SUCCESS) {
@@ -2983,7 +2977,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
 
 			do_2833(rtp_session, session);
 
-			if (rtp_session->dtmf_data.out_digit_dur > 0 || rtp_session->dtmf_data.in_digit_sanity || rtp_session->sending_dtmf > 0 || 
+			if (rtp_session->dtmf_data.out_digit_dur > 0 || rtp_session->dtmf_data.in_digit_sanity || rtp_session->sending_dtmf || 
 				switch_queue_size(rtp_session->dtmf_data.dtmf_queue) || switch_queue_size(rtp_session->dtmf_data.dtmf_inqueue)) {
 				pt = 20000;
 			}