From 1c06e693a6bf900c4834366c249f347f7054ce75 Mon Sep 17 00:00:00 2001 From: NiiightmareXD Date: Sun, 21 Apr 2024 20:45:22 +0330 Subject: [PATCH] =?UTF-8?q?Added=20send=5Fframe=5Fbuffer=20=F0=9F=90=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 2 +- src/encoder.rs | 13 ++++++++++++- src/lib.rs | 2 +- windows-capture-python/Cargo.toml | 2 +- windows-capture-python/pyproject.toml | 2 +- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee1a5e4..b412eda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,7 +306,7 @@ dependencies = [ [[package]] name = "windows-capture" -version = "1.1.4" +version = "1.1.7" dependencies = [ "parking_lot", "rayon", @@ -316,7 +316,7 @@ dependencies = [ [[package]] name = "windows-capture-python" -version = "1.1.4" +version = "1.1.7" dependencies = [ "pyo3", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index 912e6e8..eb5e0e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture" -version = "1.1.4" +version = "1.1.7" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Rust 🔥" diff --git a/README.md b/README.md index d3f15d3..830d5ff 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Add this library to your `Cargo.toml`: ```toml [dependencies] -windows-capture = "1.1.4" +windows-capture = "1.1.7" ``` or run this command diff --git a/src/encoder.rs b/src/encoder.rs index 9665c86..6a669c3 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -571,6 +571,7 @@ impl VideoEncoder { /// # Arguments /// /// * `buffer` - A reference to the byte slice to be encoded Windows API expect this to be Bgra and bottom-top. + /// * `timespan` - The timespan that correlates to the frame buffer. /// /// # Returns /// @@ -581,7 +582,17 @@ impl VideoEncoder { buffer: &[u8], timespan: i64, ) -> Result<(), VideoEncoderError> { - let timespan = TimeSpan { Duration: timespan }; + let frame_timespan = timespan; + let timespan = match self.first_timespan { + Some(timespan) => TimeSpan { + Duration: frame_timespan - timespan.Duration, + }, + None => { + let timespan = frame_timespan; + self.first_timespan = Some(TimeSpan { Duration: timespan }); + TimeSpan { Duration: 0 } + } + }; self.frame_sender.send(Some(( VideoEncoderSource::Buffer((SendDirectX::new(buffer.as_ptr()), buffer.len())), diff --git a/src/lib.rs b/src/lib.rs index e598c36..41ce70d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! //! ```toml //! [dependencies] -//! windows-capture = "1.1.4" +//! windows-capture = "1.1.7" //! ``` //! or run this command //! diff --git a/windows-capture-python/Cargo.toml b/windows-capture-python/Cargo.toml index 79e124e..3860d7e 100644 --- a/windows-capture-python/Cargo.toml +++ b/windows-capture-python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "windows-capture-python" -version = "1.1.4" +version = "1.1.7" authors = ["NiiightmareXD"] edition = "2021" description = "Fastest Windows Screen Capture Library For Python 🔥" diff --git a/windows-capture-python/pyproject.toml b/windows-capture-python/pyproject.toml index 9d51653..826f6d8 100644 --- a/windows-capture-python/pyproject.toml +++ b/windows-capture-python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "windows-capture" -version = "1.1.4" +version = "1.1.7" description = "Fastest Windows Screen Capture Library For Python 🔥" readme = "README.md" requires-python = ">=3.9"