-
Notifications
You must be signed in to change notification settings - Fork 0
Screensharing #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Screensharing #10
Conversation
Add xdg-desktop-portal-screencomposer component implementing the org.freedesktop.impl.portal.ScreenCast D-Bus interface. Features: - ScreenCast portal backend for PipeWire screen sharing - Monitor (output) capture support - Cursor modes: Hidden, Embedded, Metadata - Session and stream lifecycle management The portal acts as a bridge between the standard XDG Desktop Portal interface and ScreenComposer's internal D-Bus API, enabling applications like Chromium, Firefox, and OBS to share screens. Not yet implemented: - Window capture - Restore tokens (session persistence) - Permission dialogs (currently auto-grants)
Phase 1 of screenshare implementation - wiring up the compositor side: - Add ScreencastSession and ActiveStream structs for session state - Add screenshare_sessions HashMap to ScreenComposer state - Implement command handlers in handle_screenshare_command(): - CreateSession: creates session in compositor state - StartRecording: creates PipeWireStream + ScreencastSessionTap, registers tap - StopRecording: unregisters tap, removes stream - DestroySession: cleans up all streams in session - Wire frame capture into render loops: - winit: RGBA capture inside render closure after render_output() - udev: RGBA capture via capture_rgba_frame() after render_frame() - Call notify_rgba_with_damage() with captured frames and damage regions The PipeWire stream is still a skeleton - frames flow through the pipeline but are not yet sent to actual PipeWire. Next step is real PipeWire integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add zbus 4 and pipewire 0.9 dependencies for the screenshare D-Bus service and PipeWire stream implementation. Also clean up compiler warnings with #[allow] attributes for fields/functions that will be used in the PipeWire implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The original design doc has been superseded by screenshare-plan.md which contains the updated implementation plan with handover notes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace the placeholder PipeWire implementation with a working one: - Create dedicated PipeWire thread with MainLoopBox, ContextBox - Stream connects as video source with proper properties - Video format negotiation (BGRA/RGBA/BGRx/RGBx) - SHM buffer handling with automatic allocation (ALLOC_BUFFERS) - Thread-safe synchronization via atomics and mpsc channels - FD export for portal clients via loop_fd() - Proper cleanup on stop/drop The stream receives RGBA frames from the compositor's render loop via ScreencastSessionTap and queues them to PipeWire buffers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add docs/screenshare.md with full architecture, D-Bus API reference, and component descriptions for the screen sharing implementation - Update docs/xdg-desktop-portal.md with reference to screenshare.md and current feature status - Update docs/project-structure.md to include screenshare module - Update AGENTS.md/CLAUDE.md to reflect completed implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Minimal example demonstrating DRIVER mode with ALLOC_BUFFERS: - Self-allocated memfd buffers - Timer-based frame triggering - Animated test pattern output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add PendingFrame enum to handle both RGBA and DMA-BUF frame types - Update PipeWireThreadState with dmabuf_map for zero-copy path - Update frame reception to accept both RGBA (winit) and DMA-BUF (udev) Winit SHM screenshare still working, DMA-BUF implementation in progress
Introduces infrastructure to support both SHM (CPU copy) and DMA-BUF (zero-copy) frame paths in PipeWire stream: - Added PendingFrame enum: Rgba (SHM) | DmaBuf (zero-copy) - Updated both process callbacks to match on PendingFrame type - Frame reception wraps FrameData into PendingFrame before storage - Added dmabuf_map field to track DMA-BUF FD mappings RGBA/SHM path fully functional on winit backend. DMA-BUF path stubbed with TODOs for future implementation on udev backend.
Updated the file header and description for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements comprehensive screensharing functionality for ScreenComposer via PipeWire and xdg-desktop-portal integration. The implementation adds a D-Bus service on the compositor side, a separate portal backend component, and frame capture infrastructure integrated into the render loops.
Key Changes:
- Complete PipeWire-based screensharing pipeline with D-Bus API
- Frame tap manager for capturing rendered frames with damage tracking
- XDG Desktop Portal backend component for standard portal API compatibility
- Integration into winit and udev render loops
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/screenshare/mod.rs |
Session state management and compositor command handlers |
src/screenshare/frame_tap.rs |
Frame tap infrastructure with damage tracking support |
src/screenshare/pipewire_stream.rs |
PipeWire stream management with SHM buffer handling |
src/screenshare/dbus_service.rs |
D-Bus service implementation for compositor API |
src/screenshare/session_tap.rs |
Per-session frame filtering and distribution |
src/state/mod.rs |
Added frame tap manager and screenshare session tracking |
src/winit.rs |
RGBA frame capture integration in render loop |
src/udev.rs |
RGBA frame capture integration in render loop |
src/lib.rs |
Module export for screenshare |
components/xdg-desktop-portal-sc/ |
Complete portal backend implementation |
sample-clients/pipewire-video-source/ |
Example PipeWire video source |
docs/screenshare.md |
Comprehensive architecture documentation |
docs/xdg-desktop-portal.md |
Portal integration documentation |
Cargo.toml |
Dependency additions (zbus, pipewire, memfd, memmap2) |
Due to the comprehensive nature of this PR and reaching iteration limits, I've focused on identifying the most critical issues. The implementation is well-structured overall with good separation of concerns between the compositor-side screensharing, D-Bus service, and portal backend.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Removed quick test and debugging sections from README.md
No description provided.