Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add TURN server to android webRtc native

I'm working on WebRtc native android application. Im also compiling io.pristine lib. Im able to establish calls between two devices only if both of them are connected to the wifi. In case when one of the devices is connected to the cellular network im not able to establish call. I read any possible forum out there and its look like I need TURN server. I already run my own TURN server but idk how I can force the app to use this server. Any help is welcome. Thank you!!

like image 358
Alexander Avatar asked Jun 16 '17 02:06

Alexander


People also ask

Can we use WebRTC in Android?

You can use WebRTC facilities in the Android Platform with the help of Ant Media Server's Native WebRTC Android SDK. In this blog post, features of Webrtc Android SDK will be presented with a sample Android project which comes bundled with the SDK.

Does WebRTC require a TURN server?

For most WebRTC applications to function a server is required for relaying the traffic between peers, since a direct socket is often not possible between the clients (unless they reside on the same local network). The common way to solve this is by using a TURN server.


1 Answers

WebRTC deprecated old API to create ICE servers. (Answer which uses old API)

To create ICE server you need to use IceServer builder pattern.

 PeerConnection.IceServer stun =  PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer();
 PeerConnection.IceServer turn =  PeerConnection.IceServer.builder("turn:numb.viagenie.ca").setUsername("[email protected]").setPassword("muazkh").createIceServer();
like image 142
emin deniz Avatar answered Sep 19 '22 06:09

emin deniz