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
11 changes: 11 additions & 0 deletions doc/lib/rs/moq-video.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ cameras; links libpipewire), and `vpx` (links libvpx). `vaapi` (Intel and AMD on
Linux), `v4l2` (ARM SoC codecs such as a Raspberry Pi's), and `nvidia` are on by
default, since none needs anything on the build host.

Every config that opens hardware (`encode::Config`, `decode::Config`,
`resize::Config`, `encode::Capture`) has a `device` field, on every platform
and feature set. `Device::Auto`, the default, lets each backend choose.
`Device::Render(path)` names a DRM render node: VA-API opens it, and NVENC and
NVDEC open the NVIDIA GPU behind it, so a host with several GPUs places each
codec on the one it names. `Device::Video(path)` names a V4L2 codec node. A
named node steers automatic backend selection to the backends that drive it,
and one that fails to open is an error rather than a search for another.
macOS, Windows, and Android pick their own device and ignore the field.
`capture::Config::cursor` is `Cursor::Drawn` (the default) or `Cursor::Hidden`.

On Wayland, the `pipewire` feature lets Rust callers request a screen or
window through the system picker with `capture::Source::Portal`. Keep the
selection for automatic reopens; create a new one to choose another source.
Expand Down
1 change: 0 additions & 1 deletion quest/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ removal, a rename, or a wire, catalog, or format change that is free until
and [moq-json writes](/quest/m2/json-write-at.md).
- **Native media and gateways.** [The video producer](/quest/m2/video-producer.md),
[the hole wait](/quest/m2/delay-hole-wait.md),
[device and cursor](/quest/m2/native-media-config.md),
[sink names](/quest/m2/audio-sink-names.md),
[moq-vaapi's exports](/quest/m2/vaapi-exports.md),
[the WebRTC bind](/quest/m2/webrtc-bind.md),
Expand Down
84 changes: 0 additions & 84 deletions quest/m2/native-media-config.md

This file was deleted.

1 change: 0 additions & 1 deletion quest/m2/video-producer.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,4 @@ publisher is renamed). moq-ffi and moq-c keep their names. Wire: none.
## Related

- [Terminal operations consume](/quest/m2/finish-sweep.md) - gives the renamed type `finish(self)`; whichever lands second rebases
- [One device selector](/quest/m2/native-media-config.md) - changes `encode::Config` in the same crate
- [A published capture exposes its grant](/quest/m3/video-publish-grant.md) - adds a getter to the capture handle this runs on
2 changes: 1 addition & 1 deletion quest/m3/vaapi-render-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ which covers only NVIDIA.
- Added 2026-11-06 (maintainer, /quest-unblock) from
[moq-dev/moq#8013](https://github.com/moq-dev/moq/pull/8013)'s follow-ups:
- The VA-API tests open the first suitable render node, so a second GPU
is covered only when `Config::vaapi` names it, which moq-video no longer
is covered only when `Config::device` names it, which moq-video no longer
reads from the environment. `just rs gpu` runs the VA-API tests once for
each AMD or Intel render node, passing it to the tests through a test-only
knob ([env-knobs](/quest/m4/env-knobs.md) owns its name); a node of either vendor without its VA-API
Expand Down
8 changes: 5 additions & 3 deletions quest/m4/capture-cursor.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ Decided: ✅ a separate cursor (rejected: drawn into the frame, with the
viewer's own pointer shown on top). Milestone: ✅ m4 (rejected: m3), since
the consumer is Kixel's later (m2) plans.

Today `capture::Config::cursor` is a bool that draws the cursor in or leaves
it out: the portal's embedded mode, `SetIsCursorCaptureEnabled` on WGC,
`setShowsCursor` on macOS, and a CPU blend of the XFixes cursor on X11.
Today `capture::Config::cursor` is a `#[non_exhaustive]` enum whose
`Drawn` and `Hidden` draw the cursor in or leave it out: the portal's
embedded mode, `SetIsCursorCaptureEnabled` on WGC, `setShowsCursor` on
macOS, and a CPU blend of the XFixes cursor on X11. The separate cursor is a
third variant, which each backend's `Cursor::drawn` match must then decide.

What each system offers, to confirm in the PR:

Expand Down
4 changes: 2 additions & 2 deletions quest/m5/vaapi-vulkan-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sync_file import, so an explicit-sync producer races it.
half-written buffer.
- Device: VA-API has no device UUID, and today moq-video's
`frame::vaapi::device()` picks one process-wide render node (the first that
probes) in a `OnceLock`, unless `Config::vaapi` names one. The encoder, decoder, and
probes) in a `OnceLock`, unless `Config::device` names one. The encoder, decoder, and
resize share it so a DMA-BUF moves between them without a copy. Choosing a
node per surface makes `device()` per-node, so keep decode, resize, and
encode on one node per DMA-BUF. Decided 2026-10-05: the producer puts the
Expand All @@ -61,7 +61,7 @@ Test: an ignored hardware test in `just rs gpu`'s Intel branch renders on the
iGPU with Vulkan, exports a DMA-BUF image and an explicit-sync timeline, and
encodes H.264 at two sizes; the output decodes, and the slots recycle. On
the two-node host, also check that a surface carrying `renderD129`'s
`dev_t`, or `Config::vaapi` naming it, opens that node rather than the
`dev_t`, or `Config::device` naming it, opens that node rather than the
first render node: the second-node check moved here from
[Video hardware validation](/quest/m5/video-hardware.md) (2026-10-06 audit).

Expand Down
11 changes: 11 additions & 0 deletions rs/moq-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ use tokio_util::sync::CancellationToken;
#[global_allocator]
static ALLOC: moq_tokio::jemalloc::Allocator = moq_tokio::jemalloc::Allocator;

/// The device a render node flag (`--vaapi-device`) and a V4L2 node flag name.
/// Each command declares the two in conflict, so at most one is set.
#[cfg(any(feature = "capture", feature = "transcode", feature = "play"))]
fn device(render: &Option<std::path::PathBuf>, video: &Option<std::path::PathBuf>) -> moq_video::Device {
match (render, video) {
(Some(node), _) => moq_video::Device::Render(node.clone()),
(None, Some(node)) => moq_video::Device::Video(node.clone()),
(None, None) => moq_video::Device::Auto,
}
}

/// Everything needed to build MoQ clients/servers.
#[derive(Clone)]
struct Net {
Expand Down
11 changes: 5 additions & 6 deletions rs/moq-cli/src/play/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ pub struct Args {
#[usage(long, value_name = "PATH", value_hint = usage_rs::ValueHint::FilePath, extensions("ndjson"))]
pub metrics: Option<PathBuf>,

/// The VA-API render node, such as `/dev/dri/renderD129`. Defaults to the
/// first that encodes, decodes, and scales.
#[cfg(all(target_os = "linux", feature = "vaapi"))]
#[usage(long, env = "MOQ_VAAPI_DEVICE", value_hint = usage_rs::ValueHint::FilePath)]
/// The render node the decoder opens, such as `/dev/dri/renderD129`: VA-API
/// opens it, and NVDEC the NVIDIA GPU behind it. Defaults to the first that
/// encodes, decodes, and scales. Linux only.
#[usage(long, env = "MOQ_VAAPI_DEVICE", value_hint = usage_rs::ValueHint::FilePath, conflicts = "--v4l2-decoder")]
pub vaapi_device: Option<std::path::PathBuf>,

/// The V4L2 M2M decoder node, such as `/dev/video10`. Defaults to the first
/// that decodes H.264.
#[cfg(all(target_os = "linux", feature = "v4l2"))]
/// that decodes H.264. Linux only.
#[usage(long, env = "MOQ_V4L2_DECODER", value_hint = usage_rs::ValueHint::FilePath)]
pub v4l2_decoder: Option<std::path::PathBuf>,
}
Expand Down
6 changes: 0 additions & 6 deletions rs/moq-cli/src/play/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ mod tests {
let args = Args {
catalog_format: None,
metrics: None,
#[cfg(all(target_os = "linux", feature = "vaapi"))]
vaapi_device: None,
#[cfg(all(target_os = "linux", feature = "v4l2"))]
v4l2_decoder: None,
delay: super::super::args::Delay::Auto,
stretch: std::time::Duration::from_millis(200).into(),
Expand All @@ -172,9 +170,7 @@ mod tests {
let args = Args {
catalog_format: None,
metrics: Some(path.clone()),
#[cfg(all(target_os = "linux", feature = "vaapi"))]
vaapi_device: None,
#[cfg(all(target_os = "linux", feature = "v4l2"))]
v4l2_decoder: None,
delay: super::super::args::Delay::Auto,
stretch: std::time::Duration::from_millis(200).into(),
Expand Down Expand Up @@ -203,9 +199,7 @@ mod tests {
let args = Args {
catalog_format: None,
metrics: None,
#[cfg(all(target_os = "linux", feature = "vaapi"))]
vaapi_device: None,
#[cfg(all(target_os = "linux", feature = "v4l2"))]
v4l2_decoder: None,
delay: super::super::args::Delay::Auto,
stretch: std::time::Duration::from_millis(200).into(),
Expand Down
11 changes: 1 addition & 10 deletions rs/moq-cli/src/play/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,7 @@ impl<O: Output> Media<O> {
// that imports none.
let mut decode = moq_video::decode::Config::new();
decode.output = self.output.render().await;
#[cfg(all(target_os = "linux", feature = "vaapi"))]
{
decode.vaapi = self.args.vaapi_device.clone();
}
#[cfg(all(target_os = "linux", feature = "v4l2"))]
{
decode.v4l2 = self.args.v4l2_decoder.clone();
}
decode.device = crate::device(&self.args.vaapi_device, &self.args.v4l2_decoder);
let decoder = moq_video::decode::Sink::open(config, &decode).await?;
let delay = moq_net::track::Delay {
min: Some(self.args.video_delay()),
Expand Down Expand Up @@ -2132,9 +2125,7 @@ mod tests {
args: Args {
catalog_format: None,
metrics: None,
#[cfg(all(target_os = "linux", feature = "vaapi"))]
vaapi_device: None,
#[cfg(all(target_os = "linux", feature = "v4l2"))]
v4l2_decoder: None,
delay: Delay::Fixed(delay),
stretch: Duration::ZERO.into(),
Expand Down
2 changes: 0 additions & 2 deletions rs/moq-cli/src/play/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,7 @@ mod tests {
stretch: Duration::ZERO.into(),
catalog_format: None,
metrics: None,
#[cfg(all(target_os = "linux", feature = "vaapi"))]
vaapi_device: None,
#[cfg(all(target_os = "linux", feature = "v4l2"))]
v4l2_decoder: None,
select: Default::default(),
},
Expand Down
25 changes: 10 additions & 15 deletions rs/moq-cli/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,14 @@ pub struct CaptureArgs {
#[usage(long = "no-audio", hide = true)]
no_audio: bool,

/// The VA-API render node, such as `/dev/dri/renderD129`. Defaults to the
/// first that encodes, decodes, and scales.
#[cfg(all(target_os = "linux", feature = "vaapi"))]
#[usage(long, env = "MOQ_VAAPI_DEVICE", value_hint = usage_rs::ValueHint::FilePath)]
/// The render node the encoder opens, such as `/dev/dri/renderD129`: VA-API
/// opens it, and NVENC the NVIDIA GPU behind it. Defaults to the first that
/// encodes, decodes, and scales. Linux only.
#[usage(long, env = "MOQ_VAAPI_DEVICE", value_hint = usage_rs::ValueHint::FilePath, conflicts = "--v4l2-encoder")]
pub vaapi_device: Option<std::path::PathBuf>,

/// The V4L2 M2M encoder node, such as `/dev/video11`. Defaults to the first
/// that encodes H.264.
#[cfg(all(target_os = "linux", feature = "v4l2"))]
/// that encodes H.264. Linux only.
#[usage(long, env = "MOQ_V4L2_ENCODER", value_hint = usage_rs::ValueHint::FilePath)]
pub v4l2_encoder: Option<std::path::PathBuf>,
}
Expand Down Expand Up @@ -1132,7 +1131,10 @@ impl CaptureArgs {
.map(|fps| moq_video::FrameRate::new(fps, 1))
.transpose()
.map_err(anyhow::Error::from)?;
config.cursor = !self.no_cursor;
config.cursor = match self.no_cursor {
true => moq_video::capture::Cursor::Hidden,
false => moq_video::capture::Cursor::Drawn,
};
Ok(config)
}

Expand All @@ -1150,14 +1152,7 @@ impl CaptureArgs {
};
options.bandwidth = bandwidth;
options.on_demand = self.video == Mode::Demand;
#[cfg(all(target_os = "linux", feature = "vaapi"))]
{
options.vaapi = self.vaapi_device.clone();
}
#[cfg(all(target_os = "linux", feature = "v4l2"))]
{
options.v4l2 = self.v4l2_encoder.clone();
}
options.device = crate::device(&self.vaapi_device, &self.v4l2_encoder);
Ok(options)
}

Expand Down
31 changes: 14 additions & 17 deletions rs/moq-cli/src/transcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ pub struct Args {
#[usage(long)]
encoder_sessions: Option<std::num::NonZeroUsize>,

/// The VA-API render node, such as `/dev/dri/renderD129`. Defaults to the
/// first that encodes, decodes, and scales.
#[cfg(all(target_os = "linux", feature = "vaapi"))]
#[usage(long, env = "MOQ_VAAPI_DEVICE", value_hint = usage_rs::ValueHint::FilePath)]
/// The render node the decoder and encoders open, such as
/// `/dev/dri/renderD129`: VA-API opens it, and NVDEC and NVENC the NVIDIA
/// GPU behind it. Defaults to the first that encodes, decodes, and scales.
/// Linux only.
#[usage(
long,
env = "MOQ_VAAPI_DEVICE",
value_hint = usage_rs::ValueHint::FilePath,
conflicts("--v4l2-encoder", "--v4l2-decoder")
)]
pub vaapi_device: Option<std::path::PathBuf>,

/// The V4L2 M2M encoder node, such as `/dev/video11`. Defaults to the first
/// that encodes H.264.
#[cfg(all(target_os = "linux", feature = "v4l2"))]
/// that encodes H.264. Linux only.
#[usage(long, env = "MOQ_V4L2_ENCODER", value_hint = usage_rs::ValueHint::FilePath)]
pub v4l2_encoder: Option<std::path::PathBuf>,

/// The V4L2 M2M decoder node, such as `/dev/video10`. Defaults to the first
/// that decodes H.264.
#[cfg(all(target_os = "linux", feature = "v4l2"))]
/// that decodes H.264. Linux only.
#[usage(long, env = "MOQ_V4L2_DECODER", value_hint = usage_rs::ValueHint::FilePath)]
pub v4l2_decoder: Option<std::path::PathBuf>,
}
Expand Down Expand Up @@ -131,15 +135,8 @@ pub async fn run(moq: MoqSide, args: Args, net: Net) -> anyhow::Result<()> {
if let Some(serving) = args.encoder_sessions {
config.sessions = moq_transcode::Sessions::new(serving);
}
#[cfg(all(target_os = "linux", feature = "vaapi"))]
{
config.vaapi = args.vaapi_device.clone();
}
#[cfg(all(target_os = "linux", feature = "v4l2"))]
{
config.v4l2_encoder = args.v4l2_encoder.clone();
config.v4l2_decoder = args.v4l2_decoder.clone();
}
config.decoder_device = crate::device(&args.vaapi_device, &args.v4l2_decoder);
config.encoder_device = crate::device(&args.vaapi_device, &args.v4l2_encoder);

let source_path = moq_net::Path::try_from(
moq.broadcast
Expand Down
1 change: 1 addition & 0 deletions rs/moq-transcode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [**breaking**] `Config::decoder_device` and `Config::encoder_device`, each a `moq_video::Device` present on every platform and feature set, replace the `cfg`-gated `vaapi`, `v4l2_decoder`, and `v4l2_encoder` paths, and also place NVIDIA work on a chosen GPU.
- `active::Consumer` stops reporting a rendition the ladder retired before it encoded a frame, so a source that keeps resizing no longer grows every cursor.

### Fixed
Expand Down
Loading