diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 216f0dcb4a..a2cb14b0b9 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -7270,9 +7270,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi const char *var; switch_rtp_engine_t *a_engine, *v_engine, *t_engine; switch_media_handle_t *smh; + int is_reinvite = 0; switch_assert(session); - + if (!(smh = session->media_handle)) { return SWITCH_STATUS_FALSE; } @@ -7281,6 +7282,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO]; t_engine = &smh->engines[SWITCH_MEDIA_TYPE_TEXT]; + if (a_engine->rtp_session || v_engine->rtp_session || t_engine->rtp_session || switch_channel_test_flag(session->channel, CF_REINVITE)) { + is_reinvite = 1; + } + if (switch_channel_down(session->channel)) { return SWITCH_STATUS_FALSE; @@ -7301,16 +7306,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi goto end; } - if (!switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (!is_reinvite) { if (switch_rtp_ready(a_engine->rtp_session)) { - if (switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && !switch_rtp_ready(v_engine->rtp_session)) { - goto video; - } - if (switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE) && !switch_rtp_ready(t_engine->rtp_session)) { goto text; } + if (switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && !switch_rtp_ready(v_engine->rtp_session)) { + goto video; + } + status = SWITCH_STATUS_SUCCESS; goto end; } @@ -7367,7 +7372,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi flags[SWITCH_RTP_FLAG_GEN_TS_DELTA] = 1; } - if (a_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (a_engine->rtp_session && is_reinvite) { //const char *ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE); //const char *port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE); char *remote_host = switch_rtp_get_remote_host(a_engine->rtp_session); @@ -7407,7 +7412,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp); switch_channel_set_variable(session->channel, SWITCH_ADVERTISED_MEDIA_IP_VARIABLE, a_engine->adv_sdp_ip); - if (a_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (a_engine->rtp_session && is_reinvite) { const char *rport = NULL; switch_port_t remote_rtcp_port = a_engine->remote_rtcp_port; @@ -7756,7 +7761,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (switch_channel_test_flag(session->channel, CF_TEXT_POSSIBLE) && t_engine->cur_payload_map->rm_encoding && t_engine->cur_payload_map->remote_sdp_port) { /******************************************************************************************/ - if (t_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (t_engine->rtp_session && is_reinvite) { //const char *ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE); //const char *port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE); char *remote_host = switch_rtp_get_remote_host(t_engine->rtp_session); @@ -7792,7 +7797,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_variable(session->channel, SWITCH_LOCAL_TEXT_PORT_VARIABLE, tmp); - if (t_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (t_engine->rtp_session && is_reinvite) { const char *rport = NULL; switch_port_t remote_rtcp_port = t_engine->remote_rtcp_port; @@ -8065,7 +8070,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi if (switch_channel_test_flag(session->channel, CF_VIDEO_POSSIBLE) && v_engine->cur_payload_map->rm_encoding && v_engine->cur_payload_map->remote_sdp_port) { /******************************************************************************************/ - if (v_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (v_engine->rtp_session && is_reinvite) { //const char *ip = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE); //const char *port = switch_channel_get_variable(session->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE); char *remote_host = switch_rtp_get_remote_host(v_engine->rtp_session); @@ -8101,7 +8106,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi switch_channel_set_variable(session->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp); - if (v_engine->rtp_session && switch_channel_test_flag(session->channel, CF_REINVITE)) { + if (v_engine->rtp_session && is_reinvite) { const char *rport = NULL; switch_port_t remote_rtcp_port = v_engine->remote_rtcp_port;