|
2 | 2 | #![allow(dead_code)]
|
3 | 3 |
|
4 | 4 | //! # WebRTC Crate Overview
|
| 5 | +//! |
5 | 6 | //! The `webrtc` crate provides Rust-based bindings and high-level abstractions
|
6 | 7 | //! for WebRTC, based on the [W3C specification](https://www.w3.org/TR/webrtc/).
|
7 | 8 | //! Included is a set of communication protocols and APIs for building real-time
|
|
12 | 13 | //! resource that provides a great introduction to the topic.
|
13 | 14 | //!
|
14 | 15 | //! ## Features
|
| 16 | +//! |
15 | 17 | //! - Connections to remote peers using NAT-traversal technologies (STUN, TURN, and ICE)
|
16 | 18 | //! - Streaming of audio and video media via RTP and RTCP
|
17 | 19 | //! - Data channels for high performance, bi-directional communication
|
|
78 | 80 | //!
|
79 | 81 | //! **This will be a common source of confusion for new users of the crate.**
|
80 | 82 | //!
|
| 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 | +//! |
81 | 139 | //! ### MediaStream
|
82 | 140 | //!
|
83 | 141 | //! ### DataChannel
|
|
87 | 145 | //! ### RTCSessionDescription
|
88 | 146 | //!
|
89 | 147 | //! ## Examples
|
| 148 | +//! |
90 | 149 | //! The `examples/` directory contains a range of examples, from basic peer connections to
|
91 | 150 | //! advanced data channel usage.
|
92 | 151 | //!
|
93 | 152 | //! ## Compatibility
|
| 153 | +//! |
94 | 154 | //! This crate aims to stay up-to-date with the latest W3C WebRTC specification. However,
|
95 | 155 | //! as WebRTC is a rapidly evolving standard, there might be minor discrepancies. Always
|
96 | 156 | //! refer to the official W3C WebRTC specification for authoritative information.
|
97 | 157 | //!
|
98 | 158 | //! ## License
|
| 159 | +//! |
99 | 160 | //! This project is licensed under either of the following, at your option:
|
100 | 161 | //! - [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
101 | 162 | //! - [MIT License](https://opensource.org/license/mit/)
|
102 | 163 | //!
|
103 | 164 | //! [`RTCConfiguration`]: crate::peer_connection::configuration::RTCConfiguration
|
104 | 165 | //! [`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 |
105 | 169 |
|
106 | 170 | // re-export sub-crates
|
107 | 171 | pub use {data, dtls, ice, interceptor, mdns, media, rtcp, rtp, sctp, sdp, srtp, stun, turn, util};
|
|
0 commit comments