Tutorial on how to make the simplest WebRTC Android app

Sergio Paniego
3 min readNov 5, 2017

Tones of information are out there on how to make a simple WebRTC web app but the Android scope is quite empty by now and when you look for information on the issue you can run insane. So that’s why is this brief post I will try to explain how to make the simplest webRTC on Android possible. As signaling service, I will be using a NodeJS server that we will run on out computer. This NodeJS server is the one provided in the WebRTC Codelab given by Google for the web. The process I have followed on developing the app is almost the same as the one explained on the Codelab, also seeking for help through a couple of Medium post I have found quite interesting from fellows working the same issue as I am. I will try to cover the whole process in one post so the explanation can lack in some information. If you are looking for a further explanation, I will leave the links I have followed when I was working developing my example app. If you are unfamiliar with what WebRTC is all about and how it works, i leave you here a link where I explain it

Downloading and compiling the WebRTC binaries

I will leave you here a post that explain how to download the native libraries and compile it. It’s this one.

Connecting two peers locally

In this part of the tutorial I will refer to a post that explains just the part that I want to cover here. It is this one. This guy just explains exactly the idea we want to cover here and it’s actually the post series I followed we I was learning how to make a WebRTC app using Android. I extremely recommend you to read those post.

Connecting two peers using a NodeJS server as signaling service

Now that we have our app connected we have to add the NodeJS server so we can manage the actual exchange of data that will take place over the Internet. The NodeJS app is quite straight forward to understand. It just acts as a peer that will be listening on port 8080. The first time we will talk to the server is to make the offer. As the server receives the offer, it will create the room with the peer and them it will emit a message saying that the peers has joined the room. This message will go to the second peer of the connection. As the second peer answers the offer with its answer, this message will get to the server. It will connect this peer to the room we have created before and them it will send the message that a second peer has joined the conversation to the first peer. As the two peers store the info to connect to each other as description of the other candidate and they receive the iceServers candidates, they will be ready to start exchanging media between each other. To connect to the server I’ve used a socket and we have to implement when the program it’s going to send info through the socket to the server and what’s going to perform when it receives info from the server. I leave you here the entire example I uploaded to GitHub so you can go as deep as you want understanding what’s happening behind the scenes. Here is the link

Conclusion

As I have learned making the app, the resources out there on this topic are really few. Hope you guys enjoyed the post and don’t hesitate leaving a comment :)

--

--