From 4300b6b7fbc033ca1da055a985cbf3102f8b04ee Mon Sep 17 00:00:00 2001 From: mnovak Date: Fri, 4 Dec 2026 13:46:12 +0100 Subject: [PATCH] [domistream] Control: START_B, PERIODIC_PING and the IDR request with empty bodies (PROTOCOL.md 3.3); START_A stays refused --- crates/domistream/src/control/message.rs | 29 +++++++++++++++--------- docs/PROTOCOL.md | 11 ++++----- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/crates/domistream/src/control/message.rs b/crates/domistream/src/control/message.rs index d29f6d0..a775037 100644 --- a/crates/domistream/src/control/message.rs +++ b/crates/domistream/src/control/message.rs @@ -269,11 +269,11 @@ pub fn parse_host_message(message: &[u8]) -> Result { pub enum ClientMessage { /// `START_A` (body UNKNOWN U10). StartA, - /// `START_B` (body UNKNOWN U10): the host starts video and audio. + /// `START_B`: the host starts video and audio. Sent with an empty body (PROTOCOL.md 3.3). StartB, - /// Keep-alive (body UNKNOWN U10). + /// Keep-alive, sent with an empty body (3.3). PeriodicPing, - /// Ask for an IDR frame (body UNKNOWN U10). + /// Ask for an IDR frame, sent with an empty body (3.3). RequestIdrFrame, /// Ask the host to stop referencing frames `first..=last`. InvalidateRefFrames { @@ -289,8 +289,9 @@ pub enum ClientMessage { /// Serializes a message to the host (type, length, body), ready for [`super::ControlCipher::seal`]. /// /// # Errors -/// [`crate::Error::Unsupported`] for a message whose body is still UNKNOWN (U10: START_A, START_B, -/// PERIODIC_PING, IDR request; refused rather than guessed); input errors as [`crate::input::encode_input`]. +/// [`crate::Error::Unsupported`] for START_A, whose body is still UNKNOWN (U10; refused rather than guessed); +/// input errors as [`crate::input::encode_input`]. START_B, PERIODIC_PING and the IDR request carry an empty body: +/// what Moonshine and Lumen read (PROTOCOL.md 3.3); whether Sunshine reads more is still U10. pub fn encode_client_message(message: &ClientMessage) -> Result> { match message { ClientMessage::InvalidateRefFrames { first, last } => { @@ -304,11 +305,17 @@ pub fn encode_client_message(message: &ClientMessage) -> Result> { Ok(m) } ClientMessage::Input(e) => crate::input::encode_input(e), - ClientMessage::StartA - | ClientMessage::StartB - | ClientMessage::PeriodicPing - | ClientMessage::RequestIdrFrame => { - Err(crate::Error::Unsupported { what: "a control message whose body is still UNKNOWN (U10)" }) - } + ClientMessage::StartB => Ok(empty_body(MessageType::StartB)), + ClientMessage::PeriodicPing => Ok(empty_body(MessageType::PeriodicPing)), + ClientMessage::RequestIdrFrame => Ok(empty_body(MessageType::IdrFrame)), + ClientMessage::StartA => Err(crate::Error::Unsupported { what: "START_A, whose body is still UNKNOWN (U10)" }), } } + +/// A message of type `t` with a zero-length body: type and length (0), both little-endian (PROTOCOL.md 3.3). +fn empty_body(t: MessageType) -> Vec { + let mut m = Vec::with_capacity(4); + m.extend_from_slice(&(t as u16).to_le_bytes()); + m.extend_from_slice(&0u16.to_le_bytes()); + m +} diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 3370e14..5eeb97b 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -23,13 +23,10 @@ ours on the host side is marked as such in the host notes: | 5.2-5.3 Video | `video::packetizer` | 5.3, "Host side": FEC block split and parity | | 6.2-6.4 Audio | `audio::packetizer` | 6.4, last paragraph: no parity until U16 | -Both halves are tested against each other in one in-memory session (`crates/domistream/tests/session.rs`). Found -there, still open: the client's `ControlStream` refuses to send `START_B`, `PERIODIC_PING` and the IDR request -(bodies U10, 3.3). With `ControlStream` alone our client cannot start a stream on our host, and a host with a stop -deadline (60 s by default) would end the session; the session test sends the three with empty bodies over -`EnetClient` and `ControlCipher`, as `tools/gs-probe` does. The host keeps the client's `updateState` (1.5, U1) for the -logs without reading it. **Decided (lead, 2026-12-04):** `ControlStream` will send the three with empty bodies, -what Moonshine and Lumen read; it lands with the first streaming client of L2, and U10 stays open for Sunshine. +Both halves are tested against each other in one in-memory session (`crates/domistream/tests/session.rs`). The +client's `ControlStream` sends `START_B`, `PERIODIC_PING` and the IDR request with empty bodies (lead's decision, +2026-12-04, since stream-v0.2.1): what Moonshine and Lumen read (3.3). Whether Sunshine reads more is still U10; +`START_A` stays refused. The host keeps the client's `updateState` (1.5, U1) for the logs without reading it. ### Measured: Arena Domi Remote against lumen-host [L1]