Skip to content

Commit

Permalink
Enable restarting the video stream.
Browse files Browse the repository at this point in the history
Sometimes a client may want to restart the video stream while keeping
the same config.
  • Loading branch information
H-M-H committed Nov 12, 2024
1 parent 00a19aa commit d30b8b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum MessageInbound {
Config(ClientConfiguration),
PauseVideo,
ResumeVideo,
RestartVideo,
ChooseCustomInputAreas,
}

Expand Down
7 changes: 7 additions & 0 deletions src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum VideoCommands {
Start(VideoConfig),
Pause,
Resume,
Restart,
}

fn send_message<S>(sender: &mut S, message: MessageOutbound)
Expand Down Expand Up @@ -120,6 +121,9 @@ impl<S, R, FnUInput> WeylusClientHandler<S, R, FnUInput> {
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);
Expand Down Expand Up @@ -372,6 +376,9 @@ fn handle_video<S: WeylusSender + Clone + 'static>(
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!");
Expand Down

0 comments on commit d30b8b3

Please sign in to comment.