Home

Awesome

serverless-webrtc-android

CircleCI

A demo of using WebRTC with no signaling server. But for Android written in Kotlin.

Compatible and inspired by this project written for JavaScript by Chris Ball:

What is WebRTC?

<img src="https://webrtc.org/assets/images/webrtc-logo-vert-retro-255x305.png" width="96"> It's technology for real time peer to peer comunication. Especially useful for transfering audio and video - teleconference apps, but can be used for ordinary data as in this example. WebRTC is supported in recent Chrome browser, Node.js and also on Android/iOS.

How it works?

WebRTC requires two data payloads to be transferred between parties, it's called SDP (sesssion description protocol). One is called offer and the second is answer.

You can either create an offer and send it to other party or wait for an offer to be delivered to you. Usually SDP handshakes are done by special signalling server, but in this case we are not using any, so you'll need to pass SDPs manually by e.g. e-mail.

If it's running IPv4, it's very unlikely that both parties will have a public IP address or it will be on the same network. SDP requires that you'll need to pass external IP address there, this is done automatically by process called ICE gathering. It uses two types of external servers - STUN and TURN. We are using only STUN here, but it should work with TURN as well (and even better). It can even punch through some NAT mechanisms.

It uses libjingle library, it's a native library for WebRTC that comes with Chromium. There is also JNI wrapper for use in Java. You can compile it by yourself but it's extremely tricky. You can use already build dependency in your build.gradle. This helped me a lot:

Usage

<img src=".github/create_offer.png" width="320"> <img src=".github/paste_answer.png" width="320"> <img src=".github/demo.png" width="320">

Known issues

License

You can do whatever you want with this code.