From 70d34e7727143e070a2bc4582288af23b1c5c7b3 Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Wed, 9 Jun 2021 16:41:06 +0100 Subject: [PATCH] [CORE] Add feature to make video refresh requests pending for being process When there are multiple video refresh request sent within defined VIDEO_REFRESH_FREQ, only first one is being processed. The rests are discarded. With this feature, any second video refresh request is marked as pending and is being processed as soon as possible, so within the interval given by VIDEO_REFRESH_FREQ. --- src/switch_core_media.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 686bc344f7..68b78b5b2f 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -260,7 +260,7 @@ struct switch_media_handle_s { switch_time_t last_codec_refresh; switch_time_t last_video_refresh_req; switch_timer_t video_timer; - + int video_refresh_requested; switch_vid_params_t vid_params; switch_file_handle_t *video_read_fh; @@ -2962,6 +2962,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session check_jb_sync(session); } } + { + switch_time_t now = switch_micro_time_now(); + if (smh->video_refresh_requested > 1 && (now - smh->last_video_refresh_req >= VIDEO_REFRESH_FREQ)) { + switch_core_session_request_video_refresh(session); + } + } } /* re-set codec if necessary */ @@ -14366,9 +14372,11 @@ SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switc switch_time_t now = switch_micro_time_now(); if (!force && (smh->last_video_refresh_req && (now - smh->last_video_refresh_req) < VIDEO_REFRESH_FREQ)) { + smh->video_refresh_requested++; return SWITCH_STATUS_BREAK; } + smh->video_refresh_requested=0; smh->last_video_refresh_req = now; if (force) {