Skip to content

Commit

Permalink
chore: update readme and add todo for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
clearlysid committed May 31, 2024
1 parent ba78f01 commit 6f4154d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/capturer/engine/win/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
38 changes: 18 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand All @@ -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...");
Expand All @@ -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,
Expand All @@ -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");
Expand Down Expand Up @@ -126,6 +124,6 @@ fn main() {
}
}

// #8 Stop Capture
// Stop Capture
recorder.stop_capture();
}

0 comments on commit 6f4154d

Please sign in to comment.