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

Freeswitch SVN anthm at freeswitch.org
Wed Oct 29 11:57:58 EDT 2008


Author: anthm
Date: Wed Oct 29 11:57:57 2008
New Revision: 10189

Modified:
   freeswitch/trunk/src/switch_core_codec.c
   freeswitch/trunk/src/switch_ivr_bridge.c

Log:
fix FSCORE-212

Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c	(original)
+++ freeswitch/trunk/src/switch_core_codec.c	Wed Oct 29 11:57:57 2008
@@ -45,6 +45,10 @@
 SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t *session)
 {
 	session->real_read_codec = session->read_codec = NULL;
+	session->raw_read_frame.codec = session->read_codec;
+	session->raw_write_frame.codec = session->read_codec;
+	session->enc_read_frame.codec = session->read_codec;
+	session->enc_write_frame.codec = session->read_codec;
 }
 
 SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
@@ -60,33 +64,37 @@
 	char tmp[30];
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
-	if (!codec || !codec->implementation) {
+	if (codec && !codec->implementation) {
+		codec = NULL;
+	}
+	
+	if (codec) {
+		if (!session->real_read_codec) {
+			session->read_codec = session->real_read_codec = codec;
+			session->read_impl = *codec->implementation;
+		} else {
+			session->read_codec = codec;
+			session->read_impl = *codec->implementation;
+		}
+	} else {
+		if (session->read_codec == session->real_read_codec) {
+			goto end;
+		}
 		if (session->real_read_codec) {
 			session->read_codec = session->real_read_codec;
+			session->read_impl = *session->real_read_codec->implementation;
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Restore original codec.\n");
 		} else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot set UNINITIALIZED codec!\n");
 			status = SWITCH_STATUS_FALSE;
 			goto end;
 		}
-	} else {
-
-		if (!session->real_read_codec) {
-			session->read_codec = session->real_read_codec = codec;
-		} else {
-			session->read_codec = codec;
-		}
 	}
-
+	
 	if (!session->read_codec) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No READ codec!\n");
         status = SWITCH_STATUS_FALSE;
         goto end;
 	}
 
-	session->read_impl = *session->read_codec->implementation;
-
-
 	if (session->read_codec && session->read_impl.decoded_bytes_per_packet) {
 		if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
 			switch_channel_event_set_data(session->channel, event);
@@ -101,8 +109,7 @@
 		switch_channel_set_variable(channel, "read_codec", session->read_impl.iananame);
 		switch_snprintf(tmp, sizeof(tmp), "%d", session->read_impl.actual_samples_per_second);
 		switch_channel_set_variable(channel, "read_rate", tmp);
-
-
+		
 		session->raw_read_frame.codec = session->read_codec;
 		session->raw_write_frame.codec = session->read_codec;
 		session->enc_read_frame.codec = session->read_codec;

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Wed Oct 29 11:57:57 2008
@@ -445,6 +445,7 @@
 		switch_channel_set_private(channel, "_bridge_", NULL);
 		if (bd->session == session && *bd->b_uuid) {
 			audio_bridge_thread(NULL, (void *) bd);
+			switch_core_session_reset(session, SWITCH_TRUE);
 		} else {
 			switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		}
@@ -563,7 +564,7 @@
 		switch_channel_clear_flag(channel, CF_TRANSFER);
 		switch_channel_clear_flag(other_channel, CF_TRANSFER);
 		switch_core_session_reset(session, SWITCH_TRUE);
-		switch_core_session_reset(other_session, SWITCH_TRUE);
+
 
 		ready_a = switch_channel_ready(channel);
 		ready_b = switch_channel_ready(other_channel);



More information about the Freeswitch-svn mailing list