From 93c2ed941a5c659f701dd8987e23dbb3156f1daa Mon Sep 17 00:00:00 2001 From: Anthony Minessale <anthm@freeswitch.org> Date: Wed, 13 Oct 2010 16:17:36 -0500 Subject: [PATCH] silent recovery --- src/include/switch_types.h | 1 + .../mod_conference/mod_conference.c | 21 ++++++++++++------- src/mod/endpoints/mod_sofia/sofia_glue.c | 5 ++++- src/switch_channel.c | 12 +++++++++++ src/switch_core_session.c | 4 +++- src/switch_core_state_machine.c | 6 +++++- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index d027549bce..cf27cb747e 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1063,6 +1063,7 @@ typedef enum { CF_CONSUME_ON_ORIGINATE, CF_PASSTHRU_PTIME_MISMATCH, CF_BRIDGE_NOWRITE, + CF_RECOVERED, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index ac57dc0c15..64a76d4226 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -698,20 +698,21 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_clear_flag(conference, CFLAG_WAIT_MOD); } + channel = switch_core_session_get_channel(member->session); + switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id); + if (conference->count > 1) { if (conference->moh_sound && !switch_test_flag(conference, CFLAG_WAIT_MOD)) { /* stop MoH if any */ conference_stop_file(conference, FILE_STOP_ASYNC); } - if (conference->enter_sound) { + if (conference->enter_sound && (!switch_channel_test_flag(channel, CF_RECOVERED) || + switch_true(switch_channel_get_variable(channel, "conference_silent_entry")))) { conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), switch_test_flag(conference, CFLAG_WAIT_MOD) ? 0 : 1); } } - channel = switch_core_session_get_channel(member->session); - switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id); - call_list = (call_list_t *) switch_channel_get_private(channel, "_conference_autocall_list_"); @@ -720,7 +721,8 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_snprintf(saymsg, sizeof(saymsg), "Auto Calling %d parties", call_list->iteration); conference_member_say(member, saymsg, 0); } else { - if (zstr(conference->special_announce)) { + if (zstr(conference->special_announce) && (!switch_channel_test_flag(channel, CF_RECOVERED) || + switch_true(switch_channel_get_variable(channel, "conference_silent_entry")))) { /* announce the total number of members in the conference */ if (conference->count >= conference->announce_count && conference->announce_count > 1) { switch_snprintf(msg, sizeof(msg), "There are %d callers", conference->count); @@ -750,7 +752,8 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe switch_set_flag(conference, CFLAG_ENFORCE_MIN); } - if (test_eflag(conference, EFLAG_ADD_MEMBER) && + if (test_eflag(conference, EFLAG_ADD_MEMBER) && (!switch_channel_test_flag(channel, CF_RECOVERED) || + switch_true(switch_channel_get_variable(channel, "conference_silent_entry"))) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "add-member"); @@ -2408,7 +2411,8 @@ static void conference_loop_output(conference_member_t *member) const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix"); int to = 60; - if (ann) { + if (ann && (!switch_channel_test_flag(channel, CF_RECOVERED) || + switch_true(switch_channel_get_variable(channel, "conference_silent_entry")))) { member->conference->special_announce = switch_core_strdup(member->conference->pool, ann); } @@ -5657,7 +5661,8 @@ SWITCH_STANDARD_APP(conference_function) } } - if (conference->special_announce) { + if (conference->special_announce && (!switch_channel_test_flag(channel, CF_RECOVERED) || + switch_true(switch_channel_get_variable(channel, "conference_silent_entry")))) { conference_local_play_file(conference, session, conference->special_announce, CONF_DEFAULT_LEADIN, NULL, 0); } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index cb8b257e58..13d323f02c 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4999,7 +4999,10 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName for (param = switch_xml_child(x_extension, "application"); param; param = param->next) { const char *var = switch_xml_attr_soft(param, "app_name"); const char *val = switch_xml_attr_soft(param, "app_data"); - switch_caller_extension_add_application(session, extension, var, val); + /* skip announcement type apps */ + if (strcasecmp(var, "speak") && strcasecmp(var, "playback") && strcasecmp(var, "gentones" || strcasecmp(var, "say"))) { + switch_caller_extension_add_application(session, extension, var, val); + } } } diff --git a/src/switch_channel.c b/src/switch_channel.c index 9e76b46a5a..0b1b6e8f82 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1335,6 +1335,10 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw switch_channel_set_variable(channel, "is_outbound", "true"); } + if (flag == CF_RECOVERED) { + switch_channel_set_variable(channel, "recovered", "true"); + } + } SWITCH_DECLARE(void) switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag) @@ -1349,6 +1353,10 @@ SWITCH_DECLARE(void) switch_channel_set_flag_recursive(switch_channel_t *channel if (flag == CF_OUTBOUND) { switch_channel_set_variable(channel, "is_outbound", "true"); } + + if (flag == CF_RECOVERED) { + switch_channel_set_variable(channel, "recovered", "true"); + } } @@ -1461,6 +1469,10 @@ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch if (flag == CF_OUTBOUND) { switch_channel_set_variable(channel, "is_outbound", NULL); } + + if (flag == CF_RECOVERED) { + switch_channel_set_variable(channel, "recovered", NULL); + } } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index c8aca7dbc6..1589bebb67 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1437,7 +1437,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e } } } - + if ((callflow = switch_xml_child(xml, "callflow"))) { if ((tag2 = switch_xml_child(callflow, "caller_profile"))) { switch_caller_profile_t *caller_profile; @@ -1528,6 +1528,8 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e } + + switch_channel_set_flag(channel, CF_RECOVERED); } diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 2b8a6ced16..27579c2fb4 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -156,9 +156,13 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard EXECUTE\n", switch_channel_get_name(session->channel)); + if (switch_channel_get_variable(session->channel, "recovered") && !switch_channel_test_flag(session->channel, CF_RECOVERED)) { + switch_channel_set_flag(session->channel, CF_RECOVERED); + } + top: switch_channel_clear_flag(session->channel, CF_RESET); - + if ((extension = switch_channel_get_caller_extension(session->channel)) == 0) { switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING); return;