diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 47a0138200b..1cf38a11f49 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -162,9 +162,9 @@ moq --client-connect https://relay.example.com/anon --broadcast conference.hang ``` Video decoding prefers the platform hardware backend and falls back to the -built-in software H.264 decoder. Rendering uses Metal on macOS, D3D12 on -Windows, and Vulkan or OpenGL on Linux. Audio uses the system default output -device through CoreAudio, WASAPI, or ALSA. +built-in software H.264 decoder. Rendering picks the best graphics API the +machine offers: Metal on macOS, and Vulkan ahead of D3D12 or OpenGL elsewhere. +Audio uses the system default output device through CoreAudio, WASAPI, or ALSA. ### Publish a Video File diff --git a/rs/CLAUDE.md b/rs/CLAUDE.md index cc417a426d0..15c755b654c 100644 --- a/rs/CLAUDE.md +++ b/rs/CLAUDE.md @@ -169,7 +169,7 @@ Then `Config::load()?` (initializes tracing), build clients/servers via `.init() - **Local checks only compile the host's platform and target, and PR CI is Linux-only.** `#[cfg(target_os = "...")]` code for other platforms is invisible to them, and `cargo fmt` skips those modules too. Windows and Mac runners cost too much for a per-PR gate, so those platforms are manual: - - Windows (moq-video's Media Foundation and D3D11 backends): `just rs windows`, which must run ON Windows. You can't reproduce it elsewhere, since cross-compiling dies in openh264-sys2's vendored C++. + - Windows (moq-video's Media Foundation and D3D11 backends): `just rs windows`, which must run ON Windows. You can't reproduce it elsewhere, since cross-compiling dies in openh264-sys2's vendored C++. It names `moq-cli/play` explicitly, since that feature is what pulls in moq-video's wgpu renderer and moq-audio's cpal output; a default-feature build compiles neither. - macOS (moq-video's VideoToolbox and ScreenCaptureKit, moq-audio's system audio): `just rs macos`, which must run ON macOS. Scoped to moq-video + moq-audio, and needs `--all-features` because moq-audio's capture backend is off by default. - Linux: covered. `just rs ci` already runs `--all-features` in a dev shell carrying PipeWire and ALSA. VAAPI loads libva dynamically, so nvenc/nvdec/vaapi/pipewire all compile without libva installed. - wasm32 (moq-wasm): `just rs wasm`. The crate root is `#![cfg(target_arch = "wasm32")]`, so a host-target `cargo check --workspace` compiles it down to nothing and sees no errors at all. This one needs no special host (the Nix shell carries the target), so `just rs ci` and `just check-all` both run it, and `just check` adds it when the diff touches `rs/moq-wasm/`. It's a compile gate, distinct from the root `just wasm`, which builds the shippable `@moq/wasm` package. diff --git a/rs/justfile b/rs/justfile index 4c5c68b86f2..412ea00bd3a 100644 --- a/rs/justfile +++ b/rs/justfile @@ -142,10 +142,14 @@ fix-changed $FILES: # backend don't build on MSVC, while moq-video's Linux-only nvenc/nvdec defaults # are already no-ops off Linux. moq-gst is excluded because it links # GStreamer via pkg-config, which the Windows runner doesn't have. +# +# `moq-cli/play` is named explicitly because it's off by default and is what +# turns on moq-video's wgpu renderer and moq-audio's cpal output, neither of +# which any default-feature build compiles. # Compile the whole workspace on a Windows host. Must run ON Windows. windows *args: - cargo check --workspace --exclude moq-gst --all-targets {{ args }} + cargo check --workspace --exclude moq-gst --all-targets --features moq-cli/play {{ args }} # Runs the `#[cfg(target_os = "macos")]` code past the compiler: moq-video's # VideoToolbox encode/decode and its ScreenCaptureKit / AVFoundation capture, diff --git a/rs/moq-audio/src/decode/consumer.rs b/rs/moq-audio/src/decode/consumer.rs index 6c053b95f59..c85f8d2378b 100644 --- a/rs/moq-audio/src/decode/consumer.rs +++ b/rs/moq-audio/src/decode/consumer.rs @@ -168,4 +168,44 @@ mod tests { assert_eq!(pair[0], pair[1]); } } + + #[tokio::test] + async fn reads_the_container_the_catalog_declares() { + let mut broadcast = moq_net::broadcast::Info::new().produce(); + let track = broadcast.create_track("audio", hang::container::track_info()).unwrap(); + let subscriber = broadcast.consume(); + + let mut catalog = hang::catalog::AudioConfig::new(hang::catalog::AudioCodec::Pcm, 48_000, 1); + catalog.container = hang::catalog::Container::Loc; + + let mut producer = moq_mux::container::Producer::new(track, moq_mux::catalog::hang::Container::Loc); + let mut consumer = Consumer::new( + &subscriber, + &catalog, + "audio", + Config { + format: Format::F32, + ..Config::new() + }, + ) + .await + .unwrap(); + + let samples = [0.25f32, -0.5, 0.75, -1.0]; + let payload: Vec = samples.iter().flat_map(|sample| sample.to_le_bytes()).collect(); + producer + .write(moq_mux::container::Frame { + timestamp: Timestamp::ZERO, + duration: None, + payload: payload.into(), + keyframe: true, + }) + .unwrap(); + + let frame = consumer.read().await.unwrap().expect("decoded frame"); + assert_eq!( + Format::F32.as_interleaved_f32(&frame.data, 1).unwrap().as_ref(), + samples + ); + } } diff --git a/rs/moq-audio/src/playback.rs b/rs/moq-audio/src/playback.rs index 5a3dbb9746b..4e3a45d8801 100644 --- a/rs/moq-audio/src/playback.rs +++ b/rs/moq-audio/src/playback.rs @@ -1,6 +1,9 @@ //! Play decoded PCM out a speaker, via [`cpal`] (CoreAudio / WASAPI / ALSA). //! -//! The playback counterpart to [`capture`](crate::capture), and where a +//! The playback counterpart to `capture`, and where a +// `capture` is deliberately not a doc link: the module is behind the +// off-by-default `capture` feature, so a link to it fails the `-D warnings` +// rustdoc build of a playback-only build (what `moq-cli`'s `play` enables). //! [`decode::Consumer`](crate::decode::Consumer) ends up: //! //! ```no_run