From 5a0f8d008ed29a84dffc16af4dd6fdfff2430085 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 4 Feb 2022 22:18:48 +0800 Subject: [PATCH] video_ack_required for web --- libs/hbb_common/protos/message.proto | 1 + src/server/connection.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/hbb_common/protos/message.proto b/libs/hbb_common/protos/message.proto index 2cd496d4a..d11c48407 100644 --- a/libs/hbb_common/protos/message.proto +++ b/libs/hbb_common/protos/message.proto @@ -381,6 +381,7 @@ message Misc { string close_reason = 9; bool refresh_video = 10; OptionResponse option_response = 11; + bool video_received = 12; } } diff --git a/src/server/connection.rs b/src/server/connection.rs index 5e0078221..b03abe60a 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -63,6 +63,7 @@ pub struct Connection { disable_clipboard: bool, // by peer disable_audio: bool, // by peer tx_input: std_mpsc::Sender, // handle input messages + video_ack_required: bool, } impl Subscriber for ConnInner { @@ -142,6 +143,7 @@ impl Connection { disable_audio: false, disable_clipboard: false, tx_input, + video_ack_required: false, }; tokio::spawn(async move { if let Err(err) = start_ipc(rx_to_cm, tx_from_cm).await { @@ -271,7 +273,9 @@ impl Connection { } }, Some((instant, value)) = rx_video.recv() => { - video_service::notify_video_frame_feched(id, Some(instant.into())); + if !conn.video_ack_required { + video_service::notify_video_frame_feched(id, Some(instant.into())); + } if let Err(err) = conn.stream.send(&value as &Message).await { conn.on_close(&err.to_string(), false); break; @@ -927,6 +931,12 @@ impl Connection { super::video_service::refresh(); } } + Some(misc::Union::video_received(_)) => { + if !self.video_ack_required { + self.video_ack_required = true; + } + video_service::notify_video_frame_feched(self.inner.id, Some(Instant::now().into())); + } _ => {} }, _ => {}