Skip to main content

UserControlEvent

Enum UserControlEvent 

Source
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.

Fields

§stream_id: u32
§

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.

Fields

§stream_id: u32
§

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.

Fields

§stream_id: u32
§

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.

Fields

§stream_id: u32
§buffer_ms: u32
§

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.

Fields

§stream_id: u32
§

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.

Fields

§timestamp_ms: u32
§

PingResponse

UCM type 7 — exact echo of the timestamp from a paired Self::PingRequest. 4-byte BE timestamp.

Fields

§timestamp_ms: u32
§

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.

Fields

§event_type: u16
§data: Vec<u8>

Implementations§

Source§

impl UserControlEvent

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> UserControlEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UserControlEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for UserControlEvent

Source§

impl PartialEq for UserControlEvent

Source§

fn eq(&self, other: &UserControlEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for UserControlEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.