From 023ba7005eaae300f48f591edd24844fcab87d6a Mon Sep 17 00:00:00 2001 From: Jonathan Schnitzler <88723215+apbr@users.noreply.github.com> Date: Wed, 26 Apr 2023 16:36:33 +0200 Subject: [PATCH 01/14] Really print the format in use in Readme (#70) Actually print the format in use when saying so instead of printing the requested format. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fcd7bd..5c8206e 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ fn main() { fmt.width = 1280; fmt.height = 720; fmt.fourcc = FourCC::new(b"YUYV"); - dev.set_format(&fmt).expect("Failed to write format"); + let fmt = dev.set_format(&fmt).expect("Failed to write format"); // The actual format chosen by the device driver may differ from what we // requested! Print it out to get an idea of what is actually used now. From cf6d4125d3f37f24d18c325fd369f503d9f12a88 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Sun, 7 May 2023 20:34:59 +0200 Subject: [PATCH 02/14] sys: Bump bindgen to 0.65.1 Bump minor versions and push to crates.io Signed-off-by: Christopher N. Hesse --- Cargo.toml | 4 ++-- v4l-sys/Cargo.toml | 6 +++--- v4l2-sys/Cargo.toml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a4ae1bf..83c529f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ repository= "https://github.com/raymanfx/libv4l-rs" [dependencies] bitflags = "1.2.1" libc = "0.2" -v4l-sys = { path = "v4l-sys", version = "0.2.0", optional = true } -v4l2-sys = { path = "v4l2-sys", version = "0.2.0", package="v4l2-sys-mit", optional = true } +v4l-sys = { path = "v4l-sys", version = "0.3.0", optional = true } +v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optional = true } [dev-dependencies] glium = "0.27.0" diff --git a/v4l-sys/Cargo.toml b/v4l-sys/Cargo.toml index 2372adf..df42090 100644 --- a/v4l-sys/Cargo.toml +++ b/v4l-sys/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "v4l-sys" description = "Raw video4linux (v4l) bindings" -version = "0.2.0" +version = "0.3.0" authors = ["Christopher N. Hesse "] edition = "2018" license = "MIT" -links = "v4l1 v4l2 4lconvert" +links = "v4l1 v4l2 v4lconvert" build = "build.rs" [build-dependencies] -bindgen = "0.59" +bindgen = "0.65.1" diff --git a/v4l2-sys/Cargo.toml b/v4l2-sys/Cargo.toml index b499730..5971c8e 100644 --- a/v4l2-sys/Cargo.toml +++ b/v4l2-sys/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "v4l2-sys-mit" description = "Raw v4l2 bindings (MIT licensed)" -version = "0.2.0" +version = "0.3.0" authors = ["Christopher N. Hesse "] edition = "2018" license = "MIT" build = "build.rs" [build-dependencies] -bindgen = "0.59" +bindgen = "0.65.1" From 1ca7ff167e34c964516d14d9a02c412c545c80cb Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Sun, 7 May 2023 20:57:54 +0200 Subject: [PATCH 03/14] sys: Remove deprecated unaligned_references lint Signed-off-by: Christopher N. Hesse --- v4l-sys/src/lib.rs | 2 -- v4l2-sys/src/lib.rs | 2 -- 2 files changed, 4 deletions(-) diff --git a/v4l-sys/src/lib.rs b/v4l-sys/src/lib.rs index f8d806e..e534a8b 100644 --- a/v4l-sys/src/lib.rs +++ b/v4l-sys/src/lib.rs @@ -3,7 +3,5 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] -// https://github.com/rust-lang/rust-bindgen/issues/1651 -#![allow(unaligned_references)] include!(concat!(env!("OUT_DIR"), "/libv4l_bindings.rs")); diff --git a/v4l2-sys/src/lib.rs b/v4l2-sys/src/lib.rs index 3a7885b..1c2f4ec 100644 --- a/v4l2-sys/src/lib.rs +++ b/v4l2-sys/src/lib.rs @@ -3,7 +3,5 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] -// https://github.com/rust-lang/rust-bindgen/issues/1651 -#![allow(unaligned_references)] include!(concat!(env!("OUT_DIR"), "/v4l2_bindings.rs")); From 867d9b122fde603ff7f1bfcdf19de48845c9e1f7 Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Sat, 13 May 2023 00:10:14 +0200 Subject: [PATCH 04/14] v4l: 0.14.0 Signed-off-by: Christopher N. Hesse --- CHANGELOG.md | 9 +++++++++ Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1645ff6..b00f996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,15 @@ Multi-planar capture will not be targeted in the near future unless someone else +## [0.14.0] - 2023-05-13 +### Added +- Expose raw file descriptor of streams through `Stream::handle()` +### Changed +- Updated `bindgen` dependency to 0.65.1 +### Fixed +- Use proper C FFI struct field for `Integer64` controls +- Fix example in README.md to account for the negotiated pixelformat + ## [0.13.1] - 2022-12-08 ### Fixed - Do not block when the device is disconnected diff --git a/Cargo.toml b/Cargo.toml index 83c529f..bb3fd17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "v4l" description = "Safe video4linux (v4l) bindings" -version = "0.13.1" +version = "0.14.0" authors = ["Christopher N. Hesse "] edition = "2018" license = "MIT" From 26d203a0d7d5924cf88f72690ca514ae0cd2ce87 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 9 Nov 2023 22:12:51 +0100 Subject: [PATCH 05/14] Upgrade to `bitflags 2` CI throws an `clippy::bad_bit_mask` that has been fixed in `bitflags 2` [1], and it is always a good idea to stay up to date with the latest crate releases. The major change is an internal restructuring into _two_ types, that require the user to now re-expose default traits implemented on the inner type to the outer type by `#[derive]`'ing them. [1]: https://github.com/bitflags/bitflags/pull/373 --- Cargo.toml | 2 +- src/buffer.rs | 5 ++--- src/capability.rs | 5 ++--- src/control.rs | 5 ++--- src/format/description.rs | 5 ++--- src/format/mod.rs | 5 ++--- src/parameters.rs | 5 ++--- src/video/capture/parameters.rs | 4 ++-- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb3fd17..d8e85c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" repository= "https://github.com/raymanfx/libv4l-rs" [dependencies] -bitflags = "1.2.1" +bitflags = "2" libc = "0.2" v4l-sys = { path = "v4l-sys", version = "0.3.0", optional = true } v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optional = true } diff --git a/src/buffer.rs b/src/buffer.rs index 7bdb2a3..080597c 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -1,4 +1,3 @@ -use bitflags::bitflags; use std::fmt; use crate::timestamp::Timestamp; @@ -30,8 +29,8 @@ pub enum Type { Private = 0x80, } -bitflags! { - #[allow(clippy::unreadable_literal)] +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Flags: u32 { /// Buffer is mapped const MAPPED = 0x00000001; diff --git a/src/capability.rs b/src/capability.rs index 60bb6a7..55483ee 100644 --- a/src/capability.rs +++ b/src/capability.rs @@ -1,10 +1,9 @@ -use bitflags::bitflags; use std::{fmt, str}; use crate::v4l_sys::*; -bitflags! { - #[allow(clippy::unreadable_literal)] +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Flags: u32 { const VIDEO_CAPTURE = 0x00000001; const VIDEO_OUTPUT = 0x00000002; diff --git a/src/control.rs b/src/control.rs index 5736ad7..4631558 100644 --- a/src/control.rs +++ b/src/control.rs @@ -1,4 +1,3 @@ -use bitflags::bitflags; use std::convert::{TryFrom, TryInto}; use std::{ffi, fmt, mem, str}; @@ -63,8 +62,8 @@ impl fmt::Display for Type { } } -bitflags! { - #[allow(clippy::unreadable_literal)] +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Flags: u32 { const DISABLED = 0x0001; const GRABBED = 0x0002; diff --git a/src/format/description.rs b/src/format/description.rs index 9c71b33..24434ac 100644 --- a/src/format/description.rs +++ b/src/format/description.rs @@ -1,11 +1,10 @@ -use bitflags::bitflags; use std::{fmt, str}; use crate::format::FourCC; use crate::v4l_sys::*; -bitflags! { - #[allow(clippy::unreadable_literal)] +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Flags : u32 { const COMPRESSED = 0x0001; const EMULATED = 0x0002; diff --git a/src/format/mod.rs b/src/format/mod.rs index 04cb966..09f24fb 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -1,4 +1,3 @@ -use bitflags::bitflags; use std::{convert::TryFrom, fmt, mem}; use crate::v4l_sys::*; @@ -21,8 +20,8 @@ pub use quantization::Quantization; pub mod transfer; pub use transfer::TransferFunction; -bitflags! { - #[allow(clippy::unreadable_literal)] +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Flags : u32 { const PREMUL_ALPHA = 0x00000001; } diff --git a/src/parameters.rs b/src/parameters.rs index 713d432..f9d5331 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -1,9 +1,8 @@ -use bitflags::bitflags; use std::fmt; -bitflags! { +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Capabilities: u32 { - #[allow(clippy::unreadable_literal)] const TIME_PER_FRAME = 0x1000; } } diff --git a/src/video/capture/parameters.rs b/src/video/capture/parameters.rs index 644596f..25981ef 100644 --- a/src/video/capture/parameters.rs +++ b/src/video/capture/parameters.rs @@ -1,11 +1,11 @@ -use bitflags::bitflags; use std::{fmt, mem}; use crate::fraction::Fraction; use crate::parameters::Capabilities; use crate::v4l_sys::*; -bitflags! { +bitflags::bitflags! { + #[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] pub struct Modes: u32 { const HIGH_QUALITY = 0x1000; } From 7976fed387149846168dc66eda805b59b72a7621 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 9 Nov 2023 22:23:35 +0100 Subject: [PATCH 06/14] v4l2: Ignore clippy conversion warnings when building with `v4l-sys` --- src/v4l2/api.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/v4l2/api.rs b/src/v4l2/api.rs index a832122..0f6fb1d 100644 --- a/src/v4l2/api.rs +++ b/src/v4l2/api.rs @@ -40,7 +40,7 @@ mod detail { ) -> *mut std::os::raw::c_void { // libv4l expects `request` to be a u64, but this is not guaranteed on all platforms. // For the default CI platform (x86_64) clippy will complain about a useless conversion. - #![allow(clippy::useless_conversion)] + #![allow(clippy::useless_conversion, clippy::unnecessary_cast)] v4l2_mmap( start, length.try_into().expect("usize -> c size_t failed"), @@ -51,6 +51,7 @@ mod detail { ) } pub unsafe fn munmap(start: *mut std::os::raw::c_void, length: usize) -> std::os::raw::c_int { + #![allow(clippy::useless_conversion)] v4l2_munmap(start, length.try_into().expect("usize -> c size_t failed")) } } From dfbb778c8a9151f74b337eaa432c727a33e9bb9e Mon Sep 17 00:00:00 2001 From: Alex Maiorella <35647226+donkeyteethUX@users.noreply.github.com> Date: Fri, 10 Nov 2023 07:58:35 -0800 Subject: [PATCH 07/14] Avoid extra ioctl by allowing control query by description (#62) * refactor to avoid extra ioctl remove old control getter * fix doc link and clippy lint * inline format args to please our pedantic overlords * Add missing backticks around intradoc link * Revert "inline format args to please our pedantic overlords" This reverts commit 8ba7d1994672e3f18a0720569baf9c2997331a9a. * Drop unneeded `control_from_id()` The new implementation of `control()` takes a `&Description` directly, and callers have enough means to get that `Description` such that we shouldn't cater to the "slower" use-case of letting `libv4l-rs` query it again. --------- Co-authored-by: Marijn Suijten --- src/device.rs | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/device.rs b/src/device.rs index 3a2010a..4b62721 100644 --- a/src/device.rs +++ b/src/device.rs @@ -5,11 +5,11 @@ use std::{io, mem}; use libc; -use crate::control; +use crate::capability::Capabilities; +use crate::control::{self, Control, Description}; use crate::v4l2; use crate::v4l2::videodev::v4l2_ext_controls; use crate::v4l_sys::*; -use crate::{capability::Capabilities, control::Control}; /// Linux capture device abstraction pub struct Device { @@ -92,7 +92,7 @@ impl Device { } /// Returns the supported controls for a device such as gain, focus, white balance, etc. - pub fn query_controls(&self) -> io::Result> { + pub fn query_controls(&self) -> io::Result> { let mut controls = Vec::new(); unsafe { let mut v4l2_ctrl: v4l2_query_ext_ctrl = mem::zeroed(); @@ -107,7 +107,7 @@ impl Device { ) { Ok(_) => { // get the basic control information - let mut control = control::Description::from(v4l2_ctrl); + let mut control = Description::from(v4l2_ctrl); // if this is a menu control, enumerate its items if control.typ == control::Type::Menu @@ -167,29 +167,16 @@ impl Device { Ok(controls) } - /// Returns the control value for an ID + /// Returns the current control value from its [`Description`] /// /// # Arguments /// - /// * `id` - Control identifier - pub fn control(&self, id: u32) -> io::Result { + /// * `desc` - Control description + pub fn control(&self, desc: &Description) -> io::Result { unsafe { - let mut queryctrl = v4l2_query_ext_ctrl { - id, - ..mem::zeroed() - }; - v4l2::ioctl( - self.handle().fd(), - v4l2::vidioc::VIDIOC_QUERY_EXT_CTRL, - &mut queryctrl as *mut _ as *mut std::os::raw::c_void, - )?; - - // determine the control type - let description = control::Description::from(queryctrl); - // query the actual control value let mut v4l2_ctrl = v4l2_ext_control { - id, + id: desc.id, ..mem::zeroed() }; let mut v4l2_ctrls = v4l2_ext_controls { @@ -203,7 +190,7 @@ impl Device { &mut v4l2_ctrls as *mut _ as *mut std::os::raw::c_void, )?; - let value = match description.typ { + let value = match desc.typ { control::Type::Integer64 => { control::Value::Integer(v4l2_ctrl.__bindgen_anon_1.value64) } @@ -221,7 +208,7 @@ impl Device { } }; - Ok(Control { id, value }) + Ok(Control { id: desc.id, value }) } } From 0394443c51571181f7aa77d5d6e015b27914b730 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 11 Nov 2023 00:20:12 +0100 Subject: [PATCH 08/14] Retain instead of truncate unknown flags when converting to `bitflags` (#80) `bitflags` intrinsically supports holding unknown flag values, and pretty-printing a non-zero hex code if there are any. This should make our conversion functions lossless and allow us/users to more easily spot new, unsupported constants. --- src/buffer.rs | 2 +- src/capability.rs | 2 +- src/control.rs | 2 +- src/format/description.rs | 2 +- src/format/mod.rs | 2 +- src/parameters.rs | 2 +- src/video/capture/parameters.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 080597c..59a4c3e 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -81,7 +81,7 @@ impl Default for Flags { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/capability.rs b/src/capability.rs index 55483ee..835e2e6 100644 --- a/src/capability.rs +++ b/src/capability.rs @@ -45,7 +45,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/control.rs b/src/control.rs index 4631558..db434af 100644 --- a/src/control.rs +++ b/src/control.rs @@ -84,7 +84,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/format/description.rs b/src/format/description.rs index 24434ac..e5f0039 100644 --- a/src/format/description.rs +++ b/src/format/description.rs @@ -15,7 +15,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/format/mod.rs b/src/format/mod.rs index 09f24fb..27d782d 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -29,7 +29,7 @@ bitflags::bitflags! { impl From for Flags { fn from(flags: u32) -> Self { - Self::from_bits_truncate(flags) + Self::from_bits_retain(flags) } } diff --git a/src/parameters.rs b/src/parameters.rs index f9d5331..a46b0c0 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -9,7 +9,7 @@ bitflags::bitflags! { impl From for Capabilities { fn from(caps: u32) -> Self { - Self::from_bits_truncate(caps) + Self::from_bits_retain(caps) } } diff --git a/src/video/capture/parameters.rs b/src/video/capture/parameters.rs index 25981ef..1a3a89f 100644 --- a/src/video/capture/parameters.rs +++ b/src/video/capture/parameters.rs @@ -13,7 +13,7 @@ bitflags::bitflags! { impl From for Modes { fn from(caps: u32) -> Self { - Self::from_bits_truncate(caps) + Self::from_bits_retain(caps) } } From c85ecb2f542b8307f934b368a0e5966aa5f736c5 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 1 Dec 2023 20:53:09 +0100 Subject: [PATCH 09/14] Add dependabot configuration to GitHub CI (#82) Let dependabot suggest dependency upgrades in `Cargo.toml` and the GitHub Actions CI scripts so that we don't forget / miss out on them. --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f70c471 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + - package-ecosystem: github-actions + directory: /.github/workflows/ + schedule: + interval: weekly From 63755ad417aff5f5b451f92a22e4e95a542d0309 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:55:23 +0100 Subject: [PATCH 10/14] build(deps): bump actions/checkout from 2 to 4 in /.github/workflows (#84) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d8af7d..9576516 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - run: sudo apt-get install libv4l-dev - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-20.04 steps: - run: sudo apt-get install libv4l-dev - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -53,7 +53,7 @@ jobs: name: Rustfmt runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -70,7 +70,7 @@ jobs: runs-on: ubuntu-20.04 steps: - run: sudo apt-get install libv4l-dev - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal @@ -93,7 +93,7 @@ jobs: runs-on: ubuntu-20.04 steps: - run: sudo apt-get install libv4l-dev - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal From 21d6b20cf2f7dc0d2b66cc88dcb5f3e9bc90ebf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:56:19 +0100 Subject: [PATCH 11/14] build(deps): update jpeg-decoder requirement from 0.2.1 to 0.3.0 (#85) Updates the requirements on [jpeg-decoder](https://github.com/image-rs/jpeg-decoder) to permit the latest version. - [Changelog](https://github.com/image-rs/jpeg-decoder/blob/master/CHANGELOG.md) - [Commits](https://github.com/image-rs/jpeg-decoder/compare/v0.2.1...v0.3.0) --- updated-dependencies: - dependency-name: jpeg-decoder dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d8e85c1..9832faf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ v4l2-sys = { path = "v4l2-sys", version = "0.3.0", package="v4l2-sys-mit", optio [dev-dependencies] glium = "0.27.0" -jpeg-decoder = "0.2.1" +jpeg-decoder = "0.3.0" [features] default = ["v4l2"] From 6a6017bf9c94f6bf576cdf84605c2adfa0ce7b05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Dec 2023 17:49:45 +0100 Subject: [PATCH 12/14] build(deps): update bindgen requirement from 0.65.1 to 0.69.1 (#87) Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version. - [Release notes](https://github.com/rust-lang/rust-bindgen/releases) - [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.65.1...v0.69.1) --- updated-dependencies: - dependency-name: bindgen dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- v4l-sys/Cargo.toml | 2 +- v4l2-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v4l-sys/Cargo.toml b/v4l-sys/Cargo.toml index df42090..f0f7f1c 100644 --- a/v4l-sys/Cargo.toml +++ b/v4l-sys/Cargo.toml @@ -9,4 +9,4 @@ links = "v4l1 v4l2 v4lconvert" build = "build.rs" [build-dependencies] -bindgen = "0.65.1" +bindgen = "0.69.1" diff --git a/v4l2-sys/Cargo.toml b/v4l2-sys/Cargo.toml index 5971c8e..c1dd6bc 100644 --- a/v4l2-sys/Cargo.toml +++ b/v4l2-sys/Cargo.toml @@ -8,4 +8,4 @@ license = "MIT" build = "build.rs" [build-dependencies] -bindgen = "0.65.1" +bindgen = "0.69.1" From e0675fdac024e4a1f330114d65a169fbf1d3577f Mon Sep 17 00:00:00 2001 From: Jay Sistar Date: Thu, 21 Dec 2023 13:06:42 -0500 Subject: [PATCH 13/14] Adding change by @anatawa12 from https://github.com/raymanfx/libv4l-rs/pull/71#discussion_r1346704300 --- src/io/mmap/arena.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/io/mmap/arena.rs b/src/io/mmap/arena.rs index 2d6dd97..6d8a437 100644 --- a/src/io/mmap/arena.rs +++ b/src/io/mmap/arena.rs @@ -106,17 +106,21 @@ impl<'a> Arena<'a> { // each plane has to be mapped separately let mut planes = Vec::new(); for plane in &v4l2_planes { + let length = if !self.buf_type.planar() { + v4l2_buf.length as usize + } else { + plane.length as usize + }; let ptr = v4l2::mmap( ptr::null_mut(), - plane.length as usize, + length, libc::PROT_READ | libc::PROT_WRITE, libc::MAP_SHARED, self.handle.fd(), plane.m.mem_offset as libc::off_t, )?; - planes.push(slice::from_raw_parts_mut::( - ptr as *mut u8, plane.length as usize + ptr as *mut u8, length, )); } From 4a284320eaf39eeb41109ae0901bca3caf4af48d Mon Sep 17 00:00:00 2001 From: Jay Sistar Date: Thu, 21 Dec 2023 16:36:44 -0500 Subject: [PATCH 14/14] Adding offset --- src/io/mmap/arena.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/io/mmap/arena.rs b/src/io/mmap/arena.rs index 6d8a437..4852a09 100644 --- a/src/io/mmap/arena.rs +++ b/src/io/mmap/arena.rs @@ -106,10 +106,10 @@ impl<'a> Arena<'a> { // each plane has to be mapped separately let mut planes = Vec::new(); for plane in &v4l2_planes { - let length = if !self.buf_type.planar() { - v4l2_buf.length as usize + let (length, offset) = if !self.buf_type.planar() { + (v4l2_buf.length as usize, v4l2_buf.m.offset as libc::off_t) } else { - plane.length as usize + (plane.length as usize, plane.m.mem_offset as libc::off_t) }; let ptr = v4l2::mmap( ptr::null_mut(), @@ -117,7 +117,7 @@ impl<'a> Arena<'a> { libc::PROT_READ | libc::PROT_WRITE, libc::MAP_SHARED, self.handle.fd(), - plane.m.mem_offset as libc::off_t, + offset, )?; planes.push(slice::from_raw_parts_mut::( ptr as *mut u8, length,