[Freeswitch-trunk] [commit] r12479 - in freeswitch/trunk/src: . mod/applications/mod_dptools mod/dialplans/mod_dialplan_xml

FreeSWITCH SVN anthm at freeswitch.org
Thu Mar 5 19:54:38 PST 2009


Author: anthm
Date: Thu Mar  5 21:54:38 2009
New Revision: 12479

Log:
refactor dialplan logging lines and consolidate some logic for bypass_media mode when the a leg has audio in advance

Modified:
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_core_state_machine.c
   freeswitch/trunk/src/switch_ivr_bridge.c

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Thu Mar  5 21:54:38 2009
@@ -1961,7 +1961,6 @@
 	switch_core_session_t *peer_session = NULL;
 	unsigned int timelimit = 60;
 	const char *var, *continue_on_fail = NULL, *failure_causes = NULL;
-	uint8_t no_media_bridge = 0;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	if (switch_strlen_zero(data)) {
@@ -1989,8 +1988,10 @@
 				switch_ivr_media(switch_core_session_get_uuid(session), SMF_REBRIDGE);
 				switch_channel_set_flag(caller_channel, CF_PROXY_MODE);
 			} else {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying proxy mode 'till both legs are up.\n");
-				no_media_bridge = 1;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel is already up, delaying proxy mode 'till both legs are answered.\n");
+				switch_channel_set_variable(caller_channel, "bypass_media_after_bridge", "true");
+				switch_channel_set_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE, NULL);
+				switch_channel_clear_flag(caller_channel, CF_PROXY_MODE);
 			}
 		}
 	}
@@ -2032,60 +2033,35 @@
 		}
 		return;
 	} else {
-		if (no_media_bridge) {
-			switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-			switch_frame_t *read_frame;
-			/* SIP won't let us redir media until the call has been answered #$^#%& so we will proxy any early media until they do */
-			while (switch_channel_ready(caller_channel) && switch_channel_ready(peer_channel)
-				   && !switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
-				switch_status_t status = switch_core_session_read_frame(peer_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
-				uint8_t bad = 1;
-
-				if (SWITCH_READ_ACCEPTABLE(status)
-					&& switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0) == SWITCH_STATUS_SUCCESS) {
-					bad = 0;
-				}
-				if (bad) {
-					switch_channel_hangup(caller_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-					switch_channel_hangup(peer_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-					goto end;
-				}
-			}
-
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting media to proxy mode.\n");
-			switch_ivr_nomedia(switch_core_session_get_uuid(session), SMF_FORCE);
-			switch_ivr_nomedia(switch_core_session_get_uuid(peer_session), SMF_FORCE);
+		
+		if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
 			switch_ivr_signal_bridge(session, peer_session);
 		} else {
-			if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
-				switch_ivr_signal_bridge(session, peer_session);
+			switch_channel_t *channel = switch_core_session_get_channel(session);
+			switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
+			char *a_key = (char *) switch_channel_get_variable(channel, "bridge_terminate_key");
+			char *b_key = (char *) switch_channel_get_variable(peer_channel, "bridge_terminate_key");
+			int ok = 0;
+			switch_input_callback_function_t func = NULL;
+
+			if (a_key) {
+				a_key = switch_core_session_strdup(session, a_key);
+				ok++;
+			}
+			if (b_key) {
+				b_key = switch_core_session_strdup(session, b_key);
+				ok++;
+			}
+			if (ok) {
+				func = bridge_on_dtmf;
 			} else {
-				switch_channel_t *channel = switch_core_session_get_channel(session);
-				switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session);
-				char *a_key = (char *) switch_channel_get_variable(channel, "bridge_terminate_key");
-				char *b_key = (char *) switch_channel_get_variable(peer_channel, "bridge_terminate_key");
-				int ok = 0;
-				switch_input_callback_function_t func = NULL;
-
-				if (a_key) {
-					a_key = switch_core_session_strdup(session, a_key);
-					ok++;
-				}
-				if (b_key) {
-					b_key = switch_core_session_strdup(session, b_key);
-					ok++;
-				}
-				if (ok) {
-					func = bridge_on_dtmf;
-				} else {
-					a_key = NULL;
-					b_key = NULL;
-				}
-
-				switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, a_key);
+				a_key = NULL;
+				b_key = NULL;
 			}
+
+			switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, a_key);
 		}
-	  end:
+		
 		if (peer_session) {
 			switch_core_session_rwunlock(peer_session);
 		}

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Thu Mar  5 21:54:38 2009
@@ -97,6 +97,8 @@
 				do_break_i = BREAK_ALWAYS;
 			} else if (!strcasecmp(do_break_a, "never")) {
 				do_break_i = BREAK_NEVER;
+			} else {
+				do_break_a = NULL;
 			}
 		}
 
@@ -114,14 +116,23 @@
 			if (!field_data) {
 				field_data = "";
 			}
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex: [%s] %s(%s) =~ /%s/\n", exten_name, field, field_data, expression);
-			if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
-
+			
+			if ((proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+								  "Dialplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n", 
+								  switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+								  "Dialplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n", 
+								  switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
 				for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
 					char *application = (char *) switch_xml_attr_soft(xaction, "application");
 					char *data = (char *) switch_xml_attr_soft(xaction, "data");
-
+					
+					switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+									  "Dialplan: %s ANTI-Action %s(%s)\n", 
+									  switch_channel_get_name(channel), application, data);
+					
 					if (!*extension) {
 						if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
@@ -141,6 +152,10 @@
 				}
 			}
 			assert(re != NULL);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+							  "Dialplan: %s Absolute Condition [%s]\n", 
+							  switch_channel_get_name(channel), exten_name);
 		}
 
 		for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
@@ -178,6 +193,10 @@
 				}
 			}
 
+			switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+							  "Dialplan: %s Action %s(%s)\n", 
+							  switch_channel_get_name(channel), application, app_data);
+
 			switch_caller_extension_add_application(session, *extension, application, app_data);
 			switch_safe_free(substituted);
 		}
@@ -275,7 +294,16 @@
 
 	while (xexten) {
 		int proceed = 0;
-		char *cont = (char *) switch_xml_attr_soft(xexten, "continue");
+		const char *cont = switch_xml_attr(xexten, "continue");
+		const char *exten_name = switch_xml_attr(xexten, "name");
+
+		if (!exten_name) {
+			exten_name = "UNKNOWN";
+		}
+
+		switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, 
+						  "Dialplan: %s parsing [%s->%s] continue=%s\n", 
+						  switch_channel_get_name(channel), caller_profile->context, exten_name, cont ? cont : "false");
 
 		proceed = parse_exten(session, caller_profile, xexten, &extension);
 

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Thu Mar  5 21:54:38 2009
@@ -1299,10 +1299,13 @@
 
 	app = application_interface->interface_name;
 	
-	if (arg && (expanded = switch_channel_expand_variables(session->channel, arg)) != arg) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Expanded String %s(%s)\n", switch_channel_get_name(session->channel), app, expanded);
+	if (arg) {
+		expanded = switch_channel_expand_variables(session->channel, arg);
 	}
 
+	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, "EXECUTE %s %s(%s)\n", 
+					  switch_channel_get_name(session->channel), app, switch_str_nil(expanded));
+
 	if ((var = switch_channel_get_variable(session->channel, "verbose_presence")) && switch_true(var)) {
 		char *myarg = NULL;
 		if (expanded) {
@@ -1318,10 +1321,6 @@
 		}
 	}
 
-	if (!arg) {
-		arg = "";
-	}
-
 	if (!(var = switch_channel_get_variable(session->channel, SWITCH_DISABLE_APP_LOG_VARIABLE)) || (!(switch_true(var)))) {
 		log = switch_core_session_alloc(session, sizeof(*log));
 

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Thu Mar  5 21:54:38 2009
@@ -156,9 +156,6 @@
 
 		extension->current_application = extension->current_application->next;
 
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Execute %s(%s)\n", switch_channel_get_name(session->channel),
-						  current_application->application_name, switch_str_nil(current_application->application_data));
-
 		if (switch_core_session_execute_application(session,
 													current_application->application_name,
 													current_application->application_data) != SWITCH_STATUS_SUCCESS) {

Modified: freeswitch/trunk/src/switch_ivr_bridge.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_bridge.c	(original)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	Thu Mar  5 21:54:38 2009
@@ -250,7 +250,8 @@
 		}
 #endif
 
-		if (loop_count > DEFAULT_LEAD_FRAMES && bypass_media_after_bridge) {
+		if (loop_count > DEFAULT_LEAD_FRAMES && bypass_media_after_bridge && switch_channel_test_flag(chan_a, CF_ANSWERED) && 
+			switch_channel_test_flag(chan_b, CF_ANSWERED)) {
 			switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);
 			bypass_media_after_bridge = 0;
 		}



More information about the Freeswitch-trunk mailing list