Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/lux-ci-config.json

This file was deleted.

40 changes: 37 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,32 @@ jobs:
# with:
# category: ${{ matrix.config.os-name }}

rust-crate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Show Rust toolchain
run: |
rustc --version
cargo --version

- name: Test pyvirtualcam-core
run: cargo test -p pyvirtualcam-core --locked

- name: List pyvirtualcam-core package contents
run: cargo package -p pyvirtualcam-core --list --locked

- name: Package pyvirtualcam-core
run: cargo package -p pyvirtualcam-core --locked

- name: Store Rust crate as artifact
uses: actions/upload-artifact@v4
with:
name: crate-pyvirtualcam-core
path: target/package/pyvirtualcam-core-*.crate

test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -392,7 +418,7 @@ jobs:
publish-wheels:
runs-on: ubuntu-latest

needs: [test, docs]
needs: [test, docs, rust-crate]

if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

Expand All @@ -407,10 +433,18 @@ jobs:
merge-multiple: true
path: dist

- name: Create Release and Upload Wheels
- name: Download Rust crate from artifact storage
uses: actions/download-artifact@v4
with:
name: crate-pyvirtualcam-core
path: dist

- name: Create Release and Upload Artifacts
uses: softprops/action-gh-release@v1
with:
files: dist/*.whl
files: |
dist/*.whl
dist/*.crate

# PyPI publishing disabled for this fork
# Wheels are available as GitHub Actions artifacts after each build
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/luxie-tronic.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include Cargo.toml
recursive-include crates *.toml *.rs *.cpp
recursive-include crates *.toml *.rs *.cpp *.cc *.h LICENSE README.md
recursive-include external/libyuv/include *.h
recursive-include external/libyuv/source *.cc
18 changes: 17 additions & 1 deletion crates/pyvirtualcam-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
[package]
name = "pyvirtualcam-core"
version = "0.0.0"
version = "0.15.0"
edition = "2021"
description = "Native Rust core for pyvirtualcam, including a Linux v4l2loopback backend"
license = "GPL-2.0-only"
build = "build.rs"
readme = "README.md"
repository = "https://github.com/LuxTronic/pyvirtualcam"
homepage = "https://github.com/LuxTronic/pyvirtualcam"
keywords = ["virtual-camera", "v4l2", "v4l2loopback", "linux", "video"]
categories = ["api-bindings", "multimedia::video", "os::unix-apis"]
include = [
"Cargo.toml",
"README.md",
"build.rs",
"src/**",
"cpp/**",
"examples/**",
"vendor/libyuv/LICENSE",
"vendor/libyuv/include/**",
"vendor/libyuv/source/**",
]

[features]
default = ["linux"]
Expand Down
41 changes: 40 additions & 1 deletion crates/pyvirtualcam-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,48 @@ Linux `v4l2loopback` is the first Rust backend. macOS and Windows still use the
existing native implementations until they can be ported and tested without
changing Python behavior.

## Rust Usage

Add the crate to a Rust application:

```toml
[dependencies]
pyvirtualcam-core = "0.15.0"
```

Then create a virtual camera and send frames:

```rust
use pyvirtualcam_core::{CameraBuilder, PixelFormat, Result};

fn main() -> Result<()> {
let width = 640;
let height = 480;
let mut camera = CameraBuilder::new(width, height, 30.0)
.format(PixelFormat::Rgb)
.build()?;

let frame = vec![0; PixelFormat::Rgb.frame_size(width, height)];
camera.send(&frame)?;
camera.close();

Ok(())
}
```

The native Rust API currently supports Linux through `v4l2loopback`. Before
running an application, load and configure a loopback device, for example:

```shell
sudo modprobe v4l2loopback devices=1 video_nr=10 card_label="pyvirtualcam"
```

The crate builds a small vendored copy of libyuv through the `cc` crate, so a
C++ compiler is required when compiling dependents.

## Pixel Conversion

This crate continues to build the vendored `external/libyuv` source instead of
This crate builds the vendored `vendor/libyuv` source instead of
reimplementing pixel conversion in Rust.

That choice is deliberate:
Expand Down
8 changes: 4 additions & 4 deletions crates/pyvirtualcam-core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::path::PathBuf;

fn main() {
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let repo_root = manifest_dir.join("../..");
let libyuv_source_dir = repo_root.join("external/libyuv/source");
let libyuv_include_dir = repo_root.join("external/libyuv/include");
let libyuv_dir = manifest_dir.join("vendor/libyuv");
let libyuv_source_dir = libyuv_dir.join("source");
let libyuv_include_dir = libyuv_dir.join("include");

if !libyuv_source_dir.exists() {
panic!("external/libyuv/source not found; initialize the libyuv submodule");
panic!("vendor/libyuv/source not found; the crate package is incomplete");
}

let mut build = cc::Build::new();
Expand Down
29 changes: 29 additions & 0 deletions crates/pyvirtualcam-core/vendor/libyuv/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright 2011 The LibYuv Project Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

* Neither the name of Google nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 33 additions & 0 deletions crates/pyvirtualcam-core/vendor/libyuv/include/libyuv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2011 The LibYuv Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

#ifndef INCLUDE_LIBYUV_H_
#define INCLUDE_LIBYUV_H_

#include "libyuv/basic_types.h"
#include "libyuv/compare.h"
#include "libyuv/convert.h"
#include "libyuv/convert_argb.h"
#include "libyuv/convert_from.h"
#include "libyuv/convert_from_argb.h"
#include "libyuv/cpu_id.h"
#include "libyuv/mjpeg_decoder.h"
#include "libyuv/planar_functions.h"
#include "libyuv/rotate.h"
#include "libyuv/rotate_argb.h"
#include "libyuv/row.h"
#include "libyuv/scale.h"
#include "libyuv/scale_argb.h"
#include "libyuv/scale_row.h"
#include "libyuv/scale_uv.h"
#include "libyuv/version.h"
#include "libyuv/video_common.h"

#endif // INCLUDE_LIBYUV_H_
Loading
Loading