5
votes

Is all the work for the webRTC functionality being done on a webRTC server ? For example, in the rtc data channel from simpl.info you can just copy the html for the input text box and out text box as well as the JavaScript and copy it to your local computer and it works perfectly. When the JavaScript file is inspected closer, there are a lot of calls which are coming from webRTC libraries without having them on my local computer. I.E.

window.localPeerConnection = new webkitRTCPeerConnection(servers,
{optional: [{RtpDataChannels: true}]});

at first I thought to get these methods to work I would have to download webRTC to the local machine that will be hosting the pages and then I can call them that way. But that does not seem to be the case, I have tried most of the examples and they all work without having webRTC locally.

I have watched the webRTC intro video it goes over a lot of the features but it doesnt explain this particular question. Another aspect that confuses me as well, is the fact when you go to the official webrtc.org getting started tutorial, it gives step by step instructions for download the webRTC libraries, which I did. But what is the purpose of that if you don't need to them to create webRTC apps and the work is being done in an outside server ?

I saw another question where the title is almost identical, how does webRTC work?, but after reading the accepted response and the question its different, OP wanted to know how the peer to peer connection worked and they explained to him ICE works and TURN servers, which I kinda understood from the intro video, my question is more are these turn servers, ICE, etc being hosted by Google or can we host them locally. And if its something Google hosts etc, isn't it unsafer than being able to host locally?

3

3 Answers

4
votes

WebRTC is a very complex synergy of many components and protocols. Luckily, from a webdeveloper point of view, all of this is encapsulated by three main JavaScript API's: getUserMedia, RTCPeerConnection and RTCDataChannel. These API's are defined by the W3C and are part of the browser that support WebRTC. You can find an overview of the current support here:

This means that you do not have to "download" WebRTC to use it, if the browser supports it, it's already there.

To answer your second question about STUN and TURN servers: There are publicly available servers. However, these are mostly for testing purposes. You can deploy your own TURN server, rfc5766-turn-server is such one and documentation is found here

3
votes

As WebRTC is using peer to peer, it will work fine if you do it on your local network, because the identity of the participiants is known and WebRTC knows how to route information. But that does not work over the internet, as people are using routers and firewalls etc...

So you have to exchange signaling information to initialize the peer connection at the beginning. This information tells the participiants how they can find the others over the internet (just the IP would not be enough, as one public IP can have any number of PCs behind its router). This is called signaling. But signaling is not part of WebRTC, so it is up to you how to exchange this information. So basically you need a place where the participiants already can "see" each other and can exchange signaling data. Once the information is exchanged, WebRTC is able to set up the direct peer connection which transmits all further data like video and audio (this data is not travelling over the server then). For this you can use whatever technology you want, websockets, instant messaging, even copying the information out of an email would work.

I wrote an detailed tutorial about how to create a simple WebRTC app, which uses websockets. It also explains how to set up your own websocket server. Hope this helps!

1
votes

If you are concerned about turn server, then you can create your own turn server by using rfc5766 . I have used it to create my own turn server and it worked fine.