Skip to main content

saorsa_webrtc_core/
lib.rs

1//! Saorsa WebRTC - WebRTC implementation over ant-quic transport
2//!
3//! This library provides a WebRTC implementation that uses ant-quic as the underlying
4//! transport layer instead of traditional ICE/STUN/TURN. It features:
5//!
6//! - **Native QUIC Transport**: Uses ant-quic for reliable, encrypted connections
7//! - **DHT-based Signaling**: Distributed signaling without centralized servers
8//! - **Post-Quantum Cryptography**: Built-in PQC support via ant-quic
9//! - **NAT Traversal**: Automatic hole punching and relay fallback
10//! - **High Performance**: Low-latency media streaming with QoS
11//!
12//! # Examples
13//!
14//! ```rust,no_run
15//! use saorsa_webrtc_core::{WebRtcService, MediaConstraints, SignalingHandler, AntQuicTransport, TransportConfig, PeerIdentityString};
16//! use std::sync::Arc;
17//!
18//! # async fn example() -> anyhow::Result<()> {
19//! // Create signaling transport
20//! let transport = Arc::new(AntQuicTransport::new(TransportConfig::default()));
21//! let signaling = Arc::new(SignalingHandler::new(transport));
22//!
23//! // Create WebRTC service
24//! let service = WebRtcService::<PeerIdentityString, AntQuicTransport>::new(
25//!     signaling,
26//!     Default::default()
27//! ).await?;
28//!
29//! // Start service
30//! service.start().await?;
31//!
32//! // Initiate a video call
33//! let call_id = service.initiate_call(
34//!     PeerIdentityString::new("eve-frank-grace-henry"),
35//!     MediaConstraints::video_call()
36//! ).await?;
37//! # Ok(())
38//! # }
39//! ```
40
41#![deny(missing_docs)]
42#![deny(unsafe_code)]
43#![deny(clippy::panic)]
44#![deny(clippy::unwrap_used)]
45#![deny(clippy::expect_used)]
46#![warn(clippy::all)]
47// Allow pedantic warnings for stub implementations
48#![allow(clippy::pedantic)]
49#![allow(clippy::nursery)]
50#![allow(clippy::unused_async)]
51#![allow(clippy::module_name_repetitions)]
52#![allow(clippy::derivable_impls)]
53
54/// Core WebRTC types and data structures
55pub mod types;
56
57/// WebRTC service and configuration (requires legacy-webrtc feature)
58#[cfg(feature = "legacy-webrtc")]
59pub mod service;
60
61/// Media stream management (requires legacy-webrtc feature)
62#[cfg(feature = "legacy-webrtc")]
63pub mod media;
64
65/// Call management and state (requires legacy-webrtc feature)
66#[cfg(feature = "legacy-webrtc")]
67pub mod call;
68
69/// Signaling protocol and handlers
70pub mod signaling;
71
72/// ant-quic transport integration
73pub mod transport;
74
75/// QUIC media stream management with QoS
76pub mod quic_streams;
77
78/// Bridge between WebRTC and QUIC
79pub mod quic_bridge;
80
81/// Protocol handler for SharedTransport integration
82pub mod protocol_handler;
83
84/// Peer identity abstraction
85pub mod identity;
86
87/// Link transport abstraction layer
88pub mod link_transport;
89
90/// QUIC-based media transport for RTP/RTCP over QUIC streams
91pub mod quic_media_transport;
92
93// Re-export main types at crate root
94#[cfg(feature = "legacy-webrtc")]
95pub use call::{CallManager, CallManagerConfig};
96pub use identity::{PeerIdentity, PeerIdentityString};
97pub use link_transport::{
98    LinkTransport, LinkTransportError, PeerConnection, StreamType as LinkStreamType,
99};
100#[cfg(feature = "legacy-webrtc")]
101pub use media::{
102    AudioDevice, AudioTrack, MediaEvent, MediaStream, MediaStreamManager, VideoDevice, VideoTrack,
103};
104pub use protocol_handler::{
105    WebRtcHandlerConfig, WebRtcHandlerError, WebRtcIncoming, WebRtcProtocolHandler,
106    WebRtcProtocolHandlerBuilder,
107};
108pub use quic_bridge::{RtpPacket, StreamConfig, StreamType, WebRtcQuicBridge};
109pub use quic_media_transport::{
110    MediaTransportError, MediaTransportState, QuicMediaTransport, StreamHandle, StreamPriority,
111    TransportStats,
112};
113pub use service::{WebRtcConfig, WebRtcEvent, WebRtcService, WebRtcServiceBuilder};
114pub use signaling::{
115    SignalingHandler, SignalingMessage as SignalingMessageType, SignalingTransport,
116};
117pub use transport::{AntQuicTransport, TransportConfig};
118pub use types::*;
119
120/// Prelude module for convenient imports
121pub mod prelude {
122    #[cfg(feature = "legacy-webrtc")]
123    pub use crate::call::{CallManager, CallManagerConfig};
124    pub use crate::identity::{PeerIdentity, PeerIdentityString};
125    #[cfg(feature = "legacy-webrtc")]
126    pub use crate::media::{MediaEvent, MediaStreamManager};
127    pub use crate::protocol_handler::{WebRtcHandlerConfig, WebRtcIncoming, WebRtcProtocolHandler};
128    #[cfg(feature = "legacy-webrtc")]
129    pub use crate::service::{WebRtcConfig, WebRtcEvent, WebRtcService, WebRtcServiceBuilder};
130    pub use crate::signaling::{SignalingHandler, SignalingMessage, SignalingTransport};
131    pub use crate::transport::{AntQuicTransport, TransportConfig};
132    pub use crate::types::{
133        CallEvent, CallId, CallState, MediaConstraints, MediaType, NativeQuicConfiguration,
134    };
135}