[Freeswitch-svn] [commit] r13294 - in freeswitch/trunk/src: . mod/endpoints/mod_sofia mod/event_handlers/mod_event_socket

FreeSWITCH SVN anthm at freeswitch.org
Wed May 13 09:34:39 PDT 2009


Author: anthm
Date: Wed May 13 11:34:39 2009
New Revision: 13294

Log:
allow socket app to operate without pre_answer (please test)

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/trunk/src/switch_ivr.c

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	Wed May 13 11:34:39 2009
@@ -1401,7 +1401,7 @@
 			if (!sofia_test_flag(tech_pvt, TFLAG_ANS) && !sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
 
 				sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
+				switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO, "Sending early media\n");
 
 				/* Transmit 183 Progress with SDP */
 				if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Wed May 13 11:34:39 2009
@@ -432,10 +432,6 @@
 		
 		launch_listener_thread(listener);
 
-		if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
-			return;
-		}
-		
 		while(switch_channel_ready(channel) && !switch_test_flag(listener, LFLAG_CONNECTED)) {
 			switch_cond_next();
 		}

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Wed May 13 11:34:39 2009
@@ -642,40 +642,23 @@
 	int stream_id = 0;
 	switch_event_t *event;
 	switch_unicast_conninfo_t *conninfo = NULL;
-	uint32_t rate;
-	uint32_t bpf;
+	uint32_t rate = 0;
+	uint32_t bpf = 0;
 	const char *to;
 	int timeout = 0;
 	time_t expires = 0;
-
 	switch_codec_implementation_t read_impl = {0};
-    switch_core_session_get_read_impl(session, &read_impl);
+
 	
 	if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that are under control already.\n");
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
-		if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot establish media.\n");
-			return SWITCH_STATUS_FALSE;
-		}
-	}
-	
 	if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_get_state(channel) == CS_RESET) {
 		return SWITCH_STATUS_FALSE;
 	}
 	
-	if (!switch_channel_media_ready(channel)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that have no read codec.\n");
-		return SWITCH_STATUS_FALSE;
-	}
-
-	rate = read_impl.actual_samples_per_second;
-	bpf = read_impl.decoded_bytes_per_packet;
-
 	if ((to = switch_channel_get_variable(channel, "park_timeout"))) {
 		if ((timeout = atoi(to)) < 0) {
 			timeout = 0;
@@ -693,20 +676,36 @@
 		switch_event_fire(&event);
 	}
 
-	while (switch_channel_media_ready(channel) && switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED) 
-		   && switch_channel_test_flag(channel, CF_PARK)) {
-		
-		if ((status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id)) == SWITCH_STATUS_SUCCESS) {
-			if (!SWITCH_READ_ACCEPTABLE(status)) {
-				break;
-			}
+	while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED) && switch_channel_test_flag(channel, CF_PARK)) {
+	
+		if (!rate && switch_channel_media_ready(channel)) {
+			switch_core_session_get_read_impl(session, &read_impl);
+			rate = read_impl.actual_samples_per_second;
+			bpf = read_impl.decoded_bytes_per_packet;
+		}
+	
+		if (rate) {
+			status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
+		} else {
+			switch_yield(20000);
+			status = SWITCH_STATUS_SUCCESS;
+		}
 
+		if (!SWITCH_READ_ACCEPTABLE(status)) {
+			break;
+		} else {
 			if (expires && switch_epoch_time_now(NULL) >= expires) {
 				switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE);
 				break;
 			}
 
 			if (switch_channel_test_flag(channel, CF_UNICAST)) {
+				if (!switch_channel_media_ready(channel)) {
+					if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
+						return SWITCH_STATUS_FALSE;
+					}
+				}
+
 				if (!conninfo) {
 					if (!(conninfo = switch_channel_get_private(channel, "unicast"))) {
 						switch_channel_clear_flag(channel, CF_UNICAST);



More information about the Freeswitch-svn mailing list