[Freeswitch-svn] [commit] r11079 - in freeswitch/trunk/src: . mod/applications/mod_conference mod/endpoints/mod_sofia

FreeSWITCH SVN anthm at freeswitch.org
Tue Jan 6 13:07:58 PST 2009


Author: anthm
Date: Tue Jan  6 15:07:58 2009
New Revision: 11079

Log:
fix some media issues (shoud go into the 1.0 branch)

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/switch_core_io.c
   freeswitch/trunk/src/switch_ivr.c
   freeswitch/trunk/src/switch_ivr_async.c

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Tue Jan  6 15:07:58 2009
@@ -1552,6 +1552,13 @@
 	   and mux it with any audio from other channels. */
 
 	while (switch_test_flag(member, MFLAG_RUNNING) && switch_channel_ready(channel)) {
+
+		if (switch_channel_test_flag(channel, CF_SERVICE)) {
+			switch_yield(100000);
+			continue;
+		}
+
+
 		/* Read a frame. */
 		status = switch_core_session_read_frame(member->session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
 
@@ -2037,9 +2044,18 @@
 			}
 			switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
 		}
-
+		
 		switch_mutex_unlock(member->flag_mutex);
 
+
+		if (switch_core_session_private_event_count(member->session)) {
+			switch_channel_set_flag(channel, CF_SERVICE);
+			switch_ivr_parse_all_events(member->session);
+			switch_channel_clear_flag(channel, CF_SERVICE);
+			switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
+			switch_core_session_set_read_codec(member->session, &member->read_codec);
+		}
+		
 		if (use_timer) {
 			switch_core_timer_next(&timer);
 		} else {

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Tue Jan  6 15:07:58 2009
@@ -3562,6 +3562,22 @@
 
 				/* print debug info */
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%c)\n", dtmf.digit);
+				
+				if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+					const char *uuid;
+					switch_core_session_t *session_b;
+					
+					if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
+						while (switch_channel_has_dtmf(channel)) {
+							switch_dtmf_t idtmf = { 0, 0 };
+							if (switch_channel_dequeue_dtmf(channel, &idtmf) == SWITCH_STATUS_SUCCESS) {
+								switch_core_session_send_dtmf(session_b, &idtmf);
+							}
+						}
+
+						switch_core_session_rwunlock(session_b);
+					}
+				}
 
 				/* Send 200 OK response */
 				nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Tue Jan  6 15:07:58 2009
@@ -539,10 +539,6 @@
 	switch_mutex_unlock(session->read_codec->mutex);
 	switch_mutex_unlock(session->codec_read_mutex);
 
-	if (switch_core_session_private_event_count(session)) {
-		switch_ivr_parse_all_events(session);
-	}
-
 	return status;
 }
 

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue Jan  6 15:07:58 2009
@@ -54,9 +54,10 @@
 	int sval = 0;
 	const char *var;
 	
-	if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
+	if (switch_channel_media_ready(channel) && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
+		switch_channel_pre_answer(channel);
 		switch_core_session_get_read_impl(session, &imp);
-	
+		
 		if (switch_core_codec_init(&codec,
 								   "L16",
 								   NULL,

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Tue Jan  6 15:07:58 2009
@@ -1445,6 +1445,44 @@
 
 #define SWITCH_META_VAR_KEY "__dtmf_meta"
 
+typedef struct {
+	switch_core_session_t *session;
+	const char *app;
+	int flags;
+} bch_t;
+
+static void *SWITCH_THREAD_FUNC bcast_thread(switch_thread_t *thread, void *obj)
+{
+	bch_t *bch = (bch_t *) obj;
+
+	switch_ivr_broadcast(switch_core_session_get_uuid(bch->session), bch->app, bch->flags);
+
+	return NULL;
+
+}
+static void broadcast_in_thread(switch_core_session_t *session, const char *app, int flags)
+{
+	switch_thread_t *thread;
+	switch_threadattr_t *thd_attr = NULL;
+	switch_memory_pool_t *pool;
+	bch_t *bch;
+	
+	switch_assert(session);
+
+	pool = switch_core_session_get_pool(session);
+	
+	bch = switch_core_session_alloc(session, sizeof(*bch));
+	bch->session = session;
+	bch->app = app;
+	bch->flags = flags;
+	
+	
+	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, bcast_thread, bch, pool);
+}
+
 static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf, switch_dtmf_direction_t direction)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -1497,7 +1535,7 @@
 
 			if (ok && md->sr[direction].map[dval].app) {
 				uint32_t flags = md->sr[direction].map[dval].flags;
-
+				
 				if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_OPPOSITE)) {
 					if (direction == SWITCH_DTMF_SEND) {
 						flags |= SMF_ECHO_ALEG;
@@ -1520,7 +1558,12 @@
 
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
 								  switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app);
-				switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags);
+
+				if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+					broadcast_in_thread(session, md->sr[direction].map[dval].app, flags | SMF_REBRIDGE);
+				} else {
+					switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags);
+				}
 
 				if ((md->sr[direction].map[dval].bind_flags & SBF_ONCE)) {
 					memset(&md->sr[direction].map[dval], 0, sizeof(md->sr[direction].map[dval]));
@@ -1589,7 +1632,7 @@
 			md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
 			md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
 			md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
-
+			
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Bound A-Leg: %d %s\n", key, app);
 		}
 		if ((bind_flags & SBF_DIAL_BLEG)) {
@@ -2157,6 +2200,10 @@
 		other_session = NULL;
 	}
 
+	if (switch_stristr("record", app)) {
+		nomedia = 0;
+	}
+
 	if ((flags & SMF_ECHO_ALEG)) {
 		if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
 			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "execute");



More information about the Freeswitch-svn mailing list