Skip to content

Commit d30b8b3

Browse files
committed
Enable restarting the video stream.
Sometimes a client may want to restart the video stream while keeping the same config.
1 parent 00a19aa commit d30b8b3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/protocol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub enum MessageInbound {
2121
Config(ClientConfiguration),
2222
PauseVideo,
2323
ResumeVideo,
24+
RestartVideo,
2425
ChooseCustomInputAreas,
2526
}
2627

src/websocket.rs

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum VideoCommands {
3131
Start(VideoConfig),
3232
Pause,
3333
Resume,
34+
Restart,
3435
}
3536

3637
fn send_message<S>(sender: &mut S, message: MessageOutbound)
@@ -120,6 +121,9 @@ impl<S, R, FnUInput> WeylusClientHandler<S, R, FnUInput> {
120121
MessageInbound::ResumeVideo => {
121122
self.video_sender.send(VideoCommands::Resume).unwrap()
122123
}
124+
MessageInbound::RestartVideo => {
125+
self.video_sender.send(VideoCommands::Restart).unwrap()
126+
}
123127
MessageInbound::ChooseCustomInputAreas => {
124128
let (sender, receiver) = std::sync::mpsc::channel();
125129
crate::gui::get_input_area(self.config.no_gui, sender);
@@ -372,6 +376,9 @@ fn handle_video<S: WeylusSender + Clone + 'static>(
372376
Ok(VideoCommands::Resume) => {
373377
paused = false;
374378
}
379+
Ok(VideoCommands::Restart) => {
380+
video_encoder = None;
381+
}
375382
Err(RecvTimeoutError::Timeout) => {
376383
if recorder.is_none() {
377384
warn!("Screen capture not initalized, can not send video frame!");

0 commit comments

Comments
 (0)