Files
DomiStream/docs/CLEAN_ROOM.md
T

23 KiB
Raw Blame History

Clean room

DomiStream is a clean-room implementation of the GameStream protocol (the one Moonlight clients and Sunshine hosts speak). The protocol is written from public protocol notes and our own measurements, never from the code of a GPL-licensed implementation. This file says what may be read, what may not, and logs every source used.

Allowed sources

Source Licence How we may use it
Wolf protocol docs and their sub-pages (pairing/HTTP, RTSP, control, RTP video, RTP Opus, input) Docs site: CC BY-SA 4.0 "except where otherwise noted"; repo: MIT (see research/open-point-2.md) Read for facts. Restate facts in our own words with a link. Never paste prose or diagrams. The diagram sources (PlantUML, bytefield, wavedrom) are part of the docs pages and may be read the same way.
Moonshine BSD-2-Clause May be read. Facts taken are logged below. Code is not copied; if a snippet is ever borrowed, it keeps Moonshine's copyright line and licence text in the file that holds it.
RFCs and standards (RTP RFC 3550, RTSP RFC 2326, SDP RFC 4566, Opus RFC 6716 / RFC 7845, AES FIPS 197, GCM/CBC NIST SP 800-38D/38A, PKCS #1 RFC 8017, X.509 RFC 5280) open standards Read freely.
Crate docs (docs.rs, crates.io, crate READMEs) per crate Read freely.
Our own measurements ours Captures through our own relay (tools/lab-relay). Mark allowed one capture on his PC (answer 16, 2026-11-25), done exactly as LAB_CAPTURE.md says; never his TV, never 192.168.100.217. Recordings stay local (on E:, approved for Play remotely) under E:\build\play-remotely\lab\, out of git; only facts and test vectors derived from them go in, with the date and setup.
Official Sunshine and Moonlight PC binaries in that capture GPL-3.0 (we only run them) Black-box peers: run, observe their traffic, their --help output, their own logs and the files/registry keys they write. Never open their source, never disassemble or decompile them.
Arena Domi Remote (Android, a GPL app built apart from Domi repos) and the official Moonlight PC app, as clients of Lumen GPL-3.0 (we only run them) Black-box peers (Mark, 2026-12-04, D2): lumen-host logs what they send to it. Same limits as the row above. Their workspaces and source are never opened; the Remote app's own workers drive it and hand over facts only.
READMEs and wikis of forbidden projects n/a For facts only (licence, release notes, compatibility statements). Never their source files.
Public OS and SDK documentation (Microsoft Learn; NVIDIA, AMD and Intel encoder SDK docs and API headers; libopus and ViGEm docs) per vendor Read for the host side (Lumen), facts in our own words, each page logged. Allowed in the Lumen host lead's brief of 2026-12-04. Never the source of GPL or LGPL projects that wrap these APIs.

Approved by Mark (answer 15, 2026-11-25): "Yes, with attribution"

Read for the wire format; anything borrowed beyond a fact is attributed in the file that holds it. GPL stays off limits, and a value with GPL provenance stays out even when one of these sources carries it.

Source Licence Why
Stock ENet MIT The ENet 1.3 wire format is documented nowhere else. Read at v1.3.18 (S-17).
tokio-enet BSD-2-Clause Pure-Rust ENet 1.3 that Moonshine uses with Moonlight clients (S-10, now approved).
fec-rs BSD-2-Clause Reed-Solomon whose README claims Moonlight compatibility; its matrix construction settles U14 (S-18).

Forbidden

Never open, read, paste or port code from: Sunshine, Moonlight (any client: Qt, Android, iOS, embedded, moonlight-tv), moonlight-common-c, Moonlight's ENet fork, Apollo, Vibeshine, Rubylight, chiaki (and forks of them). That also means their source files on GitHub. Their READMEs and wikis are fine for facts.

For host work (Lumen), also forbidden (Mark, 2026-12-04, decision D2 in LUMEN-HOST-PLAN.md): the source of OBS Studio and FFmpeg (including any GPL or LGPL code that wraps NVENC, AMF, Quick Sync, Desktop Duplication or WASAPI). Their documentation pages are fine for facts, like the READMEs above.

Second-hand GPL facts

Moonshine credits Sunshine for "groundwork" on the host side, and a few Moonshine comments cite Sunshine or moonlight-common-c as the origin of a value. We treat such a value as GPL-provenance: it is logged, never copied into DomiStream, and settled by our own measurement instead. Known cases:

Where in Moonshine What What we do
src/session/stream/audio/encoder.rs the fixed 2x4 Reed-Solomon parity matrix for audio FEC; the comment cites a moonlight-common-c file Not taken. I saw the constant while reading the file; it is not in this repo. U16 in PROTOCOL.md says how to measure it ourselves.
src/session/stream/control/mod.rs HDR mode payload "matches Sunshine's" struct Field layout logged as [M*], confirm by measurement before relying on it
fec-rs src/reed_solomon.rs tests (test_partial_eq_reflects_parity_matrix_changes) the same audio parity matrix as Moonshine's encoder Not taken, same rule. Seen while reading fec-rs on 2026-11-25.
src/rtsp.rs surround-params digit packing "matching moonlight-common-c" The Wolf example surround-params=21101 gives the same packing independently, so we use the Wolf source
src/rtsp.rs (read again as S-30) encoderCscMode bit layout (comment cites Sunshine's colour-space function); maxNumReferenceFrames 0 = "host's choice" (comment cites moonlight-common-c); the 5.1/7.1 mapping rotation (comment cites GFE and Moonlight) Not taken: the host parser keeps both numbers raw and writes the mappings as configured (PROTOCOL.md 2.5, U6, U26)
src/session/stream/video/mod.rs (S-31) how the stored bitrate is reduced for FEC and audio (comment: "as Sunshine computes it") Not taken; the parser hands over the client's bitrate unchanged

How code gets written

  1. Every fact in PROTOCOL.md carries a source tag that points to the log below.
  2. A fact without a tag is UNKNOWN until a log entry or a measurement backs it.
  3. Code comments cite the PROTOCOL.md section, not the outside source directly.
  4. Anything borrowed (more than a fact) is attributed in the file that holds it and listed here.
  5. A PR that adds a source adds a row to the log in the same PR.

Source log

All entries by the DomiStream protocol engineer. Pinned commits are the ones read.

# Date Source What was taken
S-1 2026-11-25 Wolf: protocols index The six protocols, their default ports, which are encrypted (control AES-GCM 128, audio AES-CBC 128, video plain), that ports other than HTTP/S are dynamic. Licence footer (CC BY-SA 4.0).
S-2 2026-11-25 Wolf: HTTP/S pairing incl. its PlantUML diagram sources Phases 1-5; AES key from SHA-256(salt + PIN); the hash inputs of phase 2 and phase 4; field names plaincert, challengeresponse, serverchallengeresp, pairingsecret, pairchallenge, paired; phase 5 runs over HTTPS with the client certificate.
S-3 2026-11-25 Wolf: RTSP incl. diagram Method order OPTIONS, DESCRIBE, SETUP (audio, video, control), ANNOUNCE, PLAY; message layout (start line, CSeq, options, empty line, payload); example X-GS-ClientVersion: 14, a=fmtp:97 surround-params=21101.
S-4 2026-11-25 Wolf: control incl. bytefield sources ENet fork with IPv4 + IPv6; encrypted frame type 0x0001 / len / seq / 16-byte tag / payload, little-endian, seq used for the IV; message type codes; payloads of rumble, rumble triggers, motion event, RGB LED.
S-5 2026-11-25 Wolf: RTP video incl. diagrams PING to the negotiated port; packetSize default 1024 + 16-byte RTP header; 16-byte NV video header layout; flags (picture data 1, EOF 2, SOF 4); 8-byte frame prefix 01 37 63 68 61 72 73 73; FEC example (4 KB, 1024, 50 % = 4 + 2); parity packets have flags 0; IDR requests over control.
S-6 2026-11-25 Wolf: RTP Opus incl. diagrams 12-byte RTP header; 12-byte FEC header (shard index, payload type, base seq, base timestamp, SSRC); 4 data + 2 parity; AES-CBC with key and IV from the launch call, same key as control; PING.
S-7 2026-11-25 Wolf: input incl. bytefield sources INPUT_DATA layout (size BE, type LE); input type codes; layouts and example bytes for mouse move rel/abs, buttons, keys, scroll, hscroll, controller arrival, controller multi; key code table; button flags; controller types and capability bits.
S-8 2026-11-25 GitHub API for games-on-whales/wolf (/repos, /git/trees/beta, LICENSE, docs/README.adoc) Repo licence MIT; the docs live in docs/modules/protocols/pages/*.adoc of the same repo; latest tag v2026.11. No source files of Wolf were read.
S-9 2026-11-25 Moonshine at f184d5e3693e09c3a6ab1025bde6cdb67f36a6bc: LICENSE, README.md, Cargo.toml, src/clients.rs, src/crypto.rs, src/webserver/pairing.rs, src/webserver/mod.rs, src/rtsp.rs, src/session/stream/control/mod.rs, src/session/stream/audio/{mod,encoder}.rs, src/session/stream/video/{mod,packetizer,shard_batch}.rs Facts tagged [M] in PROTOCOL.md: pairing query names, AES-128-ECB, key = first 16 bytes of SHA-256(salt + PIN), 16-byte salt/challenge/secret, RSA PKCS#1 v1.5 SHA-256, "certificate signature" = X.509 signatureValue bytes; serverinfo, applist and launch XML and query fields; SDP attribute names, SETUP reply headers, encryption flag bits; control IV layout and direction bytes, START_B starts the streams, INVALIDATE_REF_FRAMES and termination layouts, ENet host settings; audio IV, payload types 97/127, millisecond timestamps; video RTP/NV header byte layout, FEC bit fields and block split, video encryption prefix and IV; PING payload. Moonshine depends on tokio-enet for the control channel.
S-10 2026-11-25 tokio-enet at 364628ed754760c99e0df7bcc88e479ad91475c4: README.md, CHANGELOG.md, src/protocol/{mod,header,commands}.rs Claims wire compatibility with C ENet 1.3.x, BSD-2; ENet command numbers 1-12, command sizes, header flags (compressed 1<<14, sent time 1<<15, session bits 12-13), 4-byte command header, big-endian fields. Approved (Mark, 2026-11-25, answer 15).
S-11 2026-11-25 crates.io API for enet, enet-rs, nsys-enet, rusty_enet, tokio-enet, enet-sys, henet, enet-cs-sys, fec-rs, reed-solomon-erasure and the RustCrypto crates Licences, versions, repositories (see research/open-point-2.md and the Cargo manifest).
S-12 2026-11-25 docs.rs: rusty_enet Transpiled from C ENet; caller-supplied Socket trait and HostSettings::time; optional crc32 checksum; MIT.
S-13 2026-11-25 fec-rs README GF(2^8) with polynomial 0x1D (0x11D), "compatible with the Moonlight streaming protocol", reconstruction supported, BSD-2.
S-14 2026-11-25 moonlight-common-c README (README only) Needs its bundled ENet; other ENet versions are incompatible; GPL-3.0.
S-15 2026-11-25 cgutman/enet repository page (description only) Forked from lsalzman/enet, has a moonlight branch. No files opened.
S-16 2026-11-25 Roadmap brief §3.2 (moonlight-android releases) Moonlight Android 12.1 added end-to-end stream encryption with Sunshine.
S-17 2026-11-25 Stock ENet v1.3.18 (2662c0d): LICENSE, include/enet/protocol.h, include/enet/enet.h (constants and peer states), host.c (enet_host_connect), peer.c (default ping and timeout setters), protocol.c (header and checksum handling, connect/verify connect session ids, retransmission timeout) MIT. Wire structs and sizes; header flags; checksum is an optional host setting (4 bytes after the header, no flag on the wire, seeded with the connect id); connect sends session ids 0xFF and channel 0xFF; defaults: MTU 1392, ping interval 500 ms, timeout limit 32 / minimum 5000 ms / maximum 30000 ms, window 4096-65536 derived from bandwidth.
S-18 2026-11-25 fec-rs at 402f41f970bb8c3ef7c88639821032e3b6460f63: LICENSE, README.md, build.rs (field tables), src/galois.rs (exp), src/matrix.rs (vandermonde), src/reed_solomon.rs (build_matrix, new) BSD-2. Field GF(2^8) with polynomial 0x11D, generator 2; systematic code whose parity rows are the Cauchy matrix P[j][i] = 1 / ((m + i) XOR j). Its tests also contain the GPL-provenance audio matrix (not taken).
S-19 2026-11-25 GitHub release API: Moonlight PC v6.2.0, Sunshine v2026.914.233613 Asset names, sizes and sha256 digests for the lab capture pins. Release metadata only.
S-20 2026-11-25 ArenaTV docs/research/sunshine-api.md and docs/research/this-pc.md (Domi's own research from LizardByte's docs) Sunshine's API calls, --creds, bind_address, port offsets, first-run behaviour, this PC's adapters and old install.
S-21 2026-11-30 Moonshine at f184d5e (same pin as S-9): src/session/stream/control/mod.rs again (client message parsing and the control loop), src/session/stream/mod.rs (StreamConfig), src/session/stream/video/mod.rs (PING handling), src/config.rs (nothing relevant); the repository tree listing BSD-2. U10, as facts only: the host reads no body from START_B (0x0307), Ping (0x0200), LOSS_STATS, FRAME_STATS or the IDR request; START_A (0x0305) is not a type it knows; inside the encrypted frame an unknown type or a failed decryption is skipped, outside it an unknown type or a bad length ends the session; INVALIDATE_REF_FRAMES first/last at message bytes 4..8 and 12..16 (LE), short bodies mean "from 0"; each Ping resets a stop deadline, StreamConfig.timeout default 60 s; the client-to-host IV is seq LE ‖ 6 zero ‖ 'C' 'C'; host messages go reliable on channel 0; the video receiver waits for START_B and takes exactly the 4 bytes PING, each PING updating the client address. No value in these parts cites Sunshine or moonlight-common-c (the HDR payload's Sunshine note is the known S-9 case). Used for the probe's default bodies (all empty) and the PROTOCOL.md 3.3 facts.
S-22 2026-12-04 Microsoft Learn: DXGI 1.5 improvements, IDXGIOutput5::DuplicateOutput1, IDXGIOutput1::DuplicateOutput, Desktop duplication, HDR and advanced colour, GraphicsCaptureSession (IsBorderRequired, IsCursorCaptureEnabled), SendInput, MOUSEINPUT, Security considerations for assistive technologies, UAC policy for UIAccess in secure locations, CreateSyntheticPointerDevice, InjectSyntheticPointerInput, Loopback recording, AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS For LUMEN-HOST-PLAN.md: DuplicateOutput1 takes a list of formats and can deliver HDR/WCG surfaces unconverted, the list should always hold B8G8R8A8_UNORM; E_ACCESSDENIED on the secure desktop unless LocalSystem; four duplicating processes per session by default; re-create after desktop switches and mode changes. WGC draws a border, removable only from build 20348 after user consent; cursor capture from 19041. SendInput is subject to UIPI and fails silently; absolute moves are 0..65535, MOUSEEVENTF_VIRTUALDESK maps to the whole virtual desktop; relative moves get pointer speed applied. UIAccess needs Authenticode signing, a secure install location and is meant for assistive technology. Synthetic touch/pen injection from Windows 10 1809. WASAPI loopback captures the render mix in shared mode; per-process loopback from build 20348.
S-23 2026-12-04 NVIDIA video-sdk-samples at aa3544d: Samples/NvCodec/NvEncoder/nvEncodeAPI.h (API 8.1, sha256 4d061c34…6042a); NVIDIA VideoProcessingFramework at e82364f: src/TC/third_party/nvEncodeAPI.h (API 12.0, sha256 067c5159…b4ad); GitHub repository metadata of both Both headers carry NVIDIA's MIT notice for the header file; the repositories are Apache-2.0 / unlicensed samples and the second is archived. Declarations used for the L0 spike shim (struct versions, preset and tuning enums, NvEncGetEncodePresetConfigEx, resource registration). No sample .cpp file was opened.
S-24 2026-12-04 NVENC Video Encoder API Programming Guide (SDK 13.0) Loading nvEncodeAPI at run time and NvEncodeAPICreateInstance; NV_ENC_DEVICE_TYPE_DIRECTX sessions; registering, mapping and unmapping D3D11 textures; tuning info (low latency, ultra low latency), presets P1-P7, CBR filler, forcing IDR, NvEncInvalidateRefFrames, intra refresh, look-ahead latency; lock/unlock of the bitstream; async mode only on Windows 10+ WDDM, recommended there; Main10 settings.
S-25 2026-12-04 Licences via the GitHub and crates.io APIs and COPYING files: nefarius/ViGEmClient (MIT, archived), nefarius/ViGEmBus (BSD-3-Clause, archived), xiph/opus COPYING (BSD-style), crates opus, audiopus_sys, vigem-client, nvidia-video-codec-sdk, nvenc, windows Licence and status only; no source files of these projects were opened.
S-30 2026-12-04 Moonshine at f184d5e3693e09c3a6ab1025bde6cdb67f36a6bc (same pin as S-9): src/rtsp.rs again, read for the host side BSD-2, facts only. One request per TCP connection, the note that Moonlight opens a connection per request; CSeq required (connection closed without it); no method order and no Session check; statuses 200/400/500 only; OPTIONS Public; SETUP needs Transport (400 without), stream from the first streamid= query segment, answer Session: MoonshineSession;timeout = 90 and Transport: server_port=<port>; DESCRIBE line order and values (featureFlags:3, encryptionSupported 5 or 7, sprop-parameter-sets=AAAAAU, invalidation, AV1, H.264, surround lines); ANNOUNCE: the ten required attributes (400 when missing), the defaults of the optional ones (maxNumReferenceFrames 1, dynamicRangeMode/chromaSamplingType/encoderCscMode/encryptionEnabled/surround.enable 0, numChannels 2, channelMask 0x3, AudioQuality 1), maxFPS 0 refused, bitrate ×1000 must fit a u32, QoS off for 0. The comments citing Sunshine, moonlight-common-c or GFE are logged as second-hand GPL facts above and not used.
S-31 2026-12-04 Moonshine at f184d5e: src/session/stream/mod.rs, src/session/stream/video/mod.rs; the repository tree listing (GitHub API) BSD-2, facts only. bitStreamFormat 0 H.264 (default), 1 HEVC, 2 AV1, others invalid; dynamic range 0 SDR (default), 1 HDR; chroma 0 4:2:0 (default), 1 4:4:4; valid video packet size 200..=65471 (one stream packet in an IPv6 UDP datagram), below 200 refused; FEC default 20 %. The bitrate comment citing Sunshine is logged above and not used.
S-32 2026-12-04 Wolf: RTSP again (as S-3); RFC 2326 Wolf: nothing new for the host (no per-method answers, no ANNOUNCE list). RFC 2326: reason phrases of 400, 451, 454, 455, 501 (7.1.1); a missing Content-Length means zero (4.4); OPTIONS may be sent at any time (10.1); session ids at least 8 random octets (3.4); Public as a comma-separated list (10.1 example).
S-34 2026-12-04 Stock ENet v1.3.18 (2662c0d, same pin as S-17), read again for the host side: protocol.c (enet_protocol_handle_connect, _verify_connect, _disconnect, _ping, _bandwidth_limit, _throttle_configure, _acknowledge, _send_unsequenced, _send_unreliable_fragment, _send_reliable/_send_fragment state checks, the acknowledgement rules of _handle_incoming_commands, the ping condition of _send_outgoing_commands) and include/enet/enet.h (peer window constants) MIT. Facts for PROTOCOL.md 3.1 "The accepting side" and enet::host: a CONNECT is answered by a reliable verify on channel 0xFF and is not itself acknowledged; repeated connects from a live peer are refused; session id derivation (offered id or the slot's, plus one mod 4, skipping the slot's previous id) and which verify field carries which; MTU, window and channel clamping, bandwidths are the host's own, throttle echoed, connect data reported with the connect event; connected on the acknowledgement of the verify; acknowledgements only while connected and only with a sent time, a failing command ends the datagram; ping, bandwidth and throttle need the connected state; unsequenced window 1024 groups, 32 free windows; pings when nothing was received for the ping interval and nothing reliable is in flight. Read through an automated summary of the raw files at the pinned commit; no code copied.