From 6f4154d67f3411367b5b5e85236dbf1639e48401 Mon Sep 17 00:00:00 2001 From: clearlysid Date: Fri, 31 May 2024 20:44:08 +0530 Subject: [PATCH] chore: update readme and add todo for windows --- README.md | 15 +++++++------- src/capturer/engine/win/mod.rs | 1 + src/main.rs | 38 ++++++++++++++++------------------ 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f51645b..76ed408 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,9 @@ use scap::{ fn main() { // Check if the platform is supported - let supported = scap::is_supported(); - if !supported { + if !scap::is_supported() { println!("❌ Platform not supported"); return; - } else { - println!("✅ Platform supported"); } // Check if we have permission to capture screen @@ -59,16 +56,18 @@ fn main() { return; } } - println!("✅ Permission granted"); - // Get capturing targets (WIP) + // Get recording targets let targets = scap::get_all_targets(); - println!("🎯 Targets: {:?}", targets); + println!("Targets: {:?}", targets); + + // All your displays and windows are targets + // You can filter this and capture the one you need. // Create Options let options = Options { fps: 60, - targets, + target: None, // None captures the primary display show_cursor: true, show_highlight: true, excluded_targets: None, diff --git a/src/capturer/engine/win/mod.rs b/src/capturer/engine/win/mod.rs index 0fdbe49..0cf288e 100644 --- a/src/capturer/engine/win/mod.rs +++ b/src/capturer/engine/win/mod.rs @@ -217,6 +217,7 @@ pub fn get_output_frame_size(options: &Options) -> [u32; 2] { } pub fn get_crop_area(options: &Options) -> Area { + // TODO: this should be based on options.target, not main display let display = targets::get_main_display(); let display_raw = WCMonitor::from_raw_hmonitor(display.raw_handle.0); diff --git a/src/main.rs b/src/main.rs index d3e712d..4446323 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ -// This program is just a testbed for the library itself -// Refer to the lib.rs file for the actual implementation +// This program is just a testing application +// Refer to `lib.rs` for the library source code use scap::{ capturer::{Area, Capturer, Options, Point, Size}, @@ -8,15 +8,13 @@ use scap::{ }; fn main() { - // #1 Check if the platform is supported + // Check if the platform is supported if !scap::is_supported() { println!("❌ Platform not supported"); return; - } else { - println!("✅ Platform supported"); } - // #2 Check if we have permission to capture screen + // Check if we have permission to capture screen // If we don't, request it. if !scap::has_permission() { println!("❌ Permission not granted. Requesting permission..."); @@ -25,23 +23,23 @@ fn main() { return; } } - println!("✅ Permission granted"); - // #3 Get recording targets + // Get recording targets let targets = scap::get_all_targets(); println!("🎯 Targets: {:?}", targets); - let target = targets.into_iter().find(|target| match target { - Target::Display(_) => false, - Target::Window(w) => w.title.contains("Visual Studio Code"), - }); + let vscode_win = targets + .into_iter() + .find(|target| match target { + Target::Display(_) => false, + Target::Window(w) => w.title.contains("Visual Studio Code"), + }) + .expect("Visual Studio Code window not found"); - println!("{:?}", target); - - // #4 Create Options + // Create Options let options = Options { fps: 60, - target, + target: Some(vscode_win), show_cursor: true, show_highlight: true, excluded_targets: None, @@ -57,13 +55,13 @@ fn main() { ..Default::default() }; - // #5 Create Recorder + // Create Recorder with options let mut recorder = Capturer::new(options); - // #6 Start Capture + // Start Capture recorder.start_capture(); - // #7 Capture 100 frames + // Capture 100 frames let mut start_time: u64 = 0; for i in 0..100 { let frame = recorder.get_next_frame().expect("Error"); @@ -126,6 +124,6 @@ fn main() { } } - // #8 Stop Capture + // Stop Capture recorder.stop_capture(); }