]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7499 FS-7508 FS-7501 some more general improvements for initial call setup
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 5 May 2015 18:27:52 +0000 (13:27 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:29 +0000 (12:47 -0500)
src/include/switch_rtp.h
src/include/switch_vidderbuffer.h
src/mod/codecs/mod_vpx/mod_vpx.c
src/switch_channel.c
src/switch_core_media.c
src/switch_rtp.c
src/switch_vidderbuffer.c

index 53e26c5a8796bb55243744e2c8e61775ad38ec65..dcb09549eef22c7960fef7373c6be69b789f0026 100644 (file)
@@ -328,6 +328,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
 SWITCH_DECLARE(switch_timer_t *) switch_rtp_get_media_timer(switch_rtp_t *rtp_session);
 
 SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames);
+SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session);
 
 /*! 
   \brief Acvite a jitter buffer on an RTP session
index 132a7bf17745c40f000762bc92443181cce7012f..73942daa0342e06c30f9ad69752a40a8ee9bf193 100644 (file)
@@ -41,6 +41,7 @@ typedef enum {
 SWITCH_BEGIN_EXTERN_C
 SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool);
 SWITCH_DECLARE(switch_status_t) switch_vb_set_frames(switch_vb_t *vb, uint32_t min_frame_len, uint32_t max_frame_len);
+SWITCH_DECLARE(switch_status_t) switch_vb_get_frames(switch_vb_t *vb, uint32_t *min_frame_len, uint32_t *max_frame_len);
 SWITCH_DECLARE(switch_status_t) switch_vb_destroy(switch_vb_t **vbp);
 SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb);
 SWITCH_DECLARE(void) switch_vb_debug_level(switch_vb_t *vb, uint8_t level);
index 1d25acd45e22cd1b59be57ac305f57381172a856..e6eeb052f7f2e89da22fbff8e9a3379fd3eaa54f 100644 (file)
@@ -772,7 +772,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
        if (context->is_vp9) {
                is_keyframe = IS_VP9_KEY_FRAME(*(unsigned char *)frame->data);
        } else { // vp8
-               is_keyframe = (*(unsigned char *)frame->data & 0x10) || IS_VP8_KEY_FRAME((uint8_t *)frame->data);
+               is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
        }
 
        // if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
index 60b3b62b350be4cd00aaa91518a2d001d0e9b903..302d4fdbbc4dfce062895fd2d0e54b1e5fa5fb82 100644 (file)
@@ -1785,7 +1785,8 @@ SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel)
 SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
 {
        int HELD = 0;
-       
+       int just_set = 0;
+
        switch_assert(channel);
        switch_assert(channel->flag_mutex);
 
@@ -1793,9 +1794,16 @@ SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, sw
        if (flag == CF_LEG_HOLDING && !channel->flags[flag] && channel->flags[CF_ANSWERED]) {
                HELD = 1;
        }
-       channel->flags[flag] = value;
+       if (channel->flags[flag] != value) {
+               just_set = 1;
+               channel->flags[flag] = value;
+       }
        switch_mutex_unlock(channel->flag_mutex);
 
+       if (flag == CF_VIDEO_READY && just_set) {
+               switch_core_session_request_video_refresh(channel->session);
+       }
+
        if (flag == CF_ORIGINATOR && switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_up_nosig(channel)) {
                switch_channel_set_callstate(channel, CCS_RING_WAIT);
        }
index 85a379e2b74f04985400dc241b4229b7d923609d..0fbda36c1bdcccb1c9b7064bcb03773441ff8a77 100644 (file)
@@ -1947,8 +1947,11 @@ static void check_jb_sync(switch_core_session_t *session)
                        jb_sync_msec = tmp;
                }
        }
-       // TBD IMPROVE get_fps func
-       fps = 15; //switch_core_media_get_video_fps(session);
+       if (smh->vid_frames < 10) {
+               fps = 15; 
+       } else {
+               fps = switch_core_media_get_video_fps(session);
+       }
        
        if (!fps) return;
 
@@ -1959,13 +1962,20 @@ static void check_jb_sync(switch_core_session_t *session)
                frames = fps / (1000 / jb_sync_msec);
        }
 
-       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
-                                         SWITCH_LOG_DEBUG, "%s Sync Audio and Video Jitterbuffer to %dms %u Video Frames FPS %u\n", 
-                                         switch_channel_get_name(session->channel),
-                                         jb_sync_msec, frames, fps);
-       
-       switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames);
-       check_jb(session, NULL, jb_sync_msec, jb_sync_msec);
+       if (frames == switch_rtp_get_video_buffer_size(v_engine->rtp_session)) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
+                                                 SWITCH_LOG_DEBUG1, "%s Audio and Video Jitterbuffer settings not changed %dms %u Video Frames FPS %u\n", 
+                                                 switch_channel_get_name(session->channel),
+                                                 jb_sync_msec, frames, fps);
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), 
+                                                 SWITCH_LOG_INFO, "%s Sync Audio and Video Jitterbuffer to %dms %u Video Frames FPS %u\n", 
+                                                 switch_channel_get_name(session->channel),
+                                                 jb_sync_msec, frames, fps);
+               
+               switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames);
+               check_jb(session, NULL, jb_sync_msec, jb_sync_msec);
+       }
 }
 
 
@@ -2088,7 +2098,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
                        }
                        smh->vid_frames++;
 
-                       if (smh->vid_frames == 45) {
+                       if (smh->vid_frames == 1 || ((smh->vid_frames % 300) == 0)) {
                                check_jb_sync(session);
                        }
                }
index 874ddf06e55caf1bfd5a8b848b9275c12caed9b4..24cf12ef525efd76494b56c440e49666bb82312f 100644 (file)
@@ -3855,6 +3855,17 @@ static void jb_logger(const char *file, const char *func, int line, int level, c
        va_end(ap);
 }
 
+SWITCH_DECLARE(uint32_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session)
+{
+       uint32_t frames = 0;
+
+       if (rtp_session->vb) {
+               switch_vb_get_frames(rtp_session->vb, &frames, NULL);
+       }
+
+       return frames;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames)
 {
        if (!switch_rtp_ready(rtp_session)) {
@@ -5415,7 +5426,9 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
                
                if (msg->header.type == RTCP_PT_PSFB && (extp->header.fmt == RTCP_PSFB_FIR || extp->header.fmt == RTCP_PSFB_PLI)) {
                        switch_core_media_gen_key_frame(rtp_session->session);
-                       //switch_channel_set_flag(switch_core_session_get_channel(rtp_session->session), CF_VIDEO_REFRESH_REQ);
+                       if (rtp_session->vbw) {
+                               switch_vb_reset(rtp_session->vbw);
+                       }
                }
 
                if (msg->header.type == RTCP_PT_RTPFB && extp->header.fmt == RTCP_RTPFB_NACK) {
@@ -5423,11 +5436,14 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
                        int i;
                        
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Got NACK count %d\n", ntohs(extp->header.length) - 2);
-                       switch_core_media_gen_key_frame(rtp_session->session);
+
+
                        for (i = 0; i < ntohs(extp->header.length) - 2; i++) {
                                handle_nack(rtp_session, *nack);
                                nack++;
                        }
+
+                       switch_core_media_gen_key_frame(rtp_session->session);
                }
 
        } else
index 887822909864cd5bbca6dc701c96d9477f7979ea..8bc6d26150339705aac209049f0a62932c313687 100644 (file)
@@ -412,6 +412,24 @@ SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb)
        switch_mutex_unlock(vb->mutex);
 }
 
+SWITCH_DECLARE(switch_status_t) switch_vb_get_frames(switch_vb_t *vb, uint32_t *min_frame_len, uint32_t *max_frame_len) 
+{
+
+       switch_mutex_lock(vb->mutex);
+
+       if (min_frame_len) {
+               *min_frame_len = vb->min_frame_len;
+       }
+
+       if (max_frame_len) {
+               *max_frame_len = vb->max_frame_len;
+       }
+
+       switch_mutex_unlock(vb->mutex);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_vb_set_frames(switch_vb_t *vb, uint32_t min_frame_len, uint32_t max_frame_len)
 {
        switch_mutex_lock(vb->mutex);