[Freeswitch-svn] [commit] r5489 - in freeswitch/trunk/src: . mod/codecs/mod_l16 mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Jul 2 16:17:10 EDT 2007


Author: anthm
Date: Mon Jul  2 16:17:10 2007
New Revision: 5489

Modified:
   freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_ivr_bridge.c

Log:
fix for everyone

Modified: freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c	(original)
+++ freeswitch/trunk/src/mod/codecs/mod_l16/mod_l16.c	Mon Jul  2 16:17:10 2007
@@ -55,8 +55,9 @@
 										 uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate,
 										 unsigned int *flag)
 {
+	printf("WTF %d %d\n", codec->implementation->samples_per_second , other_codec->implementation->samples_per_second );
 	/* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
-	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
+	if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
 		memcpy(encoded_data, decoded_data, decoded_data_len);
 		*encoded_data_len = decoded_data_len;
 		return SWITCH_STATUS_RESAMPLE;
@@ -71,7 +72,7 @@
 										 uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
 										 unsigned int *flag)
 {
-	if (codec && other_codec && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
+	if (codec && other_codec && codec->implementation && other_codec->implementation && codec->implementation->samples_per_second != other_codec->implementation->samples_per_second) {
 		memcpy(decoded_data, encoded_data, encoded_data_len);
 		*decoded_data_len = encoded_data_len;
 		return SWITCH_STATUS_RESAMPLE;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Mon Jul  2 16:17:10 2007
@@ -756,7 +756,7 @@
 		free(sql);
 		sql = switch_mprintf("insert into sip_subscriptions values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld)",
 							 proto, from_user, from_host, to_user, to_host, event, contact_str, call_id, full_from, full_via, exp);
-
+		
 		assert(sql != NULL);
 		sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
 		free(sql);
@@ -775,6 +775,7 @@
 
 
 
+
 		switch_safe_free(sstr);
 
 		if ((sql = switch_mprintf("select * from sip_subscriptions where user='%q' and host='%q'", to_user, to_host, to_user, to_host))) {

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Mon Jul  2 16:17:10 2007
@@ -94,7 +94,7 @@
 {
 	switch_io_event_hook_read_frame_t *ptr;
 	switch_status_t status;
-	int need_codec, perfect, do_bugs = 0;
+	int need_codec, perfect, do_bugs = 0, do_resample = 0;
 	unsigned int flag = 0;
   top:
 
@@ -149,6 +149,10 @@
 		goto done;
 	}
 
+	if ((*frame)->codec->implementation->samples_per_second != session->write_codec->implementation->samples_per_second) {
+		do_resample = 1;
+	}
+
 	if (session->bugs && !need_codec) {
 		do_bugs = 1;
 		need_codec = 1;
@@ -166,6 +170,10 @@
 											  session->read_codec->implementation->samples_per_second,
 											  session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &flag);
 
+			if (do_resample && status == SWITCH_STATUS_SUCCESS) {
+				status = SWITCH_STATUS_RESAMPLE;
+			}
+
 			switch (status) {
 			case SWITCH_STATUS_RESAMPLE:
 				if (!session->read_resampler) {
@@ -384,7 +392,7 @@
 
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_frame_t *enc_frame = NULL, *write_frame = frame;
-	unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0;
+	unsigned int flag = 0, need_codec = 0, perfect = 0, do_bugs = 0, do_write = 0, do_resample = 0;
 	switch_io_flag_t io_flag = SWITCH_IO_FLAG_NOOP;
 
 	assert(session != NULL);
@@ -423,6 +431,11 @@
 		need_codec = 1;
 	}
 
+	if (frame->codec->implementation->samples_per_second != session->read_codec->implementation->samples_per_second) {
+		need_codec = 1;
+		do_resample = 1;
+	}
+
 	if (need_codec) {
 		if (frame->codec) {
 			session->raw_write_frame.datalen = session->raw_write_frame.buflen;
@@ -434,6 +447,12 @@
 											  session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
 
 
+
+
+			if (do_resample && status == SWITCH_STATUS_SUCCESS) {
+				status = SWITCH_STATUS_RESAMPLE;
+			}
+
 			switch (status) {
 			case SWITCH_STATUS_RESAMPLE:
 				write_frame = &session->raw_write_frame;
@@ -570,7 +589,6 @@
 				}
 			}
 
-
 			if (perfect) {
 				enc_frame = write_frame;
 				session->enc_write_frame.datalen = session->enc_write_frame.buflen;
@@ -630,16 +648,24 @@
 					for (x = 0; x < frames; x++) {
 						if ((session->raw_write_frame.datalen = (uint32_t)
 							 switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, bytes)) != 0) {
+							int rate;
 							enc_frame = &session->raw_write_frame;
 							session->raw_write_frame.rate = session->write_codec->implementation->samples_per_second;
 							session->enc_write_frame.datalen = session->enc_write_frame.buflen;
 
+							if (frame->codec && frame->codec->implementation) {
+								rate = frame->codec->implementation->samples_per_second;
+							} else {
+								rate = session->write_codec->implementation->samples_per_second;
+							} 
 
+							printf("WTF %d %d %d\n", rate, enc_frame->datalen, session->enc_write_frame.datalen);
+							
 							status = switch_core_codec_encode(session->write_codec,
 															  frame->codec,
 															  enc_frame->data,
 															  enc_frame->datalen,
-															  frame->codec->implementation->samples_per_second,
+															  rate,
 															  session->enc_write_frame.data,
 															  &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
 

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Mon Jul  2 16:17:10 2007
@@ -187,7 +187,7 @@
 	switch_core_session_receive_message(session_a, &msg);
 
 	switch_core_session_kill_channel(session_b, SWITCH_SIG_BREAK);
-
+	switch_core_session_reset(session_a);
 	switch_channel_set_variable(chan_a, SWITCH_BRIDGE_VARIABLE, NULL);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
 	switch_channel_clear_flag(chan_a, CF_BRIDGED);



More information about the Freeswitch-svn mailing list