What is WebRTC?

google-webrtc-logoWebRTC (Web Realtime Communications) enables peer to peer video, audio, and data communication between two web browsers. This allows for video calling, video chat, and peer to peer file sharing entirely in the web browser, with no plugins.

Why You Should Use WebRTC

Because WebRTC requires no plugins, frameworks or applications, all you need is a WebRTC compatible browser. To an end user, WebRTC applications “just work” right out of the box. No Flash, no Silverlight, no JavaScript API, just pure video, audio, and data communication on any webpage.

WebRTC is entirely peer to peer, so you don’t have to pay for any of the bandwidth across the wire. Additionally, because WebRTC is entirely browser to browser, you get the highest performance and lowest latency possible. For example, say a user is trying to share a file. Without WebRTC, the user has to upload said file to a server, and the recipient user has to download that file. With WebRTC, these files are transferred directly through the WebRTC Data Channel, no servers or infrastructure required.

PeertoPeer

WebRTC to a Developer

From a developer’s standpoint, there is a bit more that goes into making a WebRTC application work. WebRTC is an integral part of the HTML5 specification, managed by the IETF and W3C. It is exposed in the browser using JavaScript.

WebRTC works by connecting two browsers through the RTCPeerConnection. First, the browsers are connected through signaling, by passing the Session Description Protocol (SDP). This signaling discovers where the two users are and how to connect. Once the RTCPeerConnection is open, video, audio, and data communication can be sent between the two browsers.

To make it work, all you need is two web browsers and a way to transfer a SDP between them. The SDP includes information about your computer, what audio codecs you support, how you can transmit data between computers, and what ports are available on your computer that you can connect to. You can read more about SDPs here.

Think of SDPs like business cards. You exchange them with somebody else, and now you know how to contact each other. Because methods of transferring SDPs are not detailed in the specification, you have to provide your own signaling implementation. THis is done by implementing your own way to transfer the SDP data.

Right now, WebRTC is compatible with Chrome, Firefox and most recently Opera, on both desktops and Android devices (this includes interoperability between the two). Internet Explorer and Safari have remained silent so far, but are expected to have implementations in the near future.

How Does PubNub Work With WebRTC?

WebRTC Diagram

So where does PubNub fit into WebRTC? You need some way to transfer the SDP from browser A to browser B. The PubNub Data Stream Network can be used as a scalable signaling server for WebRTC apps. PubNub features, such as Presence and Storage/Playback also can be used to enhance those apps.

When calling another user through a WebRTC app, the caller needs to know if the callee is currently online or offline and what device they’re using, if they’re available to accept the call, etc. PubNub Presence gives you all that information and enables you to show the users they can connect with. This is essential for signaling, to prevent users from trying to connect to other users that aren’t available.

The WebRTC protocol does not provide storage capabilities, and as a result, there are no records of what messages have been sent. Specifically with text chat, users expect a history of previous chat conversations. PubNub’s Storage/Playback feature allows users to see a history of past conversations over a desired period of time.

WebRTC Use Cases

Because WebRTC enables voice, video, and data communication, there are many use cases for WebRTC, ranging from basic video/voice chat to multiplayer gaming to file sharing and so on.

Video and Audio

With WebRTC, video and voice communication can be easily implemented into any website. This adds advanced levels of interaction to a website, allowing users to communicate in-context and in realtime, with either site operators or with each other. Such capabilities are more desirable than current limitations whereby users need to call a number, download a plugin, or leave your website. For example, a financial institution website could easily embed a WebRTC communication app to allow users to quickly speak to a financial representative (rather than forcing them to use their phone to endlessly talk with an automated representative).

Another example would be a Skype-like video chat application, that can be used entirely in the web browser. This means that end users don’t have to install any software or plugins, and can easily connect to one another, through video, audio, and text chat, browser to browser. We built WebRTC.co, a JavaScript video chat application that runs entirely on WebRTC and PubNub.

webrtc

Data Channel

The WebRTC Data Channel adds another unique dimension to WebRTC applications. Sending data between two users in today’s browser world is a tough process with JavaScript, and most developers rely on a server as the middle man. With WebRTC, the Data Channel API allows the passing of arbitrary data across the connection. This allows for large scale file sharing, fast action multiplayer games, and even remote control applications.

The WebRTC Data Channel eliminates the need to upload files to cloud services, such as Dropbox or Google Drive, to perform file transfers or share with others. Similar to these cloud services, the Data Channel allows users to transfer large amounts of data very quickly, all in the web browser in true peer to peer fashion. Check out PubShare, a peer to peer file transfer application powered by WebRTC and PubNub.

Universal remote control applications are another interesting implementation of the Data Channel. Smartphones use the RTCDataChannel to connect to SmartTVs, and this allows users to send data packets between the two devices (for example, this data can then be used to send instructions such as pausing or playing a streaming audio or video service). Anything in a web browser can easily be controlled by utalizing the WebRTC data channel.

Additional Resources

PubNub WebRTC SDK

WebRTC.co (JavaScript Skype with WebRTC and PubNub)

PubShare (P2P WebRTC Filesharing)

Get Started
Sign up for free and use PubNub for WebRTC signaling

Start Building Realtime Apps Now!

Loading...