[Freeswitch-svn] [commit] r6971 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Dec 24 13:26:39 EST 2007


Author: anthm
Date: Mon Dec 24 13:26:39 2007
New Revision: 6971

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c

Log:
update

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Mon Dec 24 13:26:39 2007
@@ -84,7 +84,7 @@
 
 	tech_pvt->read_frame.buflen = SWITCH_RTP_MAX_BUF_LEN;
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA INIT\n");
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA INIT\n", switch_channel_get_name(channel));
 	if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
 		sofia_glue_tech_absorb_sdp(tech_pvt);
 	}
@@ -112,7 +112,47 @@
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA RING\n");
+	switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RING\n", switch_channel_get_name(channel));
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t sofia_on_reset(switch_core_session_t *session)
+{
+	switch_channel_t *channel = NULL;
+	private_object_t *tech_pvt = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	switch_assert(channel != NULL);
+
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	switch_assert(tech_pvt != NULL);
+
+	switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(channel));
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t sofia_on_hibernate(switch_core_session_t *session)
+{
+	switch_channel_t *channel = NULL;
+	private_object_t *tech_pvt = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	switch_assert(channel != NULL);
+
+	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+	switch_assert(tech_pvt != NULL);
+
+	switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(channel));
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -128,7 +168,8 @@
 	tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SOFIA EXECUTE\n");
+	switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(channel));
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -206,7 +247,10 @@
 		switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+	cause = switch_channel_get_cause(channel);
+
+#if 0
+	if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
 		const char *buuid;
 		switch_core_session_t *bsession;
 		switch_channel_t *bchannel;
@@ -232,8 +276,8 @@
 		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 		
 	}
-	
-	cause = switch_channel_get_cause(channel);
+#endif	
+
 	sip_cause = hangup_cause_to_sip(cause);
 
 	sofia_glue_deactivate_rtp(tech_pvt);
@@ -1495,7 +1539,10 @@
 	/*.on_execute */ sofia_on_execute,
 	/*.on_hangup */ sofia_on_hangup,
 	/*.on_loopback */ sofia_on_loopback,
-	/*.on_transmit */ sofia_on_transmit
+	/*.on_transmit */ sofia_on_transmit,
+	/*.on_hold */ NULL,
+	/*.on_hibernate*/ sofia_on_hibernate,
+	/*.on_reset*/ sofia_on_reset
 };
 
 static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Mon Dec 24 13:26:39 2007
@@ -1462,6 +1462,7 @@
 									if (br_b) {
 										switch_ivr_uuid_bridge(br_a, br_b);
 										switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
+										switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 										switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
 									} else {
 										switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
@@ -1763,6 +1764,7 @@
 							nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 									   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
 
+							switch_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
 							switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
 						} else {
 							if (!br_a && !br_b) {
@@ -1786,8 +1788,11 @@
 									t_session = switch_core_session_locate(br_a);
 									hup_channel = channel_b;
 								} else {
+									private_object_t *h_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
 									t_session = switch_core_session_locate(br_b);
 									hup_channel = channel_a;
+									switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+									switch_clear_flag_locked(h_tech_pvt, TFLAG_SIP_HOLD);
 									switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
 								}
 
@@ -1936,9 +1941,10 @@
 	struct private_object *tech_pvt = NULL;
 	switch_channel_t *channel = NULL;
 	/* placeholder for string searching */
-	char *signal_ptr;
+	const char *signal_ptr;
 	const char *rec_header;
-
+	switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
+	
 	if (session) {
 		/* Get the channel */
 		channel = switch_core_session_get_channel(session);
@@ -1952,55 +1958,47 @@
 		/* Barf if we didn't get it */
 		switch_assert(tech_pvt != NULL);
 
+		if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype && 
+			sip->sip_payload && sip->sip_payload->pl_data) {
+			if (!strcasecmp(sip->sip_content_type->c_type, "dtmf") && !strcasecmp(sip->sip_content_type->c_subtype, "relay")) {
+				/* Try and find signal information in the payload */
+				if ((signal_ptr = switch_stristr("Signal=", sip->sip_payload->pl_data))) {
+					/* move signal_ptr where we need it (right past Signal=) */
+					signal_ptr = signal_ptr + 7;
+					dtmf.digit = *signal_ptr;
+				} else {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad signal\n");
+					goto fail;
+				}
 
-		if (sip && sip->sip_payload && sip->sip_payload->pl_data) {
-			switch_dtmf_t dtmf = { 0, SWITCH_DEFAULT_DTMF_DURATION };
-
-			/* Try and find signal information in the payload */
-			if ((signal_ptr = strstr(sip->sip_payload->pl_data, "Signal="))) {
-				/* move signal_ptr where we need it (right past Signal=) */
-				signal_ptr = signal_ptr + 7;
+				if ((signal_ptr = switch_stristr("Duration=", sip->sip_payload->pl_data))) {
+					int tmp;
+					signal_ptr += 8;
+					if ((tmp = atoi(signal_ptr)) < 0) {
+						tmp = SWITCH_DEFAULT_DTMF_DURATION;
+					} 
+					dtmf.duration = tmp;
+				}
+			} else if (!strcasecmp(sip->sip_content_type->c_type, "application") && !strcasecmp(sip->sip_content_type->c_subtype, "dtmf")) {
+				dtmf.digit = *sip->sip_payload->pl_data;
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad signal\n");
-				return;
-			}
-
-			/* unknown info type */
-			if (!signal_ptr) {
-				sip_from_t const *from = sip->sip_from;
-
-				/* print in the logs if something comes through we don't understand */
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n",
-								  from->a_display ? from->a_display : "",
-								  from->a_display ? " " : "",
-								  URL_PRINT_ARGS(from->a_url),
-								  sip->sip_payload->pl_data);
-				/* Send 415 Unsupported Media response */
-				nua_respond(nh, SIP_415_UNSUPPORTED_MEDIA, NUTAG_WITH_THIS(nua), TAG_END());
-				return;
-			}
-
-			
-			dtmf.digit = *signal_ptr;
-			if ((signal_ptr = strstr(sip->sip_payload->pl_data, "Duration="))) {
-				int tmp;
-				signal_ptr += 8;
-				if ((tmp = atoi(signal_ptr)) < 0) {
-					tmp = SWITCH_DEFAULT_DTMF_DURATION;
-				} 
-				dtmf.duration = tmp;
+				goto fail;
 			}
+		
+			if (dtmf.digit) {
+				/* queue it up */
+				switch_channel_queue_dtmf(channel, &dtmf);
 
-			/* queue it up */
-			switch_channel_queue_dtmf(channel, &dtmf);
-
-			/* print debug info */
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%c)\n", dtmf.digit);
+				/* print debug info */
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%c)\n", dtmf.digit);
 
-			/* Send 200 OK response */
-			nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
+				/* Send 200 OK response */
+				nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
 	
-			return;
+				return;
+			} else {
+				goto fail;
+			}
 		}
 
 		if ((rec_header = sofia_glue_get_unknown_header(sip, "record"))) {
@@ -2037,6 +2035,13 @@
 		}
 	}
 
+
+	return;
+
+ fail:
+
+	nua_respond(nh, 488, "Unsupported Request", NUTAG_WITH_THIS(nua), TAG_END());
+	
 }
 
 



More information about the Freeswitch-svn mailing list