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.
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.
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.”
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.
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.
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".
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.
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.
ErrorReply
The server emitted _error(transaction_id, ...). Symmetric to
Result but for the failure path.
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
impl Clone for ClientEvent
Source§fn clone(&self) -> ClientEvent
fn clone(&self) -> ClientEvent
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 ClientEvent
impl Debug for ClientEvent
Source§impl PartialEq for ClientEvent
impl PartialEq for ClientEvent
Source§fn eq(&self, other: &ClientEvent) -> bool
fn eq(&self, other: &ClientEvent) -> bool
self and other values to be equal, and is used by ==.