1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Pure SPA `video/raw` format ↔ [`PixelFormat`] mapping.
//!
//! No `PipeWire` I/O — safe to unit test without a live portal/compositor
//! session (see crate ADR-0001 § Zero runtime verification this session).
use PixelFormat;
use VideoFormat;
/// Map a negotiated SPA `video/raw` pixel format to the closest [`PixelFormat`].
///
/// `BGRx` / `RGBx` carry an unused, undefined 4th byte (`x`, not a real alpha
/// channel) — mapping them to [`PixelFormat::Bgra8`] / [`PixelFormat::Rgba8`] is
/// an approximation. This is the same call the Windows DXGI backend already
/// makes for its BGRA desktop surface (see `mediaway-device-windows` ADR-0001);
/// consumers must not read that 4th byte as meaningful alpha for `BGRx`/`RGBx`
/// sources.
///
/// Returns `None` for any format this backend does not offer in its
/// `SPA_PARAM_EnumFormat` choice list (`screencast.rs`). That choice list and
/// this match **must be kept in sync by hand** — the format list is built by a
/// proc macro (`pw::spa::pod::object!`) that cannot consume this function's
/// match arms, so there is no compiler-enforced link between the two; see the
/// comment at the `object!` call site in `screencast.rs`.
pub const