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 two roles, both **publish** (ingest) only:
13//!
14//! - An **ingest server** ([`server::ServerSession`]): a broadcaster pushes a
15//!   stream in via `connect`/`createStream`/`publish`; this engine drives the
16//!   handshake and session state machine and hands back typed audio/video/
17//!   metadata messages as FLV bytes.
18//! - A **publish client** ([`client::ClientSession`]): the other end of that
19//!   same exchange — it drives the client-side handshake, auto-advances
20//!   `connect` → `createStream` → `publish`, and offers
21//!   `send_audio`/`send_video`/`send_metadata` once publishing. It has no
22//!   `tokio` socket adapter of its own (unlike [`server::ServerSession`], which
23//!   gets one via feature `tokio`) — callers drive its sans-IO
24//!   `handle_data`/`start` directly over their own transport.
25//!
26//! An egress (play) role — pulling a stream, on either the client or server
27//! side — is on the roadmap but not implemented yet.
28//!
29//! # The sans-IO contract
30//!
31//! No sockets live in the core. You drive the engine with bytes and read back
32//! bytes + typed events: feed inbound bytes in, get outbound bytes to write
33//! plus a stream of typed events out — mirroring the
34//! [`rtsp_runtime`](https://docs.rs/rtsp-runtime) sans-IO client/server split
35//! in this same workspace.
36//!
37//! An optional `tokio` socket adapter (feature `tokio`) drives real
38//! connections over this same core.
39//!
40//! # Module map
41//!
42//! - [`handshake`] — the C0/C1/C2 + S0/S1/S2 handshake (§5.2).
43//! - [`chunk`] — the chunk stream: basic header, message header (4 `fmt`
44//!   variants), extended timestamp (§5.3).
45//! - [`message`] — RTMP message assembly from chunks, protocol control
46//!   messages (§5.4), and the message type catalogue (§6, §7.1).
47//! - [`amf0`] — AMF0 value encoding/decoding, used by command and data
48//!   messages (`[AMF0]`).
49//! - [`server`] — the ingest server session state machine (`connect` →
50//!   `createStream` → `publish`, §7.2).
51//! - [`client`] — the publish client session state machine, the other end of
52//!   that same exchange (issue #744).
53//! - `io` (feature `tokio`) — the async socket adapter driving the sans-IO
54//!   server session over a real `tokio::net::TcpStream`. There is no
55//!   equivalent client adapter; [`client::ClientSession`] is sans-IO only.
56//! - [`error`] — the [`RtmpError`] type.
57//!
58//! The handshake/chunk/message/amf0/server sans-IO engine and the `tokio`
59//! adapter (feature `tokio`) are all implemented (#738 Tasks 1-9); the
60//! publish client engine (#744) is implemented on top of the same core.
61
62#![forbid(unsafe_code)]
63#![warn(missing_docs)]
64#![cfg_attr(docsrs, feature(doc_cfg))]
65
66pub mod amf0;
67pub mod chunk;
68pub mod client;
69pub mod error;
70pub mod handshake;
71#[cfg(feature = "tokio")]
72#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
73pub mod io;
74pub mod message;
75pub mod server;
76
77pub use error::RtmpError;
78
79/// The Adobe RTMP specification version this engine implements.
80pub const RTMP_VERSION: &str = "RTMP 1.0";