[domistream] Video packetizer: even FEC block split; control host: refused input names its type; PROTOCOL 5.2/5.3 host facts (S-26); version 0.2.2

This commit is contained in:
2026-12-04 15:49:04 +01:00
parent a78bde9037
commit c7dcdc80f3
9 changed files with 37 additions and 19 deletions
+8 -1
View File
@@ -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() },
})
+7 -7
View File
@@ -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)
}