rtmp_rs/lib.rs
1//! rtmp-rs: Production RTMP client/server library
2//!
3//! This library provides a complete RTMP implementation supporting:
4//! - Server mode for receiving streams from OBS, ffmpeg, etc.
5//! - Client mode for pulling streams from remote RTMP servers
6//! - H.264 video and AAC audio codec support
7//! - GOP buffering for late-joiner support
8//! - Lenient parsing for encoder compatibility (OBS quirks)
9//!
10//! # Example: Simple Server
11//!
12//! ```no_run
13//! use rtmp_rs::{RtmpServer, ServerConfig, RtmpHandler, AuthResult};
14//! use rtmp_rs::session::SessionContext;
15//! use rtmp_rs::protocol::message::{ConnectParams, PublishParams};
16//!
17//! struct MyHandler;
18//!
19//! impl RtmpHandler for MyHandler {
20//! async fn on_connect(&self, _ctx: &SessionContext, _params: &ConnectParams) -> AuthResult {
21//! AuthResult::Accept
22//! }
23//!
24//! async fn on_publish(&self, _ctx: &SessionContext, params: &PublishParams) -> AuthResult {
25//! println!("Stream published: {}", params.stream_key);
26//! AuthResult::Accept
27//! }
28//! }
29//!
30//! #[tokio::main]
31//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
32//! let server = RtmpServer::new(ServerConfig::default(), MyHandler);
33//! server.run().await?;
34//! Ok(())
35//! }
36//! ```
37
38pub mod amf;
39pub mod client;
40pub mod error;
41pub mod media;
42pub mod protocol;
43pub mod registry;
44pub mod server;
45pub mod session;
46pub mod stats;
47
48// Re-export main types for convenience
49pub use client::config::ClientConfig;
50pub use client::connector::RtmpConnector;
51pub use client::puller::{ClientEvent, RtmpPuller};
52pub use error::{Error, Result};
53pub use registry::{BroadcastFrame, RegistryConfig, StreamKey, StreamRegistry};
54pub use server::config::ServerConfig;
55pub use server::handler::{AuthResult, RtmpHandler};
56pub use server::listener::RtmpServer;