mecha10-video 0.1.25

WebRTC video streaming for Mecha10 - camera frame capture and broadcasting
Documentation
/// Mecha10 Video Streaming
///
/// Provides WebRTC-based low-latency video streaming for robotics applications.
///
/// # Features
///
/// - **WebRTC Streaming**: H.264 video encoding with OpenH264
/// - **Multi-client Support**: Broadcast frames to multiple WebRTC connections
/// - **Low Latency**: 30-50ms latency with optimized encoding pipeline
/// - **Zero-copy Frame Sharing**: Efficient frame distribution using Arc
/// - **Optional Diagnostics**: Enable with `diagnostics` feature flag
///
/// # Architecture
///
/// ```text
/// ┌─────────────┐
/// │   Source    │ (Godot, Camera, etc.)
/// │  (Frames)   │
/// └──────┬──────┘
///        │ mpsc::channel
////// ┌─────────────────────┐
/// │  WebRTCServer       │
/// │  (Frame Broadcast)  │
/// └──────┬──────────────┘
///        │ broadcast::channel
///        ├─────────┬─────────┐
///        ▼         ▼         ▼
///   ┌────────┐ ┌────────┐ ┌────────┐
///   │ Conn 1 │ │ Conn 2 │ │ Conn 3 │
///   │ (H.264)│ │ (H.264)│ │ (H.264)│
///   └────┬───┘ └────┬───┘ └────┬───┘
///        │          │          │
///        ▼          ▼          ▼
///    Browser    Browser    Browser
/// ```
///
/// # Example Usage
///
/// ```no_run
/// use mecha10_video::{CameraFrame, ImageFormat, WebRTCServer};
/// use mecha10_video::signaling::start_signaling_server;
/// use tokio::sync::mpsc;
/// use std::sync::Arc;
///
/// #[tokio::main]
/// async fn main() -> anyhow::Result<()> {
///     // Create frame channel
///     let (frame_tx, frame_rx) = mpsc::channel(10);
///
///     // Create WebRTC server
///     # #[cfg(not(feature = "diagnostics"))]
///     let webrtc_server = WebRTCServer::new(frame_rx).await?;
///
///     // Start signaling server for SDP exchange
///     let server = Arc::new(webrtc_server);
///     tokio::spawn(async move {
///         start_signaling_server(11010, server).await.unwrap();
///     });
///
///     // Send frames to WebRTC server
///     let frame = CameraFrame {
///         camera_id: "camera0".to_string(),
///         width: 640,
///         height: 480,
///         timestamp: 0,
///         image_bytes: Arc::new(vec![0u8; 640 * 480 * 3]),
///         format: ImageFormat::Rgb,
///     };
///     frame_tx.send(frame).await?;
///
///     Ok(())
/// }
/// ```
///
/// # Features
///
/// - `diagnostics` - Enable streaming diagnostics (frame encoding/sending metrics)
///
/// # Performance
///
/// - **Encoding**: ~8-15ms per frame (160×120 @ 30 FPS)
/// - **Latency**: 30-50ms glass-to-glass
/// - **Bitrate**: 400 Kbps (configurable)
/// - **Codec**: H.264 (OpenH264)
///
/// # Source of Truth
///
/// This package was extracted from `simulation-bridge`, which is the
/// production-tested reference implementation. See
/// `docs/VIDEO_EXTRACTION_PLAN.md` for extraction details.
pub mod frame;
pub mod publisher;
pub mod signaling;
pub mod signaling_relay;
pub mod webrtc;

// Re-export commonly used types
pub use frame::{CameraFrame, FrameBroadcaster, ImageFormat};
pub use publisher::CameraPublisher;
pub use signaling::start_signaling_server;
pub use signaling_relay::{start_signaling_relay_client, SignalingRelayConfig};
pub use webrtc::{SignalingMessage, WebRTCConnection, WebRTCServer};