Skip to main content

rtmp_runtime/
lib.rs

1//! Sans-IO RTMP 1.0 **ingest** (publish) session engine — Adobe Real-Time
2//! Messaging Protocol.
3//!
4//! Spec grounding: Adobe RTMP 1.0, transcribed at
5//! [`docs/rtmp.md`](../docs/rtmp.md) (handshake §5.2, chunk stream §5.3,
6//! protocol control messages §5.4, message format §6, message types §7.1,
7//! command messages §7.2). AMF0 encoding (used by command/data messages) is
8//! `[AMF0]` per that same document's provenance section.
9//!
10//! # Scope of this release
11//!
12//! This crate implements the **ingest** (publish-receiving server) side only:
13//! a broadcaster pushes a stream in via `connect`/`createStream`/`publish`,
14//! and this engine drives the handshake and session state machine and hands
15//! back typed audio/video/metadata messages. A client role (for pulling from
16//! or pushing to a remote RTMP server) and an egress (play) server role are
17//! on the roadmap but not implemented yet.
18//!
19//! # The sans-IO contract
20//!
21//! No sockets live in the core. You drive the engine with bytes and read back
22//! bytes + typed events: feed inbound bytes in, get outbound bytes to write
23//! plus a stream of typed events out — mirroring the
24//! [`rtsp_runtime`](https://docs.rs/rtsp-runtime) sans-IO client/server split
25//! in this same workspace.
26//!
27//! An optional `tokio` socket adapter (feature `tokio`) drives real
28//! connections over this same core.
29//!
30//! # Module map
31//!
32//! - [`handshake`] — the C0/C1/C2 + S0/S1/S2 handshake (§5.2).
33//! - [`chunk`] — the chunk stream: basic header, message header (4 `fmt`
34//!   variants), extended timestamp (§5.3).
35//! - [`message`] — RTMP message assembly from chunks, protocol control
36//!   messages (§5.4), and the message type catalogue (§6, §7.1).
37//! - [`amf0`] — AMF0 value encoding/decoding, used by command and data
38//!   messages (`[AMF0]`).
39//! - [`server`] — the ingest server session state machine (`connect` →
40//!   `createStream` → `publish`, §7.2).
41//! - `io` (feature `tokio`) — the async socket adapter driving the sans-IO
42//!   server session over a real `tokio::net::TcpStream`.
43//! - [`error`] — the [`RtmpError`] type.
44//!
45//! The handshake/chunk/message/amf0/server sans-IO engine and the `tokio`
46//! adapter (feature `tokio`) are all implemented (#738 Tasks 1-9).
47
48#![forbid(unsafe_code)]
49#![warn(missing_docs)]
50#![cfg_attr(docsrs, feature(doc_cfg))]
51
52pub mod amf0;
53pub mod chunk;
54pub mod error;
55pub mod handshake;
56#[cfg(feature = "tokio")]
57#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
58pub mod io;
59pub mod message;
60pub mod server;
61
62pub use error::RtmpError;
63
64/// The Adobe RTMP specification version this engine implements.
65pub const RTMP_VERSION: &str = "RTMP 1.0";