53

I'm assuming that WebRTC is an API that decodes/encodes audio and video, although the communication between the server and the clients is done via web sockets, or some other network protocol? I'm a bit confused. Does WebRTC have its own communications protocol?

AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158

4 Answers4

84

There's two sides to WebRTC.

  1. JavaScript APIs (getUserMedia) that allow an app to access camera and microphone hardware. You can use this access to simply display the stream locally (perhaps applying effects), or send the stream over the network. You could send the data to your server, or you could use...
  2. PeerConnection, an API that allows browsers to establish direct peer-to-peer socket connections. You can establish a connection directly to someone else's browser and exchange data directly. This is very useful for high-bandwidth data like video, where you don't want your server to have to deal with relaying large amounts of data.

Take a look at the demos to see both parts of WebRTC in action.

So in a nutshell:

  • WebSockets allow full-duplex communication between a browser and a web server.
  • WebRTC's PeerConnection allows full-duplex communication between two browsers.
Skomski
  • 4,827
  • 21
  • 30
josh3736
  • 139,160
  • 33
  • 216
  • 263
  • 2
    WOW... thank you for perhaps the most concise answer i could ever expect. * So PeerConnection is a P2P connection, does the handshaking phase require a server in the mix? is a server requiered for any of PeerConnection's API? – AndrewMcLagan Oct 05 '12 at 05:07
  • 7
    'does the handshaking phase require a server in the mix?' Yes. WebRTC has been implemented using the JSEP architecture, which means that user discovery and signalling are done via a separate communication channel (for example, using WebSocket or XHR and the DataChannel API). See the http://apprtc.appspot.com example or (apologies for self promotion) http://www.html5rocks.com/en/tutorials/webrtc/basics/#toc-signalling – Sam Dutton Oct 12 '12 at 09:18
  • 1
    @josh3736 When you say "direct peer-to-peer socket" and "full-duplex communication" does that mean that someone built a reliable, packet-ordered, and error checked solution on top of the UDP protocol for P2P communication (not TCP, but something like it)? I'm under the impression that WebRTC doesn't support P2P TCP connections. – Landon Poch Aug 22 '14 at 18:25
  • peerConnection can be used without a browser. There are native APIs for iOS and Android (and x86 I believe). Also, audio and video is not the only thing webrtc does, you can also open a datachannel to send files peer-to-peer amongst various other creative uses. – Kevin Aug 26 '14 at 05:47
14

WebRTC uses RTP (a UDP based protocol) for the media transport, but requires an out-of-band signaling channel to setup the communication. One option for the signaling channel is WebSocket.

oberstet
  • 21,353
  • 10
  • 64
  • 97
4

Instead of peerConnection you can also look at the WebRTC data channel draft: https://datatracker.ietf.org/doc/html/draft-jesup-rtcweb-data-protocol-00 which is basically bidirectional udp. Which can be a really valuable alternative to WebSockets as doesn't have the "negative" sides of a tcp connection.

Community
  • 1
  • 1
3rdEden
  • 4,388
  • 1
  • 20
  • 18
3

No, Signaling is not defined by WebRTC.

Here is an post by the IETF which explains it pretty good why it is not: http://www.ietf.org/mail-archive/web/rtcweb/current/msg01143.html

This means that you are free to choose how you exchange network information. I.e. you could use websockets, HTTP and even Email, but that would be a bit of a struggle :)

Felix Hagspiel
  • 2,634
  • 2
  • 30
  • 43