]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
manually cherry pick 7c19615 -- FS-10417: [freeswitch-core] Reduce flicker in screen...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 22 Jun 2017 00:29:45 +0000 (19:29 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 22 Jun 2017 00:29:45 +0000 (19:29 -0500)
src/include/switch_core.h
src/include/switch_core_media.h
src/mod/applications/mod_conference/conference_video.c
src/switch_core_media.c
src/switch_core_video.c
src/switch_jitterbuffer.c
src/switch_rtp.c

index 60157085a1b18d27f390858af289477f27b2630f..bee66f13e45b67f71f112c5b90a3d93d63821c3a 100644 (file)
@@ -2744,7 +2744,8 @@ SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix);
 SWITCH_DECLARE(int) switch_core_cert_gen_fingerprint(const char *prefix, dtls_fingerprint_t *fp);
 SWITCH_DECLARE(int) switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, const char *str);
 SWITCH_DECLARE(int) switch_core_cert_verify(dtls_fingerprint_t *fp);
-SWITCH_DECLARE(switch_status_t) switch_core_session_request_video_refresh(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, const char *file, const char *func, int line);
+#define switch_core_session_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, __FILE__, __SWITCH_FUNC__, __LINE__)
 SWITCH_DECLARE(switch_status_t) switch_core_session_send_and_request_video_refresh(switch_core_session_t *session);
 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
 SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
index e8cec64927a592a94e6ac2a4a52eece8ca75627c..482f435f626981deeecd64d383a561998cf71ffa 100644 (file)
@@ -328,11 +328,11 @@ SWITCH_DECLARE(switch_bool_t) switch_core_media_codec_get_cap(switch_core_sessio
                                                                                                                                switch_codec_flag_t flag);
 
 
-#define switch_core_media_gen_key_frame(_session) switch_core_media_codec_control(_session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_WRITE, \
-                                                                                                                                                                 SCC_VIDEO_GEN_KEYFRAME, SCCT_NONE, NULL, SCCT_NONE, NULL, NULL, NULL) \
+#define switch_core_media_gen_key_frame(_session) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(_session), SWITCH_LOG_DEBUG1, "%s Send KeyFrame\n", switch_core_session_get_name(_session)); \
+       switch_core_media_codec_control(_session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_WRITE, SCC_VIDEO_GEN_KEYFRAME, SCCT_NONE, NULL, SCCT_NONE, NULL, NULL, NULL)
 
 #define switch_core_media_write_bandwidth(_session, _val) switch_core_media_codec_control(_session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_WRITE, \
-                                                                                                                                                                                 SCC_VIDEO_BANDWIDTH, SCCT_STRING, _val, SCCT_NONE, NULL, NULL, NULL) \
+                                                                                                                                                                                 SCC_VIDEO_BANDWIDTH, SCCT_STRING, _val, SCCT_NONE, NULL, NULL, NULL)
 
 
 SWITCH_DECLARE(switch_timer_t *) switch_core_media_get_timer(switch_core_session_t *session, switch_media_type_t mtype);
index 6c08bf2faf2cf9c9fd33958fffb549f2bf9ce35b..f8433c56bfc7b33447f963b67335800032443f27 100644 (file)
@@ -2345,7 +2345,7 @@ void *SWITCH_THREAD_FUNC conference_video_muxing_thread_run(switch_thread_t *thr
        codec_set_t *write_codecs[MAX_MUX_CODECS] = { 0 };
        int buflen = SWITCH_RTP_MAX_BUF_LEN;
        int i = 0;
-       uint32_t video_key_freq = 10000000;
+       uint32_t video_key_freq = 0;
        switch_time_t last_key_time = 0;
        mcu_layer_t *layer = NULL;
        switch_frame_t write_frame = { 0 };
@@ -3353,7 +3353,7 @@ void *SWITCH_THREAD_FUNC conference_video_super_muxing_thread_run(switch_thread_
        int buflen = SWITCH_RTP_MAX_BUF_LEN;
        int i = 0;
        switch_time_t last_key_time = 0;
-       uint32_t video_key_freq = 10000000;
+       uint32_t video_key_freq = 0;
        mcu_layer_t *layer = NULL;
        switch_frame_t write_frame = { 0 };
        uint8_t *packet = NULL;
index d013064778be4735ea432dfa409806f6faf802af..3ae933b6b292df19ef1842d0923575d0b7216013 100644 (file)
@@ -1701,9 +1701,9 @@ SWITCH_DECLARE(switch_status_t) switch_media_handle_create(switch_media_handle_t
 
                session->media_handle->mparams = params;
                
-               if (!session->media_handle->mparams->video_key_freq) {
-                       session->media_handle->mparams->video_key_freq = 10000000;
-               }
+               //if (!session->media_handle->mparams->video_key_freq) {
+               //      session->media_handle->mparams->video_key_freq = 10000000;
+               //}
 
                if (!session->media_handle->mparams->video_key_first) {
                        session->media_handle->mparams->video_key_first = 1000000;
@@ -11590,7 +11590,7 @@ SWITCH_DECLARE(switch_timer_t *) switch_core_media_get_timer(switch_core_session
 
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_session_request_video_refresh(switch_core_session_t *session)
+SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, const char *file, const char *func, int line)
 {
        switch_channel_t *channel = switch_core_session_get_channel(session);
        switch_media_handle_t *smh = NULL;
@@ -11610,7 +11610,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_request_video_refresh(switch
                }
 
                smh->last_video_refresh_req = now;
-
+               msg._file = file;
+               msg._func = func;
+               msg._line = line;
+               switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), 
+                                                 SWITCH_LOG_DEBUG1, "%s Video refresh requested.\n", switch_channel_get_name(session->channel));
                msg.from = __FILE__;
                msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
                switch_core_session_receive_message(session, &msg);
index 75718e32a10b1163a0869959d8da6f04b58ed9b6..f87e4ec298419bca32af6f13d08476d451362532 100644 (file)
@@ -1643,8 +1643,8 @@ SWITCH_DECLARE(void) switch_img_patch_hole(switch_image_t *IMG, switch_image_t *
        }
 }
 
-#define SWITCH_IMG_MAX_WIDTH  1920 * 2
-#define SWITCH_IMG_MAX_HEIGHT 1080 * 2
+#define SWITCH_IMG_MAX_WIDTH  1920 * 4
+#define SWITCH_IMG_MAX_HEIGHT 1080 * 4
 
 #if !defined(SWITCH_HAVE_YUV)
 #undef SWITCH_HAVE_PNG
index 23af728c90f16edd730a964543fb62a9d42f381f..5b8c9b8d92209b713b3374663ced35bb8e7a553e 100644 (file)
@@ -505,9 +505,9 @@ static void jb_frame_inc_line(switch_jb_t *jb, int i, int line)
 
        if (old_frame_len != jb->frame_len) {
                jb_debug(jb, 2, "%d Change framelen from %u to %u\n", line, old_frame_len, jb->frame_len);
-               if (jb->session) {
-                       switch_core_session_request_video_refresh(jb->session);
-               }
+               //if (jb->session) {
+               //      switch_core_session_request_video_refresh(jb->session);
+               //}
        }
 
 }
@@ -742,9 +742,9 @@ static inline switch_status_t jb_next_packet_by_seq(switch_jb_t *jb, switch_jb_n
                        jb_debug(jb, 2, "%s", "DROPPED FRAME DETECTED RESYNCING\n");
                        jb->target_seq = 0;
 
-                       if (jb->session) {
-                               switch_core_session_request_video_refresh(jb->session);
-                       }
+                       //if (jb->session) {
+                       //      switch_core_session_request_video_refresh(jb->session);
+                       //}
                }
        }
 
@@ -772,9 +772,9 @@ static inline switch_status_t jb_next_packet_by_seq(switch_jb_t *jb, switch_jb_n
                                jb_frame_inc(jb, 1);
                        }
 
-                       if (jb->session) {
-                               switch_core_session_request_video_refresh(jb->session);
-                       }
+                       //if (jb->session) {
+                       //      switch_core_session_request_video_refresh(jb->session);
+                       //}
 
                        for (x = 0; x < 10; x++) {
                                increment_seq(jb);
@@ -919,9 +919,9 @@ SWITCH_DECLARE(void) switch_jb_reset(switch_jb_t *jb)
                switch_core_inthash_init(&jb->missing_seq_hash);
                switch_mutex_unlock(jb->mutex);
 
-               if (jb->session) {
-                       switch_core_session_request_video_refresh(jb->session);
-               }
+               //if (jb->session) {
+               //      switch_core_session_request_video_refresh(jb->session);
+               //}
        }
 
        jb_debug(jb, 2, "%s", "RESET BUFFER\n");
@@ -1210,9 +1210,6 @@ SWITCH_DECLARE(switch_status_t) switch_jb_put_packet(switch_jb_t *jb, switch_rtp
                        if (got - want > jb->max_frame_len && got - want > 17) {
                                jb_debug(jb, 2, "Missing %u frames, Resetting\n", got - want);
                                switch_jb_reset(jb);
-                               if (jb->session) {
-                                       switch_core_session_request_video_refresh(jb->session);
-                               }
                        } else {
 
                                if (jb->frame_len < got - want) {
index d48d455445134b8e0cc7f12546e0407414611b63..f4cd0720020b02f399d70264f1d45691f2401fb7 100644 (file)
@@ -1665,9 +1665,9 @@ static void check_jitter(switch_rtp_t *rtp_session)
                                                  (rtp_session->stats.inbound.last_processed_seq + 1), lost);
                rtp_session->stats.inbound.last_loss++;
 
-               if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
-                       switch_core_session_request_video_refresh(rtp_session->session);
-               }
+               //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+                       //switch_core_session_request_video_refresh(rtp_session->session);
+               //}
 
                if (rtp_session->stats.inbound.last_loss > 0 && rtp_session->stats.inbound.last_loss < LOST_BURST_CAPTURE) {
                        rtp_session->stats.inbound.loss[rtp_session->stats.inbound.last_loss] += lost;
@@ -4667,6 +4667,7 @@ SWITCH_DECLARE(void) switch_rtp_video_refresh(switch_rtp_t *rtp_session)
 
 SWITCH_DECLARE(void) switch_rtp_video_loss(switch_rtp_t *rtp_session)
 {
+
        if (!rtp_write_ready(rtp_session, 0, __LINE__)) {
                return;
        }
@@ -6195,7 +6196,7 @@ static void handle_nack(switch_rtp_t *rtp_session, uint32_t nack)
                if (blp & (1 << i)) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Also Got NACK for seq %u\n", ntohs(seq) + i + 1);
                        /* If they are missing more than one, may as well gen a key frame for good measure */
-                       switch_core_media_gen_key_frame(rtp_session->session);
+                       //switch_core_media_gen_key_frame(rtp_session->session);
                        if (switch_jb_get_packet_by_seq(rtp_session->vbw, htons(ntohs(seq) + i + 1), (switch_rtp_packet_t *) &send_msg, &bytes) == SWITCH_STATUS_SUCCESS) {
                                if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_WRITE]) {
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(rtp_session->session), SWITCH_LOG_CONSOLE,
@@ -6231,8 +6232,8 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
                rtcp_ext_msg_t *extp = (rtcp_ext_msg_t *) msg;
 
                if (extp->header.fmt != 15) { // <---- REMOVE WHEN BRIA STOPS SENDING UNSOLICITED REMB
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "PICKED UP %s XRTCP type: %d fmt: %d\n",
-                                                         rtp_type(rtp_session), msg->header.type, extp->header.fmt);
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s PICKED UP %s XRTCP type: %d fmt: %d\n",
+                                                         switch_core_session_get_name(rtp_session->session), rtp_type(rtp_session), msg->header.type, extp->header.fmt);
                }
 
                if (msg->header.type == _RTCP_PT_FIR ||
@@ -6247,19 +6248,27 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
                                }
                        }
 #endif
-                       switch_core_media_gen_key_frame(rtp_session->session);
-                       if (rtp_session->vbw) {
-                               switch_jb_reset(rtp_session->vbw);
+                       
+                       if (switch_core_session_media_flow(rtp_session->session, SWITCH_MEDIA_TYPE_VIDEO) == SWITCH_MEDIA_FLOW_RECVONLY) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Ignoring FIR/PLI from a sendonly stream.\n", 
+                                                                 switch_core_session_get_name(rtp_session->session));
+                       } else {
+                               switch_core_media_gen_key_frame(rtp_session->session);
+                               if (rtp_session->vbw) {
+                                       switch_jb_reset(rtp_session->vbw);
+                               }
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Got FIR/PLI\n", 
+                                                                 switch_core_session_get_name(rtp_session->session));
+                               switch_channel_set_flag(switch_core_session_get_channel(rtp_session->session), CF_VIDEO_REFRESH_REQ);
                        }
-
-                       switch_channel_set_flag(switch_core_session_get_channel(rtp_session->session), CF_VIDEO_REFRESH_REQ);
                }
 
                if (msg->header.type == _RTCP_PT_RTPFB && extp->header.fmt == _RTCP_RTPFB_NACK) {
                        uint32_t *nack = (uint32_t *) extp->body;
                        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_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Got NACK count %d\n", 
+                                                         switch_core_session_get_name(rtp_session->session), ntohs(extp->header.length) - 2);
 
 
                        for (i = 0; i < ntohs(extp->header.length) - 2; i++) {
@@ -6267,7 +6276,7 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
                                nack++;
                        }
 
-                       switch_core_media_gen_key_frame(rtp_session->session);
+                       //switch_core_media_gen_key_frame(rtp_session->session);
                }
                
        } else {