[Freeswitch-svn] [commit] r5490 - in freeswitch/branches/greenlizard/src: . mod/applications/mod_conference mod/asr_tts/mod_cepstral mod/codecs/mod_l16 mod/endpoints/mod_dingaling mod/endpoints/mod_sofia

Freeswitch SVN greenlizard at freeswitch.org
Mon Jul 2 18:27:07 EDT 2007


Author: greenlizard
Date: Mon Jul  2 18:27:07 2007
New Revision: 5490

Modified:
   freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/greenlizard/src/mod/asr_tts/mod_cepstral/Makefile
   freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/branches/greenlizard/src/switch_core_io.c
   freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
   freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
   freeswitch/branches/greenlizard/src/switch_loadable_module.c

Log:
merge in trunk revision 5477 to 5489

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c	Mon Jul  2 18:27:07 2007
@@ -1575,6 +1575,7 @@
 		char *digit;
 		switch_event_t *event;
 		caller_control_action_t *caller_action = NULL;
+		int use_timer = 0;
 
 		switch_mutex_lock(member->flag_mutex);
 
@@ -1757,7 +1758,7 @@
 				}
 
 				switch_mutex_unlock(member->audio_out_mutex);
-				switch_core_timer_next(&timer);
+				use_timer = 1;
 
 			} else {
 				if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
@@ -1767,12 +1768,17 @@
 					write_frame.timestamp = timer.samplecount;
 					switch_core_session_write_frame(member->session, &write_frame, -1, 0);
 				}
-				switch_core_timer_next(&timer);
+				use_timer = 1;
 			}
 		}
+
 		switch_mutex_unlock(member->flag_mutex);
-		switch_yield(1);
-	}							/* Rinse ... Repeat */
+
+		if (use_timer) {
+			switch_core_timer_next(&timer);
+		}
+
+	} /* Rinse ... Repeat */
 
 	if (member->digit_stream != NULL) {
 		switch_ivr_digit_stream_destroy(member->digit_stream);

Modified: freeswitch/branches/greenlizard/src/mod/asr_tts/mod_cepstral/Makefile
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/asr_tts/mod_cepstral/Makefile	(original)
+++ freeswitch/branches/greenlizard/src/mod/asr_tts/mod_cepstral/Makefile	Mon Jul  2 18:27:07 2007
@@ -1,6 +1,8 @@
-LOCAL_INSERT_LDFLAGS=if test $$osarch = "Darwin" ; then echo "-framework swift" ; else echo "-L$(SWIFT_HOME)/lib -lswift -lceplex_us -lceplang_en -lm" ; fi ;
 
-LOCAL_INSERT_CFLAGS=test $$osarch = "Darwin" || echo "-I$(SWIFT_HOME)/include";
+LOCAL_INSERT_LDFLAGS=if test $$osarch = "Darwin" ; then echo "-framework swift" ; else echo "-L$(SWIFT_HOME)/lib -L/opt/swift/lib -lswift -lceplex_us -lceplang_en -lm" ; fi ;
+
+LOCAL_INSERT_CFLAGS=test $$osarch = "Darwin" || echo "-I$(SWIFT_HOME)/include -I/opt/swift/include";
+
 LOCAL_CFLAGS=-w
 include ../../../../build/modmake.rules
 

Modified: freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/codecs/mod_l16/mod_l16.c	Mon Jul  2 18:27:07 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/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Jul  2 18:27:07 2007
@@ -687,7 +687,7 @@
 
 		tech_pvt = switch_core_session_get_private(*session);
 
-		if (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY)) {
+		if (!switch_core_session_running(*session) && (!tech_pvt || !switch_test_flag(tech_pvt, TFLAG_READY))) {
 			switch_core_session_destroy(session);
 			return;
 		}
@@ -870,7 +870,7 @@
 												 tech_pvt->remote_ip,
 												 tech_pvt->remote_port,
 												 tech_pvt->codec_num,
-												 tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
+												 tech_pvt->read_codec.implementation->samples_per_frame,
 												 tech_pvt->read_codec.implementation->microseconds_per_frame,
 												 flags, NULL, tech_pvt->profile->timer_name, &err, switch_core_session_get_pool(tech_pvt->session)))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_presence.c	Mon Jul  2 18:27:07 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/branches/greenlizard/src/switch_core_io.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_io.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_io.c	Mon Jul  2 18:27:07 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/branches/greenlizard/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_bridge.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_bridge.c	Mon Jul  2 18:27:07 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);

Modified: freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_play_say.c	Mon Jul  2 18:27:07 2007
@@ -392,14 +392,20 @@
 		org_silence_hits = fh->silence_hits;
 	}
 
-	while (switch_channel_ready(channel)) {
+	for(;;) {
 		switch_size_t len;
 
+		if (!switch_channel_ready(channel)) {
+			status = SWITCH_STATUS_FALSE;
+			break;
+		}
+
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
+			status = SWITCH_STATUS_BREAK;
 			break;
 		}
-
+		
 		if (switch_core_session_private_event_count(session)) {
 			switch_ivr_parse_all_events(session);
 		}
@@ -539,9 +545,15 @@
 		switch_buffer_set_loops(audio_buffer, loops);
 	}
 
-	while(switch_channel_ready(channel)) {
+	for(;;) {
 		switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
 		
+		if (!switch_channel_ready(channel)) {
+            status = SWITCH_STATUS_FALSE;
+            break;
+        }
+
+
 		if (switch_channel_test_flag(channel, CF_BREAK)) {
 			switch_channel_clear_flag(channel, CF_BREAK);
 			break;
@@ -1150,6 +1162,8 @@
 	write_frame.samples = len / 2;
 	write_frame.codec = codec;
 
+	assert(codec->implementation != NULL);
+
 	for (x = 0; !done && x < lead_in_out; x++) {
 		switch_yield(codec->implementation->microseconds_per_frame);
 		if (timer) {
@@ -1322,6 +1336,8 @@
 
 	timer_name = switch_channel_get_variable(channel, "timer_name");
 
+	switch_core_session_reset(session);
+
 	if (rate == 0) {
 		read_codec = switch_core_session_get_read_codec(session);
 		rate = read_codec->implementation->samples_per_second;
@@ -1359,7 +1375,7 @@
 	if (timer_name) {
 		if (switch_core_timer_init(&timer, timer_name, interval, (int) samples, pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
-			switch_core_codec_destroy(&codec);
+			switch_core_codec_destroy(write_frame.codec);
 			flags = 0;
 			switch_core_speech_close(&sh, &flags);
 
@@ -1374,7 +1390,7 @@
 		}
 	}
 
-	status = switch_ivr_speak_text_handle(session, &sh, &codec, timer_name ? &timer : NULL, text, args);
+	status = switch_ivr_speak_text_handle(session, &sh, write_frame.codec, timer_name ? &timer : NULL, text, args);
 	flags = 0;
 	switch_core_speech_close(&sh, &flags);
 	switch_core_codec_destroy(&codec);

Modified: freeswitch/branches/greenlizard/src/switch_loadable_module.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_loadable_module.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_loadable_module.c	Mon Jul  2 18:27:07 2007
@@ -1226,6 +1226,8 @@
 		last = name = next = cur = buf;
 
 		for (;;) {
+
+
 			if (!next) {
 				break;
 			}
@@ -1233,10 +1235,11 @@
 				*p++ = '\0';
 			}
 			next = p;
+
 			if (cur != name) {
 				if (strchr(cur, 'i')) {
 					interval = atoi(cur);
-				} else if (strchr(cur, 'k' || strchr(cur, 'h'))) {
+				} else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
 					rate = atoi(cur);
 				}
 			}



More information about the Freeswitch-svn mailing list