diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index d9342a0d8e..bfba4e5af5 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -702,7 +702,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi private_object_t *tech_pvt = switch_core_session_get_private(session); switch_status_t status; - switch_assert(tech_pvt != NULL); + if (switch_channel_get_state(channel) >= CS_HANGUP || !tech_pvt) { + return SWITCH_STATUS_FALSE; + } if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) { const char *var; @@ -755,11 +757,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi switch_core_session_t *other_session; switch_channel_t *other_channel; const char *ip = NULL, *port = NULL; - - if (switch_channel_get_state(channel) >= CS_HANGUP) { - return SWITCH_STATUS_FALSE; - } - + switch_channel_set_flag(channel, CF_BYPASS_MEDIA); tech_pvt->local_sdp_str = NULL; if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) @@ -792,10 +790,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi { uint32_t count = 0; - if (switch_channel_get_state(channel) >= CS_HANGUP) { - return SWITCH_STATUS_FALSE; - } - switch_channel_clear_flag(channel, CF_BYPASS_MEDIA); tech_pvt->local_sdp_str = NULL; if (!switch_rtp_ready(tech_pvt->rtp_session)) { @@ -975,8 +969,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_ANSWER: sofia_answer_channel(session); break; - case SWITCH_MESSAGE_INDICATE_PROGRESS:{ - if (!switch_test_flag(tech_pvt, TFLAG_ANS)) { + case SWITCH_MESSAGE_INDICATE_PROGRESS: + { + if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) { switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 662c7af62c..e9d08b02bb 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1462,6 +1462,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } + if (status == 183 && !r_sdp) { + status = 180; + } + if (channel && (status == 180 || status == 183) && switch_channel_test_flag(channel, CF_OUTBOUND)) { const char *val; if ((val = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(val)) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index fb54ac43a7..d6b95eadf5 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1084,6 +1084,11 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force) { int ms; + if (!tech_pvt->iananame) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No audio codec available\n"); + return SWITCH_STATUS_FALSE; + } + if (tech_pvt->read_codec.implementation) { if (!force) { return SWITCH_STATUS_SUCCESS; @@ -1102,11 +1107,6 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force) } } - if (!tech_pvt->iananame) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n"); - return SWITCH_STATUS_FALSE; - } - if (switch_core_codec_init(&tech_pvt->read_codec, tech_pvt->iananame, tech_pvt->rm_fmtp,