]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
block all possible routes to write data during ice and dtls negotiation
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 24 Jan 2014 22:48:25 +0000 (03:48 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 24 Jan 2014 22:48:32 +0000 (03:48 +0500)
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/switch_core_media.c
src/switch_rtp.c

index 5c0d36b596619d027f94c0ce8d815b86dd85cfe6..6c098e4c6781facd01f1e804194c4771e9ac5bab 100644 (file)
@@ -2341,7 +2341,7 @@ static switch_status_t channel_write_video_frame(switch_core_session_t *session,
                wrote = switch_rtp_write_frame(tech_pvt->transports[LDL_TPORT_VIDEO_RTP].rtp_session, frame);
        }
 
-       return wrote > 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
+       return wrote > -1 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_GENERR;
 }
 
 static switch_status_t channel_answer_channel(switch_core_session_t *session)
index 1fd368f9d5c3c6e4c0c11d24da84a52966eb4bca..9c42a03a46788c905ab5b241b094a3e3c565bea2 100644 (file)
@@ -1815,7 +1815,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio
 
        engine->timestamp_send += samples;
 
-       if (!switch_rtp_write_frame(engine->rtp_session, frame)) {
+       if (switch_rtp_write_frame(engine->rtp_session, frame) <= 0) {
                status = SWITCH_STATUS_FALSE;
        }
 
index a53dc5b7faf5d4936f7a6d16df0222f457a9dcb7..4f36819ff90bb343954b570b2928df4641d4accc 100644 (file)
@@ -5639,6 +5639,26 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_sessi
        return SWITCH_STATUS_SUCCESS;
 }
 
+static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line)
+{
+       if (rtp_session->ice.ice_user && !(rtp_session->ice.rready)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Skip sending %s packet %ld bytes (ice not ready @ line %d!)\n", 
+                                                 rtp_type(rtp_session), (long)bytes, line);
+               return 0;
+       }
+
+       if (rtp_session->dtls && rtp_session->dtls->state != DS_READY) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Skip sending %s packet %ld bytes (dtls not ready @ line %d!)\n", 
+                                                 rtp_type(rtp_session), (long)bytes, line);
+               return 0;
+       }
+       
+       return 1;
+}
+
+
+
+
 static int rtp_common_write(switch_rtp_t *rtp_session,
                                                        rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags)
 {
@@ -5650,7 +5670,11 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
        uint8_t m = 0;
 
        if (!switch_rtp_ready(rtp_session)) {
-               return SWITCH_STATUS_FALSE;
+               return -1;
+       }
+
+       if (!rtp_write_ready(rtp_session, datalen, __LINE__)) {
+               return 0;
        }
 
        WRITE_INC(rtp_session);
@@ -5918,16 +5942,6 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
                }
        }
 
-       if (rtp_session->ice.ice_user && !(rtp_session->ice.rready)) {
-               send = 0;
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Skip sending %s packet %ld bytes (ice not ready!)\n", rtp_type(rtp_session), (long)bytes);
-       }
-
-       if (rtp_session->dtls && rtp_session->dtls->state != DS_READY) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Skip sending %s packet %ld bytes (dtls not ready!)\n", rtp_type(rtp_session), (long)bytes);
-               send = 0;
-       }
-
        if (rtp_session->flags[SWITCH_RTP_FLAG_PAUSE]) {
                send = 0;
        }
@@ -6148,6 +6162,10 @@ SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_fra
        if (!switch_rtp_ready(rtp_session) || !rtp_session->remote_addr) {
                return -1;
        }
+
+       if (!rtp_write_ready(rtp_session, frame->datalen, __LINE__)) {
+               return 0;
+       }
        
        //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
        //      rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]++;
@@ -6339,6 +6357,10 @@ SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session,
                return -1;
        }
 
+       if (!rtp_write_ready(rtp_session, datalen, __LINE__)) {
+               return 0;
+       }
+
        WRITE_INC(rtp_session);
 
        rtp_session->write_msg = rtp_session->send_msg;