[domistream] Control: START_B, PERIODIC_PING and the IDR request with empty bodies (PROTOCOL.md 3.3); START_A stays refused
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user