lunes, 25 de marzo de 2013

Web Real-Time Communications

WebRTC, a huge leap in multimedia web-based solutions

Over the years, we have been involved in the development of several video-conference platforms with different requirements such as multi-conference or real-time file-sharing, to point out some examples either for enhancing professional-to-professional or patient-to-professional communication in our medical environment.

Back then, when those projects started, the only reliable platform to achieve those requirements was Adobe Flash ©, which, by the way, has proved to be fully functional in all our possible scenarios, that is, not just state-of-the-art test connection scenarios but real ones such as DSL or even lossy packet scenarios like WiFi or 3G, all of this, in hospital environments where security is not an option but a requirement (firewalls, proxies,VPN, etc).


However, post-PC era has arrived and has brought some significant changes into the market that needs to be adjusted.

For example, there are some constraints in all smartphone or tablet browsers; they don’t support Adobe Flash © anymore, so it is mandatory to find another solution capable of delivering the same results we already have in terms of reliability and quality.

There seems to be several possible solutions out there, but, from our point of view,  the most promising one is webRTC, being conceived as a browser end-to-end solution from scratch, which addresses many problems with a javascript API.

According to its information webpage:
“WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple Javascript APIs. The WebRTC components have been optimized to best serve this purpose.”
The main aim isto enable rich, high quality, RTC applications to be developed in the browser via simple Javascript APIs and HTML5.”

It brings out of the box:

  1. P2P communication between browsers
  2. NAT traversing (ICE and STUN)
  3. Adaptive QoS based on bandwidth allocation
  4. Automatic Multimedia Discovery
  5. *Audio and Video Recording
  6. *P2P File Sharing

That being said, how easy is to develop an application that makes use of that technology?

var userMedia = navigator.webkitGetUserMedia({video :true,audio: true}, function(localMediaStream){
var video = document.querySelector('video');
video.src = window.webkitURL.createObjectURL(localMediaStream);
$('#videoPlayer').on('loadedmetadata', function() {        
}, Error);

That simple piece of code:

  1. Detects the hardware available resources in the computer according to our requirements (in this example, audio and video resources)
  2. Let’s us choose the right stream source (in case you have 2 cams for example)
  3. Opens and creates the media stream/s
  4. Starts playing it on a canvas element in our html (in our case video is a canvas)

And of course, that code will work across all API-compliant browsers (currently Chrome, Firefox and Opera, but also IExplorer plans to implement it).

At this stage, we don’t know if it will be as good as it seems but it is definitely worth doing a research effort to discover if is a compelling alternative to our stable Adobe Flash © platforms.

*Currently drafts for both APIs have been released.