From d30b8b3e56820b72a858e227654823722f0d5d8f Mon Sep 17 00:00:00 2001 From: HMH Date: Tue, 12 Nov 2024 23:52:21 +0100 Subject: [PATCH] Enable restarting the video stream. Sometimes a client may want to restart the video stream while keeping the same config. --- src/protocol.rs | 1 + src/websocket.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/protocol.rs b/src/protocol.rs index 77460ed..2f453ad 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -21,6 +21,7 @@ pub enum MessageInbound { Config(ClientConfiguration), PauseVideo, ResumeVideo, + RestartVideo, ChooseCustomInputAreas, } diff --git a/src/websocket.rs b/src/websocket.rs index d877135..4cfb2f5 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -31,6 +31,7 @@ enum VideoCommands { Start(VideoConfig), Pause, Resume, + Restart, } fn send_message(sender: &mut S, message: MessageOutbound) @@ -120,6 +121,9 @@ impl WeylusClientHandler { MessageInbound::ResumeVideo => { self.video_sender.send(VideoCommands::Resume).unwrap() } + MessageInbound::RestartVideo => { + self.video_sender.send(VideoCommands::Restart).unwrap() + } MessageInbound::ChooseCustomInputAreas => { let (sender, receiver) = std::sync::mpsc::channel(); crate::gui::get_input_area(self.config.no_gui, sender); @@ -372,6 +376,9 @@ fn handle_video( Ok(VideoCommands::Resume) => { paused = false; } + Ok(VideoCommands::Restart) => { + video_encoder = None; + } Err(RecvTimeoutError::Timeout) => { if recorder.is_none() { warn!("Screen capture not initalized, can not send video frame!");