Getting started with WebRTC for Android — Loopback P2P calls

Vivek Chanddru
Adventurous Android
5 min readJul 15, 2017

--

Peer to Peer video calling is on the rage for sometime and now every app has audio/video calling inbuilt. This tutorial series is all about exploring the possibility of providing such feature in an easy and understandable manner for beginners.

This tutorial series is loosely based on the Codelabs for WebRTC.

This part of the series is primarily based on Step 2 of the above mentioned codelab where we use PeerConnection in WebRTC to transfer audio and video data between two peers in a same device.

This is Part 3 of the series “Getting started with WebRTC for Android” and if you are new to this article, please make sure that you have read the previous parts of this series before continuing with this part.

Part 1: Introduction to WebRTC

Part 2: Introduction to PeerConnection

Part 3: Peer-to-Peer Video Calling — Loopback (this article)

Part 4: Peer-to-Peer Video Calling with socket.io

Let us consider the following scenario where our courageous boy wishes to call the lady (to propose, of course!)

He plans to use an app which provides awesome video and audio calling feature. He wants to see her reaction when he proposes (awww). The following steps happens at both the ends of the peer connection.

  • Initially, our app creates an peer connection and an offer SDP. This offer contains the data about the calling peer and it is used to identify the codecs and other entities of the peer.
  • This offer is then stored as “Local Description” at the calling peer and is then sent over to the callee over some signaling mechanism (Typically, most of the systems use Websockets as the signaling medium. It might vary depending on your usage and requirements).
  • Once our app at the callee side receives the offer, it knows that there is a call to be established. It will store the “offer” as its “Remote Description” and creates the corresponding “Answer” SDP.
  • This answer SDP is similar…

--

--

Android Developer@Amazon; Web Enthusiast; Program Geek; Gadget Lover; Droidcon India Organizer