WebRTC is a technology that helps to enable real-time peer to peer media communication between web browsers or devices without any external plugin.
It is available natively modern web browsers and mobile platforms like Chrome, Firefox, Safari, Edge, Opera Android, and iOS.
There are 3 primary components in WebRTC
The RTCPeerConnection API takes care of the NAT traversal, Codec processing, SDP negotiation, Media transferring and much more on handling the secure connection between peers.
The RTCDataChannel API allows to setup bidirectional data transfer channel between peers.
Establishing the connection between peers
Signaling is the process which establishes the connection between peers. It can achieve by WebSockets, XMPP, SIP or any copy & paste mechanism.
- Session Description Protocol
Also known as SDP, It is a protocol used to negotiate media capabilities between peers before establishing a connection.
- ICE (Interactive Connectivity Establishment)
ICE is a framework used for NAT traversal mechanism. ICE collects all available candidates (local IP addresses, reflexive addresses – STUN ones and relayed addresses – TURN ones). All the collected addresses are then sent to the remote peer via SDP.
- STUN server
The STUN server allows clients to find out their public address, the type of NAT they are behind and the Internet side port associated by the NAT with a particular local port.
- TURN server
TURN is used to relay media via a TURN server when the use of STUN isn’t possible.
WebRTC is not all about peer to peer
In Mesh network all peers send their stream directly to other connected peers in network individually.
SFU stands for Selective Forwarding Unit. An SFU receives the incoming media streams from all users, and then decides which streams to send to which users.
MCU stands for Multipoint Conferencing Unit. An MCU receives the incoming media streams from all users, decodes it all, creates a new layout of everything and sends it out to all users as a single stream.