Skip to content

Commit

Permalink
Allow access to DirectX device 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
NiiightmareXD committed Oct 24, 2024
1 parent 9d3109d commit 0f22075
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 101 deletions.
68 changes: 34 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "windows-capture"
version = "1.3.6"
version = "1.4.0"
authors = ["NiiightmareXD"]
edition = "2021"
description = "Fastest Windows Screen Capture Library For Rust 🔥"
Expand Down Expand Up @@ -52,8 +52,8 @@ parking_lot = "0.12.3"
rayon = "1.10.0"

# Error handling
thiserror = "1.0.63"
clap = { version = "4.5.17", features = ["derive"] }
thiserror = "1.0.65"
clap = { version = "4.5.20", features = ["derive"] }
ctrlc = "3.4.5"

[package.metadata.docs.rs]
Expand All @@ -64,5 +64,9 @@ targets = ["x86_64-pc-windows-msvc"]
name = "basic"
doc-scrape-examples = false

[[example]]
name = "cli"
doc-scrape-examples = false

[workspace]
members = ["windows-capture-python"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add this library to your `Cargo.toml`:

```toml
[dependencies]
windows-capture = "1.3.6"
windows-capture = "1.4.0"
```

or run this command
Expand All @@ -42,7 +42,7 @@ use std::{
};

use windows_capture::{
capture::GraphicsCaptureApiHandler,
capture::{Context, GraphicsCaptureApiHandler},
encoder::{AudioSettingsBuilder, ContainerSettingsBuilder, VideoEncoder, VideoSettingsBuilder},
frame::Frame,
graphics_capture_api::InternalCaptureControl,
Expand All @@ -66,8 +66,8 @@ impl GraphicsCaptureApiHandler for Capture {
type Error = Box<dyn std::error::Error + Send + Sync>;

// Function that will be called to create the struct. The flags can be passed from settings.
fn new(message: Self::Flags) -> Result<Self, Self::Error> {
println!("Got The Flag: {message}");
fn new(ctx: Context<Self::Flags>) -> Result<Self, Self::Error> {
println!("Got The Flag: {}", ctx.flags);

let encoder = VideoEncoder::new(
VideoSettingsBuilder::new(1920, 1080),
Expand Down
6 changes: 3 additions & 3 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use windows_capture::{
capture::{GraphicsCaptureApiHandler, RawDirect3DDevice},
capture::{Context, GraphicsCaptureApiHandler},
encoder::{AudioSettingsBuilder, ContainerSettingsBuilder, VideoEncoder, VideoSettingsBuilder},
frame::Frame,
graphics_capture_api::InternalCaptureControl,
Expand All @@ -28,8 +28,8 @@ impl GraphicsCaptureApiHandler for Capture {
type Error = Box<dyn std::error::Error + Send + Sync>;

// Function that will be called to create the struct. The flags can be passed from settings.
fn new(_: RawDirect3DDevice, message: Self::Flags) -> Result<Self, Self::Error> {
println!("Got The Flag: {message}");
fn new(ctx: Context<Self::Flags>) -> Result<Self, Self::Error> {
println!("Got The Flag: {}", ctx.flags);

let encoder = VideoEncoder::new(
VideoSettingsBuilder::new(1920, 1080),
Expand Down
14 changes: 7 additions & 7 deletions examples/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
use clap::Parser;

use windows_capture::{
capture::{GraphicsCaptureApiHandler, RawDirect3DDevice},
capture::{Context, GraphicsCaptureApiHandler},
encoder::{AudioSettingsBuilder, ContainerSettingsBuilder, VideoEncoder, VideoSettingsBuilder},
frame::Frame,
graphics_capture_api::InternalCaptureControl,
Expand Down Expand Up @@ -53,26 +53,26 @@ impl GraphicsCaptureApiHandler for Capture {
type Error = Box<dyn std::error::Error + Send + Sync>;

// Function that will be called to create the struct. The flags can be passed from settings.
fn new(_: RawDirect3DDevice, settings: Self::Flags) -> Result<Self, Self::Error> {
fn new(ctx: Context<Self::Flags>) -> Result<Self, Self::Error> {
println!("Capture started.");

let video_settings = VideoSettingsBuilder::new(settings.width, settings.height)
.bitrate(settings.bitrate)
.frame_rate(settings.frame_rate);
let video_settings = VideoSettingsBuilder::new(ctx.flags.width, ctx.flags.height)
.bitrate(ctx.flags.bitrate)
.frame_rate(ctx.flags.frame_rate);

let encoder = VideoEncoder::new(
video_settings,
AudioSettingsBuilder::default().disabled(true),
ContainerSettingsBuilder::default(),
&settings.path,
&ctx.flags.path,
)?;

Ok(Self {
encoder: Some(encoder),
start: Instant::now(),
frame_count_since_reset: 0,
last_reset: Instant::now(),
settings,
settings: ctx.flags,
})
}

Expand Down
Loading

0 comments on commit 0f22075

Please sign in to comment.