Revision
17097
Author
mikej
Date
2010-03-24 22:51:04 -0500 (Wed, 24 Mar 2010)

Log Message

fix telephone-event negotiation with devices that don't do what the rfc says they SHOULD do

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (17096 => 17097)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2010-03-25 00:28:56 UTC (rev 17096)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2010-03-25 03:51:04 UTC (rev 17097)
@@ -622,6 +622,7 @@
 	switch_mutex_t *flag_mutex;
 	switch_mutex_t *sofia_mutex;
 	switch_payload_t te;
+	switch_payload_t recv_te;
 	switch_payload_t bte;
 	switch_payload_t cng_pt;
 	switch_payload_t bcng_pt;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (17096 => 17097)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-03-25 00:28:56 UTC (rev 17096)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2010-03-25 03:51:04 UTC (rev 17097)
@@ -549,9 +549,9 @@
 	switch_mutex_unlock(tech_pvt->flag_mutex);
 
 	if (tech_pvt->bte) {
-		tech_pvt->te = tech_pvt->bte;
+		tech_pvt->recv_te = tech_pvt->te = tech_pvt->bte;
 	} else if (!tech_pvt->te) {
-		tech_pvt->te = profile->te;
+		tech_pvt->recv_te = tech_pvt->te = profile->te;
 	}
 
 	tech_pvt->dtmf_type = profile->dtmf_type;
@@ -2771,10 +2771,15 @@
 		}
 
 		if (tech_pvt->te) {
+			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send payload to %u\n", tech_pvt->te);
 			switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
-			switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, tech_pvt->te);
 		}
 
+		if (tech_pvt->recv_te) {
+			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Set 2833 dtmf receive payload to %u\n", tech_pvt->recv_te);
+			switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, tech_pvt->recv_te);
+		}
+
 		if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) ||
 			((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val)) ||
 			((val = switch_channel_get_variable(tech_pvt->channel, "suppress_cng")) && switch_true(val))) {
@@ -3509,16 +3514,17 @@
 
 				if (!te && !strcasecmp(rm_encoding, "telephone-event")) {
 					if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf recv payload to %u\n", te);
+						te = tech_pvt->te = (switch_payload_t) map->rm_pt;
+						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send payload to %u\n", map->rm_pt);
 						if (tech_pvt->rtp_session) {
-							switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, (switch_payload_t) map->rm_pt);
+							switch_rtp_set_telephony_event(tech_pvt->rtp_session, (switch_payload_t) map->rm_pt);
 						}
 					} else {
-						te = tech_pvt->te = (switch_payload_t) map->rm_pt;
-						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send payload to %u\n", te);
+						te = tech_pvt->recv_te = tech_pvt->te = (switch_payload_t) map->rm_pt;
+						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set 2833 dtmf send/recv payload to %u\n", te);
 						if (tech_pvt->rtp_session) {
-							switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te);
-							switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, tech_pvt->te);
+							switch_rtp_set_telephony_event(tech_pvt->rtp_session, te);
+							switch_rtp_set_telephony_recv_event(tech_pvt->rtp_session, te);
 						}
 					}
 				}