How webrtc-rs/webrtc works
Main Components
• Underlying Transport Mechanisms: Create separate blocks for ICE (handling candidate gathering and networking), DTLS (for secure transport), SCTP (for data channels), and SRTP (for secure RTP flows). Each of these corresponds to separate crates (dtls, ice, sctp, srtp).
• Media and Data Paths: Show components for RTP/RTCP (packetization, codecs, feedback reporting) along with media handling (audio/video processing) that sit on top of the underlying transport.
• Auxiliary Components: Include blocks for handling SDP (session description), mDNS (multicast DNS discovery), utility functions, and interceptors (for metrics, statistics, and media stream manipulations).
Project’s Modularity
• Each subdirectory (for “webrtc”, “dtls”, “ice”, “rtp”, “rtcp”, “sctp”, “sdp”, etc.) represents a major module that encapsulates a separate layer of functionality.
Establish Interactions and Data Flows
• The “Peer Connection” interacts with the “ICE Transport” to handle network connectivity.
• Once ICE gathers candidates, it triggers a “DTLS Transport” handshake for establishing a secure channel.
• With a secure channel established, “SCTP” modules manage data channels while “RTP/RTCP” modules handle media streams.
• The “SDP” module is used by the Peer Connection to exchange session descriptions.
Architectural Patterns and Design Principles
• The project is organized as a Cargo workspace with each crate acting as an isolated yet interdependent module. This promotes a microservices-like architecture at the library/component level.
• That many modules follow a layered approach – for instance, the “Transport” layer (DTLS/ICE) sits below the “Application” layer (Peer Connection) and above the “Media/Data channels” modules.
• That the design encapsulates concerns by having each protocol (e.g., DTLS, ICE, RTP) manage its own set of responsibilities, communicating with each other via well-defined interfaces.
Be Detailed Yet Organized
• Avoid simply listing every file – instead, capture the architectural essence by identifying the boundary layers and interaction points.
• A clear separation between high-level WebRTC API components and low-level protocol implementations.
• Detailed interconnections between network transport (ICE), security (DTLS), data channels (SCTP), and media streams (RTP/RTCP) with supporting modules like SDP, mDNS, and interceptors.