diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 31bf08387b..09958e7e45 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -332,7 +332,7 @@ SWITCH_DECLARE(switch_media_flow_t) switch_core_session_media_flow(switch_core_s SWITCH_DECLARE(switch_status_t) switch_core_media_get_vid_params(switch_core_session_t *session, switch_vid_params_t *vid_params); SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_session_t *session, switch_file_handle_t *fh, switch_rw_t rw); SWITCH_DECLARE(switch_bool_t) switch_core_session_in_video_thread(switch_core_session_t *session); -SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session); +SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type); SWITCH_END_EXTERN_C #endif diff --git a/src/switch_channel.c b/src/switch_channel.c index 60f0ee6802..a944e2f6a1 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -3402,6 +3402,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_ const char *uuid; switch_core_session_t *other_session; + switch_core_media_check_dtls(channel->session, SWITCH_MEDIA_TYPE_AUDIO); + switch_channel_check_zrtp(channel); switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name); switch_channel_set_flag(channel, CF_EARLY_MEDIA); @@ -3673,6 +3675,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan return SWITCH_STATUS_SUCCESS; } + switch_core_media_check_dtls(channel->session, SWITCH_MEDIA_TYPE_AUDIO); + if (channel->caller_profile && channel->caller_profile->times) { switch_mutex_lock(channel->profile_mutex); channel->caller_profile->times->answered = switch_micro_time_now(); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index df872dfa30..ed095b075c 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -4847,6 +4847,8 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi mh->up = 1; switch_mutex_lock(mh->cond_mutex); + switch_core_media_check_dtls(session, SWITCH_MEDIA_TYPE_VIDEO); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Video thread started. Echo is %s\n", switch_channel_get_name(session->channel), switch_channel_test_flag(channel, CF_VIDEO_ECHO) ? "on" : "off"); switch_core_session_request_video_refresh(session); @@ -8585,11 +8587,11 @@ static int check_engine(switch_rtp_engine_t *engine) return 1; } -SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session) +SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type) { switch_media_handle_t *smh; - switch_rtp_engine_t *a_engine, *v_engine; - int audio_checking = 0, video_checking = 0; + switch_rtp_engine_t *engine; + int checking = 0; switch_assert(session); @@ -8605,15 +8607,13 @@ SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t return SWITCH_TRUE; } - a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO]; - v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO]; + engine = &smh->engines[type]; do { - if (a_engine->rtp_session) audio_checking = check_engine(a_engine); - if (v_engine->rtp_session) check_engine(v_engine); - } while (switch_channel_ready(session->channel) && (audio_checking || video_checking)); - - if (!audio_checking && !video_checking) { + if (engine->rtp_session) checking = check_engine(engine); + } while (switch_channel_ready(session->channel) && checking); + + if (!checking) { return SWITCH_TRUE; } diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c index 26750ff58e..f9449bfc39 100644 --- a/src/switch_core_state_machine.c +++ b/src/switch_core_state_machine.c @@ -487,10 +487,6 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session) } } - if (state > CS_INIT && switch_channel_media_up(session->channel)) { - switch_core_media_check_dtls(session); - } - switch (state) { case CS_NEW: /* Just created, Waiting for first instructions */ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "(%s) State NEW\n", switch_channel_get_name(session->channel));