]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix rare t38 gateway issue
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 12 May 2011 15:32:39 +0000 (10:32 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 12 May 2011 15:32:39 +0000 (10:32 -0500)
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_rtp.c

index c1431c28e9c3022a04966ecca4aa4833c630fe3e..c9ea6790b7e2867d4f0b0742fdb03c0dde4954b3 100644 (file)
@@ -1241,6 +1241,7 @@ static void start_udptl(private_object_t *tech_pvt, switch_t38_options_t *t38_op
                switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
                const char *err, *val;
 
+               sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
                switch_rtp_udptl_mode(tech_pvt->rtp_session);
 
                if (!t38_options || !t38_options->remote_ip) {
@@ -1527,8 +1528,11 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                        }
                        
                        if (sofia_test_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE)) {
-                               switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-                               switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+                               if (!switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_UDPTL) && 
+                                       !switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
+                                       switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
+                                       switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+                               }
                                sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
                        }
 
@@ -2153,6 +2157,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                                        if (t38_options) {
                                                                sofia_glue_set_image_sdp(tech_pvt, t38_options, 0);
                                                                if (switch_rtp_ready(tech_pvt->rtp_session)) {
+                                                                       sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
                                                                        switch_rtp_udptl_mode(tech_pvt->rtp_session);
                                                                }
                                                        }
index 36822608093fae409bf0d650f9498dfa7a8c11ca..815606137673cbe19414b1b48a25cbf22632df2c 100644 (file)
@@ -4514,6 +4514,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
                                        
                                        if (status == 200 && sofia_test_flag(tech_pvt, TFLAG_T38_PASSTHRU) && has_t38) {
                                                if (switch_rtp_ready(tech_pvt->rtp_session) && switch_rtp_ready(other_tech_pvt->rtp_session)) {
+                                                       sofia_clear_flag(tech_pvt, TFLAG_NOTIMER_DURING_BRIDGE);
                                                        switch_rtp_udptl_mode(tech_pvt->rtp_session);
                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating T38 Passthru\n");
                                                }
index cc21bd0c0411a1de7421275129357313e7bfbc4d..69bc4d1e7d3f4d8bbc5e5d887708ee9b2a4a1f94 100644 (file)
@@ -3445,9 +3445,9 @@ switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_f
 
                        if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
                                !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
-                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
+                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
                        } else {
-                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
+                               flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
                        }
 
                        if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
index 2eeb7bfdb9e70f324ab01a411e45f28031eec6e1..7e70557191ea77929fd1751980be739d7dce1456 100644 (file)
@@ -1262,9 +1262,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
        READ_INC(rtp_session);
        WRITE_INC(rtp_session);
 
-       if (rtp_session->timer.timer_interface) {
+       if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER) || rtp_session->timer.timer_interface) {
                switch_core_timer_destroy(&rtp_session->timer);
                memset(&rtp_session->timer, 0, sizeof(rtp_session->timer));
+               switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
        }
 
        switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP);
@@ -1293,9 +1294,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
        switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_UDPTL);
        switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA);
        switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
-
-       switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-       switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+       switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
                
        WRITE_DEC(rtp_session);
        READ_DEC(rtp_session);
@@ -3850,7 +3849,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
                        rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
                } else {
-                       rtp_session->last_write_timestamp = (uint32_t) switch_micro_time_now();
+                       rtp_session->last_write_timestamp = switch_micro_time_now();
                }
 
                rtp_session->last_write_ts = this_ts;