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//! #[async_trait::async_trait]
20//! impl RtmpHandler for MyHandler {
21//!     async fn on_connect(&self, _ctx: &SessionContext, _params: &ConnectParams) -> AuthResult {
22//!         AuthResult::Accept
23//!     }
24//!
25//!     async fn on_publish(&self, _ctx: &SessionContext, params: &PublishParams) -> AuthResult {
26//!         println!("Stream published: {}", params.stream_key);
27//!         AuthResult::Accept
28//!     }
29//! }
30//!
31//! #[tokio::main]
32//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
33//!     let server = RtmpServer::new(ServerConfig::default(), MyHandler);
34//!     server.run().await?;
35//!     Ok(())
36//! }
37//! ```
38
39pub mod amf;
40pub mod client;
41pub mod error;
42pub mod media;
43pub mod protocol;
44pub mod registry;
45pub mod server;
46pub mod session;
47pub mod stats;
48
49// Re-export main types for convenience
50pub use client::config::ClientConfig;
51pub use client::connector::RtmpConnector;
52pub use client::puller::{ClientEvent, RtmpPuller};
53pub use error::{Error, Result};
54pub use registry::{BroadcastFrame, RegistryConfig, StreamKey, StreamRegistry};
55pub use server::config::ServerConfig;
56pub use server::handler::{AuthResult, RtmpHandler};
57pub use server::listener::RtmpServer;