Files
DomiStream/docs/LIVE-INTEROP.md
T
mnovak 3e09dbc09a [probe] U10 candidates from Moonshine: empty control bodies as defaults; run book P3/P4
Moonshine f184d5e (BSD-2, CLEAN_ROOM S-21) reads no body from START_B, PERIODIC_PING or the IDR request, ignores
LOSS_STATS and FRAME_STATS, does not know START_A (skipped inside the encrypted frame, fatal outside it), and stops a
stream after 60 s without a ping. No GPL-provenance value taken.

- Probe defaults: START_A and START_B empty, PERIODIC_PING empty every 500 ms, an empty IDR request on frame loss;
  every body stays overridable by hex or `none`.
- Tests: the candidates' plaintext headers, their sealed frame layout and Moonshine's client-to-host IV, and the
  INVALIDATE_REF_FRAMES field offsets Moonshine reads.
- PROTOCOL.md 3.3 and the U10 row narrowed with the [M] facts.
- LIVE-INTEROP.md: P3 decided (dev-only `sunshine-api` in arena-host behind a never-shipped feature, credentials from
  Custos), P4 done, table V rewritten without guessed bodies, first launch 90 s to outlast a 60 s ping deadline, the
  black-box list pointed at PLAY-REMOTELY's handover, §8 and §15 (§17 is the installer spec).
2026-11-30 11:01:41 +01:00

325 lines
21 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Live interop: the one sitting with Mark
Status: **prepared 2026-11-30, not run.** The probe (`tools/gs-probe`) is built and unit-tested and has never talked
to a host: no Sunshine existed when it was written.
This sitting settles the open UNKNOWNs of [PROTOCOL.md](PROTOCOL.md) §8 live, in one go, and answers the black-box
checks a GameStream client can answer from Arena `docs/PLAY-REMOTELY.md`. That list lives in its handover ("Next on
RESUME", item 3), §8 (the `pairing_id` call, the clients list) and §15 (the test-PC checks); §17 is the installer
spec and is not part of this sitting. The host is the pinned Sunshine
`v2026.914.233613`, installed by arena-host at Turn on to `E:\Apps\Sunshine` and bound to `192.168.100.140`. The
client is our probe, which runs DomiStream `stream-v0.1.0`'s state machines over real sockets from this PC. No
Moonlight, no TV and no other machine take part.
## 0. Hard limits
- **One address.** Every probe socket goes to `192.168.100.140`. If `sessionUrl0` names another host, the probe
records it and still connects only to .140.
- **No listening port on this PC.** During `launch` the probe has only three ephemeral UDP client sockets. Nothing
binds a fixed port.
- **Out folder:** `F:\build\play-remotely\live\<date>\` (E: is full). It is outside git and holds:
- `identity\`: the probe's test-only key and certificate, made on the first run;
- `runs\<utc>-<command>\`: one folder per command, with `log.jsonl` and the dumps.
It is deleted at the end (section 7).
- **Secrets:**
- The probe never prints its key and never logs the stream key (`rikey`), pairing salts, challenges or secrets.
- The PIN goes to the operator's terminal only, never to the log. Every log line is also scanned for the session
key's hex before it is written.
- Sunshine's API credentials stay in Custos: never typed, never on a command line, never in a log.
- **Nothing changes on Mark's PC** during the sitting: no Sunshine config, firewall, arena-host setting or install.
The only exceptions are the steps below that the run book names (pairing the probe, launching one game) and their
undo in section 7.
- **The stop-and-report rule** (section 6) wins over everything in this file.
## 1. What Mark sees
- **Nothing on his screen except:**
- Sunshine's own notifications, if any (for example when a client asks to pair, or a stream starts or ends);
- at `launch`, the game starting on his PC;
- at `quit`, the game closing.
- The probe runs in our terminal. No UAC prompt, no Custos card (Arena Domi was approved at Turn on), and no PIN is
shown to Mark.
- **Two things we cannot rule out before the sitting.** If either appears, Mark answers as below and we stop and
report:
- A **Windows Security Alert** for `probe.exe` when its UDP sockets first receive. Mark clicks **Cancel**.
- **Arena Domi's own first-stream toast** (PLAY-REMOTELY §7.4). It can appear if the Arena window is running when
Sunshine's prep-cmd hook reports the probe's stream. Mark dismisses it.
- **Mark's part:** be present, agree on the game for `launch` beforehand (a light one from the `apps` list), and keep
hands off mouse and keyboard while the stream runs (90 s for the first launch, about 30 s for any variant).
## 2. Before the sitting (without Mark)
| # | What | How |
| :-- | :-- | :-- |
| P1 | Probe built | `cd tools\gs-probe`, `CARGO_BUILD_BUILD_DIR=F:\build\play-remotely\cargo-build-probe`, `TEMP`/`TMP=F:\build\play-remotely\tmp\protocol`, load gate (CPU and RAM < 90 %, D: and F: < 95 %), then `cargo test --offline -j 2` and `cargo build --offline --release -j 2`. Binary: `tools\gs-probe\target\release\probe.exe`. |
| P2 | Sunshine as arena-host left it (read-only) | `Get-NetTCPConnection -State Listen \| ? LocalPort -in 47984,47989,47990,48010` shows each on `192.168.100.140` only: nothing on `0.0.0.0` or loopback on Day 1 (PLAY-REMOTELY §4). `Get-NetUDPEndpoint \| ? LocalPort -in 47998,47999,48000` is empty while idle (PLAY-REMOTELY §9). |
| P3 | Sunshine's API without seeing the credentials (**decided: a**, build lead 2026-11-30) | Needed for the PIN (step S2) and checks B1–B3. The host engineer writes a dev-only `sunshine-api <GET\|POST> <path> [json]` command in arena-host (Play remotely's own crate), behind a cargo feature that never ships. It takes the credentials from Custos (never typed, printed or logged), calls `https://192.168.100.140:47990` with arena-host's pinned client (§3, §4) and prints the answer with secrets redacted. Its first call also answers §15's "does `pc` cover a self-connection to .140". It must be built and checked before the sitting; this file writes the calls as `sunshine-api …`. |
| P4 | U10 bodies (**done** 2026-11-30, CLEAN_ROOM S-21) | Moonshine (BSD-2) reads **no body** from START_B, PERIODIC_PING or the IDR request, ignores LOSS_STATS and FRAME_STATS, and does not know START_A. Inside the encrypted frame, an unknown type is skipped, not fatal. Each PERIODIC_PING pushes its stop deadline out (60 s by default). Nothing taken has GPL provenance. The probe's defaults follow: START_A and START_B empty, PERIODIC_PING empty every 500 ms, an empty IDR request on frame loss. Table V holds what to try if Sunshine differs. |
| P5 | Game | Agree the `launch` game with Mark (a light one) and note its app id after S4. |
Shell variables used below (PowerShell):
```powershell
$P = "F:\Akce\DomiStream-wt-probe\tools\gs-probe\target\release\probe.exe"
$O = "F:\build\play-remotely\live\2026-12-XX" # the sitting's date
$H = "192.168.100.140"
```
Exit codes: 0 done, 1 error, 2 bad command line, 3 **stop and report** (a `stop` record is in the log).
## 3. The sequence
Each step names the command, the UNKNOWNs it settles and what to look for. "Log" means that run's
`$O\runs\<utc>-<command>\log.jsonl` (format in section 4).
### S0. Preflight (read-only, 1 min)
- Run the P2 checks again.
- Sunshine's own traffic baseline (B4): `Get-NetTCPConnection -OwningProcess (Get-Process sunshine).Id` and
`Get-NetUDPEndpoint -OwningProcess …`. Note every remote address.
### S1. `& $P serverinfo --host $H --out $O`
- **Settles:** U25 (codec bits, from a host whose GPU we know: RTX 3090).
- **Look for:**
- `serverinfo.http` recv: status 200, the XML in full;
- the note with `parsed` and `codec_mode_support_bits`;
- `HttpsPort` (if it is not 47984, add `--https-port` to every later command);
- `appversion`, `state` (…`_FREE`), `PairStatus 0`.
- On the first run the probe generates its identity: log record `identity` (`generated a new …`).
### S2. `& $P pair --host $H --out $O`
- **Settles:**
- U1: the parameter names we send are accepted, and the order of steps 4 and 5;
- U2: our RSA-2048 self-signed certificate is accepted;
- U24: the TLS version and suite at step 5;
- with B1 and B2, PLAY-REMOTELY §8.
- **Procedure.** The probe prints `PIN for the operator: NNNN` and waits up to 120 s at step 1. Within that time:
1. **B1, the pending pairing.**
- Call each documented read-only GET of the pinned API docs (at least `sunshine-api GET /api/clients/list`).
- Look for an entry naming the probe's `uniqueid` (log record `identity`) or the device name
`DomiStream probe`.
- Read `E:\Apps\Sunshine\config\sunshine.log` (black-box: Sunshine's own log, read-only) for a line about the
incoming pairing and any id it names.
- Record which call or line shows the pending pairing and its `pairing_id`.
2. **Submit:** `sunshine-api POST /api/pin '{"pairing_id":"<id>","pin":"NNNN","name":"DomiStream probe"}'`. If no
`pairing_id` was found, try `{"pin":"NNNN","name":"DomiStream probe"}` once and record the answer. If that is
refused too: stop and report (B1 open, and pairing cannot go on).
3. The probe goes on by itself through steps 2–5 and ends with an HTTPS `serverinfo` (`PairStatus 1`).
- **Look for:**
- `pair.1` … `pair.5`: send and recv of each step (values redacted, names and order kept);
- `pair.1`'s `elapsed_ms` (the time until the PIN went in);
- the `host certificate sha256` note;
- `pair.5`'s `tls` (version, suite);
- `pair.done`;
- on failure, the `stop` record, with the step and the state it failed in.
- **B2:** `sunshine-api GET /api/clients/list` must show exactly one new client, named `DomiStream probe`. Record the
entry's fields: this is also B3's input.
### S3. `& $P apps --host $H --out $O`
- **Settles:** nothing new. It confirms HTTPS with the pinned certificate (U24 again).
- **Look for:** the agreed game's id (P5); `Desktop`, if listed, is the fallback.
### S4. `& $P launch <id> --host $H --out $O --seconds 90 --nudge-mouse`
90 s outlasts Moonshine's 60 s no-ping deadline. A stream that lives to the end shows Sunshine accepts the default
empty PERIODIC_PING, or does not need one within 90 s; `sunshine.log` tells which (U10). Variants use `--seconds 30`.
- **Mark sees** the game start.
- **Settles:**
| Area | UNKNOWNs |
| :-- | :-- |
| Launch | U4 |
| RTSP | U5, U6, U7, U26 |
| UDP setup | U8 |
| Control stream | U9, U10, U11 |
| Video | U13, U14, U15, U29; U19 only if the host offers video encryption |
| Audio | U17; data for U16 |
| Host events | U23, only if any arrive |
- **Look for**, in order:
| Record | Settles | What it shows |
| :-- | :-- | :-- |
| `launch` send/recv | U4 | Our parameter set accepted (`uniqueid, appid, mode, rikey=<redacted>, rikeyid, hdrMode, surroundAudioInfo`); `gamesession`, `sessionUrl0` |
| `rtsp.*` send/recv | U5 | Every request and answer in full; `end` (`Length` / `Closed` / `Idle`), `content_length_header`, and notes about new TCP connections |
| `rtsp.describe` recv | U26 | The SDP: every `surround-params` line, `encryptionSupported`, `featureFlags` |
| `rtsp.setup_*` recv | U5, U7 | Every header of the three answers (`Session`, `Transport`, anything extra) |
| `rtsp.announce` | U6 | 200 means our 19 attributes are accepted as they are |
| `ping` + `video.first` / `audio.first` | U8 | Payload `PING`; `pings_before` and the source port of the first packet |
| `control.datagram` (first 64 each way) | U9 | Decoded ENet: our connect, the host's verify connect (channel count, MTU, window, flags), anything stock 1.3 lacks (`unparsed: …` or `parse_error`) |
| `control.start_a`, `control.start_b` | U10 | What we sent (empty bodies by default). Video then flowing means the host accepted it |
| `control.periodic_ping` (first 3), `launch.summary` `control.ended` | U10 | The empty ping every 500 ms; `ended` null after 90 s means the pings kept the session alive |
| `control.host` | U10, U11, U23 | Every decrypted host message: type, sequence, body |
| `video.frame` (first 16) | U13 | `header_raw`: Wolf's constant `0137636861727373` or Moonshine's fields |
| `launch.summary` | U14 | `u14_*`: whole-packet parity matches (5.3 confirmed), or payload-only, or neither |
| `launch.summary` | U15 | `multi_fec_flags_u15` histogram |
| `launch.summary` | U29 | `u29_rtp_ticks_per_frame`, `u29_clock_hz_estimate` (90000 expected) |
| `launch.summary` | U17 | `u17_decrypting` vs `u17_plain`: the receiver that accepts the packets says whether audio is encrypted. Compare with bit 0x04 of `negotiated.encryption` |
| `launch.summary` | U19 | `decrypt_failures` is 0 when video encryption was negotiated |
| `audio.u16` | U16 | Matrix solved from `audio-packets.bin` (or later: `& $P solve-audio-fec <run>\audio-packets.bin`); `matrix_is_mds` |
| `launch.summary` counters | — | Video: `frames`, `decode_ready_frames`, `frames_lost`, `fec_recovered_shards`. Audio: data and parity packets, losses |
- **B3, per-device input:**
- The `--nudge-mouse` input is one relative move of +1 then −1 pixel after the first decodable frame:
harmless, and invisible to Mark.
- If the B2 entry has a per-client input field, an extra launch with that input turned off for the probe shows
whether Sunshine drops it (watch `sunshine.log`). That launch needs the build lead's OK: it changes a Sunshine
setting.
- If the entry has no such field, record "per-client: enable/disable only".
- **B4:** during the stream, list Sunshine's sockets again (S0). The three UDP ports appear, and no remote address
besides .140 shows up.
- **B5:** with arena-host running, the prep-cmd hook should report `start <game>` with
`SUNSHINE_CLIENT_NAME = DomiStream probe`, and arena-host should write its audit record "Play remotely started".
Record what happened.
- Then `& $P quit --host $H --out $O`: the game closes. B5 again: `end`.
**Variants (table V), only when S4 stops.** Each variant is one `launch` (with `quit` before the next). There are at
most 6 launches in the sitting, and the same variant is never tried twice.
| Symptom (log) | Variant |
| :-- | :-- |
| ANNOUNCE not 200 (U6) | `--encryption 1`, then `--codec hevc`, then `--packet-size 1392`. Attribute values beyond the CLI need a code change: stop and report |
| No verify connect, ENet `timed_out` (U9) | `--enet-channels 48`. Nothing else is known about the connect fields: stop and report |
| Connected, but the host ends the session right after START_A, or `sunshine.log` names an unknown control message (U10) | `--start-a none` (Moonshine has no START_A) |
| Connected but no video within 5 s of START_B (U10) | Read `sunshine.log` for what it says about START_B. If it names a body or a length, give that body with `--start-b <hex>` (one try). Otherwise stop and report: P4 found no body, and none is guessed |
| Video stops after N s, host disconnects (U10) | `--periodic-ping-ms 100`; if it still stops, `--periodic-ping none` (to see whether the empty ping is what the host refuses), then stop and report |
| Frames lost and never recovered (U10) | `--rfi`, if DESCRIBE has `refPicInvalidation`; else `--idr none`, to compare with the default empty request |
| Surround (U26), only if time allows | `--audio 5.1` |
### S5. U28, a refused pairing (optional, 2 min)
1. `& $P unpair --host $H --out $O`.
2. `& $P pair --host $H --out $O --wrong-pin`. The probe prints one PIN, uses another, and must stop at step 3 with
`ProofMismatch`.
3. Submit the printed PIN as in S2.
4. Look for:
- what `/api/pin` answers;
- whether B1's call still lists a pending pairing afterwards;
- whether the client list stays without the probe;
- whether a fresh `probe pair` works without any clean-up. That last point is U28's answer.
5. Leave it unpaired.
## 4. Reading the log
One JSON object per line, flushed as written:
```json
{"n":12,"t_ms":845.210,"step":"rtsp.setup_video","kind":"recv","u":["U5","U7"],"data":{…}}
```
- **`kind`:**
- `send`: what the probe sent;
- `recv`: what the host sent;
- `note`: an observation;
- `parse_error`: the parser's error plus the bytes that caused it (hex or text, capped at 4 KiB);
- `stop`: the stop-and-report rule fired;
- `summary`: the end-of-step counters.
- **`u`:** the UNKNOWNs the record bears on.
- **Filtering** (PowerShell):
`Get-Content log.jsonl | ConvertFrom-Json | ? { $_.u -contains 'U5' } | ConvertTo-Json -Depth 8`.
- **Run folder contents:**
- `video.h264` (or `.h265`): the first `--dump-frames` frames' Annex-B elementary stream, for `ffprobe` later.
The probe decodes nothing.
- `video-packets.bin`: plaintext video packets, `--dump-packets` of them.
- `audio-packets.bin`: audio datagrams as received.
The `.bin` files use the format in `tools/gs-probe/src/dump.rs`. **The video files hold frames of Mark's game:**
they never go into git and are deleted after analysis.
## 5. From the log to PROTOCOL.md and the code
1. **Facts first.** Each settled UNKNOWN gets its fact in PROTOCOL.md with the tag `[L2]` (live sitting, date,
Sunshine `v2026.914.233613`, probe commit). Add the tag to the tag table and the row to §8. An UNKNOWN that stays
open says why.
2. **Tests before code** (repo rule). Every fact becomes a unit test or vector in `crates/domistream`:
- structure and constants only;
- re-encrypted with keys generated in the test;
- never bytes of Mark's video.
3. **Where each U lands:**
| U | PROTOCOL.md | Code |
| :-- | :-- | :-- |
| U1, U28 | 1.5 | `pairing/mod.rs` (`request`, step order) |
| U2 | 1.5 | `pairing/identity.rs` (`generate`) |
| U4 | 1.4 | `http/launch.rs` (`launch_request`, the `sessionUrl0` default) |
| U5 | 2.1, 2.2 | `rtsp/mod.rs` (`RtspFramer`), `rtsp/client.rs` (`CLIENT_VERSION`, `SETUP_TARGETS`, `TRANSPORT`, `Session` echo, PLAY target) |
| U6 | 2.4 | `rtsp/sdp.rs` (`build_announce`) |
| U7 | 2.2 | `rtsp/client.rs` (`advance`, `NegotiatedStream`) |
| U8 | 5.1, 6.1 | `rtsp/client.rs` (`PING_PAYLOAD`); the ping interval in the platform layer's docs |
| U9 | 3.1 | the `EnetConfig` defaults the callers use (docs in `enet/mod.rs`); `enet/protocol.rs` only if the host sends something stock 1.3 lacks |
| U10 | 3.3 | `control/message.rs` (`encode_client_message`: START_A, START_B, PERIODIC_PING, IDR bodies instead of `Unsupported`), `control/mod.rs` (send PERIODIC_PING on `ping_interval`) |
| U11 | 3.2 | `control/mod.rs` (`next_sequence` start, replay rule) |
| U13, U15 | 5.2 | `video/packet.rs` (docs, `FrameHeader`) |
| U14 | 5.3 | `fec.rs`: confirmed, nothing to change (or stop and report if `u14_no_match`) |
| U16 | 6.4 | a `pub const` parity matrix in `audio/mod.rs`, used as `AudioFec::ParityMatrix` by the callers |
| U17 | 6.3 | `AudioConfig.cipher` policy (docs in `audio/mod.rs`) |
| U19 | 7 | `video/mod.rs` (`VideoCipher::decrypt`) |
| U23 | 3.3 | `control/message.rs` (host event bodies) |
| U25, U27 | 1.2, 1.1 | `http/serverinfo.rs`, `http/xml.rs` docs |
| U26 | 2.3 | `rtsp/sdp.rs` |
| U29 | 5.2 | `rtp.rs` / `video/mod.rs` docs |
4. **Re-run** clippy, fmt, rustdoc, the tests, the mutation script and the fuzz targets of the touched parsers (load
gate first).
5. **Re-run the probe** against Sunshine with the patched crate: `launch` with **no** variant flags must give
`decode_ready_frames > 0`, audio packets, and no `stop`. Then release `stream-v0.1.1` (HANDOVER).
6. **Arena:** B1–B5 answers go to Arena `docs/PLAY-REMOTELY.md` (handover, §8, §15). That file and arena-host are Play
remotely's own, so we write them; the seam files stay the Arena build lead's.
**Not settled by the probe:**
- U20, U21, U22: no keyboard, touch or gamepad input beyond the one mouse nudge.
- U24 beyond what rustls negotiates.
- U26 beyond stereo, unless the 5.1 variant runs.
- U19, if the host does not offer video encryption.
- U23, if no host event arrives.
`tools/lab-relay` cannot be used as it stands: its upstream must be loopback, and Sunshine listens on .140 only.
`--relay` is ready on the probe side if the build lead ever widens that rule. The probe's own log already holds the
plaintext of HTTP, HTTPS and RTSP, and the decrypted control messages.
## 6. Stop and report
**Stop** means: no further probe command, no Sunshine call beyond read-only GETs, no retry outside table V. Report to
the coordinator:
- the step;
- the log path and the record number `n`;
- what was expected;
- what was seen.
Then wait.
**Stop when:**
- a probe command exits with code 3 (a `stop` record), or with 1;
- anything appears on Mark's screen beyond section 1's list, or Mark asks to stop;
- any socket of the probe or of Sunshine talks to an address other than `192.168.100.140` or loopback;
- Sunshine crashes, restarts, or its notifications show an error;
- the game misbehaves, or the PC slows down noticeably;
- an answer fits none of the expectations above, even if the probe accepted it;
- table V is used up (6 launches), or a variant would need a code change, a Sunshine setting or an install;
- a secret shows up anywhere it should not (terminal, log, file name). Stop at once and delete the record.
## 7. Clean-up (same sitting)
1. `& $P quit --host $H --out $O`, if a game is still running.
2. `& $P unpair --host $H --out $O`, then B2 again: the client list no longer shows the probe.
3. Delete `$O\identity\` (the probe's test key).
4. **The run folders stay** until the facts are in PROTOCOL.md and the tests are in. Then they are deleted on the
build lead's word. `video.*` and `video-packets.bin` go first, right after the U13/U14/U15/U29 analysis.
5. Nothing to undo on Sunshine, arena-host or the firewall: nothing was changed.
## 8. Timeline for Mark (about 20 minutes)
| When | What happens | Mark |
| :-- | :-- | :-- |
| 0:00 | S0, S1: read-only checks, `serverinfo` | nothing |
| 0:02 | S2: the probe pairs (we submit the PIN through Sunshine's API). Sunshine may show a notification | nothing |
| 0:05 | S3, S4: the agreed game starts on his PC and streams to the probe for 90 s; then we close it | hands off mouse and keyboard while it runs |
| 0:07-0:15 | Variants, only if needed (up to 6 launches, each about 1 min) | same |
| 0:15 | S5 (optional), clean-up | nothing |
| later | Analysis offline; the game frames are deleted | nothing |