pub enum UserControlEvent {
StreamBegin {
stream_id: u32,
},
StreamEof {
stream_id: u32,
},
StreamDry {
stream_id: u32,
},
SetBufferLength {
stream_id: u32,
buffer_ms: u32,
},
StreamIsRecorded {
stream_id: u32,
},
PingRequest {
timestamp_ms: u32,
},
PingResponse {
timestamp_ms: u32,
},
Unknown {
event_type: u16,
data: Vec<u8>,
},
}Expand description
Strongly-typed view of a User Control Message body per RTMP 1.0 §3.7 / §7.1.7.
The build_user_control_* family above produces a Message
with msg_type_id == MSG_USER_CONTROL and a payload shaped
event_type:U16BE | event_data:... UserControlEvent::parse
is the inverse: lift such a payload into one of the seven
spec-defined variants (or the catch-all Self::Unknown for
forward compatibility — the spec leaves event types 5, 8..,
reserved).
Unknown carries both the raw event_type and the unconsumed
event_data bytes so a forwarding ingest can route unrecognised
UCMs without losing information; a strict consumer can refuse
the message by matching on it.
Round-trip helper: UserControlEvent::to_message produces the
same Message the matching build_user_control_* builder
emits, so parse(build_x().payload) == Ok(x) for every variant.
Variants§
StreamBegin
UCM type 0 — server tells the client that a stream is ready to
receive messages on the given stream id. Emitted right after
_result(createStream) from the server side; carried as the
4-byte BE stream id in the event data.
StreamEof
UCM type 1 — playback / publish finished on the given stream id. The publisher emits this before tearing down its socket so the peer learns “EOF was intentional” rather than guessing whether the TCP FIN was a crash. 4-byte BE stream id.
StreamDry
UCM type 2 — server has not seen any data on the given stream
for a while. Distinct from Self::StreamEof: this is a
transient “no data right now” signal; the stream may resume.
4-byte BE stream id.
SetBufferLength
UCM type 3 — client tells the server how many milliseconds of buffer it is willing to keep filled. The only standard UCM event with an 8-byte event-data body: 4 bytes BE stream id followed by 4 bytes BE buffer length in ms.
StreamIsRecorded
UCM type 4 — server announces that the stream is recorded
(on-demand / archival). 4-byte BE stream id. Typically emitted
right after Self::StreamBegin on a play request.
PingRequest
UCM type 6 — sender’s local time in ms; receiver must echo the
same value back in a Self::PingResponse. Used for liveness
probing + RTT measurement. 4-byte BE timestamp.
PingResponse
UCM type 7 — exact echo of the timestamp from a paired
Self::PingRequest. 4-byte BE timestamp.
Unknown
Any event type not assigned by RTMP 1.0 §3.7 — UCM 5 is
reserved, and any UCM type ≥ 8 is forward-compatible space
the spec leaves unspecified. data holds the unconsumed
event-data bytes verbatim so a forwarding ingest can route
the message through without re-encoding.
Implementations§
Source§impl UserControlEvent
impl UserControlEvent
Sourcepub fn parse(payload: &[u8]) -> Result<Self>
pub fn parse(payload: &[u8]) -> Result<Self>
Decode a UCM payload (the contents of a Message with
msg_type_id == MSG_USER_CONTROL) into a UserControlEvent
per RTMP 1.0 §3.7 / §7.1.7.
Returns Error::ProtocolViolation if the payload is shorter
than the 2-byte event-type header, or if one of the
fixed-shape spec-defined variants is truncated below its
declared event-data size (4 bytes for the stream-id-carrying
variants and ping, 8 bytes for SetBufferLength). Unknown
event types accept any tail length, including zero, so a
forwarding ingest never rejects forward-compatible messages.
Sourcepub fn event_type(&self) -> u16
pub fn event_type(&self) -> u16
2-byte BE event-type identifier per §7.1.7. Matches the value the wire form embeds in its first two bytes.
Sourcepub fn is_spec_defined(&self) -> bool
pub fn is_spec_defined(&self) -> bool
True iff this is one of the seven event types §3.7 / §7.1.7
assigns a fixed shape to. Self::Unknown returns false.
Sourcepub fn to_message(&self) -> Message
pub fn to_message(&self) -> Message
Inverse of Self::parse: produce the matching protocol
control Message (msg_type_id = 4, msg_stream_id = 0,
timestamp = 0). For the seven spec-defined variants this
emits byte-for-byte the same payload the corresponding
build_user_control_* builder would; for Self::Unknown
the event-type bytes and the carried data are concatenated
verbatim, so a parse / re-encode cycle is byte-stable.
Trait Implementations§
Source§impl Clone for UserControlEvent
impl Clone for UserControlEvent
Source§fn clone(&self) -> UserControlEvent
fn clone(&self) -> UserControlEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UserControlEvent
impl Debug for UserControlEvent
impl Eq for UserControlEvent
Source§impl PartialEq for UserControlEvent
impl PartialEq for UserControlEvent
Source§fn eq(&self, other: &UserControlEvent) -> bool
fn eq(&self, other: &UserControlEvent) -> bool
self and other values to be equal, and is used by ==.