MCPSERV.CLUB
Sunshine

Sunshine

Self-Hosted

Self-hosted low-latency game streaming for Moonlight

Active(100)
30.6kstars
0views
Updated 3 days ago

Overview

Discover what makes Sunshine powerful

Sunshine is a lightweight, self‑hosted game streaming server that implements the **P2P streaming protocol** used by NVIDIA’s GameStream. It exposes a single TCP/UDP port and negotiates with Moonlight clients (Android, iOS, Windows, macOS, Linux, Xbox, etc.) to deliver a low‑latency, full‑resolution video feed of the host machine’s desktop. From a developer standpoint, Sunshine is essentially an *edge device* that bridges raw GPU frames to a WebRTC‑style transport, while also providing an HTTP/JSON API for discovery and configuration.

Language & Runtime

Encoding & GPU Access

Networking

Web UI

Overview

Sunshine is a lightweight, self‑hosted game streaming server that implements the P2P streaming protocol used by NVIDIA’s GameStream. It exposes a single TCP/UDP port and negotiates with Moonlight clients (Android, iOS, Windows, macOS, Linux, Xbox, etc.) to deliver a low‑latency, full‑resolution video feed of the host machine’s desktop. From a developer standpoint, Sunshine is essentially an edge device that bridges raw GPU frames to a WebRTC‑style transport, while also providing an HTTP/JSON API for discovery and configuration.

Technical Stack

  • Language & Runtime: The core is written in Rust, chosen for its zero‑cost abstractions, safety guarantees, and native support for asynchronous I/O via the tokio runtime.
  • Encoding & GPU Access: Hardware encoding is delegated to platform‑specific backends:
    • Windows: DirectX Video Acceleration (DXVA) via the dxva2 crate.
    • Linux: VA‑API (AMD/Intel) or NVENC through the nvenc crate.
    • macOS: VideoToolbox (Apple’s hardware encoder).
  • Networking: Implements the GameStream protocol over UDP, with optional TCP fallback for control channels. Uses tokio::net for non‑blocking sockets and serde_json for the JSON control API.
  • Web UI: A minimal single‑page app served by warp (Rust web framework). The UI communicates with the backend over a local WebSocket for real‑time status updates.
  • Database: No persistent database; configuration is stored in a simple toml file and runtime state is kept in memory.

Core Capabilities

FeatureDescription
Device DiscoverySunshine advertises itself via mDNS (Bonjour) and a local HTTP endpoint (/info) for Moonlight to query.
Pairing & AuthenticationUses a short‑lived pairing key (displayed on the UI) that Moonlight clients validate over HTTPS.
Encoding OptionsRuntime flags allow selection between hardware encoders (NVENC, VA‑API, VideoToolbox) or software x264.
Input EmulationImplements the GameStream input protocol to translate controller events (Xbox, PlayStation, Switch) into raw HID reports.
Dynamic ConfigurationExposes /config API to adjust bitrate, resolution, frame‑rate caps, and encoder presets on the fly.

Deployment & Infrastructure

  • Self‑Hosting: Sunshine runs as a single binary with no external dependencies beyond the GPU driver stack. It can be launched on bare‑metal PCs, Raspberry Pi 4 (with NVENC support), or any Docker host.
  • Containerization: Official Docker images are available on Docker Hub, GHCR, and Flathub. The container exposes ports 47984 (UDP) and 47998/48010 (TCP) and mounts a volume for the config file.
  • Scalability: Each Sunshine instance handles one client at a time due to the nature of GameStream. For multi‑player setups, developers can orchestrate multiple Sunshine instances behind a load balancer and use a custom session manager to route clients.
  • Resource Utilization: Because encoding runs on the GPU, CPU usage is minimal. Memory footprint stays below 50 MiB for a typical game stream.

Integration & Extensibility

  • Plugin Hooks: Sunshine exposes a simple plugin API via dynamic library loading (.so/.dll). Plugins can intercept input events or modify encoder settings at runtime.
  • Webhooks: The HTTP API supports POST callbacks on pairing events, enabling integration with home‑automation systems (e.g., trigger a smart light when a stream starts).
  • Custom UI: The front‑end is written in vanilla JS and can be forked; developers may replace it with a React or Vue wrapper if they need richer analytics dashboards.
  • SDK: The Rust crate sunshine-client (not yet published) provides a thin wrapper around the GameStream protocol, useful for building custom clients or bots.

Developer Experience

  • Documentation: The GitHub repo contains a comprehensive README, API reference (JSON schemas), and example configuration snippets. The codebase follows Rust idioms, making it approachable for developers familiar with async patterns.
  • Community: An active Discord channel and issue tracker allow rapid feedback. The project is open‑source under the MIT license, facilitating commercial use without licensing fees.
  • Testing: Unit tests cover protocol parsing and configuration logic; integration tests use a headless Moonlight client to validate end‑to‑end streaming.

Use Cases

  1. Home Cloud Gaming – Run Sunshine on a high‑end PC to stream games to phones or smart TVs without paying for commercial services.
  2. Embedded Gaming Appliances – Deploy Sunshine on a Raspberry Pi 4 with an NVIDIA Jetson GPU to create low‑cost streaming boxes for retro gaming.
  3. Enterprise Training – Use Sunshine in a lab to provide instructors with remote, low‑latency access to simulation software on powerful workstations.
  4. IoT Edge Gaming – Combine Sunshine with a custom IoT controller to create “living room” kiosks that stream games on demand.

Advantages

  • Zero Cost & Full Control – No subscription fees; all data stays on local hardware.
  • Low Latency & High Fidelity – Hardware‑accelerated encoding and UDP transport deliver <30 ms latency on modern networks.

Open SourceReady to get started?

Join the community and start self-hosting Sunshine today

Weekly Views

Loading...
Support Us
Most Popular

Infrastructure Supporter

$5/month

Keep our servers running and help us maintain the best directory for developers

Repository Health

Loading health data...

Information

Category
other
License
GPL-3.0
Stars
30.6k
Technical Specs
Pricing
Open Source
Docker
Official
Supported OS
LinuxDocker
Author
LizardByte
LizardByte
Last Updated
3 days ago