Skip to content

Feature/background sessions - #261

Draft
lukemarsden wants to merge 3 commits into
games-on-whales:stablefrom
helixml:feature/background-sessions
Draft

Feature/background sessions#261
lukemarsden wants to merge 3 commits into
games-on-whales:stablefrom
helixml:feature/background-sessions

Conversation

@lukemarsden

Copy link
Copy Markdown

No description provided.

**Problem:**
API-created apps generate malformed GStreamer video producer pipelines due to missing
video_producer_buffer_caps field in the API, while TOML-loaded apps work correctly.

**Root Cause:**
The API was missing video_producer_buffer_caps field in three critical places:

1. **API Schema** (reflectors.hpp): ReflType struct missing field
2. **Response Serialization** (reflectors.hpp): from() method omitting field
3. **Request Deserialization** (endpoints.cpp): endpoint_AddApp not populating field

This caused video producer to generate malformed pipelines:
`waylanddisplaysrc render_node=/dev/dri/renderD128 ! , width=3840, height=2160`
(Note the stray comma from empty buffer_format parameter)

**Solution:**
- Add video_producer_buffer_caps to API ReflType struct as optional field
- Add field to response serialization in from() method
- Add field to request deserialization with proper NVIDIA GPU default
- Use video/x-raw(memory:DMABuf) default for optimal GPU zero-copy performance

**Testing:**
- TOML apps: Continue working as before
- API apps: Now generate proper pipelines and stream successfully
- Backwards compatible: Missing field gets sensible defaults

**Files Changed:**
- src/moonlight-server/events/reflectors.hpp: Add field to schema and serialization
- src/moonlight-server/api/endpoints.cpp: Add field to deserialization with defaults

Fixes API-created apps failing to start streaming due to GStreamer syntax errors.
- Add auto_start_containers configuration flag
- Create background sessions with virtual clients when apps are added
- Implement session reuse by app ID for multiple client support
- Add stop protection for auto-started background sessions
- Include full video/audio streaming pipeline for background sessions
- Support iPad resolution (2360x1640@120fps) for all auto-started sessions

This enables Personal Dev environments to run continuously in background
without requiring Moonlight clients, while supporting multiple clients
connecting to the same running session.
- Preserve background session display mode instead of creating new session with client's requested mode
- Prevents GStreamer DMA buffer format transformation errors
- Resume logic now correctly maintains 2360x1640@120fps from background session
- Moonlight clients adapt to server's display mode automatically
- Video and audio pipelines start successfully on resume
- RTSP handshake completes without format negotiation errors

Issue: Input devices still missing, causing session pause after successful pipeline start
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