Skip to content

Commit

Permalink
in progress v4l2 implementation, mostly stable core
Browse files Browse the repository at this point in the history
  • Loading branch information
l1npengtul committed Jan 16, 2025
1 parent f0ffb0e commit 33f0787
Show file tree
Hide file tree
Showing 26 changed files with 1,267 additions and 1,309 deletions.
678 changes: 306 additions & 372 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 3 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,12 @@ docs-features = []
test-fail-warning = []

[dependencies]
thiserror = "1.0"
paste = "1.0"

[dependencies.mozjpeg]
version = "0.10"
optional = true

[dependencies.dcv-color-primitives]
version = "0.6"
optional = true

[dependencies.nokhwa-core]
version = "0.2"
path = "nokhwa-core"
Expand All @@ -73,11 +68,11 @@ version = "0.2"
optional = true

[dependencies.wgpu]
version = "0.20"
version = "23"
optional = true

[dependencies.opencv]
version = "0.92"
version = "0.93"
default-features = false
features = ["videoio"]
optional = true
Expand All @@ -97,14 +92,10 @@ path = "nokhwa-bindings-macos"
optional = true

[dependencies.nokhwa-bindings-linux]
version = "0.1"
version = "0.2"
path = "nokhwa-bindings-linux"
optional = true

[dependencies.regex]
version = "1.7"
optional = true

[dependencies.web-sys]
version = "0.3"
features = [
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

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

87 changes: 48 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,59 @@
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
outputs = {
self,
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system overlays;
inherit system;
overlays = [rust-overlay.overlays.default];
};
in
{
rustbin = pkgs.rust-bin.selectLatestNightlyWith (toolchain:
toolchain.default.override {
extensions = ["rust-src"];
});
in {
formatter = pkgs.alejandra;

devShells.default = pkgs.mkShell {
#LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
#BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${pkgs.libclang.lib}/lib/clang/${flake-utils.lib.getVersion pkgs.clang}/include";
packages = [
rustbin
] ++ (with pkgs; [
llvmPackages.libclang.lib
llvmPackages.clang
pkg-config
cmake
vcpkg
rustPlatform.bindgenHook
xmlstarlet
opencv
alsa-lib
systemdLibs
cmake
fontconfig
linuxHeaders
v4l-utils
libv4l
pipewire
]);

buildInputs = with pkgs; [
rust-bin.stable.latest.default
rust-bin.stable.latest.rustfmt
rust-bin.stable.latest.clippy
];
nativeBuildInputs = [
pkgs.pkg-config
pkgs.cmake
pkgs.vcpkg
];
packages = with pkgs; [
rust-analyzer
pkg-config
opencv
alsa-lib
systemdLibs
cmake
fontconfig
linuxHeaders
rustPlatform.bindgenHook
llvmPackages.libclang.lib
llvmPackages.clang
v4l-utils
libv4l
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
shellHook = ''
export LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
cargo version
'';
env.RUST_SRC_PATH = "${rustbin}/lib/rustlib/src/rust/library";
env.LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";

shellHook = let
pathToRustProject = "/project/component[@name='RustProjectSettings']";
in
''
echo "WONDERHOOOOOY!!!!"
xmlstarlet edit --inplace --update "${pathToRustProject}/option[@name='explicitPathToStdlib']/@value" --value "${rustbin}/lib/rustlib/src/rust/library" .idea/workspace.xml
xmlstarlet edit --inplace --update "${pathToRustProject}/option[@name='toolchainHomeDirectory']/@value" --value "${rustbin}/bin" .idea/workspace.xml
'';
};
}
);
Expand Down
17 changes: 10 additions & 7 deletions nokhwa-bindings-linux/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
[package]
name = "nokhwa-bindings-linux"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/l1npengtul/nokhwa"
description = "The V4L2 bindings crate for `nokhwa`"
keywords = ["v4l", "v4l2", "linux", "capture", "webcam"]
description = "The Linux V4L2 bindings crate for `nokhwa`"
keywords = ["v4l", "v4l2", "linux", "nokhwa", "webcam"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
v4l2 = ["v4l", "v4l2-sys-mit"]
pw = ["pipewire"]

[dependencies]
v4l = { version = "0.14", features = ["v4l2"], optional = true }
v4l2-sys-mit = { version = "0.3", optional = true }

[dependencies.pipewire]
version = "0.8"
optional = true

[dependencies.nokhwa-core]
version = "0.2"
path = "../nokhwa-core"

[target.'cfg(target_os="linux")'.dependencies]
v4l = { version = "0.14", optional = true }
v4l2-sys-mit = { version = "0.3", optional = true }
Loading

0 comments on commit 33f0787

Please sign in to comment.