Peer-to-Peer Video Calling using WebRTC
— Ruman Saleem
About Me
Hi! I'm Ruman. I'm a student at Department of Computer Science, University of Delhi.
I am a self-taught web developer. I started learning Laravel, about 3 years ago.
I have worked on various projects some as intern as well as freelancer.
I developed a online registration and quizzing platform for our department's annual technical fest "Sankalan".
WebRTC: Real-Time Communication
Free and Open project to provide Real-Time Communication(RTC) capabilties via simple APIs.
WebRTC Architechture

WebRTC Terminologies
-
Session Description Protocol (SDP) is a standard for describing the multimedia content of the connection such as resolution, formats, codecs, encryption, etc.
-
Interactive Connectivity Establishment (ICE) is a framework to allow your web browser to connect with peers.
-
Session Traversal Utilities for NAT (STUN) is a protocol to discover your public address and determine any restrictions in your router that would prevent a direct connection with a peer.
- Traversal Using Relays around NAT (TURN) is meant to bypass the Symmetric NAT restriction by opening a connection with a TURN server and relaying all information through that server.
A WebRTC Application
- Get streaming audio, video or other data.
- Get network information such as IP addresses and ports, and exchange this with other WebRTC clients (peers).
- Initiate or close sessions using some signaling mechanism.
- Exchange information about media and client capability, such as resolution and codecs.
- Communicate streaming audio, video or data.
Flow of Peer-to-Peer Communication
John
Jane
John's End: Prepare for Negotiation
- Create an RTCPeerConnection
- Acess WebCam & Microphone using getUserMedia() API
- Add Stream to the peer by calling RTCPeerConnection.addTrack().
John's End: Ready For Negotiation
- Create an SDP offer, by calling RTCPeerConnection.createOffer()
- Set local session description using RTCPeerConnection.setLocalDescription()
- Send the offer through signaling mechanism.
Jane's End: On Receiving Offer
- Create new RTCPeerConnection
- Save John's Session Information, by SDP to setRemoteDescription.
- Access webcam, add Stream tracks to RTCPeerConnection.
- Create Answer SDP using RTCPeerConnection.createAnswer().
- Configure session information by calling setLocalDescription().
- Send answer SDP through signaling mechanism.
John's End: Receive Answer
- Configure John's end of Connection to know about Jane's configuration, by passing answer SDP to RTCPeerConnection.setRemoteDescription().
ICE Layer: Exchange of Network Information
- Both Ends start discovering ICE candidates.
- Send the ICE candidate to the other end.
- Other End on receiving ICE candidate, calls RTCPeerConnection.addIceCandidate().
- ICE Layer takes care of the rest and establishes connection.
Talk is Cheap, Show Me Code!
— Linus Torvalds
References
Thank You!
WebRTC: Real Time Communications on Web
By Ruman Saleem
WebRTC: Real Time Communications on Web
- 146