WebRTC - RTCDataChannel demo, API changes... and Chrome talks to Firefox

More good news from our old friend WebRTC.

To be precise: three pieces of good news and a couple of minor API changes.

RTCDataChannel for Chrome

RTCDataChannel has been implemented in Chrome, and there's a great little demo at simpl.info/dc.

This demo shows peer-to-peer communication of arbitrary data – in less than a hundred lines of code. You'll need Chrome 25 or above for this, which at this point means Beta or Canary.

RTCDataChannel makes the most of features built into RTCPeerConnection – not least, the use if the ICE framework to get through firewalls and NATs – and has lots of potential applications where low latency is paramount: for gaming, remote desktop applications, real-time text chat and file transfer.

For more information about RTCDataChannel, take a look at Getting Started with WebRTC.

API changes

Less exciting, but still important: from Chrome 26, some RTCPeerConnection and MediaStream API properties have become getter methods:

  1. MediaStream now has the getAudioTracks() method instead of the audioTracks property, and getVideoTracks() instead of videoTracks.
  2. RTCPeerConnection now has getLocalStreams() instead of localStreams, and getRemoteStreams() instead of remoteStreams.

To get a glimpse of MediaStream in action, take a look at the simpl.info/gum getUserMedia demo. The stream variable is in global scope: examine it from the console. Likewise for RTCPeerConnection at simpl.info/pc: the RTCPeerConnection objects pc1 and pc2 are in global scope.

Chrome <=> Firefox

And in case you missed it, Chrome can now 'talk' to Firefox.

You can try this out now at webrtc.org/start, which has full instructions, links to source code, and information about API differences.

Tip of the hat to those at Mozilla and Google who made it all happen.

Happy coding! And please let us know of any bugs, either by commenting on this post, or at bugs.chromium.org. And don't forget, you can always get up-to-date implementation information from the excellent chromestatus.com.