[Freeswitch-svn] [commit] r5685 - in freeswitch/branches/greenlizard: . conf scripts scripts/contrib/trixter scripts/py_modules src src/include src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/applications/mod_ivrtest src/mod/applications/mod_rss src/mod/asr_tts/mod_openmrcp src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_iax src/mod/endpoints/mod_portaudio src/mod/endpoints/mod_sofia src/mod/endpoints/mod_woomera src/mod/languages/mod_spidermonkey src/mod/say/mod_say_en src/mod/xml_int/mod_xml_cdr src/mod/xml_int/mod_xml_curl

Freeswitch SVN greenlizard at freeswitch.org
Thu Sep 6 12:57:44 EDT 2007


Author: greenlizard
Date: Thu Sep  6 12:57:43 2007
New Revision: 5685

Added:
   freeswitch/branches/greenlizard/scripts/contrib/trixter/softphone.pl
      - copied unchanged from r5684, /freeswitch/trunk/scripts/contrib/trixter/softphone.pl
   freeswitch/branches/greenlizard/scripts/py_modules/
      - copied from r5684, /freeswitch/trunk/scripts/py_modules/
   freeswitch/branches/greenlizard/scripts/py_modules/__init__.py
      - copied unchanged from r5684, /freeswitch/trunk/scripts/py_modules/__init__.py
   freeswitch/branches/greenlizard/scripts/py_modules/speechtools.py
      - copied unchanged from r5684, /freeswitch/trunk/scripts/py_modules/speechtools.py
   freeswitch/branches/greenlizard/scripts/recipewizard.py
      - copied unchanged from r5684, /freeswitch/trunk/scripts/recipewizard.py
Modified:
   freeswitch/branches/greenlizard/Makefile.am
   freeswitch/branches/greenlizard/conf/conference.conf.xml
   freeswitch/branches/greenlizard/src/include/switch_caller.h
   freeswitch/branches/greenlizard/src/include/switch_core.h
   freeswitch/branches/greenlizard/src/include/switch_ivr.h
   freeswitch/branches/greenlizard/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_ivrtest/mod_ivrtest.c
   freeswitch/branches/greenlizard/src/mod/applications/mod_rss/mod_rss.c
   freeswitch/branches/greenlizard/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
   freeswitch/branches/greenlizard/src/mod/say/mod_say_en/mod_say_en.c
   freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
   freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
   freeswitch/branches/greenlizard/src/switch_caller.c
   freeswitch/branches/greenlizard/src/switch_console.c
   freeswitch/branches/greenlizard/src/switch_core_directory.c
   freeswitch/branches/greenlizard/src/switch_core_session.c
   freeswitch/branches/greenlizard/src/switch_core_speech.c
   freeswitch/branches/greenlizard/src/switch_cpp.cpp
   freeswitch/branches/greenlizard/src/switch_ivr_bridge.c
   freeswitch/branches/greenlizard/src/switch_ivr_menu.c
   freeswitch/branches/greenlizard/src/switch_ivr_originate.c
   freeswitch/branches/greenlizard/src/switch_ivr_play_say.c
   freeswitch/branches/greenlizard/src/switch_odbc.c
   freeswitch/branches/greenlizard/src/switch_swig.c
   freeswitch/branches/greenlizard/src/switch_xml.c

Log:
merge trunk 5651:5684

Modified: freeswitch/branches/greenlizard/Makefile.am
==============================================================================
--- freeswitch/branches/greenlizard/Makefile.am	(original)
+++ freeswitch/branches/greenlizard/Makefile.am	Thu Sep  6 12:57:43 2007
@@ -90,7 +90,8 @@
 src/include/switch_cpp.h\
 libs/libteletone/src/libteletone_detect.h\
 libs/libteletone/src/libteletone_generate.h\
-libs/libteletone/src/libteletone.h
+libs/libteletone/src/libteletone.h\
+src/include/switch_odbc.h
 
 CORE_CFLAGS     = `$(switch_srcdir)/libs/apr/apr-1-config --cflags --cppflags --includes`
 CORE_CFLAGS    += `$(switch_srcdir)/libs/apr-util/apu-1-config --includes`
@@ -104,11 +105,6 @@
 CORE_LIBS      = libs/apr/libapr-1.la libs/apr-util/libaprutil-1.la
 CORE_LIBS     += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la
 CORE_LIBS     += libs/srtp/libsrtp.la $(RESAMPLE_LIB)
-if ADD_ODBC
-libfreeswitch_la_SOURCES += src/switch_odbc.c
-library_include_HEADERS += src/include/switch_odbc.h
-CORE_LIBS     += -lodbc
-endif
 
 lib_LTLIBRARIES	          = libfreeswitch.la
 libfreeswitch_la_CFLAGS   = $(CORE_CFLAGS) $(AM_CFLAGS)
@@ -136,6 +132,10 @@
 freeswitch_LDADD += -lcurses
 endif
 
+if ADD_ODBC
+libfreeswitch_la_SOURCES += src/switch_odbc.c
+CORE_LIBS     += -lodbc
+endif
 
 
 libs/libedit/Makefile:

Modified: freeswitch/branches/greenlizard/conf/conference.conf.xml
==============================================================================
--- freeswitch/branches/greenlizard/conf/conference.conf.xml	(original)
+++ freeswitch/branches/greenlizard/conf/conference.conf.xml	Thu Sep  6 12:57:43 2007
@@ -44,9 +44,9 @@
       <!-- Name of the caller control group to use for this profile -->
       <!-- <param name="caller-controls" value="some name"/> -->
       <!-- TTS Engine to use -->
-      <!--<param name="tts-engine" value="cepstral"/>-->
+      <param name="tts-engine" value="cepstral"/>
       <!-- TTS Voice to use -->
-      <!--<param name="tts-voice" value="david"/>-->
+      <param name="tts-voice" value="david"/>
 
       <!-- If TTS is enabled all audio-file params beginning with -->
       <!-- 'say:' will be considered text to say with TTS -->

Modified: freeswitch/branches/greenlizard/src/include/switch_caller.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_caller.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_caller.h	Thu Sep  6 12:57:43 2007
@@ -99,6 +99,7 @@
 	struct switch_caller_profile *originatee_caller_profile;
 	struct switch_channel_timetable *times;
 	struct switch_caller_extension *caller_extension;
+	switch_memory_pool_t *pool;
 	struct switch_caller_profile *next;
 };
 
@@ -189,10 +190,16 @@
   \param session session associated with the profile (bound by scope)
   \param tocopy the existing profile
 */
-
 SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy);
 
 /*!
+  \brief Duplicate an existing caller profile object
+  \param pool pool to duplicate with
+  \param tocopy the existing profile
+*/
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy);
+
+/*!
   \brief Add headers to an existing event in regards to a specific profile
   \param caller_profile the desired profile
   \param prefix a prefix string to all of the field names (for uniqueness)

Modified: freeswitch/branches/greenlizard/src/include/switch_core.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_core.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_core.h	Thu Sep  6 12:57:43 2007
@@ -1173,13 +1173,17 @@
   \param module_name the speech module to use
   \param voice_name the desired voice name
   \param rate the sampling rate
+  \param interval the sampling interval
   \param flags tts flags
   \param pool the pool to use (NULL for new pool)
   \return SWITCH_STATUS_SUCCESS if the handle is opened
 */
 SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
 														char *module_name,
-														char *voice_name, unsigned int rate, switch_speech_flag_t *flags, switch_memory_pool_t *pool);
+														char *voice_name, 
+														unsigned int rate, 
+														unsigned int interval, 
+														switch_speech_flag_t *flags, switch_memory_pool_t *pool);
 /*! 
   \brief Feed text to the TTS module
   \param sh the speech handle to feed

Modified: freeswitch/branches/greenlizard/src/include/switch_ivr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_ivr.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_ivr.h	Thu Sep  6 12:57:43 2007
@@ -317,13 +317,12 @@
   \param session the session to speak on
   \param tts_name the desired tts module
   \param voice_name the desired voice
-  \param rate the sample rate
   \param text the text to speak
   \param args arguements to pass for callbacks etc
   \return SWITCH_STATUS_SUCCESS if all is well
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
-													  char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args);
+													  char *tts_name, char *voice_name, char *text, switch_input_args_t *args);
 
 /*!
   \brief Make an outgoing call

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	Thu Sep  6 12:57:43 2007
@@ -155,7 +155,7 @@
 
 typedef struct conference_file_node {
 	switch_file_handle_t fh;
-	switch_speech_handle_t sh;
+	switch_speech_handle_t *sh;
 	node_type_t type;
 	uint8_t done;
 	uint8_t async;
@@ -218,6 +218,8 @@
 	uint32_t count;
 	int32_t energy_level;
 	uint8_t min;
+	switch_speech_handle_t lsh;
+	switch_speech_handle_t *sh;
 } conference_obj_t;
 
 /* Relationship with another member */
@@ -257,6 +259,8 @@
 	conference_file_node_t *fnode;
 	conference_relationship_t *relationships;
 	switch_ivr_digit_stream_t *digit_stream;
+	switch_speech_handle_t lsh;
+	switch_speech_handle_t *sh;
 	struct conference_member *next;
 };
 
@@ -606,10 +610,7 @@
 			cur = fnode;
 			fnode = fnode->next;
 
-			if (cur->type == NODE_TYPE_SPEECH) {
-				switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-				switch_core_speech_close(&cur->sh, &flags);
-			} else {
+			if (cur->type != NODE_TYPE_SPEECH) {
 				switch_core_file_close(&cur->fh);
 			}
 
@@ -618,6 +619,12 @@
 		}
 	}
 
+	if (member->sh) {
+		switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+		switch_core_speech_close(&member->lsh, &flags);
+		member->sh = NULL;
+	}
+
 	member->conference = NULL;
 
 	if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
@@ -763,7 +770,7 @@
 					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
 					uint32_t rate = conference->rate;
 
-					if (switch_core_speech_read_tts(&conference->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
+					if (switch_core_speech_read_tts(conference->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
 						file_sample_len = file_data_len / 2;
 					} else {
 						file_sample_len = file_data_len = 0;
@@ -896,10 +903,7 @@
 			conference_file_node_t *fnode;
 			switch_memory_pool_t *pool;
 
-			if (conference->fnode->type == NODE_TYPE_SPEECH) {
-				switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-				switch_core_speech_close(&conference->fnode->sh, &flags);
-			} else {
+			if (conference->fnode->type != NODE_TYPE_SPEECH) {
 				switch_core_file_close(&conference->fnode->fh);
 			}
 
@@ -942,10 +946,7 @@
 				cur = fnode;
 				fnode = fnode->next;
 
-				if (cur->type == NODE_TYPE_SPEECH) {
-					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-					switch_core_speech_close(&cur->sh, &flags);
-				} else {
+				if (cur->type != NODE_TYPE_SPEECH) {
 					switch_core_file_close(&cur->fh);
 				}
 
@@ -991,6 +992,12 @@
 
 		switch_ivr_digit_stream_parser_destroy(conference->dtmf_parser);
 
+		if (conference->sh) {
+			switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+			switch_core_speech_close(&conference->lsh, &flags);
+			conference->sh = NULL;
+		}
+
 		if (conference->pool) {
 			switch_memory_pool_t *pool = conference->pool;
 			switch_core_destroy_memory_pool(&pool);
@@ -1657,10 +1664,7 @@
 				conference_file_node_t *fnode;
 				switch_memory_pool_t *pool;
 
-				if (member->fnode->type == NODE_TYPE_SPEECH) {
-					switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
-					switch_core_speech_close(&member->fnode->sh, &flags);
-				} else {
+				if (member->fnode->type != NODE_TYPE_SPEECH) {
 					switch_core_file_close(&member->fnode->fh);
 				}
 
@@ -1680,7 +1684,7 @@
 						switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
 						uint32_t rate = member->conference->rate;
 
-						if (switch_core_speech_read_tts(&member->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
+						if (switch_core_speech_read_tts(member->fnode->sh, file_frame, &file_data_len, &rate, &flags) == SWITCH_STATUS_SUCCESS) {
 							file_sample_len = file_data_len / 2;
 						} else {
 							file_sample_len = file_data_len = 0;
@@ -2238,11 +2242,15 @@
 		fnode->leadin = leadin;
 		fnode->pool = pool;
 
-		memset(&fnode->sh, 0, sizeof(fnode->sh));
-		if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &flags, fnode->pool) !=
-			SWITCH_STATUS_SUCCESS) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
-			return SWITCH_STATUS_FALSE;
+		if (!member->sh) {
+			memset(&member->lsh, 0, sizeof(member->lsh));
+			if (switch_core_speech_open(&member->lsh, conference->tts_engine, conference->tts_voice, 
+										conference->rate, conference->interval, &flags, fnode->pool) !=
+				SWITCH_STATUS_SUCCESS) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
+				return SWITCH_STATUS_FALSE;
+			}
+			member->sh = &member->lsh;
 		}
 
 		/* Queue the node */
@@ -2254,10 +2262,24 @@
 		} else {
 			member->fnode = fnode;
 		}
-
+		
+		fnode->sh = member->sh;
 		/* Begin Generation */
 		switch_sleep(200000);
-		switch_core_speech_feed_tts(&fnode->sh, text, &flags);
+
+		if (*text == '#') {
+			char *tmp = (char *)text + 1;
+			char *vp = tmp, voice[128] = "";
+			if ((tmp = strchr(tmp, '#'))) {
+				text = tmp + 1;
+				switch_copy_string(voice, vp, (tmp - vp) + 1);
+				switch_core_speech_text_param_tts(fnode->sh, "voice", voice);
+			}
+		} else {
+			switch_core_speech_text_param_tts(fnode->sh, "voice", conference->tts_voice);
+		}
+		
+		switch_core_speech_feed_tts(fnode->sh, text, &flags);
 		switch_mutex_unlock(member->flag_mutex);
 
 		status = SWITCH_STATUS_SUCCESS;
@@ -2309,12 +2331,16 @@
 
 	fnode->type = NODE_TYPE_SPEECH;
 	fnode->leadin = leadin;
-
-	memset(&fnode->sh, 0, sizeof(fnode->sh));
-	if (switch_core_speech_open(&fnode->sh, conference->tts_engine, conference->tts_voice, conference->rate, &flags, conference->pool) !=
-		SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
-		return SWITCH_STATUS_FALSE;
+	
+	if (!conference->sh) {
+		memset(&conference->lsh, 0, sizeof(conference->lsh));
+		if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice, 
+									conference->rate, conference->interval, &flags, conference->pool) !=
+			SWITCH_STATUS_SUCCESS) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
+			return SWITCH_STATUS_FALSE;
+		}
+		conference->sh = &conference->lsh;
 	}
 
 	fnode->pool = pool;
@@ -2329,9 +2355,22 @@
 		conference->fnode = fnode;
 	}
 
+	fnode->sh = conference->sh;
+	if (*text == '#') {
+		char *tmp = (char *)text + 1;
+		char *vp = tmp, voice[128] = "";
+		if ((tmp = strchr(tmp, '#'))) {
+			text = tmp + 1;
+			switch_copy_string(voice, vp, (tmp - vp) + 1);
+			switch_core_speech_text_param_tts(fnode->sh, "voice", voice);
+		}
+	} else {
+		switch_core_speech_text_param_tts(fnode->sh, "voice", conference->tts_voice);
+	}
+
 	/* Begin Generation */
 	switch_sleep(200000);
-	switch_core_speech_feed_tts(&fnode->sh, (char *) text, &flags);
+	switch_core_speech_feed_tts(fnode->sh, (char *) text, &flags);
 	switch_mutex_unlock(conference->mutex);
 
 	status = SWITCH_STATUS_SUCCESS;
@@ -3826,7 +3865,7 @@
 			if (!(conference->tts_engine && conference->tts_voice)) {
 				status = SWITCH_STATUS_FALSE;
 			} else {
-				status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, 0, path + 4, NULL);
+				status = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, path + 4, NULL);
 			}
 			goto done;
 		}

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_dptools/mod_dptools.c	Thu Sep  6 12:57:43 2007
@@ -346,6 +346,88 @@
 	}
 }
 
+
+SWITCH_STANDARD_APP(set_profile_var_function)
+{
+	switch_channel_t *channel;
+	switch_caller_profile_t *caller_profile;
+	char *name, *val = NULL;
+
+	channel = switch_core_session_get_channel(session);
+	assert(channel != NULL);
+
+	caller_profile = switch_channel_get_caller_profile(channel);
+
+	if (switch_strlen_zero(data)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No variable name specified.\n");
+	} else {
+		name = switch_core_session_strdup(session, data);
+		val = strchr(name, '=');
+
+		if (val) {
+			*val++ = '\0';
+			if (switch_strlen_zero(val)) {
+				val = NULL;
+			}
+		}
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET_PROFILE_VAR [%s]=[%s]\n", name, val ? val : "UNDEF");
+
+		if (!strcasecmp(name, "dialplan")) {
+			caller_profile->dialplan = val;
+		}
+		if (!strcasecmp(name, "username")) {
+			caller_profile->username = val;
+		}
+		if (!strcasecmp(name, "caller_id_name")) {
+			caller_profile->caller_id_name = val;
+		}
+		if (!strcasecmp(name, "caller_id_number")) {
+			caller_profile->caller_id_number = val;
+		}
+		if (!strcasecmp(name, "caller_ton")) {
+			caller_profile->caller_ton = (uint8_t)atoi(val);
+		}
+		if (!strcasecmp(name, "caller_numplan")) {
+			caller_profile->caller_numplan = (uint8_t)atoi(val);
+		}
+		if (!strcasecmp(name, "destination_number_ton")) {
+			caller_profile->destination_number_ton = (uint8_t)atoi(val);
+		}
+		if (!strcasecmp(name, "destination_number_numplan")) {
+			caller_profile->destination_number_numplan = (uint8_t)atoi(val);
+		}
+		if (!strcasecmp(name, "ani")) {
+			caller_profile->ani = val;
+		}
+		if (!strcasecmp(name, "aniii")) {
+			caller_profile->aniii = val;
+		}
+		if (!strcasecmp(name, "network_addr")) {
+			caller_profile->network_addr = val;
+		}
+		if (!strcasecmp(name, "rdnis")) {
+			caller_profile->rdnis = val;
+		}
+		if (!strcasecmp(name, "destination_number")) {
+			caller_profile->destination_number = val;
+		}
+		if (!strcasecmp(name, "uuid")) {
+			caller_profile->uuid = val;
+		}
+		if (!strcasecmp(name, "source")) {
+			caller_profile->source = val;
+		}
+		if (!strcasecmp(name, "context")) {
+			caller_profile->context = val;
+		}
+		if (!strcasecmp(name, "chan_name")) {
+			caller_profile->chan_name = val;
+		}
+	}
+}
+
+
 SWITCH_STANDARD_APP(export_function)
 {
 	switch_channel_t *channel;
@@ -860,7 +942,7 @@
 	args.input_callback = on_dtmf;
 	args.buf = buf;
 	args.buflen = sizeof(buf);
-	switch_ivr_speak_text(session, engine, voice, codec->implementation->samples_per_second, text, &args);
+	switch_ivr_speak_text(session, engine, voice, text, &args);
 
 }
 
@@ -1141,6 +1223,7 @@
 #define SCHED_HANGUP_DESCR "Schedule a hangup in the future"
 #define UNSET_LONG_DESC "Unset a channel varaible for the channel calling the application."
 #define SET_LONG_DESC "Set a channel varaible for the channel calling the application."
+#define SET_PROFILE_VAR_LONG_DESC "Set a caller profile varaible for the channel calling the application."
 #define EXPORT_LONG_DESC "Set and export a channel varaible for the channel calling the application."
 #define LOG_LONG_DESC "Logs a channel varaible for the channel calling the application."
 #define TRANSFER_LONG_DESC "Immediatly transfer the calling channel to a new extension"
@@ -1171,6 +1254,7 @@
 	SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "export", "Export a channel varaible across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "set", "Set a channel varaible", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile varaible", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "unset", "Unset a channel varaible", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_ivrtest/mod_ivrtest.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_ivrtest/mod_ivrtest.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_ivrtest/mod_ivrtest.c	Thu Sep  6 12:57:43 2007
@@ -207,7 +207,7 @@
 	args.input_callback = show_dtmf;
 	args.buf = buf;
 	args.buflen = sizeof(buf);
-	switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, &args);
+	switch_ivr_speak_text(session, tts_name, voice_name, text, &args);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Done\n");
 }
 
@@ -405,7 +405,7 @@
 		}
 		snprintf(say, sizeof(say), "You Dialed [%s]\n", buf);
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, say);
-		switch_ivr_speak_text(session, "cepstral", "david", codec->implementation->samples_per_second, say, NULL);
+		switch_ivr_speak_text(session, "cepstral", "david", say, NULL);
 	}
 
 }

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_rss/mod_rss.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_rss/mod_rss.c	Thu Sep  6 12:57:43 2007
@@ -243,7 +243,7 @@
 	}
 
 	memset(&sh, 0, sizeof(sh));
-	if (switch_core_speech_open(&sh, engine, voice, rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_speech_open(&sh, engine, voice, rate, interval, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
 		return;
 	}

Modified: freeswitch/branches/greenlizard/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/asr_tts/mod_openmrcp/mod_openmrcp.c	Thu Sep  6 12:57:43 2007
@@ -62,14 +62,9 @@
 #include "mrcp_recognizer.h"
 #include "mrcp_synthesizer.h"
 #include "mrcp_generic_header.h"
-#include "mrcp_resource_set.h"
 
 #include <switch.h>
 	
-#define OPENMRCP_WAIT_TIMEOUT 5000
-#define MY_BUF_LEN 1024 * 128
-#define MY_BLOCK_SIZE MY_BUF_LEN
-
 SWITCH_MODULE_LOAD_FUNCTION(mod_openmrcp_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_openmrcp_shutdown);
 SWITCH_MODULE_DEFINITION(mod_openmrcp, mod_openmrcp_load, 
@@ -95,12 +90,9 @@
 } openmrcp_session_t;
 
 typedef enum {
-	FLAG_HAS_TEXT =       (1 << 0),
-	FLAG_BARGE =          (1 << 1),
-	FLAG_READY =          (1 << 2),
-	FLAG_SPEAK_COMPLETE = (1 << 3),
-	FLAG_FEED_STARTED =   (1 << 4),
-	FLAG_TERMINATING =    (1 << 5)
+	FLAG_HAS_MESSAGE =    (1 << 0),
+	FLAG_FEED_STARTED =   (1 << 1),
+	FLAG_TERMINATING =    (1 << 2)
 } mrcp_flag_t;
 
 typedef struct {
@@ -220,38 +212,19 @@
 		return MRCP_STATUS_FAILURE;
 	}
 
-	if (mrcp_message->start_line.message_type != MRCP_MESSAGE_TYPE_EVENT) {
+	if (mrcp_message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE && mrcp_message->start_line.request_state == MRCP_REQUEST_STATE_INPROGRESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "ignoring mrcp response\n");
 		return MRCP_STATUS_SUCCESS;
 	}
 
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mrcp msg body: %s\n", mrcp_message->body);
-
-	if (mrcp_message->channel_id.resource_id == MRCP_RESOURCE_RECOGNIZER) {
-		if (mrcp_message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
-			openmrcp_session->mrcp_message_last_rcvd = mrcp_message;
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting FLAG_HAS_TEXT\n");
-			switch_set_flag_locked(openmrcp_session, FLAG_HAS_TEXT);
-		}
-		else if (mrcp_message->start_line.method_id == RECOGNIZER_START_OF_INPUT) {
-			openmrcp_session->mrcp_message_last_rcvd = mrcp_message;
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting FLAG_BARGE\n");
-			switch_set_flag_locked(openmrcp_session, FLAG_BARGE);
-		}
-		else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ignoring event: %s\n", mrcp_message->start_line.method_name);
-		}
-	}
-	else if(mrcp_message->channel_id.resource_id == MRCP_RESOURCE_SYNTHESIZER) {
-		if (mrcp_message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setting FLAG_SPEAK_COMPLETE\n");
-			switch_set_flag_locked(openmrcp_session, FLAG_SPEAK_COMPLETE);
-		}
-		else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "ignoring event: %s\n", mrcp_message->start_line.method_name);
-		}
+	if (switch_test_flag(openmrcp_session, FLAG_HAS_MESSAGE)) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "already has message\n");
+		return MRCP_STATUS_SUCCESS;
 	}
-		
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "setting FLAG_HAS_MESSAGE\n");
+	openmrcp_session->mrcp_message_last_rcvd = mrcp_message;
+	switch_set_flag_locked(openmrcp_session, FLAG_HAS_MESSAGE);
 	return MRCP_STATUS_SUCCESS;
 }
 
@@ -473,8 +446,8 @@
 {
 	openmrcp_session_t *asr_session = (openmrcp_session_t *) ah->private_info;
 	
-	switch_status_t rv = (switch_test_flag(asr_session, FLAG_HAS_TEXT) || switch_test_flag(asr_session, FLAG_BARGE)) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
-	
+	switch_status_t rv = (switch_test_flag(asr_session, FLAG_HAS_MESSAGE)) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+
 	return rv;
 }
 
@@ -483,50 +456,61 @@
 {
 	openmrcp_session_t *asr_session = (openmrcp_session_t *) ah->private_info;
 	switch_status_t ret = SWITCH_STATUS_SUCCESS;
+	mrcp_message_t *message;
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "openmrcp_asr_get_results called\n");
 
-	if (switch_test_flag(asr_session, FLAG_BARGE)) {
-		switch_clear_flag_locked(asr_session, FLAG_BARGE);
-		ret = SWITCH_STATUS_BREAK;
-	}
-	
-	if (switch_test_flag(asr_session, FLAG_HAS_TEXT)) {
-		/*! 
-		   we have to extract the XML but stripping off the <?xml version="1.0"?>
-		   header.  the body looks like:
-		
-		   Completion-Cause:001 no-match
-		   Content-Type: application/nlsml+xml
-		   Content-Length: 260
-		 
-		  <?xml version="1.0"?>
-          <result xmlns="http://www.ietf.org/xml/ns/mrcpv2" xmlns:ex="http://www.example.com/example" score="100" grammar="session:request1 at form-level.store">
-            <interpretation>             <input mode="speech">open a</input>
-            </interpretation>
-          </result>
-		*/
-
-		if(asr_session->mrcp_message_last_rcvd && asr_session->mrcp_message_last_rcvd->body) {
-			char *marker = "?>";  // FIXME -- lame and brittle way of doing this.  use regex or better.
-			char *position = strstr(asr_session->mrcp_message_last_rcvd->body, marker);
-			if (!position) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", asr_session->mrcp_message_last_rcvd->body);
-				ret = SWITCH_STATUS_FALSE;
+	message = asr_session->mrcp_message_last_rcvd;
+	asr_session->mrcp_message_last_rcvd = NULL;
+	// since we are returning our result here, future calls to check_results
+	// should return False
+	switch_clear_flag_locked(asr_session, FLAG_HAS_MESSAGE);
+
+	if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
+		if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && 
+			message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "error code received [%d]\n", message->start_line.status_code);
+			ret = SWITCH_STATUS_FALSE;
+		}
+	} 
+	else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
+		if (message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
+			/*! 
+			   we have to extract the XML but stripping off the <?xml version="1.0"?>
+			   header.  the body looks like:
+			
+			   Completion-Cause:001 no-match
+			   Content-Type: application/nlsml+xml
+			   Content-Length: 260
+			 
+			  <?xml version="1.0"?>
+			  <result xmlns="http://www.ietf.org/xml/ns/mrcpv2" xmlns:ex="http://www.example.com/example" score="100" grammar="session:request1 at form-level.store">
+				<interpretation>             <input mode="speech">open a</input>
+				</interpretation>
+			  </result>
+			*/
+
+			if(message->body) {
+				char *marker = "?>";  // FIXME -- lame and brittle way of doing this.  use regex or better.
+				char *position = strstr(message->body, marker);
+				if (!position) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad result received from mrcp server: %s", message->body);
+					ret = SWITCH_STATUS_FALSE;
+				}
+				else {
+					position += strlen(marker);
+					*xmlstr = strdup(position);
+				}
 			}
 			else {
-				position += strlen(marker);
-				*xmlstr = strdup(position);
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No result received from mrcp server\n");
+				ret = SWITCH_STATUS_FALSE;
 			}
-		}
-		else {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No result received from mrcp server\n");
-			ret = SWITCH_STATUS_FALSE;
-		}
 
-		// since we are returning our result here, future calls to check_results
-		// should return False
-		switch_clear_flag_locked(asr_session, FLAG_HAS_TEXT);
-		ret = SWITCH_STATUS_SUCCESS;	
+			ret = SWITCH_STATUS_SUCCESS;	
+		} 
+		else if (message->start_line.method_id == RECOGNIZER_START_OF_INPUT) {
+			ret = SWITCH_STATUS_BREAK;
+		}
 	}
 	return ret;
 }
@@ -658,10 +642,25 @@
 	media_frame_t media_frame;
 	audio_source_t *audio_source;
 
-	if (switch_test_flag(tts_session, FLAG_SPEAK_COMPLETE)) {
-		/* tell fs we are done */
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FLAG_SPEAK_COMPLETE\n");
-		return SWITCH_STATUS_BREAK;
+	if (switch_test_flag(tts_session, FLAG_HAS_MESSAGE)) {
+		mrcp_message_t *message = tts_session->mrcp_message_last_rcvd;
+		tts_session->mrcp_message_last_rcvd = NULL;
+		switch_clear_flag_locked(tts_session, FLAG_HAS_MESSAGE);
+
+		if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
+			if (message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS && 
+				message->start_line.status_code != MRCP_STATUS_CODE_SUCCESS_WITH_IGNORE) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "error code received [%d]\n", message->start_line.status_code);
+				return SWITCH_STATUS_BREAK;
+			}
+		} 
+		else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
+			if (message->start_line.method_id == SYNTHESIZER_SPEAK_COMPLETE) {
+				/* tell fs we are done */
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "FLAG_SPEAK_COMPLETE\n");
+				return SWITCH_STATUS_BREAK;
+			}
+		}
 	}
 
 	audio_source = mrcp_client_audio_source_get(tts_session->audio_channel);
@@ -962,5 +961,5 @@
 {
 	/* destroy openmrcp */
 	openmrcp_destroy();
-	return SWITCH_STATUS_UNLOAD;
+	return SWITCH_STATUS_SUCCESS;
 }

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	Thu Sep  6 12:57:43 2007
@@ -2650,12 +2650,11 @@
 																			  cid_name,
 																			  cid_num,
 																			  ldl_session_get_ip(dlsession),
-																			  ldl_session_get_value(dlsession,
-																									"ani"),
-																			  ldl_session_get_value(dlsession,
-																									"aniii"),
-																			  ldl_session_get_value(dlsession,
-																									"rdnis"), (char *) modname, context,
+																			  ldl_session_get_value(dlsession, "ani"),
+																			  ldl_session_get_value(dlsession, "aniii"),
+																			  ldl_session_get_value(dlsession, "rdnis"),
+																			  modname,
+																			  context,
 																			  exten)) != 0) {
 						char name[128];
 						snprintf(name, sizeof(name), "DingaLing/%s", tech_pvt->caller_profile->destination_number);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_iax/mod_iax.c	Thu Sep  6 12:57:43 2007
@@ -1107,8 +1107,9 @@
 																				  iaxevent->ies.calling_ani,
 																				  NULL,
 																				  NULL,
-																				  (char *) modname,
-																				  iaxevent->ies.called_context, iaxevent->ies.called_number)) != 0) {
+																				  modname,
+																				  iaxevent->ies.called_context,
+																				  iaxevent->ies.called_number)) != 0) {
 							char name[128];
 							snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
 							switch_channel_set_name(channel, name);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Thu Sep  6 12:57:43 2007
@@ -1600,8 +1600,8 @@
 		}
 
 		if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-																  NULL,
-																  dialplan, cid_name, cid_num, NULL, NULL, NULL, NULL, (char *) modname, NULL,
+																  NULL, dialplan, cid_name, cid_num,
+																  NULL, NULL, NULL, NULL, modname, NULL,
 																  dest)) != 0) {
 			char name[128];
 			snprintf(name, sizeof(name), "PortAudio/%s",

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia.c	Thu Sep  6 12:57:43 2007
@@ -1935,7 +1935,10 @@
 	tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 														 from_user,
 														 profile->dialplan,
-														 displayname, from_user, network_ip, NULL, NULL, NULL, MODNAME, context, destination_number);
+														 displayname,
+														 from_user,
+														 network_ip,
+														 NULL, NULL, NULL, MODNAME, context, destination_number);
 
 	if (tech_pvt->caller_profile) {
 

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_glue.c	Thu Sep  6 12:57:43 2007
@@ -505,10 +505,10 @@
 		if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
 			priv = "name";
 			if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
-				priv = "yes";
+				priv = "full";
 			}
 		} else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
-			priv = "yes";
+			priv = "full";
 		}
 		if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
 			screen = "yes";
@@ -1369,6 +1369,7 @@
 	case 603:
 		return SWITCH_CAUSE_CALL_REJECTED;
 	case 404:
+		return SWITCH_CAUSE_UNALLOCATED;
 	case 485:
 	case 604:
 		return SWITCH_CAUSE_NO_ROUTE_DESTINATION;

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c	Thu Sep  6 12:57:43 2007
@@ -729,8 +729,9 @@
 	const char *passwd = NULL;
 	const char *a1_hash = NULL;
 	char *sql;
-	switch_xml_t domain, xml, user, param, xparams;	
-
+	switch_xml_t domain, xml = NULL, user, param, xparams;	
+	char hexdigest[2 * SU_MD5_DIGEST_SIZE + 1] = "";
+	
 	username = realm = nonce = uri = qop = cnonce = nc = response = NULL;
 	
 	if (authorization->au_params) {
@@ -805,7 +806,6 @@
 		
 	if (!(xparams = switch_xml_child(user, "params"))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find params for user [%s@%s]\n", username, realm);
-		switch_xml_free(xml);
 		ret = AUTH_FORBIDDEN;
 		goto end;
 	}
@@ -838,8 +838,6 @@
 		}
 	}
 
-	switch_xml_free(xml);
-
 	if (switch_strlen_zero(passwd) && switch_strlen_zero(a1_hash)) {
 		ret = AUTH_OK;
 		goto end;
@@ -847,7 +845,6 @@
 
 	if (!a1_hash) {
 		su_md5_t ctx;
-		char hexdigest[2 * SU_MD5_DIGEST_SIZE + 1];
 		char *input;
 
 		input = switch_mprintf("%s:%s:%s", username, realm, passwd);
@@ -894,6 +891,9 @@
 	}
 
   end:
+	if (xml) {
+		switch_xml_free(xml);
+	}
 	switch_safe_free(input);
 	switch_safe_free(input2);
 	switch_safe_free(username);

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_woomera/mod_woomera.c	Thu Sep  6 12:57:43 2007
@@ -1059,7 +1059,15 @@
 				if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
 																		  NULL,
 																		  tech_pvt->profile->dialplan,
-																		  cid_name, cid_num, ip, NULL, NULL, NULL, (char *) modname, NULL, exten)) != 0) {
+																		  cid_name,
+																		  cid_num,
+																		  ip,
+																		  NULL,
+																		  NULL,
+																		  NULL,
+																		  modname,
+																		  NULL,
+																		  exten)) != 0) {
 					char name[128];
 					snprintf(name, sizeof(name), "Woomera/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
 					switch_channel_set_name(channel, name);

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Thu Sep  6 12:57:43 2007
@@ -1242,6 +1242,7 @@
 	char *phrase_name = NULL;
 	char *phrase_data = NULL;
 	char *phrase_lang = NULL;
+	char *tmp = NULL;
 	//char *input_callback = NULL;
 	void *bp = NULL;
 	int len = 0;
@@ -1272,7 +1273,10 @@
 	}
 
 	if (argc > 2) {
-		phrase_lang = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+		tmp = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
+		if (!switch_strlen_zero(tmp)) {
+			phrase_lang = tmp;
+		}
 	}
 
 	if (argc > 3) {
@@ -1502,6 +1506,53 @@
 	return JS_TRUE;
 }
 
+static void destroy_speech_engine(struct js_session *jss)
+{
+	if (jss->speech) {
+		switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+		switch_core_codec_destroy(&jss->speech->codec);
+		switch_core_speech_close(&jss->speech->sh, &flags);
+		jss->speech = NULL;
+	}
+}
+
+
+static switch_status_t init_speech_engine(struct js_session *jss, char *engine, char *voice)
+{
+	switch_codec_t *read_codec;
+	switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
+	uint32_t rate = 0;
+	int interval = 0;
+
+	read_codec = switch_core_session_get_read_codec(jss->session);
+	rate = read_codec->implementation->samples_per_second;
+	interval = read_codec->implementation->microseconds_per_frame / 1000;
+
+	if (switch_core_codec_init(&jss->speech->codec,
+							   "L16",
+							   NULL,
+							   rate,
+							   interval,
+							   1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+							   switch_core_session_get_pool(jss->session)) == SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", rate, interval);
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", rate, interval);
+		return SWITCH_STATUS_FALSE;
+	}
+
+
+	if (switch_core_speech_open(&jss->speech->sh, engine, voice, rate, interval,
+								&flags, switch_core_session_get_pool(jss->session)) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
+		switch_core_codec_destroy(&jss->speech->codec);
+		return SWITCH_STATUS_FALSE;
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+
+}
+
 
 static JSBool session_speak(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
@@ -1520,13 +1571,13 @@
 
 	METHOD_SANITY_CHECK();
 
+	*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
 	CHANNEL_SANITY_CHECK();
 
 	if (argc < 3) {
-		*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
 		return JS_FALSE;
 	}
 
@@ -1534,6 +1585,34 @@
 	voice_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 	text = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
 
+
+	if (switch_strlen_zero(tts_name)) {
+		eval_some_js("~throw new Error(\"Invalid TTS Name\");", cx, obj, rval);
+		return JS_TRUE;
+	}
+
+	if (switch_strlen_zero(text)) {
+		eval_some_js("~throw new Error(\"Invalid Text\");", cx, obj, rval);
+		return JS_TRUE;
+	}
+
+
+	if (jss->speech && strcasecmp(jss->speech->sh.name, tts_name)) {
+		destroy_speech_engine(jss);
+	}
+	
+	if (jss->speech) {
+		switch_core_speech_text_param_tts(&jss->speech->sh, "voice", voice_name);
+	} else {
+		jss->speech = switch_core_session_alloc(jss->session, sizeof(*jss->speech));
+		assert(jss->speech != NULL);
+		if (init_speech_engine(jss, tts_name, voice_name) != SWITCH_STATUS_SUCCESS) {
+			eval_some_js("~throw new Error(\"Cannot allocate speech engine!\");", cx, obj, rval);
+			jss->speech = NULL;
+			return JS_TRUE;
+		}
+	}
+
 	if (argc > 3) {
 		if ((function = JS_ValueToFunction(cx, argv[3]))) {
 			memset(&cb_state, 0, sizeof(cb_state));
@@ -1551,9 +1630,6 @@
 		}
 	}
 
-	if (!tts_name && text) {
-		return JS_FALSE;
-	}
 
 	codec = switch_core_session_get_read_codec(jss->session);
 	cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -1561,8 +1637,9 @@
 	args.input_callback = dtmf_func;
 	args.buf = bp;
 	args.buflen = len;
-	switch_ivr_speak_text(jss->session, tts_name, voice_name
-						  && strlen(voice_name) ? voice_name : NULL, codec->implementation->samples_per_second, text, &args);
+	
+	switch_core_speech_flush_tts(&jss->speech->sh);
+	switch_ivr_speak_text_handle(jss->session, &jss->speech->sh, &jss->speech->codec, NULL, text, &args);
 	JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 
@@ -2353,9 +2430,8 @@
 			return JS_FALSE;
 		}
 
-		caller_profile = switch_caller_profile_new(pool,
-												   username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, (char *) modname, context,
-												   dest);
+		caller_profile = switch_caller_profile_new(pool,username, dialplan, cid_name, cid_num, network_addr,
+												   ani, aniii, rdnis, modname, context, dest);
 
 		if (switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
@@ -2385,6 +2461,8 @@
 
 	if (cx && obj) {
 		if ((jss = JS_GetPrivate(cx, obj))) {
+			destroy_speech_engine(jss);
+			
 			if (jss->session) {
 				channel = switch_core_session_get_channel(jss->session);
 				switch_channel_set_private(channel, "jss", NULL);

Modified: freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h	Thu Sep  6 12:57:43 2007
@@ -122,6 +122,11 @@
 typedef struct sm_module_interface sm_module_interface_t;
 typedef switch_status_t (*spidermonkey_init_t) (const sm_module_interface_t ** module_interface);
 
+struct js_session_speech {
+	switch_speech_handle_t sh;
+	switch_codec_t codec;
+};
+
 struct js_session {
 	switch_core_session_t *session;
 	JSContext *cx;
@@ -141,6 +146,7 @@
 	char *rdnis;
 	char *context;
 	char *username;
+	struct js_session_speech *speech;
 };
 
 JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)

Modified: freeswitch/branches/greenlizard/src/mod/say/mod_say_en/mod_say_en.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/say/mod_say_en/mod_say_en.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/say/mod_say_en/mod_say_en.c	Thu Sep  6 12:57:43 2007
@@ -156,7 +156,8 @@
 {
 	switch_channel_t *channel;
 	int in;
-	int x = 0, places[9] = { 0 };
+	uint32_t x = 0;
+	int places[9] = { 0 };
 	char sbuf[13] = "";
 	switch_status_t status;
 

Modified: freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c	Thu Sep  6 12:57:43 2007
@@ -88,7 +88,8 @@
 		if(!switch_strlen_zero(logdir)) {
 			if ((path = switch_mprintf("%s/xml_cdr/%s.cdr.xml", logdir, switch_core_session_get_uuid(session)))) {
 				if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
-					write(fd, xml_text, (unsigned) strlen(xml_text));
+					int wrote;
+					wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
 					close(fd);
 					fd = -1;
 				} else {
@@ -160,7 +161,8 @@
 
 			if ((path = switch_mprintf("%s/%s.cdr.xml", globals.errLogDir, switch_core_session_get_uuid(session)))) {
 				if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
-					write(fd, xml_text, (unsigned) strlen(xml_text));
+					int wrote;
+					wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
 					close(fd);
 					fd = -1;
 				} else {

Modified: freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	Thu Sep  6 12:57:43 2007
@@ -53,8 +53,8 @@
 {
 	register unsigned int realsize = (unsigned int) (size * nmemb);
 	struct config_data *config_data = data;
-
-	write(config_data->fd, ptr, realsize);
+	int x;
+	x = write(config_data->fd, ptr, realsize);
 	return realsize;
 }
 
@@ -72,7 +72,7 @@
 	xml_binding_t *binding = (xml_binding_t *) user_data;
 	char *file_url;
 	struct curl_slist *slist = NULL;
-	long httpRes;
+	long httpRes = 0;
 
 	if (!binding) {
 		return NULL;

Modified: freeswitch/branches/greenlizard/src/switch_caller.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_caller.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_caller.c	Thu Sep  6 12:57:43 2007
@@ -63,29 +63,31 @@
 		profile->context = switch_clean_string(switch_core_strdup(pool, switch_str_nil(context)));
 		profile->destination_number = switch_clean_string(switch_core_strdup(pool, switch_str_nil(destination_number)));
 		switch_set_flag(profile, SWITCH_CPF_SCREEN);
+		profile->pool = pool;
 	}
 
 	return profile;
 }
 
 
-SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_dup(switch_memory_pool_t *pool, switch_caller_profile_t *tocopy)
 {
 	switch_caller_profile_t *profile = NULL;
-	if ((profile = switch_core_session_alloc(session, sizeof(switch_caller_profile_t))) != 0) {
-		profile->username = switch_core_session_strdup(session, tocopy->username);
-		profile->dialplan = switch_core_session_strdup(session, tocopy->dialplan);
-		profile->caller_id_name = switch_core_session_strdup(session, tocopy->caller_id_name);
-		profile->ani = switch_core_session_strdup(session, tocopy->ani);
-		profile->aniii = switch_core_session_strdup(session, tocopy->aniii);
-		profile->caller_id_number = switch_core_session_strdup(session, tocopy->caller_id_number);
-		profile->network_addr = switch_core_session_strdup(session, tocopy->network_addr);
-		profile->rdnis = switch_core_session_strdup(session, tocopy->rdnis);
-		profile->destination_number = switch_core_session_strdup(session, tocopy->destination_number);
-		profile->uuid = switch_core_session_strdup(session, tocopy->uuid);
-		profile->source = switch_core_session_strdup(session, tocopy->source);
-		profile->context = switch_core_session_strdup(session, tocopy->context);
-		profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
+
+	if ((profile = switch_core_alloc(pool, sizeof(switch_caller_profile_t))) != 0) {
+		profile->username = switch_core_strdup(pool, tocopy->username);
+		profile->dialplan = switch_core_strdup(pool, tocopy->dialplan);
+		profile->caller_id_name = switch_core_strdup(pool, tocopy->caller_id_name);
+		profile->ani = switch_core_strdup(pool, tocopy->ani);
+		profile->aniii = switch_core_strdup(pool, tocopy->aniii);
+		profile->caller_id_number = switch_core_strdup(pool, tocopy->caller_id_number);
+		profile->network_addr = switch_core_strdup(pool, tocopy->network_addr);
+		profile->rdnis = switch_core_strdup(pool, tocopy->rdnis);
+		profile->destination_number = switch_core_strdup(pool, tocopy->destination_number);
+		profile->uuid = switch_core_strdup(pool, tocopy->uuid);
+		profile->source = switch_core_strdup(pool, tocopy->source);
+		profile->context = switch_core_strdup(pool, tocopy->context);
+		profile->chan_name = switch_core_strdup(pool, tocopy->chan_name);
 		profile->caller_ton = tocopy->caller_ton;
 		profile->caller_numplan = tocopy->caller_numplan;
 		profile->ani_ton = tocopy->ani_ton;
@@ -95,11 +97,23 @@
 		profile->destination_number_ton = tocopy->destination_number_ton;
 		profile->destination_number_numplan = tocopy->destination_number_numplan;
 		profile->flags = tocopy->flags;
+		profile->pool = pool;
 	}
 
 	return profile;
 }
 
+
+SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_clone(switch_core_session_t *session, switch_caller_profile_t *tocopy)
+{
+	switch_memory_pool_t *pool;
+
+	pool = switch_core_session_get_pool(session);
+
+	return switch_caller_profile_dup(pool, tocopy);
+}
+
+
 SWITCH_DECLARE(char *) switch_caller_get_field_by_name(switch_caller_profile_t *caller_profile, const char *name)
 {
 	if (!strcasecmp(name, "dialplan")) {
@@ -141,6 +155,30 @@
 	if (!strcasecmp(name, "chan_name")) {
 		return caller_profile->chan_name;
 	}
+	if (!strcasecmp(name, "caller_ton")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
+	}
+	if (!strcasecmp(name, "caller_numplan")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_numplan);
+	}
+	if (!strcasecmp(name, "destination_number_ton")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_ton);
+	}
+	if (!strcasecmp(name, "destination_number_numplan")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->destination_number_numplan);
+	}
+	if (!strcasecmp(name, "ani_ton")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_ton);
+	}
+	if (!strcasecmp(name, "ani_numplan")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->ani_numplan);
+	}
+	if (!strcasecmp(name, "rdnis_ton")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_ton);
+	}
+	if (!strcasecmp(name, "rdnis_numplan")) {
+		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->rdnis_numplan);
+	}
 	return NULL;
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_console.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_console.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_console.c	Thu Sep  6 12:57:43 2007
@@ -183,7 +183,7 @@
 static char prompt_str[512] = "";
 
 char * prompt(EditLine *e) {
-	if (switch_strlen_zero(prompt_str)) {
+	if (*prompt_str == '\0') {
 		gethostname(hostname, sizeof(hostname));
 		snprintf(prompt_str, sizeof(prompt_str), "freeswitch@%s> ", hostname);
 	}	

Modified: freeswitch/branches/greenlizard/src/switch_core_directory.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_directory.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_directory.c	Thu Sep  6 12:57:43 2007
@@ -76,28 +76,3 @@
 	return dh->directory_interface->directory_close(dh);
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
-														char *module_name,
-														char *voice_name, unsigned int rate, switch_speech_flag_t *flags, switch_memory_pool_t *pool)
-{
-	switch_status_t status;
-
-	if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid speech module [%s]!\n", module_name);
-		return SWITCH_STATUS_GENERR;
-	}
-
-	switch_copy_string(sh->engine, module_name, sizeof(sh->engine));
-	sh->flags = *flags;
-	if (pool) {
-		sh->memory_pool = pool;
-	} else {
-		if ((status = switch_core_new_memory_pool(&sh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
-			return status;
-		}
-		switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL);
-	}
-	sh->rate = rate;
-	sh->name = switch_core_strdup(pool, module_name);
-	return sh->speech_interface->speech_open(sh, voice_name, rate, flags);
-}

Modified: freeswitch/branches/greenlizard/src/switch_core_session.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_session.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_session.c	Thu Sep  6 12:57:43 2007
@@ -201,23 +201,14 @@
 				ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number");
 
 				if (ecaller_id_name || ecaller_id_number) {
-					if (!ecaller_id_name) {
-						ecaller_id_name = caller_profile->caller_id_name;
+					outgoing_profile = switch_caller_profile_clone(session, caller_profile);
+
+					if (ecaller_id_name) {
+						outgoing_profile->caller_id_name = ecaller_id_name;
 					}
-					if (!ecaller_id_number) {
-						ecaller_id_number = caller_profile->caller_id_number;
+					if (ecaller_id_number) {
+						outgoing_profile->caller_id_number = ecaller_id_number;
 					}
-					outgoing_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-																 caller_profile->username,
-																 caller_profile->dialplan,
-																 ecaller_id_name,
-																 ecaller_id_number,
-																 caller_profile->network_addr,
-																 caller_profile->ani,
-																 caller_profile->aniii,
-																 caller_profile->rdnis,
-																 caller_profile->source, caller_profile->context, caller_profile->destination_number);
-					outgoing_profile->flags = caller_profile->flags;
 				}
 			}
 			if (!outgoing_profile) {

Modified: freeswitch/branches/greenlizard/src/switch_core_speech.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_speech.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_speech.c	Thu Sep  6 12:57:43 2007
@@ -34,6 +34,40 @@
 #include <switch.h>
 #include "private/switch_core_pvt.h"
 
+
+SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,
+														char *module_name,
+														char *voice_name, 
+														unsigned int rate,
+														unsigned int interval,
+														switch_speech_flag_t *flags, 
+														switch_memory_pool_t *pool)
+{
+	switch_status_t status;
+
+	if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid speech module [%s]!\n", module_name);
+		return SWITCH_STATUS_GENERR;
+	}
+
+	switch_copy_string(sh->engine, module_name, sizeof(sh->engine));
+	sh->flags = *flags;
+	if (pool) {
+		sh->memory_pool = pool;
+	} else {
+		if ((status = switch_core_new_memory_pool(&sh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
+			return status;
+		}
+		switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL);
+	}
+	sh->rate = rate;
+	sh->name = switch_core_strdup(pool, module_name);
+	sh->samples = switch_bytes_per_frame(rate, interval);
+
+	return sh->speech_interface->speech_open(sh, voice_name, rate, flags);
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 {
 	assert(sh != NULL);

Modified: freeswitch/branches/greenlizard/src/switch_cpp.cpp
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_cpp.cpp	(original)
+++ freeswitch/branches/greenlizard/src/switch_cpp.cpp	Thu Sep  6 12:57:43 2007
@@ -123,7 +123,6 @@
 int CoreSession::speak(char *text)
 {
     switch_status_t status;
-    switch_codec_t *codec;
 
 	sanity_check(-1);
 
@@ -142,9 +141,9 @@
 		return SWITCH_STATUS_FALSE;
 	}
 
-    codec = switch_core_session_get_read_codec(session);
+
 	begin_allow_threads();
-	status = switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, ap);
+	status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap);
 	end_allow_threads();
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }

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	Thu Sep  6 12:57:43 2007
@@ -84,12 +84,14 @@
 		switch_event_t *event;
 		loop_count++;
 
-		/* if you really want to make sure it's not ready, test it twice because it might be just a break */
-		if (!switch_channel_ready(chan_a) && !switch_channel_ready(chan_a)) {
+		if (!switch_channel_ready(chan_a)) {
 			break;
 		}
 
 		if ((b_state = switch_channel_get_state(chan_b)) >= CS_HANGUP) {
+			if (originator && !ans_a && !ans_b) {
+				switch_channel_hangup(chan_a, switch_channel_get_cause(chan_b));
+			}
 			break;
 		}
 
@@ -163,8 +165,7 @@
 				continue;
 			}
 		}
-
-
+		
 		/* read audio from 1 channel and write it to the other */
 		status = switch_core_session_read_frame(session_a, &read_frame, -1, stream_id);
 

Modified: freeswitch/branches/greenlizard/src/switch_ivr_menu.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_menu.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_menu.c	Thu Sep  6 12:57:43 2007
@@ -263,7 +263,7 @@
 		} else {
 			if (strlen(sound) > 4 && strncmp(sound, "say:", 4) == 0) {
 				if (menu->tts_engine && menu->tts_voice) {
-					status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, sound + 4, &args);
+					status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, sound + 4, &args);
 				} else {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
 				}
@@ -369,7 +369,7 @@
 						status = switch_ivr_play_file(session, NULL, aptr, NULL);
 						break;
 					case SWITCH_IVR_ACTION_SAYTEXT:
-						status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, aptr, NULL);
+						status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, aptr, NULL);
 						break;
 					case SWITCH_IVR_ACTION_SAYPHRASE:
 						status = switch_ivr_phrase_macro(session, aptr, "", menu->phrase_lang, NULL);

Modified: freeswitch/branches/greenlizard/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_originate.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_originate.c	Thu Sep  6 12:57:43 2007
@@ -470,34 +470,18 @@
 					}
 
 					caller_caller_profile = caller_profile_override ? caller_profile_override : switch_channel_get_caller_profile(caller_channel);
+					new_profile = switch_caller_profile_clone(session, caller_caller_profile);
+					new_profile->destination_number = chan_data;
 
-					if (!cid_name_override) {
-						cid_name_override = caller_caller_profile->caller_id_name;
+					if (cid_name_override) {
+						new_profile->caller_id_name = cid_name_override;
 					}
-					if (!cid_num_override) {
-						cid_num_override = caller_caller_profile->caller_id_number;
+					if (cid_num_override) {
+						new_profile->caller_id_number = cid_num_override;
 					}
 
-					new_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
-															caller_caller_profile->username,
-															caller_caller_profile->dialplan,
-															cid_name_override,
-															cid_num_override,
-															caller_caller_profile->network_addr,
-															NULL,
-															NULL,
-															caller_caller_profile->rdnis,
-															caller_caller_profile->source, caller_caller_profile->context, chan_data);
-					new_profile->flags = caller_caller_profile->flags;
 					pool = NULL;
 				} else {
-					if (!cid_name_override) {
-						cid_name_override = "FreeSWITCH";
-					}
-					if (!cid_num_override) {
-						cid_num_override = "0000000000";
-					}
-
 					if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
 						status = SWITCH_STATUS_TERM;
@@ -505,22 +489,23 @@
 					}
 
 					if (caller_profile_override) {
-						new_profile = switch_caller_profile_new(pool,
-																 caller_profile_override->username,
-																 caller_profile_override->dialplan,
-																 caller_profile_override->caller_id_name,
-																 caller_profile_override->caller_id_number,
-																 caller_profile_override->network_addr,
-																 caller_profile_override->ani,
-																 caller_profile_override->aniii,
-																 caller_profile_override->rdnis,
-																 caller_profile_override->source, caller_profile_override->context, chan_data);
+						new_profile = switch_caller_profile_dup(pool, caller_profile_override);
+						new_profile->destination_number = chan_data;
 					} else {
+						if (!cid_name_override) {
+							cid_name_override = "FreeSWITCH";
+						}
+						if (!cid_num_override) {
+							cid_num_override = "0000000000";
+						}
+
 						new_profile = switch_caller_profile_new(pool,
-																 NULL,
-																 NULL,
-																 cid_name_override, cid_num_override, NULL, NULL, NULL, NULL, __FILE__, NULL,
-																 chan_data);
+																NULL,
+																NULL,
+																cid_name_override,
+																cid_num_override,
+																NULL, NULL, NULL, NULL, __FILE__, NULL,
+																chan_data);
 					}
 				}
 				

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	Thu Sep  6 12:57:43 2007
@@ -250,11 +250,7 @@
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", chan_lang);
 						}
 					} else if (!strcasecmp(func, "speak-text")) {
-						switch_codec_t *read_codec;
-						if ((read_codec = switch_core_session_get_read_codec(session))) {
-
-							status = switch_ivr_speak_text(session, tts_engine, tts_voice, read_codec->implementation->samples_per_second, odata, args);
-						}
+						status = switch_ivr_speak_text(session, tts_engine, tts_voice, odata, args);
 					}
 				}
 			}
@@ -1340,11 +1336,11 @@
 
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *session,
-													  char *tts_name, char *voice_name, uint32_t rate, char *text, switch_input_args_t *args)
+													  char *tts_name, char *voice_name, char *text, switch_input_args_t *args)
 {
 	switch_channel_t *channel;
+	uint32_t rate = 0;
 	int interval = 0;
-	uint32_t len = 0;
 	switch_frame_t write_frame = { 0 };
 	switch_timer_t timer;
 	switch_core_thread_session_t thread_session;
@@ -1366,12 +1362,12 @@
 	switch_core_session_reset(session);
 	read_codec = switch_core_session_get_read_codec(session);
 	
-	if (rate == 0) {
-		rate = read_codec->implementation->samples_per_second;
-	}
+	rate = read_codec->implementation->samples_per_second;
+	interval = read_codec->implementation->microseconds_per_frame / 1000;
 
 	memset(&sh, 0, sizeof(sh));
-	if (switch_core_speech_open(&sh, tts_name, voice_name, (uint32_t) rate, &flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_core_speech_open(&sh, tts_name, voice_name, (uint32_t) rate, interval, 
+								&flags, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module!\n");
 		switch_core_session_reset(session);
 		return SWITCH_STATUS_FALSE;
@@ -1380,9 +1376,6 @@
 	switch_channel_answer(channel);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OPEN TTS %s\n", tts_name);
 
-	interval = read_codec->implementation->microseconds_per_frame / 1000;
-	sh.samples = switch_bytes_per_frame(rate, interval);
-	len = sh.samples * 2;
 
 	codec_name = "L16";
 
@@ -1409,7 +1402,7 @@
 			switch_core_session_reset(session);
 			return SWITCH_STATUS_GENERR;
 		}
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", len, interval);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "setup timer success %u bytes per %d ms!\n", sh.samples * 2, interval);
 
 		/* start a thread to absorb incoming audio */
 		for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {

Modified: freeswitch/branches/greenlizard/src/switch_odbc.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_odbc.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_odbc.c	Thu Sep  6 12:57:43 2007
@@ -415,14 +415,14 @@
 
 SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt)
 {
-	char buffer[SQL_MAX_MESSAGE_LENGTH + 1];
-	char sqlstate[SQL_SQLSTATE_SIZE + 1];
+	char buffer[SQL_MAX_MESSAGE_LENGTH + 1] = "";
+	char sqlstate[SQL_SQLSTATE_SIZE + 1] = "";
 	SQLINTEGER sqlcode;
 	SQLSMALLINT length;
 	char *ret = NULL;
 
 	if (SQLError(handle->env, handle->con, stmt, (SQLCHAR *)sqlstate, &sqlcode, (SQLCHAR *)buffer, sizeof(buffer), &length) == SQL_SUCCESS) {
-		ret = switch_mprintf("STATE: %s CODE %ld ERROR: %s\n", switch_str_nil(sqlstate),  sqlcode,  switch_str_nil(buffer));
+		ret = switch_mprintf("STATE: %s CODE %ld ERROR: %s\n", sqlstate,  sqlcode, buffer);
 	};
 
 	return ret;

Modified: freeswitch/branches/greenlizard/src/switch_swig.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_swig.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_swig.c	Thu Sep  6 12:57:43 2007
@@ -260,11 +260,11 @@
 	return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
-int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, uint32_t rate, char *text)
+int fs_switch_ivr_speak_text(switch_core_session_t *session, char *tts_name, char *voice_name, char *text)
 {
 	switch_status_t status;
 
-	status = switch_ivr_speak_text(session, tts_name, voice_name, rate, text, NULL);
+	status = switch_ivr_speak_text(session, tts_name, voice_name, text, NULL);
 	return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 

Modified: freeswitch/branches/greenlizard/src/switch_xml.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_xml.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_xml.c	Thu Sep  6 12:57:43 2007
@@ -966,16 +966,16 @@
 			}
 		}
 
-		if ((cmd = strstr(bp, "<!--#"))) {
-			if(write(write_fd, bp, (unsigned) (cmd - bp)) != (cmd - bp)) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
-			}
+		if ((cmd = strstr(bp, "<!--#"))) {
+			if(write(write_fd, bp, (unsigned) (cmd - bp)) != (cmd - bp)) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
+			}
 			if ((e = strstr(cmd, "-->"))) {
 				*e = '\0';
-				e += 3;
-				if(write(write_fd, e, (unsigned) strlen(e)) != (int) strlen(e)) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
-				}
+				e += 3;
+				if(write(write_fd, e, (unsigned) strlen(e)) != (int) strlen(e)) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
+				}
 			} else {
 				ml++;
 			}
@@ -1031,11 +1031,11 @@
 
 			continue;
 		}
-
-		if(write(write_fd, bp, (unsigned) cur) != (int) cur) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
-		}
-
+
+		if(write(write_fd, bp, (unsigned) cur) != (int) cur) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
+		}
+
 	}
 
 	close(read_fd);



More information about the Freeswitch-svn mailing list