Skip to content

fix(linux): update PipeWire engine to the two-level Frame enum + SystemTime display_time#183

Open
Tristan-Stoltz-ERC wants to merge 1 commit intoCapSoftware:mainfrom
Luminous-Dynamics:fix/linux-engine-two-level-frame-enum
Open

fix(linux): update PipeWire engine to the two-level Frame enum + SystemTime display_time#183
Tristan-Stoltz-ERC wants to merge 1 commit intoCapSoftware:mainfrom
Luminous-Dynamics:fix/linux-engine-two-level-frame-enum

Conversation

@Tristan-Stoltz-ERC
Copy link
Copy Markdown

Summary

The Frame enum was refactored into a two-level shape (Frame::Audio(AudioFrame) / Frame::Video(VideoFrame::*)) and the per-format structs' display_time field was changed from u64 to SystemTime, but the Linux PipeWire engine in src/capturer/engine/linux/mod.rs was not updated to match.

Result: 8 compile errors on Linux; 0.1.0-beta.1 on crates.io does not build there, and neither does the current main (verified on Ubuntu 24 with pipewire 1.0). fix-windows addressed the Windows path but left Linux untouched.

Changes

  • Wraps the four emit sites (RGBx / RGB / xBGR / BGRx) in Frame::Video(VideoFrame::...(...)) to match frame::Frame's current two-level shape.
  • Replaces display_time: timestamp as u64 with display_time: SystemTime::now(), matching what the macOS (src/capturer/engine/mac/mod.rs) and Windows (src/capturer/engine/win/mod.rs) engines already do. The raw PipeWire pts from spa_meta_header is monotonic ns since an arbitrary reference, not wall-clock — it cannot be converted losslessly to SystemTime. Relative frame ordering survives via channel-send order.
  • Adds SystemTime to the std::time imports and VideoFrame to the crate::frame imports.

Verification

$ cargo check
   Compiling scap v0.1.0-beta.1 (/tmp/scap)
    Finished dev profile [unoptimized + debuginfo] target(s) in 48.04s

16 warnings remain, all pre-existing lifetime-elision nits unrelated to this PR.

Follow-ups not in this PR

  • The pts value is currently discarded (let _ = timestamp;) since we can't faithfully convert monotonic-ns to wall-clock SystemTime. A follow-up could add a monotonic_time: Option<Duration> sibling field if callers want sub-ms buffer timing on Linux. Left as a separate concern.
  • The lifetime-elision warnings in portal.rs and a few other files are out of scope here but would be an easy clippy pass.

Context

Found while integrating scap into xenia-capture, the screen-capture abstraction of the Xenia remote-session stack — we picked scap as our primary cross-platform backend specifically because of your PipeWire-native Wayland path. Thanks for the work on this crate.

…Time display_time

The Frame enum was refactored into a two-level shape (Frame::Audio /
Frame::Video(VideoFrame::*)) and the per-format structs' display_time
field was changed from u64 to SystemTime, but the Linux PipeWire engine
in src/capturer/engine/linux/mod.rs was not updated to match. Result:
8 compile errors on Linux, no crates.io release compiles there.

This commit:

- Wraps the four emit sites (RGBx / RGB / xBGR / BGRx) in
  Frame::Video(VideoFrame::...(...)) to match frame::Frame's current
  two-level shape.
- Replaces `display_time: timestamp as u64` with
  `display_time: SystemTime::now()`, matching what the macOS and
  Windows engines already do.  The raw PipeWire pts from
  spa_meta_header is monotonic ns since an arbitrary reference, not
  wall-clock, so it cannot be converted losslessly to SystemTime.
  Relative frame ordering survives via channel-send order.
- Adds SystemTime to the std::time imports and VideoFrame to the
  crate::frame imports.

`cargo check` on Linux (Ubuntu 24, pipewire 1.0, via nix develop)
now succeeds — 16 warnings remaining, all pre-existing lifetime-
elision nits unrelated to this fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant