Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a2305cbafa | |||
| c7dcdc80f3 | |||
| a78bde9037 | |||
| 90c49c4041 | |||
| 28750eee81 | |||
| 597484425e | |||
| 0d45628c4e | |||
| 25557d4c38 | |||
| 9434d16422 |
Generated
+1
-1
@@ -241,7 +241,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "domistream"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ exclude = ["fuzz"]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
edition = "2024"
|
||||
rust-version = "1.89"
|
||||
license = "CPAL-1.0"
|
||||
|
||||
@@ -63,6 +63,9 @@ pub enum ClientControlMessage {
|
||||
InputRejected {
|
||||
/// Body length.
|
||||
body_len: usize,
|
||||
/// The input type field (body bytes 4..8, little-endian, PROTOCOL.md 4) when the body is long enough: for the
|
||||
/// logs, so a host can name what a client sends.
|
||||
input_type: Option<u32>,
|
||||
/// Why.
|
||||
error: Error,
|
||||
},
|
||||
@@ -111,7 +114,11 @@ pub fn parse_client_message(message: &[u8]) -> Result<ClientControlMessage> {
|
||||
t if t == MessageType::FrameStats as u16 => ClientControlMessage::FrameStats(b.to_vec()),
|
||||
t if t == MessageType::InputData as u16 => match crate::input::parse_input(message) {
|
||||
Ok(e) => ClientControlMessage::Input(e),
|
||||
Err(error) => ClientControlMessage::InputRejected { body_len: b.len(), error },
|
||||
Err(error) => ClientControlMessage::InputRejected {
|
||||
body_len: b.len(),
|
||||
input_type: b.get(4..8).and_then(|t| <[u8; 4]>::try_from(t).ok()).map(u32::from_le_bytes),
|
||||
error,
|
||||
},
|
||||
},
|
||||
other => ClientControlMessage::Unknown { message_type: other, body_len: b.len() },
|
||||
})
|
||||
|
||||
@@ -183,14 +183,14 @@ pub fn plan_fec_blocks(data_shards: usize, fec_percentage: u8, min_parity: u8) -
|
||||
let blocks = (1..=MAX_FEC_BLOCKS)
|
||||
.find(|&b| wished_percentage(data_shards.div_ceil(b), fec_percentage, min_parity).is_some())
|
||||
.unwrap_or(MAX_FEC_BLOCKS);
|
||||
let k_full = data_shards.div_ceil(blocks);
|
||||
let count = data_shards.div_ceil(k_full);
|
||||
let mut plan = Vec::with_capacity(count);
|
||||
let mut left = data_shards;
|
||||
while left > 0 {
|
||||
let k = left.min(k_full);
|
||||
// Even split (RFC 5052 9.1, as a BSD-2 host does it; PROTOCOL.md 5.3): the first `r` blocks carry one shard
|
||||
// more, so block sizes differ by at most one and the largest is `ceil(n / blocks)`, the size checked above.
|
||||
let blocks = blocks.min(data_shards);
|
||||
let (q, r) = (data_shards / blocks, data_shards % blocks);
|
||||
let mut plan = Vec::with_capacity(blocks);
|
||||
for i in 0..blocks {
|
||||
let k = if i < r { q + 1 } else { q };
|
||||
plan.push(block(k, fec_percentage, min_parity)?);
|
||||
left -= k;
|
||||
}
|
||||
Ok(plan)
|
||||
}
|
||||
|
||||
@@ -784,3 +784,27 @@ proptest! {
|
||||
prop_assert!(messages <= plains.len());
|
||||
}
|
||||
}
|
||||
|
||||
/// Diagnostics (decision D2 on the host): an INPUT_DATA the host cannot read still says which input type it was, so
|
||||
/// the black-box log can name what a real client sends (L2 demo: one 10-byte body of an unknown layout, U21).
|
||||
#[test]
|
||||
fn refused_input_names_its_type() {
|
||||
// INPUT_DATA (0x0206): length 10, size (BE) 6 = type + 2 data bytes, type TOUCH 0x55000002 (LE), 2 data bytes.
|
||||
let mut m = vec![0x06, 0x02, 10, 0];
|
||||
m.extend_from_slice(&6u32.to_be_bytes());
|
||||
m.extend_from_slice(&0x5500_0002u32.to_le_bytes());
|
||||
m.extend_from_slice(&[0xAA, 0xBB]);
|
||||
match parse_client_message(&m) {
|
||||
Ok(ClientControlMessage::InputRejected { body_len, input_type, .. }) => {
|
||||
assert_eq!(body_len, 10);
|
||||
assert_eq!(input_type, Some(0x5500_0002));
|
||||
}
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
// Too short to carry a type: none.
|
||||
let short = vec![0x06, 0x02, 2, 0, 0, 0];
|
||||
match parse_client_message(&short) {
|
||||
Ok(ClientControlMessage::InputRejected { input_type, .. }) => assert_eq!(input_type, None),
|
||||
other => panic!("{other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,16 +438,18 @@ fn fec_plan_properties() {
|
||||
assert!((1..=MAX_FEC_BLOCKS).contains(&plan.len()), "{ctx}: {} blocks", plan.len());
|
||||
assert_eq!(plan.iter().map(|b| usize::from(b.data_shards)).sum::<usize>(), n, "{ctx}");
|
||||
let first_k = plan[0].data_shards;
|
||||
// Even split (RFC 5052 9.1, as a BSD-2 host does it, PROTOCOL.md 5.3): sizes differ by at most one,
|
||||
// the larger blocks first.
|
||||
let q = n / plan.len();
|
||||
let r = n % plan.len();
|
||||
for (i, b) in plan.iter().enumerate() {
|
||||
let (k, m, p) =
|
||||
(usize::from(b.data_shards), usize::from(b.parity_shards), usize::from(b.fec_percentage));
|
||||
assert!(k >= 1 && k + m <= 255, "{ctx}: k {k} m {m}");
|
||||
assert_eq!(m, parity_count(k, b.fec_percentage).unwrap(), "{ctx}: m follows from the percentage");
|
||||
if i + 1 < plan.len() {
|
||||
assert_eq!(b.data_shards, first_k, "{ctx}: every block but the last carries the same k");
|
||||
} else {
|
||||
let want = if i < r { q + 1 } else { q };
|
||||
assert_eq!(usize::from(b.data_shards), want, "{ctx}: block {i} of an even split");
|
||||
assert!(b.data_shards <= first_k, "{ctx}");
|
||||
}
|
||||
let t = target(k, pct, min);
|
||||
assert_eq!(
|
||||
b.reduced,
|
||||
@@ -480,6 +482,15 @@ fn fec_plan_properties() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocks_split_evenly_larger_first() {
|
||||
// 217 shards at 255 %: at most 72 data shards fit a block (72 + 184 = 256 would not), so 4 blocks, split
|
||||
// 55, 54, 54, 54 (RFC 5052 9.1), not 55, 55, 55, 52.
|
||||
let plan = plan_fec_blocks(217, 255, 0).unwrap();
|
||||
let ks: Vec<u16> = plan.iter().map(|b| b.data_shards).collect();
|
||||
assert_eq!(ks, vec![55, 54, 54, 54]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn minimum_parity_raises_the_written_percentage() {
|
||||
// One data shard at 0 % with at least 2 parity packets: 101 % is the smallest percentage giving
|
||||
|
||||
@@ -97,3 +97,4 @@ All entries by the DomiStream protocol engineer. Pinned commits are the ones rea
|
||||
| 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](https://games-on-whales.github.io/wolf/stable/protocols/rtsp.html) again (as S-3); [RFC 2326](https://www.rfc-editor.org/rfc/rfc2326.txt) | 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](https://github.com/lsalzman/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. |
|
||||
| S-26 | 2026-12-04 | [Moonshine](https://github.com/hgaiser/moonshine) at `f184d5e` (same pin as S-9): `src/session/stream/video/packetizer.rs` and `src/session/stream/video/mod.rs` again, read for the host after the L2 demo | BSD-2, facts only. The raised FEC percentage for a minimum parity count (`(minimum - 1) * 100 / k + 1`, capped by 255 and the 255-shard limit), parity rounded up; the even block split (RFC 5052 9.1); per-block data shards from `255 * 100 / (100 + percentage)`, at most 4 blocks; which parity header fields it patches; the 8-byte frame header and last-shard length; the encryption prefix order (IV, frame number, tag). A comment in `video/mod.rs`: a fresh Moonlight session expects frame numbers to start at 1 (a client behaviour, no Sunshine or moonlight-common-c value; to be confirmed by our measurement). No comment in these parts cites Sunshine or moonlight-common-c for a packetizer value. |
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# DomiStream — handover
|
||||
|
||||
## stream-v0.2.2 (2026-12-04)
|
||||
|
||||
After the L2 demo (Arena Domi Remote crashed at Lumen's first video frame): the video packetizer splits FEC blocks
|
||||
evenly, larger blocks first (RFC 5052 9.1, as Moonshine's host does it), and a refused INPUT_DATA names its input
|
||||
type for the logs (`ClientControlMessage::InputRejected::input_type`). The frame index starting at 1 is the caller's
|
||||
(Lumen's) job; PROTOCOL.md 5.2 records it. Tests first; workspace 424 passed, 0 failed.
|
||||
|
||||
## stream-v0.2.1 (2026-12-04)
|
||||
|
||||
Patch for Lumen L2: the client's `ControlStream` sends `START_B`, `PERIODIC_PING` and the IDR request with empty
|
||||
bodies (PROTOCOL.md 3.3; `START_A` stays refused, U10), so our own clients can start and keep a stream on Lumen
|
||||
(PR #15, tests first). Workspace 422 passed, 0 failed; clippy, fmt and rustdoc clean.
|
||||
|
||||
## stream-v0.2.0 (2026-12-04)
|
||||
|
||||
The GameStream host side, sans-I/O, for Lumen (milestone L1, `docs/LUMEN-HOST-PLAN.md` 3.1), next to the client of
|
||||
|
||||
+31
-7
@@ -53,6 +53,27 @@ and the operator's notes:
|
||||
|
||||
The other clients (the Moonlight PC app, Arena Domi TV) are measured when they connect.
|
||||
|
||||
**L2 demo, the same client against lumen-host with streaming (2026-12-04) [L1]:** pairing again in about 4 s from
|
||||
the typed code; box art from `/appasset` shown for all 11 games; `/launch` (1280x720x60, `surroundAudioInfo=196610`)
|
||||
answered with `sessionUrl0=rtsp://127.0.0.1:49010`. Then, for this client:
|
||||
- **RTSP (U5):** one TCP connection per request, and the client **reads until the host closes the connection**; a
|
||||
host that keeps it open makes every request wait for a timeout (measured: about 10.5 s per request against
|
||||
lumen-host before its fix; Arena PR #56 now closes after every answer). Requests: OPTIONS (target
|
||||
`rtsp://0.0.0.0:49010`; headers `CSeq`, `X-GS-ClientVersion: 14`, `Host`), DESCRIBE (adds `Accept`,
|
||||
`If-Modified-Since`), SETUP `streamid=audio/0/0`, `streamid=video/0/0`, `streamid=control/13/0` (adds `Transport`;
|
||||
`Session` from the second SETUP on), ANNOUNCE (on `streamid=control/13/0`, 1491 bytes), PLAY.
|
||||
- **ANNOUNCE (U6):** 37 attributes, among them `x-nv-vqos[0].bitStreamFormat` = HEVC, viewport 1280x720, `maxFPS`
|
||||
60, `packetSize` 1360, `configuredBitrateKbps` 10000, `x-ss-general.encryptionEnabled` 7, `minRequiredFecPackets`
|
||||
2, `maxNumReferenceFrames` 1, `dynamicRangeMode` 0, `encoderCscMode` 2, stereo (`surround.enable` 0, 2 channels,
|
||||
mask 3), `x-nv-aqos.packetDuration` 5; no `refPicInvalidation` line. Also sent: `x-ml-general.featureFlags`,
|
||||
`x-nv-video[0].rateControlMode`, `timeoutLengthMs`, `framesWithInvalidRefThreshold`, `initialBitrateKbps`,
|
||||
`initialPeakBitrateKbps`, `x-nv-vqos[0].bw.minimumBitrateKbps`/`maximumBitrateKbps`, `fec.enable`,
|
||||
`videoQualityScoreUpdateTime`, `x-nv-general.featureFlags`, `useReliableUdp`, `bllFec.enable`, `drc.enable`,
|
||||
`enableRecoveryMode`, `videoEncoderSlicesPerFrame`, `x-nv-clientSupportHevc`, `clientRefreshRateX100`.
|
||||
- The client's own error text, when the RTSP handshake failed, named the GameStream default ports (TCP 48010, UDP
|
||||
48000, 48010), not the ports it was using: it is a fixed text, not a statement of what it connected to.
|
||||
- `/cancel` answered 200 with the ok root brings the client back to its game list without an error.
|
||||
|
||||
**Tags** (details in the source log, [CLEAN_ROOM.md](CLEAN_ROOM.md)):
|
||||
|
||||
| Tag | Source |
|
||||
@@ -592,7 +613,7 @@ Each packet is `packetSize + 16` bytes, `packetSize` from ANNOUNCE (default 1024
|
||||
| 8 | 4 | SSRC, 0 [M] |
|
||||
| 12 | 4 | reserved [W5] |
|
||||
| 16 | 4 | stream packet index, LE (= RTP sequence << 8 [M]) |
|
||||
| 20 | 4 | frame index, LE [W5][M] |
|
||||
| 20 | 4 | frame index, LE [W5][M]; **starts at 1** in a fresh session (Moonshine's note on what Moonlight-family clients expect [M], S-26; a host that started at 0 crashed Arena Domi Remote at its first frame, L2 demo) |
|
||||
| 24 | 1 | flags: 0x01 picture data, 0x02 end of frame, 0x04 start of frame [W5] |
|
||||
| 25 | 1 | reserved [W5] |
|
||||
| 26 | 1 | multi-FEC flags, `0x10` [M] (UNKNOWN U15: meaning) |
|
||||
@@ -629,12 +650,15 @@ Reed-Solomon erasure code over GF(2^8), polynomial `0x11D` [F] [W5]:
|
||||
`P = [[8e f4 47 a7], [f4 8e a7 47]]`; `k = 3, m = 1`: `P = [[01 8e f4]]`.
|
||||
The capture settles it without any loss: parity packets are always sent, so our encoder must reproduce the
|
||||
captured parity bytes (offset 32 on) of every block.
|
||||
- **Host side (Lumen, `video::packetizer`).** Our own choices, not from a source, until a capture compares them
|
||||
with a real host: the fewest blocks (at most 4) in which every block can carry the requested parity within
|
||||
`k + m <= 255`, every block but the last carrying `k = ceil(n / blocks)` data shards; per block the least
|
||||
percentage, at or above the requested one, whose `m` reaches `minRequiredFecPackets`; a frame too big for that
|
||||
gets the most parity that still fits (counted in the packetizer's stats). Data shards in order, then the block's
|
||||
parity, block by block; RTP sequence numbers run on across frames, one per packet.
|
||||
- **Host side (Lumen, `video::packetizer`).** The fewest blocks (at most 4) in which every block can carry the
|
||||
requested parity within `k + m <= 255`, split **evenly**: sizes differ by at most one, the larger blocks first
|
||||
(RFC 5052 9.1, as Moonshine's host does it [M], S-26); per block the least percentage, at or above the requested
|
||||
one, whose `m` reaches `minRequiredFecPackets`; Moonshine computes the same raised percentage
|
||||
(`(minimum - 1) * 100 / k + 1`, e.g. 101 % for 1 shard, 51 % for 2, 34 % for 3 with a minimum of 2) [M]; a frame
|
||||
too big for that gets the most parity that still fits (counted in the packetizer's stats). Data shards in order,
|
||||
then the block's parity, block by block; RTP sequence numbers run on across frames, one per packet. A capture of a
|
||||
real host still has to confirm the parity header fields: Moonshine patches only the RTP sequence, frame index,
|
||||
multi-FEC blocks byte and FEC info of a parity packet [M]; we write all header fields.
|
||||
- The audio code is **not** this matrix (section 6.4).
|
||||
|
||||
### 5.4 Feedback
|
||||
|
||||
Generated
+1
-1
@@ -236,7 +236,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "domistream"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
|
||||
Generated
+1
-1
@@ -228,7 +228,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "domistream"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
|
||||
Reference in New Issue
Block a user