The simple (non-digest) RTMP handshake, server side.
The client sends C0 (one version byte) and C1 (1536 bytes); the server answers with S0 and S1 as soon as C0 arrives, and S2 (an echo of C1) once C1 arrives; the client finishes with C2 (1536 bytes, an echo of S1). After C2 the connection speaks the chunk stream protocol.
S0/S1 are sent on C0 alone rather than waiting for C1 — the spec allows either, and answering early means a client that waits for S1 before sending C1 can't deadlock against us.
Only the simple handshake is supported. The HMAC "digest" handshake used by some Flash-era clients is not — modern encoders (OBS, FFmpeg, vMix, hardware encoders) use the simple one. Encrypted RTMPE (version byte 6) is rejected.
This module is a pure state machine: feed it bytes with feed/2, send
whatever it hands back, and stop once it returns {:done, ...}. Timeouts
are the caller's job (RTMP.Connection applies one per step).
Summary
Types
Functions
@spec feed(t(), binary()) :: {:more, t(), iodata()} | {:done, binary(), iodata()} | {:error, term()}
Feeds received bytes into the handshake.
Returns:
{:more, hs, to_send}— need more bytes; sendto_send(may be empty).{:done, rest, to_send}— handshake complete;restis any data that arrived after C2 and belongs to the chunk stream.{:error, reason}— the client sent something that isn't a valid simple handshake.
@spec new() :: t()
@spec packet_size() :: pos_integer()
Size in bytes of C1, C2, S1 and S2.