]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9206: [core] endable proxy media auto-adjust on re-invite for text and video every...
authorMike Jerris <mike@jerris.com>
Sat, 7 Jan 2017 00:12:25 +0000 (18:12 -0600)
committerMike Jerris <mike@jerris.com>
Tue, 17 Jan 2017 19:10:06 +0000 (13:10 -0600)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_media.c

index 3b3cc9af721bc0c28db006eee330aee1fcd6053c..81f3bb999768af135bd4bcf840b4ec774865a56c 100644 (file)
@@ -669,6 +669,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session)
                switch_core_media_set_local_sdp(session, b_sdp, SWITCH_TRUE);
 
                if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
+                       sofia_media_activate_rtp(tech_pvt);
                        switch_core_media_patch_sdp(tech_pvt->session);                 
                        switch_core_media_proxy_remote_addr(tech_pvt->session, NULL);
                }
index de780ef41ac8f7c8361ae9c2e8828110433ec003..2cb191949fe54c7fca3fc1d401ff7fb91b6b0867 100644 (file)
@@ -1702,6 +1702,7 @@ static void our_sofia_event_callback(nua_event_t event,
                                                switch_channel_set_variable_partner(tech_pvt->channel, SWITCH_B_SDP_VARIABLE, r_sdp);
                                                
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
+                                               sofia_media_activate_rtp(tech_pvt);
                                                switch_core_media_proxy_remote_addr(tech_pvt->session, r_sdp);
                                                sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
                                                sofia_clear_flag(tech_pvt, TFLAG_PASS_ACK);
@@ -7934,10 +7935,13 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                                        }
                                                }
 
-                                               if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && !(tech_pvt->profile->mndlb & SM_NDLB_NEVER_PATCH_REINVITE)) {
-                                                       if (switch_core_media_proxy_remote_addr(session, r_sdp) == SWITCH_STATUS_SUCCESS && !is_t38) {
+                                               if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
+                                                       sofia_media_activate_rtp(tech_pvt);
+                                                       switch_core_media_proxy_remote_addr(session, r_sdp);
+
+                                                       if ((tech_pvt->profile->mndlb & SM_NDLB_NEVER_PATCH_REINVITE)) {
                                                                nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
-                                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio params changed, NOT proxying re-invite.\n");
+                                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "NOT proxying re-invite.\n");
                                                                switch_core_session_rwunlock(other_session);
                                                                goto done;
                                                        }
index 12dd673d29a965ffebd298b7f0df80a95c0842fe..f413618ede41ee947af75c527775973619692202 100644 (file)
@@ -1230,9 +1230,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
        }
 
        if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-               if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) {
-                       switch_core_media_proxy_remote_addr(session, NULL);
-               }
+               switch_core_media_proxy_remote_addr(session, NULL);
                switch_core_media_patch_sdp(tech_pvt->session);
        }
 
index 8caa3a88d9f7a4d959922111664fc82f6f13ec31..e326004e0b2fcd7f319d48b95b759384eb9aea60 100644 (file)
@@ -7018,18 +7018,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_
                                } else {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
                                                                          v_engine->cur_payload_map->remote_sdp_ip, v_engine->cur_payload_map->remote_sdp_port);
-                                       if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
-                                               !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) && 
-                                               !switch_channel_test_flag(session->channel, CF_AVPF)) {
-                                               /* Reactivate the NAT buster flag. */
-                                               switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
-                                       }
                                        if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) {
                                                v_engine->check_frames = 0;
                                        }
                                }
                        }
                }
+               if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
+                       !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+                       v_engine->rtp_session &&
+                       !switch_channel_test_flag(session->channel, CF_AVPF)) {
+                       /* Reactivate the NAT buster flag. */
+                       switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+               }
        }
 
        if (t_engine->cur_payload_map && t_engine->cur_payload_map->remote_sdp_ip && t_engine->cur_payload_map->remote_sdp_port) {
@@ -7056,18 +7057,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_proxy_remote_addr(switch_core_
                                } else {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "TEXT RTP CHANGING DEST TO: [%s:%d]\n",
                                                                          t_engine->cur_payload_map->remote_sdp_ip, t_engine->cur_payload_map->remote_sdp_port);
-                                       if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
-                                               !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) && 
-                                               !switch_channel_test_flag(session->channel, CF_AVPF)) {
-                                               /* Reactivate the NAT buster flag. */
-                                               switch_rtp_set_flag(t_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
-                                       }
                                        if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) {
                                                t_engine->check_frames = 0;
                                        }
                                }
                        }
                }
+               if (!switch_media_handle_test_media_flag(smh, SCMF_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(session->channel, CF_PROXY_MODE) &&
+                       !((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val)) &&
+                       t_engine->rtp_session &&
+                       !switch_channel_test_flag(session->channel, CF_AVPF)) {
+                       /* Reactivate the NAT buster flag. */
+                       switch_rtp_set_flag(t_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
+               }
        }
 
        if (switch_rtp_ready(a_engine->rtp_session)) {
@@ -7264,6 +7266,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_choose_port(switch_core_sessio
                }
        }
 
+       /* Always too late when RTP has already started */
+       if (engine->rtp_session) {
+               return SWITCH_STATUS_SUCCESS;
+       }
+
        /* Release the local sdp port */
        if (engine->local_sdp_port) {
                switch_rtp_release_port(smh->mparams->rtpip, engine->local_sdp_port);