feat(capture): implement Phase 3 PipeWire/portal desktop capture
Implement the xdg-desktop-portal ScreenCast backend via libportal: a
blocking portal handshake (interactive source picker), a PipeWire stream
on the portal's node enumerating BGRx/BGRA/RGBx/RGBA, and a latest-frame
slot handing frames to next_frame(). stop() is thread-safe; teardown
follows the order PipeWire requires. All proxy operations run under the
thread-loop lock to satisfy the protocol extension context checks
('impl_ext_end_proxy called from wrong context' otherwise).
The encoder now accepts padded strides for packed RGB inputs (real
PipeWire row pitches) and maps the new PixelFormat::Bgrx to
AV_PIX_FMT_BGRA.
Add tools/capture_smoke: a manual smoke tool (interactive, not in
meson test) that captures N frames, encodes them, and writes a
self-contained Annex-B elementary stream with prepended SPS/PPS.
Validated manually on Wayland/Hyprland: 2256x1504 H.264 elementary
stream, ffprobe clean. Phase 3 marked complete in docs/PHASES.md.
This commit is contained in:
+4
-4
@@ -32,9 +32,9 @@ frames.
|
||||
|
||||
**Goal**: capture the desktop and feed frames into the encoder.
|
||||
|
||||
- Add `libpipewire-0.3` dependency.
|
||||
- Implement `CaptureFactory::create()` using the xdg-desktop-portal.
|
||||
- Wire `CaptureSession::next_frame()` → `Encoder::encode()` in a local smoke
|
||||
- [x] Add `libpipewire-0.3` dependency.
|
||||
- [x] Implement `CaptureFactory::create()` using the xdg-desktop-portal.
|
||||
- [x] Wire `CaptureSession::next_frame()` → `Encoder::encode()` in a local smoke
|
||||
test that just writes a few encoded frames to disk.
|
||||
|
||||
**Validation**: manual run on a real Linux desktop session produces a valid
|
||||
@@ -89,4 +89,4 @@ where available.
|
||||
|
||||
## Current phase
|
||||
|
||||
Phase 3 — PipeWire screen capture.
|
||||
Phase 4 — RTP Framing.
|
||||
|
||||
@@ -27,6 +27,28 @@ FFmpeg may keep some "still reachable" allocations at exit; that is normal.
|
||||
This check caught two real defects in the Phase 2 decoder: a per-packet
|
||||
payload leak and an unpadded extradata buffer over-read. Keep using it.
|
||||
|
||||
## Capture smoke test (Phase 3, manual)
|
||||
|
||||
Requires a running desktop session with `xdg-desktop-portal` and a backend
|
||||
that implements the ScreenCast portal (e.g. Hyprland, GNOME, KDE). The
|
||||
portal shows an interactive source picker, so this cannot run unattended.
|
||||
|
||||
```sh
|
||||
meson compile -C build # builds tools/capture_smoke
|
||||
./build/tools/capture_smoke 10 out.h264 # captures 10 frames
|
||||
ffprobe -v error -show_entries stream=codec_name,width,height out.h264
|
||||
```
|
||||
|
||||
Expected: the tool prints the negotiated resolution/format/stride and
|
||||
writes a non-empty file; `ffprobe` reports `codec_name=h264` and the correct
|
||||
width/height. The encoder prepends its Annex-B SPS/PPS extradata so the
|
||||
file is a self-contained elementary stream.
|
||||
|
||||
If you see `impl_ext_end_proxy called from wrong context` warnings, a
|
||||
PipeWire proxy operation ran without the thread-loop lock — all pw
|
||||
calls that send messages (connect, stream, core) must happen under
|
||||
`pw_thread_loop_lock`.
|
||||
|
||||
## Formatting
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user