1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/// 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.
// Re-export commonly used types
pub use ;
pub use CameraPublisher;
pub use start_signaling_server;
pub use ;
pub use ;