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
150 changes: 139 additions & 11 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ strip = true
# doesn't have that feature yet, so consume a fork branch until it's merged.
[patch.crates-io]
nvidia-video-codec-sdk = { git = "https://github.com/kixelated/nvidia-video-codec-sdk.git", branch = "dynamic-loading" }
# moq-video's `vaapi` feature uses discord/cros-codecs (`vaapi_dlopen`), which
# pulls cros-libva 0.0.13. The `dlopen` feature it needs (load libva at runtime
# so a vaapi-enabled binary still links without libva-dev and still loads on a
# libva-less machine, falling back to software) lives only on discord's fork, so
# point the published 0.0.13 at it. Drop once `dlopen` is upstreamed.
cros-libva = { git = "https://github.com/discord/cros-libva.git", branch = "discord-0.0.13" }
10 changes: 9 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ allow-registry = ["https://github.com/rust-lang/crates.io-index"]
# moq-video patches nvidia-video-codec-sdk to a fork that adds dlopen
# (`dynamic-loading`); see the root Cargo.toml [patch.crates-io]. Drop this once
# the feature is upstreamed and the patch is removed.
allow-git = ["https://github.com/kixelated/nvidia-video-codec-sdk"]
#
# The `vaapi` feature pulls discord/cros-codecs (the maintained fork: cros-libva
# 0.0.13 + a hardened H.264 VAAPI encoder) and patches cros-libva to discord's
# fork for the `dlopen` feature. Drop these once `dlopen` is upstreamed.
allow-git = [
"https://github.com/kixelated/nvidia-video-codec-sdk",
"https://github.com/discord/cros-codecs",
"https://github.com/discord/cros-libva",
]
6 changes: 3 additions & 3 deletions doc/bin/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ moq-cli publish --url https://relay.example.com --broadcast cam.hang capture --n

Video capture uses a native per-platform backend (AVFoundation on macOS, V4L2 on
Linux, Media Foundation on Windows) and picks a hardware H.264 encoder
(VideoToolbox on macOS, NVENC on Linux NVIDIA) when one is present, falling back
to the built-in software encoder (openh264); force either with `--hardware` /
`--software`. `--camera` takes a bare integer as a device index, otherwise a
(VideoToolbox on macOS, NVENC on Linux NVIDIA, VAAPI on Linux Intel/AMD) when one
is present, falling back to the built-in software encoder (openh264); force either
with `--hardware` / `--software`. `--camera` takes a bare integer as a device index, otherwise a
device path (Linux) or name (a friendly-name substring on Windows, the
AVFoundation `uniqueID` on macOS). Audio capture uses cpal (CoreAudio / WASAPI /
ALSA) and encodes Opus.
Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
# cpal's `alsa-sys` (moq-audio `capture` feature) links libasound on
# Linux via pkg-config; macOS uses CoreAudio, so no dep there.
pkgs.alsa-lib
# moq-video `vaapi` feature: cros-libva runs bindgen against the libva
# headers at build time (found via pkg-config), even though libva is
# dlopen'd at runtime (`vaapi_dlopen`). macOS has no VAAPI.
pkgs.libva
];

# JavaScript dependencies
Expand Down
14 changes: 14 additions & 0 deletions rs/moq-video/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,24 @@ doctest = false
# driver, falling back to software (see backend::open). `cuda-12020` pins the CUDA
# API version so the build needs no CUDA toolkit.
nvenc = ["dep:nvidia-video-codec-sdk", "nvidia-video-codec-sdk/dynamic-loading", "cudarc/fallback-dynamic-loading", "cudarc/cuda-12020"]
# Intel/AMD VAAPI hardware encoder (Linux). Off by default; enable for a build
# that should use VAAPI where present. Everything is dlopen'd at runtime:
# discord/cros-codecs's `vaapi_dlopen` resolves libva through the cros-libva
# `dlopen` feature (a fork feature, see the root [patch.crates-io]). So a
# vaapi-enabled binary still links on a libva-less builder and still loads on
# machines without libva, falling back to software (see backend::open). The
# build still needs libva *headers* for bindgen (provided by the nix devShell).
vaapi = ["dep:cros-codecs"]

[dependencies]
anyhow = "1"
bytes = "1"
# VAAPI H.264 encoder + zero-copy dmabuf import, gated behind `vaapi` + a linux
# cfg. discord's fork is the maintained one: cros-libva 0.0.13 so it builds
# against libva >= 2.23 (published cros-codecs pins the broken 0.0.12), plus a
# hardened H.264 encoder (packed SPS/PPS + slice headers, frame_num, rate
# control). `vaapi_dlopen` loads libva at runtime.
cros-codecs = { git = "https://github.com/discord/cros-codecs.git", branch = "discord-0.0.5", optional = true, default-features = false, features = ["vaapi_dlopen"] }
cudarc = { version = "0.19", optional = true, default-features = false, features = ["driver"] }
moq-mux = { workspace = true }
moq-net = { workspace = true }
Expand Down
Loading
Loading