Skip to main content

ClientEvent

Enum ClientEvent 

Source
pub enum ClientEvent {
    StreamBegin {
        stream_id: u32,
    },
    StreamEof {
        stream_id: u32,
    },
    StreamDry {
        stream_id: u32,
    },
    StreamIsRecorded {
        stream_id: u32,
    },
    PingResponse {
        timestamp_ms: u32,
    },
    OnStatus {
        level: String,
        code: String,
        description: String,
    },
    ReconnectRequest {
        tc_url: Option<String>,
        description: String,
    },
    Result {
        transaction_id: f64,
        values: Vec<Amf0Value>,
    },
    ErrorReply {
        transaction_id: f64,
        values: Vec<Amf0Value>,
    },
    Other,
}
Expand description

Server-originated event observed by an RtmpClient in publish mode.

During an active publish the client mostly writes audio / video / data and the server stays mostly silent — but a few server→client notifications matter end-to-end. The most important is StreamEof: the server signalling, per RTMP 1.0 §7.1.7, that “the stream is dry, no more data will be sent without additional commands.” A symmetric publish-side server uses the same UserControl StreamEOF event to mark end-of-publish before closing the TCP write half — and the client should treat that as a clean stream end rather than as an unexpected FIN.

Variants§

§

StreamBegin

The server emitted UserControl StreamBegin(stream_id) (UCM event type 0). Informational — most servers send this once right after createStream succeeds.

Fields

§stream_id: u32
§

StreamEof

The server emitted UserControl StreamEOF(stream_id) (UCM event type 1). End-of-stream from the server side. After observing this, the caller should stop writing and shut the client down via RtmpClient::close.

Fields

§stream_id: u32
§

StreamDry

The server emitted UserControl StreamDry(stream_id) (UCM event type 2). Per RTMP 1.0 §3.7, the server uses this to notify the client “that there is no more data on the stream. If the server does not detect any message for a time period, it can notify the subscribed clients that the stream is dry.” Distinct from StreamEof: StreamDry is a “no data right now” signal that may resolve once more data arrives; StreamEof is “playback finished, no more without further commands.”

Fields

§stream_id: u32
§

StreamIsRecorded

The server emitted UserControl StreamIsRecorded(stream_id) (UCM event type 4). Per RTMP 1.0 §3.7, “the server sends this event to notify the client that the stream is a recorded stream.” Servers typically emit this right after StreamBegin for an on-demand stream; for a publish-only client the event is informational and usually ignored.

Fields

§stream_id: u32
§

PingResponse

The server emitted UserControl PingResponse(timestamp_ms) (UCM event type 7). Per RTMP 1.0 §3.7, the client sends a PingResponse “in response to the ping request. The event data is a 4-byte timestamp, which was received with the kMsgPingRequest request.” A server that emits PingResponse is typically echoing back our own (publisher-side) PingRequest — useful for measuring round-trip latency. The variant carries the echoed timestamp verbatim.

Fields

§timestamp_ms: u32
§

OnStatus

The server emitted onStatus(...) carrying NetStream state. level is typically "status" / "warning" / "error"; code is e.g. "NetStream.Publish.Start" / "NetStream.Unpublish.Success" / "NetStream.Publish.BadName".

Fields

§level: String
§code: String
§description: String
§

ReconnectRequest

The server emitted onStatus(NetConnection.Connect.ReconnectRequest) — Enhanced RTMP v2 §“Reconnect Request”. The server is asking us to reconnect, e.g. ahead of a server update or to remap us to a different server instance.

Per the spec’s message flow, on receipt the client “persists in streaming to/from the current server up to the next appropriate media boundary, such as a keyframe. Subsequently, it establishes a connection with a new server and disconnects from the old server.” So: finish the current GOP, then dial RtmpClient::resolve_reconnect_url(tc_url.as_deref()) with a fresh RtmpClient::connect and drop this client.

tc_url is the optional Info-Object property naming where to reconnect — an absolute (rtmp://host/app) or relative (//host/app, /app) URI reference. None means “use the tcUrl for the current connection” per spec.

Fields

§tc_url: Option<String>
§description: String
§

Result

The server emitted _result(transaction_id, ...) for a command the client issued. The publish-time connect / createStream transactions are consumed internally by RtmpClient::connect; any subsequent _result (e.g. a custom RPC sent after publish started) surfaces here so the caller can match it against its own transaction id.

Fields

§transaction_id: f64
§values: Vec<Amf0Value>
§

ErrorReply

The server emitted _error(transaction_id, ...). Symmetric to Result but for the failure path.

Fields

§transaction_id: f64
§values: Vec<Amf0Value>
§

Other

Any other server-originated message (ping, ack, set-chunk-size, bandwidth — most of which the client handles transparently inside RtmpClient::poll_event before this variant ever fires). The variant exists so the caller’s match arm can keep going.

Trait Implementations§

Source§

impl Clone for ClientEvent

Source§

fn clone(&self) -> ClientEvent

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 ClientEvent

Source§

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

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

impl PartialEq for ClientEvent

Source§

fn eq(&self, other: &ClientEvent) -> 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 ClientEvent

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.