Compare commits

...

4 Commits

4 changed files with 36 additions and 24 deletions
+18 -11
View File
@@ -269,11 +269,11 @@ pub fn parse_host_message(message: &[u8]) -> Result<HostMessage> {
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<Vec<u8>> {
match message {
ClientMessage::InvalidateRefFrames { first, last } => {
@@ -304,11 +305,17 @@ pub fn encode_client_message(message: &ClientMessage) -> Result<Vec<u8>> {
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<u8> {
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
}
+11 -4
View File
@@ -381,11 +381,18 @@ fn client_messages() {
encode_client_message(&ClientMessage::Input(ev.clone())).unwrap(),
domistream::input::encode_input(&ev).unwrap()
);
// Bodies still UNKNOWN (U10) are refused rather than guessed.
for m in [ClientMessage::StartA, ClientMessage::StartB, ClientMessage::PeriodicPing, ClientMessage::RequestIdrFrame]
{
assert_err!(encode_client_message(&m), Error::Unsupported { .. }, "{m:?}");
// START_B, PERIODIC_PING and the IDR request go with an empty body (PROTOCOL.md 3.3: what Moonshine and Lumen
// read; the lead's decision of 2026-12-04). START_A's body is still UNKNOWN (U10) and stays refused.
for (m, t) in [
(ClientMessage::StartB, 0x0307u16),
(ClientMessage::PeriodicPing, 0x0200),
(ClientMessage::RequestIdrFrame, 0x0302),
] {
let mut want = t.to_le_bytes().to_vec();
want.extend_from_slice(&0u16.to_le_bytes());
assert_eq!(encode_client_message(&m).unwrap(), want, "{m:?}");
}
assert_err!(encode_client_message(&ClientMessage::StartA), Error::Unsupported { .. });
}
proptest! {
+3 -2
View File
@@ -623,8 +623,9 @@ fn a_whole_session_between_our_client_and_our_host() {
(launched.mode.width, launched.mode.height, launched.mode.fps)
);
// ENet connect on the control port, then START_B. ControlStream refuses START_B (body U10), hence the probe path.
assert_err!(encode_client_message(&ClientMessage::StartB), Error::Unsupported { .. });
// ENet connect on the control port, then START_B. ControlStream sends START_B with an empty body (3.3); the
// session below drives the same bytes over EnetClient + ControlCipher, as gs-probe does.
assert_eq!(encode_client_message(&ClientMessage::StartB).unwrap(), vec![0x07, 0x03, 0x00, 0x00]);
let host_control = HostControl {
config: ControlHostConfig {
enet: EnetHostConfig {
+4 -7
View File
@@ -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]