Skip to content

Commit 1b1f7bb

Browse files
committed
docs
1 parent d63ea69 commit 1b1f7bb

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

webrtc/src/lib.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(dead_code)]
33

44
//! # WebRTC Crate Overview
5+
//!
56
//! The `webrtc` crate provides Rust-based bindings and high-level abstractions
67
//! for WebRTC, based on the [W3C specification](https://www.w3.org/TR/webrtc/).
78
//! Included is a set of communication protocols and APIs for building real-time
@@ -12,6 +13,7 @@
1213
//! resource that provides a great introduction to the topic.
1314
//!
1415
//! ## Features
16+
//!
1517
//! - Connections to remote peers using NAT-traversal technologies (STUN, TURN, and ICE)
1618
//! - Streaming of audio and video media via RTP and RTCP
1719
//! - Data channels for high performance, bi-directional communication
@@ -78,6 +80,62 @@
7880
//!
7981
//! **This will be a common source of confusion for new users of the crate.**
8082
//!
83+
//! #### Session Descriptions
84+
//!
85+
//! In the WebRTC protocol, session descriptions serve as the mechanism for exchanging
86+
//! information about media capabilities, network addresses, and other metadata between
87+
//! peers. Session descriptions are represented by the [`RTCSessionDescription`] struct.
88+
//!
89+
//! Session descriptions are exchanged via an offer/answer model, where one peer sends
90+
//! an offer to the other peer, and the other peer responds with an answer. Offers and
91+
//! answers are represented by the [`RTCOfferOptions`] and [`RTCAnswerOptions`] structs,
92+
//! respectively.
93+
//!
94+
//! On the wire, session descriptions are encoded as SDP
95+
//! ([Session Description Protocol](https://en.wikipedia.org/wiki/Session_Description_Protocol))
96+
//! documents.
97+
//!
98+
//! #### Signaling
99+
//!
100+
//! In order to establish a connection, both peers must exchange their session descriptions
101+
//! with each other. The process of exchanging of session descriptions between peers is
102+
//! more commonly referred to as the signaling process.
103+
//!
104+
//! At a high level, the signaling process looks something like this:
105+
//!
106+
//! | Step # | Peer | Action | Method |
107+
//! | :----: | :--: |--------|--------|
108+
//! | 1 | Peer A | Creates an offer | [`create_offer()`](crate::peer_connection::RTCPeerConnection::create_offer) |
109+
//! | 2 | Peer A | Sets the offer as the local description | [`set_local_description()`](crate::peer_connection::RTCPeerConnection::set_local_description) |
110+
//! | 3 | Peer A | Sends the offer to Peer B via the signaling channel | |
111+
//! | 4 | Peer B | Receives the offer from the signaling channel | |
112+
//! | 5 | Peer B | Sets the received offer as the remote description | [`set_remote_description()`](crate::peer_connection::RTCPeerConnection::set_remote_description) |
113+
//! | 6 | Peer B | Creates an answer | [`create_answer()`](crate::peer_connection::RTCPeerConnection::create_answer) |
114+
//! | 7 | Peer B | Sets the answer as the local description | [`set_local_description()`](crate::peer_connection::RTCPeerConnection::set_local_description) |
115+
//! | 8 | Peer B | Sends the answer to Peer A via the signaling channel | |
116+
//! | 9 | Peer A | Receives the answer from the signaling channel | |
117+
//! | 10 | Peer A | Sets the received answer as the remote description | [`set_remote_description()`](crate::peer_connection::RTCPeerConnection::set_remote_description) |
118+
//! | 11 | Both | Are now connected | |
119+
//!
120+
//! #### No Automatic Signaling in WebRTC
121+
//!
122+
//! **In the WebRTC protocol, the signaling process does not happen automatically.**
123+
//!
124+
//! Signaling is outside the scope of the WebRTC specification, and is left up to the
125+
//! application to implement. In other words, you will have to provide your own signaling
126+
//! implementation. There is generally no one-size-fits-all solution for signaling, as
127+
//! it is highly dependent on the specific use case (which may need to consider things
128+
//! such as user authentication, security, encryption, etc.).
129+
//!
130+
//! Common signaling methods include (but may not be limited to):
131+
//! - WebSockets
132+
//! - HTTPS (e.g. using a REST API)
133+
//! - SIP (Session Initiation Protocol)
134+
//! - XMPP (Extensible Messaging and Presence Protocol)
135+
//!
136+
//! As signaling is an application-specific concern, this crate does not provide any
137+
//! built-in signaling functionality or guidance on how to implement.
138+
//!
81139
//! ### MediaStream
82140
//!
83141
//! ### DataChannel
@@ -87,21 +145,27 @@
87145
//! ### RTCSessionDescription
88146
//!
89147
//! ## Examples
148+
//!
90149
//! The `examples/` directory contains a range of examples, from basic peer connections to
91150
//! advanced data channel usage.
92151
//!
93152
//! ## Compatibility
153+
//!
94154
//! This crate aims to stay up-to-date with the latest W3C WebRTC specification. However,
95155
//! as WebRTC is a rapidly evolving standard, there might be minor discrepancies. Always
96156
//! refer to the official W3C WebRTC specification for authoritative information.
97157
//!
98158
//! ## License
159+
//!
99160
//! This project is licensed under either of the following, at your option:
100161
//! - [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
101162
//! - [MIT License](https://opensource.org/license/mit/)
102163
//!
103164
//! [`RTCConfiguration`]: crate::peer_connection::configuration::RTCConfiguration
104165
//! [`RTCPeerConnection`]: crate::peer_connection::RTCPeerConnection
166+
//! [`RTCSessionDescription`]: crate::peer_connection::sdp::session_description::RTCSessionDescription
167+
//! [`RTCOfferOptions`]: crate::peer_connection::offer_answer_options::RTCOfferOptions
168+
//! [`RTCAnswerOptions`]: crate::peer_connection::offer_answer_options::RTCAnswerOptions
105169
106170
// re-export sub-crates
107171
pub use {data, dtls, ice, interceptor, mdns, media, rtcp, rtp, sctp, sdp, srtp, stun, turn, util};

0 commit comments

Comments
 (0)