[Freeswitch-branches] [commit] r5190 - in freeswitch/branches/greenlizard: . docs libs/js/nsprpub/pr/src/misc scripts src src/include src/include/private src/mod/applications/mod_commands src/mod/endpoints/mod_sofia src/mod/languages/mod_spidermonkey

Freeswitch SVN greenlizard at freeswitch.org
Wed May 16 12:53:27 EDT 2007


Author: greenlizard
Date: Wed May 16 12:53:25 2007
New Revision: 5190

Added:
   freeswitch/branches/greenlizard/scripts/api.js
      - copied unchanged from r5189, /freeswitch/trunk/scripts/api.js
   freeswitch/branches/greenlizard/src/include/private/switch_core_pvt.h
      - copied unchanged from r5189, /freeswitch/trunk/src/include/private/switch_core_pvt.h
Removed:
   freeswitch/branches/greenlizard/src/include/private/switch_core.h
   freeswitch/branches/greenlizard/src/include/switch_sqlite.h
Modified:
   freeswitch/branches/greenlizard/Makefile.am
   freeswitch/branches/greenlizard/bootstrap.sh
   freeswitch/branches/greenlizard/docs/Doxygen.conf
   freeswitch/branches/greenlizard/libs/js/nsprpub/pr/src/misc/pratom.c
   freeswitch/branches/greenlizard/src/include/switch.h
   freeswitch/branches/greenlizard/src/include/switch_apr.h
   freeswitch/branches/greenlizard/src/include/switch_core.h
   freeswitch/branches/greenlizard/src/include/switch_core_event_hook.h
   freeswitch/branches/greenlizard/src/include/switch_regex.h
   freeswitch/branches/greenlizard/src/include/switch_scheduler.h
   freeswitch/branches/greenlizard/src/include/switch_types.h
   freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/sofia_reg.c
   freeswitch/branches/greenlizard/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/greenlizard/src/switch_console.c
   freeswitch/branches/greenlizard/src/switch_core.c
   freeswitch/branches/greenlizard/src/switch_core_asr.c
   freeswitch/branches/greenlizard/src/switch_core_codec.c
   freeswitch/branches/greenlizard/src/switch_core_db.c
   freeswitch/branches/greenlizard/src/switch_core_directory.c
   freeswitch/branches/greenlizard/src/switch_core_event_hook.c
   freeswitch/branches/greenlizard/src/switch_core_file.c
   freeswitch/branches/greenlizard/src/switch_core_hash.c
   freeswitch/branches/greenlizard/src/switch_core_io.c
   freeswitch/branches/greenlizard/src/switch_core_media_bug.c
   freeswitch/branches/greenlizard/src/switch_core_memory.c
   freeswitch/branches/greenlizard/src/switch_core_port_allocator.c
   freeswitch/branches/greenlizard/src/switch_core_rwlock.c
   freeswitch/branches/greenlizard/src/switch_core_session.c
   freeswitch/branches/greenlizard/src/switch_core_speech.c
   freeswitch/branches/greenlizard/src/switch_core_sqldb.c
   freeswitch/branches/greenlizard/src/switch_core_state_machine.c
   freeswitch/branches/greenlizard/src/switch_core_timer.c
   freeswitch/branches/greenlizard/src/switch_ivr.c
   freeswitch/branches/greenlizard/src/switch_ivr_async.c
   freeswitch/branches/greenlizard/src/switch_ivr_bridge.c

Log:
Sync up changes from trunk version 5170 to 5186

Modified: freeswitch/branches/greenlizard/Makefile.am
==============================================================================
--- freeswitch/branches/greenlizard/Makefile.am	(original)
+++ freeswitch/branches/greenlizard/Makefile.am	Wed May 16 12:53:25 2007
@@ -133,7 +133,7 @@
 if ADD_LIBEDIT
 CORE_CFLAGS    += -Ilibs/libedit/src -DSWITCH_HAVE_LIBEDIT
 CORE_LIBS      += libs/libedit/src/.libs/libedit.a
-freeswitch_LDADD += -ltermcap
+freeswitch_LDADD += -lcurses
 endif
 
 

Modified: freeswitch/branches/greenlizard/bootstrap.sh
==============================================================================
--- freeswitch/branches/greenlizard/bootstrap.sh	(original)
+++ freeswitch/branches/greenlizard/bootstrap.sh	Wed May 16 12:53:25 2007
@@ -22,6 +22,8 @@
 echo "           to build FreeSWITCH from SVN."
 exit 1
 fi
+IFS=_; set $ac_version; IFS=' '
+ac_version=$1
 IFS=.; set $ac_version; IFS=' '
 if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
 echo "bootstrap: autoconf version $ac_version found."

Modified: freeswitch/branches/greenlizard/docs/Doxygen.conf
==============================================================================
--- freeswitch/branches/greenlizard/docs/Doxygen.conf	(original)
+++ freeswitch/branches/greenlizard/docs/Doxygen.conf	Wed May 16 12:53:25 2007
@@ -83,7 +83,7 @@
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = ../src ../src/include 
+INPUT                  = ../src ../src/include ../src/include/private
 FILE_PATTERNS          = *.c \
                          *.cc \
                          *.cxx \

Modified: freeswitch/branches/greenlizard/libs/js/nsprpub/pr/src/misc/pratom.c
==============================================================================
--- freeswitch/branches/greenlizard/libs/js/nsprpub/pr/src/misc/pratom.c	(original)
+++ freeswitch/branches/greenlizard/libs/js/nsprpub/pr/src/misc/pratom.c	Wed May 16 12:53:25 2007
@@ -54,6 +54,50 @@
  */
 
 #if !defined(_PR_HAVE_ATOMIC_OPS)
+#include "prbit.h"
+
+/*
+** Compute the log of the least power of 2 greater than or equal to n
+*/
+PR_IMPLEMENT(PRIntn) PR_CeilingLog2(PRUint32 n)
+{
+    PRIntn log2 = 0;
+
+    if (n & (n-1))
+	log2++;
+    if (n >> 16)
+	log2 += 16, n >>= 16;
+    if (n >> 8)
+	log2 += 8, n >>= 8;
+    if (n >> 4)
+	log2 += 4, n >>= 4;
+    if (n >> 2)
+	log2 += 2, n >>= 2;
+    if (n >> 1)
+	log2++;
+    return log2;
+}
+
+/*
+** Compute the log of the greatest power of 2 less than or equal to n.
+** This really just finds the highest set bit in the word.
+*/
+PR_IMPLEMENT(PRIntn) PR_FloorLog2(PRUint32 n)
+{
+    PRIntn log2 = 0;
+
+    if (n >> 16)
+	log2 += 16, n >>= 16;
+    if (n >> 8)
+	log2 += 8, n >>= 8;
+    if (n >> 4)
+	log2 += 4, n >>= 4;
+    if (n >> 2)
+	log2 += 2, n >>= 2;
+    if (n >> 1)
+	log2++;
+    return log2;
+}
 
 #if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
 /*

Modified: freeswitch/branches/greenlizard/src/include/switch.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch.h	Wed May 16 12:53:25 2007
@@ -51,7 +51,9 @@
 #define FREESWITCH_OID_PREFIX ".1.3.6.1.4.1." FREESWITCH_PEN
 #define FREESWITCH_ITAD "543"
 #define __EXTENSIONS__ 1
+#ifndef MACOSX
 #define _XOPEN_SOURCE 600
+#endif
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>

Modified: freeswitch/branches/greenlizard/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_apr.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_apr.h	Wed May 16 12:53:25 2007
@@ -167,7 +167,7 @@
 
 /**
  * Continue iterating over the entries in a hash table.
- * @param hi The iteration state
+ * @param ht The iteration state
  * @return a pointer to the updated iteration state.  NULL if there are no more  
  *         entries.
  */
@@ -520,7 +520,7 @@
  * create a FIFO queue
  * @param queue The new queue
  * @param queue_capacity maximum size of the queue
- * @param a pool to allocate queue from
+ * @param pool a pool to allocate queue from
  */
 SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, unsigned int queue_capacity, switch_memory_pool_t *pool);
 
@@ -684,7 +684,7 @@
 
 /**
  * Close the specified file.
- * @param file The file descriptor to close.
+ * @param thefile The file descriptor to close.
  */
 SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t * thefile);
 
@@ -771,7 +771,7 @@
 /**
  * Create and initialize a new threadattr variable
  * @param new_attr The newly created threadattr.
- * @param cont The pool to use
+ * @param pool The pool to use
  */
 SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool);
 
@@ -904,7 +904,7 @@
  *                 made the connection request.  This is the socket which should
  *                 be used for all future communication.
  * @param sock The socket we are listening on.
- * @param connection_pool The pool for the new socket.
+ * @param pool The pool for the new socket.
  */
 SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock, switch_socket_t * sock, switch_memory_pool_t *pool);
 
@@ -943,7 +943,7 @@
  *                                 isn't NULL and APR_HAVE_IPV6; mutually exclusive
  *                                 with APR_IPV4_ADDR_OK
  * </PRE>
- * @param p The pool for the apr_sockaddr_t and associated storage.
+ * @param pool The pool for the apr_sockaddr_t and associated storage.
  */
 SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname,
 														 int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
@@ -1149,7 +1149,6 @@
 
 
 /** @} */
-/** @} */
 
 SWITCH_END_EXTERN_C
 #endif

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	Wed May 16 12:53:25 2007
@@ -491,7 +491,7 @@
 SWITCH_DECLARE(char *) switch_core_get_uuid(void);
 
 #ifdef SWITCH_DEBUG_RWLOCKS
-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(char *uuid_str, const char *file, const char *func, int line);
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
 #endif
 
 /*! 
@@ -690,7 +690,7 @@
   \param session the session to check
   \return the number of events
 */
-SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *session);
+SWITCH_DECLARE(uint32_t) switch_core_session_event_count(switch_core_session_t *session);
 
 /*! 
   \brief DE-Queue an event on a given session
@@ -714,7 +714,7 @@
   \param session the session to check
   \return the number of events
 */
-SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_session_t *session);
+SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(switch_core_session_t *session);
 
 /*! 
   \brief DE-Queue a private event on a given session

Modified: freeswitch/branches/greenlizard/src/include/switch_core_event_hook.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_core_event_hook.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_core_event_hook.h	Wed May 16 12:53:25 2007
@@ -226,7 +226,7 @@
 /*! 
   \brief Add an event hook to be executed when a session writes a video frame
   \param session session to bind hook to
-  \param write_frame hook to bind
+  \param video_write_frame hook to bind
   \return SWITCH_STATUS_SUCCESS on suceess
 */
 SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_video_write_frame(switch_core_session_t *session, switch_video_write_frame_hook_t video_write_frame);

Modified: freeswitch/branches/greenlizard/src/include/switch_regex.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_regex.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_regex.h	Wed May 16 12:53:25 2007
@@ -36,7 +36,7 @@
 
 SWITCH_BEGIN_EXTERN_C
 /**
- * @defgroup switch_regex
+ * @defgroup switch_regex Regular Expressions
  * @ingroup FREESWITCH
  * @{
  */

Modified: freeswitch/branches/greenlizard/src/include/switch_scheduler.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_scheduler.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_scheduler.h	Wed May 16 12:53:25 2007
@@ -51,7 +51,7 @@
 
 /*!
   \brief Schedule a task in the future
-  \param runtime the time in epoch seconds to execute the task.
+  \param task_runtime the time in epoch seconds to execute the task.
   \param func the callback function to execute when the task is executed.
   \param desc an arbitrary description of the task.
   \param group a group id tag to link multiple tasks to a single entity.

Modified: freeswitch/branches/greenlizard/src/include/switch_types.h
==============================================================================
--- freeswitch/branches/greenlizard/src/include/switch_types.h	(original)
+++ freeswitch/branches/greenlizard/src/include/switch_types.h	Wed May 16 12:53:25 2007
@@ -538,7 +538,7 @@
 CF_ORIGINATOR	= (1 <<  3) - Channel is an originator
 CF_TRANSFER		= (1 <<  4) - Channel is being transfered
 CF_ACCEPT_CNG	= (1 <<  5) - Channel will accept CNG frames
-CF_LOCK_THREAD	= (1 <<  6) - Prevent the channel thread from exiting while this flag is set
+CF_WAIT_FOR_ME	= (1 <<  6) - Channel wants you to wait
 CF_BRIDGED		= (1 <<  7) - Channel in a bridge
 CF_HOLD			= (1 <<  8) - Channel is on hold
 CF_SERVICE		= (1 <<  9) - Channel has a service thread
@@ -565,7 +565,7 @@
 	CF_ORIGINATOR = (1 << 3),
 	CF_TRANSFER = (1 << 4),
 	CF_ACCEPT_CNG = (1 << 5),
-	CF_LOCK_THREAD = (1 << 6),
+	CF_WAIT_FOR_ME = (1 << 6),
 	CF_BRIDGED = (1 << 7),
 	CF_HOLD = (1 << 8),
 	CF_SERVICE = (1 << 9),

Modified: freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/applications/mod_commands/mod_commands.c	Wed May 16 12:53:25 2007
@@ -575,7 +575,7 @@
 		stream->write_function(stream, "-Error Cannot locate session!\n");
 		return SWITCH_STATUS_SUCCESS;
 	}
-
+	
 	if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
 		goto usage;
 	}
@@ -594,11 +594,11 @@
 
 	stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
 	switch_safe_free(mycmd);
-	return SWITCH_STATUS_SUCCESS;
+
 
   done:
 
-	if (session) {
+	if (rsession) {
 		switch_core_session_rwunlock(rsession);
 	}
 

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.c	Wed May 16 12:53:25 2007
@@ -39,7 +39,7 @@
 #include "mod_sofia.h"
 
 struct mod_sofia_globals mod_sofia_globals;
-
+const switch_endpoint_interface_t sofia_endpoint_interface;
 static switch_frame_t silence_frame = { 0 };
 static char silence_data[13] = "";
 
@@ -690,6 +690,11 @@
 			switch_core_session_t *other_session;
 			switch_channel_t *other_channel;
 			char *ip = NULL, *port = NULL;
+
+			if (switch_channel_get_state(channel) >= CS_HANGUP) {
+				return SWITCH_STATUS_FALSE;
+			}
+
 			switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
 			tech_pvt->local_sdp_str = NULL;
 			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -710,6 +715,11 @@
 		break;
 	case SWITCH_MESSAGE_INDICATE_MEDIA:{
 		uint32_t count = 0;
+
+		if (switch_channel_get_state(channel) >= CS_HANGUP) {
+			return SWITCH_STATUS_FALSE;
+		}
+
 		switch_channel_clear_flag(channel, CF_BYPASS_MEDIA);
 			tech_pvt->local_sdp_str = NULL;
 			if (!switch_rtp_ready(tech_pvt->rtp_session)) {

Modified: freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/branches/greenlizard/src/mod/endpoints/mod_sofia/mod_sofia.h	Wed May 16 12:53:25 2007
@@ -456,7 +456,7 @@
 void sofia_glue_do_xfer_invite(switch_core_session_t *session);
 uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, 
 								  sofia_regtype_t regtype, char *key, uint32_t keylen, switch_event_t **v_event);
-const switch_endpoint_interface_t sofia_endpoint_interface;
+extern const switch_endpoint_interface_t sofia_endpoint_interface;
 void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
 switch_status_t sofia_on_hangup(switch_core_session_t *session);
 char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup);

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	Wed May 16 12:53:25 2007
@@ -327,10 +327,21 @@
 	}
 
 	if (authorization) {
+		char *v_contact_str;
 		if ((auth_res = sofia_reg_parse_auth(profile, authorization, sip->sip_request->rq_method_name, key, keylen, network_ip, v_event)) == AUTH_STALE) {
 			stale = 1;
 		}
 		
+		if (v_event && *v_event && (v_contact_str = switch_event_get_header(*v_event, "force-contact"))) {
+			char *p;
+			switch_copy_string(contact_str, v_contact_str, sizeof(contact_str));
+			for(p = contact_str; p && *p; p++) {
+				if (*p == '\'' || *p == '[' || *p == ']') {
+					*p = '"';
+				}
+			}
+		}
+
 		if (auth_res != AUTH_OK && !stale) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "send %s for [%s@%s]\n", forbidden ? "forbidden" : "challange", from_user, from_host);
 			if (auth_res == AUTH_FORBIDDEN) {
@@ -459,6 +470,7 @@
 void sofia_reg_handle_sip_i_register(nua_t * nua, sofia_profile_t *profile, nua_handle_t * nh, sofia_private_t * sofia_private, sip_t const *sip, tagi_t tags[])
 {
 	char key[128] = "";
+	switch_event_t *v_event = NULL;
 
 	if (!sip || !sip->sip_request || !sip->sip_request->rq_method_name) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received an invalid packet!\n");
@@ -472,7 +484,10 @@
 		return;
 	}
 
-	sofia_reg_handle_register(nua, profile, nh, sip, REG_REGISTER, key, sizeof(key), NULL);
+	sofia_reg_handle_register(nua, profile, nh, sip, REG_REGISTER, key, sizeof(key), &v_event);
+	if (v_event) {
+		switch_event_fire(&v_event);
+	}
 }
 
 

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	Wed May 16 12:53:25 2007
@@ -2678,14 +2678,17 @@
 
 static JSBool js_api_execute(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
-
-	if (argc > 1) {
+	if (argc > 0) {
 		char *cmd = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
-		char *arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		char *arg = NULL;
 		switch_core_session_t *session = NULL;
 		switch_stream_handle_t stream = { 0 };
 		char retbuf[2048] = "";
 
+		if (argc > 1) {
+			arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		}
+		
 		if (argc > 2) {
 			JSObject *session_obj;
 			struct js_session *jss;
@@ -2801,6 +2804,7 @@
 
 static JSFunctionSpec fs_functions[] = {
 	{"console_log", js_log, 2},
+	{"consoleLog", js_log, 2},
 	{"exit", js_exit, 0},
 	{"include", js_include, 1},
 	{"bridge", js_bridge, 2},
@@ -2853,6 +2857,9 @@
 		/* Emaculent conception of session object into the script if one is available */
 		if (session && new_js_session(cx, javascript_global_object, session, &jss, "session", flags)) {
 			JS_SetPrivate(cx, javascript_global_object, session);
+		} else {
+			snprintf(buf, sizeof(buf), "~var session = false;");
+			eval_some_js(buf, cx, javascript_global_object, &rval);
 		}
 		if (ro) {
 			new_request(cx, javascript_global_object, ro);

Modified: freeswitch/branches/greenlizard/src/switch_console.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_console.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_console.c	Wed May 16 12:53:25 2007
@@ -176,6 +176,7 @@
 }
 
 static char hostname[256] = "";
+static int32_t running = 1;
 
 #ifdef SWITCH_HAVE_LIBEDIT
 #include <histedit.h>
@@ -191,33 +192,16 @@
 	
 }
 
-SWITCH_DECLARE(void) switch_console_loop(void)
+static EditLine *el;
+static History *myhistory;
+static HistEvent ev;
+static char *hfile = NULL;
+
+static void *SWITCH_THREAD_FUNC console_thread(switch_thread_t *thread, void *obj)
 {
-	EditLine *el;
-	History *myhistory;
 	int count;
 	const char *line;
-	HistEvent ev;
-	int32_t running = 1;
-	char *hfile;
-
-	el = el_init(__FILE__, switch_core_get_console(), switch_core_get_console(), switch_core_get_console());
-	el_set(el, EL_PROMPT, &prompt);
-	el_set(el, EL_EDITOR, "emacs");
-
-	myhistory = history_init();
-	if (myhistory == 0) {
-		fprintf(stderr, "history could not be initialized\n");
-		return;
-	}
-
-	hfile = switch_mprintf("%s%sfreeswitch.history", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);
-	assert(hfile != NULL);
-
-	
-	history(myhistory, &ev, H_SETSIZE, 800);
-	el_set(el, EL_HIST, history, myhistory);
-	history(myhistory, &ev, H_LOAD, hfile);
+	switch_memory_pool_t *pool = (switch_memory_pool_t *) obj;
 
 	while (running) {
 		uint32_t arg;
@@ -245,15 +229,63 @@
 		}
 	}
 	
+  	switch_core_destroy_memory_pool(&pool);	
+	return NULL;
+}
 
-	history(myhistory, &ev, H_SAVE, hfile);
 
+SWITCH_DECLARE(void) switch_console_loop(void)
+{
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
+	switch_memory_pool_t *pool;
+	
+	if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
+		return;
+	}
+	
+	el = el_init(__FILE__, switch_core_get_console(), switch_core_get_console(), switch_core_get_console());
+	el_set(el, EL_PROMPT, &prompt);
+	el_set(el, EL_EDITOR, "emacs");
+
+	myhistory = history_init();
+	if (myhistory == 0) {
+		fprintf(stderr, "history could not be initialized\n");
+		return;
+	}
+
+	hfile = switch_mprintf("%s%sfreeswitch.history", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);
+	assert(hfile != NULL);
+
+	
+	history(myhistory, &ev, H_SETSIZE, 800);
+	el_set(el, EL_HIST, history, myhistory);
+	history(myhistory, &ev, H_LOAD, hfile);
+
+
+	switch_threadattr_create(&thd_attr, pool);
+	switch_threadattr_detach_set(thd_attr, 1);
+	switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+	switch_thread_create(&thread, thd_attr, console_thread, pool, pool);
+	
+	while (running) {
+		uint32_t arg = 0;
+		switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
+		if (!arg) {
+			break;
+		}
+		switch_yield(1000000);
+	}
+
+	history(myhistory, &ev, H_SAVE, hfile);
 	free(hfile);
 	
 	/* Clean up our memory */
 	history_end(myhistory);
 	el_end(el);
-  	
+
+
 }
 
 #else
@@ -262,7 +294,7 @@
 {
 
 	char cmd[2048];
-	int32_t activity = 1, running = 1;
+	int32_t activity = 1;
 	switch_size_t x = 0;
 
 	gethostname(hostname, sizeof(hostname));

Modified: freeswitch/branches/greenlizard/src/switch_core.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core.c	Wed May 16 12:53:25 2007
@@ -35,7 +35,7 @@
 
 #include <switch.h>
 #include <switch_version.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = { 0 };
 

Modified: freeswitch/branches/greenlizard/src/switch_core_asr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_asr.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_asr.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,
 													 char *module_name,

Modified: freeswitch/branches/greenlizard/src/switch_core_codec.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_codec.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_codec.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
 {

Modified: freeswitch/branches/greenlizard/src/switch_core_db.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_db.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_db.c	Wed May 16 12:53:25 2007
@@ -31,7 +31,7 @@
  */
 
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 #include <sqlite3.h>
 

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	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh,
 														   char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool)

Modified: freeswitch/branches/greenlizard/src/switch_core_event_hook.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_event_hook.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_event_hook.c	Wed May 16 12:53:25 2007
@@ -29,7 +29,7 @@
  *
  */
 #include "switch.h"
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_event_hook_add_outgoing(switch_core_session_t *session, switch_outgoing_channel_hook_t outgoing_channel)
 {

Modified: freeswitch/branches/greenlizard/src/switch_core_file.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_file.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_file.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_file_open(switch_file_handle_t *fh,
 													  char *file_path, uint8_t channels, uint32_t rate, unsigned int flags, switch_memory_pool_t *pool)

Modified: freeswitch/branches/greenlizard/src/switch_core_hash.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_hash.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_hash.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_hash_init(switch_hash_t ** hash, switch_memory_pool_t *pool)
 {

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	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, int stream_id)

Modified: freeswitch/branches/greenlizard/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_media_bug.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_media_bug.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include "switch.h"
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
 {

Modified: freeswitch/branches/greenlizard/src/switch_core_memory.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_memory.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_memory.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 static struct {
 	switch_memory_pool_t *memory_pool;

Modified: freeswitch/branches/greenlizard/src/switch_core_port_allocator.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_port_allocator.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_port_allocator.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 struct switch_core_port_allocator {
 	switch_port_t start;

Modified: freeswitch/branches/greenlizard/src/switch_core_rwlock.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_rwlock.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_rwlock.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 #ifdef SWITCH_DEBUG_RWLOCKS
 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(switch_core_session_t *session, const char *file, const char *func, int line)

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	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 static struct {
 	switch_memory_pool_t *memory_pool;
@@ -500,13 +500,13 @@
 	return status;
 }
 
-SWITCH_DECLARE(int32_t) switch_core_session_event_count(switch_core_session_t *session)
+SWITCH_DECLARE(uint32_t) switch_core_session_event_count(switch_core_session_t *session)
 {
 	if (session->event_queue) {
-		return (int32_t) switch_queue_size(session->event_queue);
+		return switch_queue_size(session->event_queue);
 	}
 
-	return -1;
+	return 0;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(switch_core_session_t *session, switch_event_t **event)
@@ -547,13 +547,13 @@
 	return status;
 }
 
-SWITCH_DECLARE(int32_t) switch_core_session_private_event_count(switch_core_session_t *session)
+SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(switch_core_session_t *session)
 {
 	if (session->private_event_queue) {
-		return (int32_t) switch_queue_size(session->private_event_queue);
+		return switch_queue_size(session->private_event_queue);
 	}
-
-	return -1;
+	
+	return 0;
 }
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch_core_session_t *session, switch_event_t **event)
@@ -581,6 +581,7 @@
 	return status;
 }
 
+
 SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session)
 {
 	switch_channel_t *channel;

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	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 {

Modified: freeswitch/branches/greenlizard/src/switch_core_sqldb.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_sqldb.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_sqldb.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 static struct {
 	switch_core_db_t *db;

Modified: freeswitch/branches/greenlizard/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_state_machine.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_state_machine.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 static void switch_core_standard_on_init(switch_core_session_t *session)
 {

Modified: freeswitch/branches/greenlizard/src/switch_core_timer.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_core_timer.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_core_timer.c	Wed May 16 12:53:25 2007
@@ -32,7 +32,7 @@
  *
  */
 #include <switch.h>
-#include "private/switch_core.h"
+#include "private/switch_core_pvt.h"
 
 SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, char *timer_name, int interval, int samples, switch_memory_pool_t *pool)
 {

Modified: freeswitch/branches/greenlizard/src/switch_ivr.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr.c	Wed May 16 12:53:25 2007
@@ -374,6 +374,23 @@
 
 }
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
+{
+	switch_event_t *event;
+	switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(session);
+    assert(channel != NULL);
+
+	while (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+		switch_ivr_parse_event(session, event);
+		switch_event_fire(&event);
+	}
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args)
 {
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
@@ -383,6 +400,7 @@
 	switch_event_t *event;
 	switch_unicast_conninfo_t *conninfo = NULL;
 	switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
+
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -467,10 +485,8 @@
 				}
 			}
 			
-			if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
-				switch_ivr_parse_event(session, event);
-				switch_channel_event_set_data(switch_core_session_get_channel(session), event);
-				switch_event_fire(&event);
+			if (switch_core_session_private_event_count(session)) {
+				switch_ivr_parse_all_events(session);
 			}
 
 			if (switch_channel_has_dtmf(channel)) {
@@ -540,10 +556,9 @@
 			}
 		}
 
-		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
-			switch_ivr_parse_event(session, event);
-			switch_event_destroy(&event);
-		}
+		if (switch_core_session_private_event_count(session)) {
+            switch_ivr_parse_all_events(session);
+        }
 
 		if (switch_channel_has_dtmf(channel)) {
 			switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
@@ -606,8 +621,7 @@
 
 	while (switch_channel_ready(channel)) {
 		switch_frame_t *read_frame;
-		switch_event_t *event;
-
+		
 		if (timeout) {
 			elapsed = (uint32_t) ((switch_time_now() - started) / 1000);
 			if (elapsed >= timeout) {
@@ -615,10 +629,9 @@
 			}
 		}
 
-		if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
-			switch_ivr_parse_event(session, event);
-			switch_event_destroy(&event);
-		}
+        if (switch_core_session_private_event_count(session)) {
+            switch_ivr_parse_all_events(session);
+        }
 
 		if (switch_channel_has_dtmf(channel)) {
 			char dtmf[128];
@@ -776,7 +789,7 @@
 	switch_core_session_message_t msg = { 0 };
 	switch_status_t status = SWITCH_STATUS_GENERR;
 	uint8_t swap = 0;
-
+	
 	msg.message_id = SWITCH_MESSAGE_INDICATE_NOMEDIA;
 	msg.from = __FILE__;
 
@@ -790,16 +803,23 @@
 		}
 
 		if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
-			switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
-			switch_core_session_receive_message(session, &msg);
+			switch_ivr_parse_all_events(session);
+			
 			if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
 				(other_session = switch_core_session_locate(other_uuid))) {
 				other_channel = switch_core_session_get_channel(other_session);
 				assert(other_channel != NULL);
+				
+				switch_ivr_parse_all_events(other_session);
+
 				switch_core_session_receive_message(other_session, &msg);
 				switch_channel_clear_state_handler(other_channel, NULL);
-
+				
 			}
+
+			switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
+			switch_core_session_receive_message(session, &msg);
+
 			if (other_channel) {
 				switch_channel_clear_state_handler(channel, NULL);
 				if (swap) {

Modified: freeswitch/branches/greenlizard/src/switch_ivr_async.c
==============================================================================
--- freeswitch/branches/greenlizard/src/switch_ivr_async.c	(original)
+++ freeswitch/branches/greenlizard/src/switch_ivr_async.c	Wed May 16 12:53:25 2007
@@ -771,7 +771,7 @@
 
 	if ((session = switch_core_session_locate(uuid))) {
 		char *cause = NULL;
-		char *mypath = strdup(path);
+		char *mypath;
 		char *p;
 
 		master = session;
@@ -779,6 +779,16 @@
 		channel = switch_core_session_get_channel(session);
 		assert(channel != NULL);
 
+		if ((switch_channel_test_flag(channel, CF_EVENT_PARSE))) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Channel [%s] already broadcasting...broadcast aborted\n", 
+							  switch_channel_get_name(channel));
+			switch_core_session_rwunlock(session);
+			return SWITCH_STATUS_FALSE;
+		}
+
+		mypath = strdup(path);
+
+
 		if ((nomedia = switch_channel_test_flag(channel, CF_BYPASS_MEDIA))) {
 			switch_ivr_media(uuid, SMF_REBRIDGE);
 		}

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	Wed May 16 12:53:25 2007
@@ -55,6 +55,7 @@
 	switch_channel_t *chan_a, *chan_b;
 	switch_frame_t *read_frame;
 	switch_core_session_t *session_a, *session_b;
+	uint32_t loop_count = 0;
 
 	session_a = data->session;
 	if (!(session_b = switch_core_session_locate(data->b_uuid))) {
@@ -80,6 +81,7 @@
 		switch_channel_state_t b_state;
 		switch_status_t status;
 		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)) {
@@ -96,24 +98,22 @@
 			break;
 		}
 
-		if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
-			switch_yield(100000);
-			continue;
-		}
-
-		if (switch_core_session_dequeue_private_event(session_a, &event) == SWITCH_STATUS_SUCCESS) {
+		if (loop_count > 10 && switch_core_session_private_event_count(session_a)) {
 			switch_channel_set_flag(chan_b, CF_SUSPEND);
 			msg.string_arg = data->b_uuid;
 			msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
 			msg.from = __FILE__;
 			switch_core_session_receive_message(session_a, &msg);
-			switch_ivr_parse_event(session_a, event);
+			switch_ivr_parse_all_events(session_a);
 			msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
 			switch_core_session_receive_message(session_a, &msg);
 			switch_channel_clear_flag(chan_b, CF_SUSPEND);
-			switch_event_destroy(&event);
 		}
 		
+		if (switch_channel_test_flag(chan_a, CF_SUSPEND) || switch_channel_test_flag(chan_b, CF_SUSPEND)) {
+			switch_yield(1000);
+			continue;
+		}
 
 		/* if 1 channel has DTMF pass it to the other */
 		if (switch_channel_has_dtmf(chan_a)) {
@@ -644,14 +644,14 @@
 			switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
 			switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);
 
-			/* release the read locks we have on the channels */
-			switch_core_session_rwunlock(originator_session);
-			switch_core_session_rwunlock(originatee_session);
-
 			/* change the states and let the chips fall where they may */
 			switch_channel_set_state(originator_channel, CS_TRANSMIT);
 			switch_channel_set_state(originatee_channel, CS_TRANSMIT);
 
+			/* release the read locks we have on the channels */
+			switch_core_session_rwunlock(originator_session);
+			switch_core_session_rwunlock(originatee_session);
+
 			status = SWITCH_STATUS_SUCCESS;
 
 			while (switch_channel_get_state(originatee_channel) < CS_HANGUP && switch_channel_test_flag(originatee_channel, CF_TAGGED)) {



More information about the Freeswitch-branches mailing list