[Freeswitch-svn] [commit] r8949 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Jul 8 19:30:17 EDT 2008


Author: anthm
Date: Tue Jul  8 19:30:17 2008
New Revision: 8949

Modified:
   freeswitch/trunk/src/switch_ivr.c

Log:
fix outbound event_socket + late negotiation

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue Jul  8 19:30:17 2008
@@ -481,15 +481,25 @@
 	int stream_id = 0;
 	switch_event_t *event;
 	switch_unicast_conninfo_t *conninfo = NULL;
-	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
+	switch_codec_t *read_codec;
 	uint32_t rate;
 	uint32_t bpf;
 
 	if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that is under control already.\n");
+		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;
+		}
+	}
+
+	read_codec = switch_core_session_get_read_codec(session);
+
 	if (!read_codec || !read_codec->implementation) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot park channels that have no read codec.\n");
 		return SWITCH_STATUS_FALSE;
@@ -498,11 +508,6 @@
 	rate = read_codec->implementation->actual_samples_per_second;
 	bpf = read_codec->implementation->bytes_per_frame;
 
-	if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Careful, Channel is unanswered. Pre-answering...\n");
-		switch_channel_pre_answer(channel);
-	}
-
 	switch_channel_set_flag(channel, CF_CONTROLLED);
 	if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PARK) == SWITCH_STATUS_SUCCESS) {
 		switch_channel_event_set_data(channel, event);



More information about the Freeswitch-svn mailing list