]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
webrtc tweaks
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 28 Oct 2013 18:39:23 +0000 (23:39 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 28 Oct 2013 18:39:33 +0000 (23:39 +0500)
src/include/switch_types.h
src/switch_core_media.c
src/switch_rtp.c

index 49dbfd006410116e05efb20b019d9598f0cd42c5..5c049ddd0a2dde64d2beb8851768e822f7e28d08 100644 (file)
@@ -667,6 +667,7 @@ typedef enum {
        SWITCH_RTP_FLAG_RTCP_MUX,
        SWITCH_RTP_FLAG_KILL_JB,
        SWITCH_RTP_FLAG_VIDEO_BREAK,
+       SWITCH_RTP_FLAG_PAUSE,
        SWITCH_RTP_FLAG_INVALID
 } switch_rtp_flag_t;
 
index 8643a1d6930ba352ade1514be12ec2f937e64429..a2452308afb3bfffcdc003b8cf12ee0b2f786fca 100644 (file)
@@ -3372,7 +3372,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
 SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session, int sendonly)
 {
        int changed = 0;
-       switch_rtp_engine_t *a_engine;//, *v_engine;
+       switch_rtp_engine_t *a_engine, *v_engine;
        switch_media_handle_t *smh;
        switch_core_session_t *b_session = NULL;
        switch_channel_t *b_channel = NULL;
@@ -3384,7 +3384,7 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
        }
 
        a_engine = &smh->engines[SWITCH_MEDIA_TYPE_AUDIO];
-       //v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
+       v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
 
        
        if (switch_core_session_get_partner(session, &b_session) == SWITCH_STATUS_SUCCESS) {
@@ -3412,6 +3412,11 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
                                        msg = "hold-private";
                                }
                        }
+                       
+                       switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       if (v_engine->rtp_session) {
+                               switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       }
 
                        switch_channel_set_flag(session->channel, CF_PROTO_HOLD);
                        switch_channel_mark_hold(session->channel, SWITCH_TRUE);
@@ -3444,6 +3449,12 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
                if (switch_channel_test_flag(session->channel, CF_HOLD_LOCK)) {
                        switch_channel_set_flag(session->channel, CF_PROTO_HOLD);
                        switch_channel_mark_hold(session->channel, SWITCH_TRUE);
+
+                       switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       if (v_engine->rtp_session) {
+                               switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       }
+
                        changed = 1;
                }
 
@@ -3471,6 +3482,12 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
                        switch_channel_clear_flag(session->channel, CF_PROTO_HOLD);
                        switch_channel_mark_hold(session->channel, SWITCH_FALSE);
                        switch_channel_presence(session->channel, "unknown", "unhold", NULL);
+
+                       switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       if (v_engine->rtp_session) {
+                               switch_rtp_clear_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PAUSE);
+                       }
+
                        changed = 1;
                }
        }
@@ -6965,7 +6982,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
 
                                if (ok) {
                                        switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-                                       switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+                                       //switch_rtp_clear_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
                                        switch_channel_set_flag(session->channel, CF_NOTIMER_DURING_BRIDGE);
                                }
 
@@ -7013,7 +7030,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
                                if (!switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_UDPTL) && 
                                        !switch_rtp_test_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
                                        switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_USE_TIMER);
-                                       switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+                                       //switch_rtp_set_flag(a_engine->rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
                                }
                                switch_channel_clear_flag(session->channel, CF_NOTIMER_DURING_BRIDGE);
                        }
index ff621e18260f95a695f63998f955070a40b4e8a4..d9226571e67752f3900dea06c1a494f973093ce7 100644 (file)
@@ -4545,7 +4545,14 @@ static switch_status_t read_rtcp_packet(switch_rtp_t *rtp_session, switch_size_t
        return status;
 }
 
+static int using_ice(switch_rtp_t *rtp_session)
+{
+       if (rtp_session->ice.ice_user || rtp_session->rtcp_ice.ice_user) {
+               return 1;
+       }
 
+       return 0;
+}
 
 static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
 {
@@ -4693,7 +4700,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                                pt = 100000;
                        }
 
-                       
+                       if (using_ice(rtp_session)) {
+                               pt = 20000;
+                       }
+
                        poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
 
 
@@ -4780,20 +4790,19 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                                }
                        }
 
-                       if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {                                
+                       if (using_ice(rtp_session)) {
                                if (check_rtcp_and_ice(rtp_session) == -1) {
                                        ret = -1;
                                        goto end;
                                }
-                               goto recvfrom;
-                       }  
+                       }
                        
                        if ((!(io_flags & SWITCH_IO_FLAG_NOBLOCK)) && 
                                (rtp_session->dtmf_data.out_digit_dur == 0)) {
                                return_cng_frame();
                        }
                }
-
+               
        rtcp:
 
                if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
@@ -5749,7 +5758,9 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
                send = 0;
        }
 
-
+       if (rtp_session->flags[SWITCH_RTP_FLAG_PAUSE]) {
+               send = 0;
+       }
 
        if (send) {
                send_msg->header.seq = htons(++rtp_session->seq);