rtmp_rs/registry/mod.rs
1//! Stream registry for pub/sub routing
2//!
3//! The registry manages active streams and routes media from publishers to subscribers.
4//! It uses `tokio::sync::broadcast` for efficient zero-copy fan-out to multiple subscribers.
5//!
6//! # Architecture
7//!
8//! ```text
9//! Arc<StreamRegistry>
10//! ┌─────────────────────────┐
11//! │ streams: HashMap<Key, │
12//! │ StreamEntry { │
13//! │ gop_buffer, │
14//! │ tx: broadcast::Tx, │
15//! │ } │
16//! │ > │
17//! └───────────┬─────────────┘
18//! │
19//! ┌───────────────────────┼───────────────────────┐
20//! │ │ │
21//! ▼ ▼ ▼
22//! [Publisher] [Subscriber] [Subscriber]
23//! handle_video() frame_rx.recv() frame_rx.recv()
24//! │ │ │
25//! └──► registry.broadcast()──► send_video() ──► TCP
26//! ```
27//!
28//! # Zero-Copy Design
29//!
30//! `bytes::Bytes` uses reference counting, so all subscribers share the same
31//! memory allocation. The broadcast channel clones the `BroadcastFrame`, but
32//! the inner `Bytes` data is only reference-counted, not copied.
33
34pub mod config;
35pub mod entry;
36pub mod error;
37pub mod frame;
38pub mod store;
39
40pub use config::RegistryConfig;
41pub use entry::{StreamEntry, StreamState, StreamStats};
42pub use error::RegistryError;
43pub use frame::{BroadcastFrame, FrameType, StreamKey};
44pub use store::StreamRegistry;