diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 7d9f6af505..35973a74f8 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1507,8 +1507,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "strftime", NULL, NULL, strftime_function, NULL, SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "phrase", "Say a Phrase", "Say a Phrase", phrase_function, ",", SAF_NONE); SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA); - SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA); - SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_NONE); + SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "log", "Logs a channel variable", LOG_LONG_DESC, log_function, "", SAF_SUPPORT_NOMEDIA); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index b0b87faebf..a9a7860b23 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -712,13 +712,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi goto end; } - if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { - const char *var; - if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) { - switch_set_flag_locked(tech_pvt, TFLAG_SECURE); - } - } - switch (msg->message_id) { case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ: { @@ -794,10 +787,26 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_MEDIA: { - uint32_t count = 0; - + uint32_t count = 0, send_invite = 1; + switch_channel_clear_flag(channel, CF_PROXY_MODE); tech_pvt->local_sdp_str = NULL; + + if (!switch_channel_media_ready(channel)) { + if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) { + const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE); + + tech_pvt->num_codecs = 0; + sofia_glue_tech_prepare_codecs(tech_pvt); + if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) { + switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR"); + status = SWITCH_STATUS_FALSE; + goto end; + } + send_invite = 0; + } + } + if (!switch_rtp_ready(tech_pvt->rtp_session)) { sofia_glue_tech_prepare_codecs(tech_pvt); if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) { @@ -806,20 +815,22 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } } sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); - sofia_glue_do_invite(session); - /* wait for rtp to start and first real frame to arrive */ - tech_pvt->read_frame.datalen = 0; - while (switch_test_flag(tech_pvt, TFLAG_IO) && switch_channel_get_state(channel) < CS_HANGUP && !switch_rtp_ready(tech_pvt->rtp_session)) { - if (++count > 1000) { - status = SWITCH_STATUS_FALSE; - goto end; + if (send_invite) { + sofia_glue_do_invite(session); + /* wait for rtp to start and first real frame to arrive */ + tech_pvt->read_frame.datalen = 0; + while (switch_test_flag(tech_pvt, TFLAG_IO) && switch_channel_get_state(channel) < CS_HANGUP && !switch_rtp_ready(tech_pvt->rtp_session)) { + if (++count > 1000) { + status = SWITCH_STATUS_FALSE; + goto end; + } + if (!switch_rtp_ready(tech_pvt->rtp_session)) { + switch_yield(1000); + continue; + } + break; } - if (!switch_rtp_ready(tech_pvt->rtp_session)) { - switch_yield(1000); - continue; - } - break; } } break; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 77b0d21e5a..69ee786a14 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1422,11 +1422,18 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f uint32_t rtp_timeout_sec = tech_pvt->profile->rtp_timeout_sec; uint32_t rtp_hold_timeout_sec = tech_pvt->profile->rtp_hold_timeout_sec; char *timer_name; + const char *var; switch_assert(tech_pvt != NULL); switch_core_session_signal_lock(tech_pvt->session); + + if ((var = switch_channel_get_variable(tech_pvt->channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) { + switch_set_flag_locked(tech_pvt, TFLAG_SECURE); + } + + if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE)) { status = SWITCH_STATUS_SUCCESS; goto end; diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 76dd08ea49..0e990efb5b 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -137,8 +137,7 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) while (switch_channel_get_state(session->channel) == CS_EXECUTE && extension->current_application) { char *expanded = NULL; - int nomedia = 0; - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Execute %s(%s)\n", switch_channel_get_name(session->channel), extension->current_application->application_name, switch_str_nil(extension->current_application->application_data)); if ((application_interface = switch_loadable_module_get_application_interface(extension->current_application->application_name)) == 0) { @@ -155,7 +154,6 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) && !switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA)) { switch_ivr_media(session->uuid_str, SMF_NONE); - nomedia++; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media on channel %s!\n", extension->current_application->application_name, switch_channel_get_name(session->channel)); } else if (!switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) && !switch_channel_media_ready(session->channel)) { @@ -189,12 +187,6 @@ static void switch_core_standard_on_execute(switch_core_session_t *session) goto top; } - if (nomedia) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Application %s Releasing media\n", - extension->current_application->application_name); - switch_ivr_nomedia(session->uuid_str, SMF_NONE); - } - extension->current_application = extension->current_application->next; } diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index b0690cee79..dc9a9614c9 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -496,7 +496,7 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session) switch_core_session_t *other_session; switch_event_t *event; - if (switch_channel_test_flag(channel, CF_ORIGINATOR)) { + if (switch_channel_test_flag(channel, CF_ORIGINATOR)) { switch_channel_clear_flag(channel, CF_ORIGINATOR); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); @@ -514,17 +514,10 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session) switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL); switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL); - assert (!switch_channel_test_flag(other_channel, CF_TRANSFER)); + if (switch_channel_get_state(other_channel) < CS_HANGUP) { + switch_channel_hangup(other_channel, switch_channel_get_cause(channel)); + } - if (!switch_channel_test_flag(other_channel, CF_TRANSFER)) { - if (switch_channel_test_flag(other_channel, CF_ANSWERED) && - switch_channel_get_state(other_channel) < CS_HANGUP && - switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) { - switch_channel_hangup(other_channel, switch_channel_get_cause(channel)); - } else { - switch_channel_set_state(other_channel, CS_EXECUTE); - } - } switch_core_session_rwunlock(other_session); }