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

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

  1. Create an RTCPeerConnection
  2. Acess WebCam & Microphone using getUserMedia() API
  3. Add Stream to the peer by calling RTCPeerConnection.addTrack().

John's End: Ready For Negotiation

  1. Create an SDP offer, by calling RTCPeerConnection.createOffer()
  2. Set local session description using RTCPeerConnection.setLocalDescription()
  3. Send the offer through signaling mechanism.

Jane's End: On Receiving Offer

  1. Create new RTCPeerConnection
  2. Save John's Session Information, by SDP to setRemoteDescription.
  3. Access webcam, add Stream tracks to RTCPeerConnection.
  4. Create Answer SDP using RTCPeerConnection.createAnswer().
  5. Configure session information by calling setLocalDescription().
  6. Send answer SDP through signaling mechanism.

John's End: Receive Answer

  1. 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

  1. Both Ends start discovering ICE candidates.
  2. Send the ICE candidate to the other end.
  3. Other End on receiving ICE candidate, calls RTCPeerConnection.addIceCandidate().
  4. ICE Layer takes care of the rest and establishes connection.

Talk is Cheap, Show Me Code!

— Linus Torvalds

References

Thank You!

Twitter: @ruman_saleem

E-Mail: ruman63@gmail.com

Website: https://rumansaleem.github.io

WebRTC: Real Time Communications on Web

By Ruman Saleem

WebRTC: Real Time Communications on Web

  • 146