Create video/audio chat with webRTC

  • webRTC = Web Real Time Communication
  • Open source project that enables peer-to-peer communication between browsers or the applications(mobile)
  • webRTC allows you to exchange any kind of media through the web(video, audio, data) without any required plugin or framework.

Applications using webRTC

  • Google Meet and Google Hangouts
  • Facebook Messenger
  • Discord etc

How webRTC working

What is signaling server

  • Signaling server helps to exchange necessary information which are required to establish direct connection between users
  • We can use whatever we like, from WebSocket to XMLHttpRequest

What is STUN server

  • STUN(Session Traversal Utilities for NAT) that allows clients to discover their public IP address and the type of NAT they are behind.
  • This information is used to set up UDP communication.
  • In 15-20% cases STUN server will fail and to establish connection between the peers we will need TURN server.

ex: stun:stun.l.google.com:19302

What is TURN server

  • TURN server(Traversal Using Relay NAT) is a protocol for relaying network traffic
  • TURN server will be used if STUN server will fail
  • TURN server will be used as an assist to establish connection between the peers
  • TURN server are not public because of the costs which they can generate because of the traffic which is going through them

What is SDP

  • SDP(Session description protocol) is a format to describing multimedia communication sessions for the purposes of session announcement and session invitation
  • It does not deliver the media data but is used for negotiation between peers of various audio and video codecs, source address, timing information of audio and video

What are ICE candidates

  • ICE (Interactive Connectivity Establishment) is the information about the network connection of the peers.
  • Each peer will propose its best candidates first, making their way down the line toward their worse candidates.

User Datagram Protocol

  • UDP is the transport protocol of choice when dealing with webRTC applications.

TCP vs UDP