Skip to content

Commit

Permalink
Disable remote control (#19)
Browse files Browse the repository at this point in the history
Remote control is enabled by default unless Sharer specifies it in the
command line.
eg.  cargo run --release -- --display 0 --disable-control

Co-authored-by: z943zhan <z943zhan>
  • Loading branch information
AlisonZhangzx authored Nov 28, 2022
1 parent 15effc4 commit 008b07a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/capture/macos/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use failure::format_err;

use crate::capture::DisplayInfo;
use crate::result::Result;
use failure::format_err;
use std::mem;

use super::ffi::*;
Expand Down
5 changes: 4 additions & 1 deletion src/inputs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ impl InputHandler {
Ok(())
}

pub fn new() -> Self {
pub fn new(disabled_control: bool) -> Self {
let (sender, mut receiver) = mpsc::channel::<Bytes>(32);
tokio::spawn(async move {
while let Some(msg) = receiver.recv().await {
if disabled_control{
continue; // Skip the message if user disabled remote control
}
if let Err(err) = Self::handle_input_event(msg) {
warn!("Error handling input event: {}", err);
}
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct Args {
/// Config file path
#[arg(short, long, default_value = "config.toml")]
config: String,
/// Disable remote control
#[arg(long, default_value = "false")]
disable_control: bool,
}

#[tokio::main]
Expand All @@ -51,7 +54,7 @@ async fn main() -> Result<()> {
let resolution = display.resolution();
let mut capture = ScreenCaptureImpl::new(display, &config)?;
let mut encoder = encoder::FfmpegEncoder::new(resolution.0, resolution.1, &config.encoder);
let input_handler = Arc::new(inputs::InputHandler::new());
let input_handler = Arc::new(inputs::InputHandler::new(args.disable_control));
let my_uuid = uuid::Uuid::new_v4().to_string();

info!("Resolution: {:?}", resolution);
Expand Down

0 comments on commit 008b07a

Please sign in to comment.