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

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12479 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-03-06 03:54:38 +00:00
parent 8f9637d3f4
commit 1ea293ff56
5 changed files with 69 additions and 68 deletions

View File

@ -1961,7 +1961,6 @@ SWITCH_STANDARD_APP(audio_bridge_function)
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_STANDARD_APP(audio_bridge_function)
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 @@ SWITCH_STANDARD_APP(audio_bridge_function)
}
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);
} 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;
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);
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);
}
end:
if (peer_session) {
switch_core_session_rwunlock(peer_session);
}

View File

@ -97,6 +97,8 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
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 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
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 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
}
}
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 @@ static int parse_exten(switch_core_session_t *session, switch_caller_profile_t *
}
}
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 @@ SWITCH_STANDARD_DIALPLAN(dialplan_hunt)
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);

View File

@ -1299,10 +1299,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
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 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
}
}
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));

View File

@ -156,9 +156,6 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
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) {

View File

@ -250,7 +250,8 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
}
#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;
}