Mozilla is excited to announce that we’ve achieved a major milestone in WebRTC development: WebRTC RTCPeerConnection interoperability between Firefox and Chrome. This effort was made possible because of the close collaboration between the open Web community and engineers from both Mozilla and Google.

RTCPeerConnection (also known simply as PeerConnection or PC) interoperability means that developers can now create Firefox WebRTC applications that make direct audio/video calls to Chrome WebRTC applications without having to install a third-party plugin. Because the functionality is now baked into the browser, users can avoid problems with first-time installs and buggy plugins, and developers can deploy their apps much more easily and universally.

To help celebrate this momentous milestone, we thought it would be fun to call up our friends at Google to discuss it with them. Check out this Firefox-Chrome demonstration call between Mozilla’s Chief Innovation Officer, Todd Simpson, and Google’s Director of Product Management, Hugh Finnan, and read what Google had to say about this momentous occasion in their blog post.

This milestone builds on an earlier demo we showed late last year of WebRTC integrated with Social API. There we demonstrated an industry first with our implementation of DataChannels, a powerful component of WebRTC that can combined with an audio/video chat to allow users to share almost anything on their computer or device. Send vacation photos, memorable videos, links news stories etc., simply by dragging the item into your video chat window. Look out for more on this to come.

The purpose of WebRTC, an open standard being defined jointly at the W3C and IETF standards organizations, is to provide a common platform for all user devices to communicate and share audio, video and data in real-time. This is a first step toward that vision of interoperability and true, open, real-time communication on the web.

Posted by:

Serge Lachapelle, Chrome Product Manager and Maire Reavy, Firefox Media Product Lead

Start Developing Using RTCPeerConnection in Firefox

For JavaScript developers who haven’t tried RTCPeerConnection in Firefox yet (since it is a brand new feature for us), you can try this out using the most recent Firefox Nightly by setting the media.peerconnection.enabled pref to “true” (browse to about:config and search for the media.peerconnection.enabled pref in the list of prefs). Here is a snippet of code from a sample app that shows off how to initiate, accept, and end a WebRTC call in Firefox using RTCPeerConnection:

function initiateCall(user) { document.getElementById("main").style.display = "none"; document.getElementById("call").style.display = "block"; // Here's where you ask user permission to access the camera and microphone streams navigator.mozGetUserMedia({video:true, audio:true}, function(stream) { document.getElementById("localvideo").mozSrcObject = stream; document.getElementById("localvideo").play(); document.getElementById("localvideo").muted = true; // Here's where you set up a Firefox PeerConnection var pc = new mozRTCPeerConnection(); pc.addStream(stream); pc.onaddstream = function(obj) { log("Got onaddstream of type " + obj.type); document.getElementById("remotevideo").mozSrcObject = obj.stream; document.getElementById("remotevideo").play(); document.getElementById("dialing").style.display = "none"; document.getElementById("hangup").style.display = "block"; }; pc.createOffer(function(offer) { log("Created offer" + JSON.stringify(offer)); pc.setLocalDescription(offer, function() { // Send offer to remote end. log("setLocalDescription, sending to remote"); peerc = pc; jQuery.post( "offer", { to: user, from: document.getElementById("user").innerHTML, offer: JSON.stringify(offer) }, function() { console.log("Offer sent!"); } ).error(error); }, error); }, error); }, error); } function acceptCall(offer) { log("Incoming call with offer " + offer); document.getElementById("main").style.display = "none"; document.getElementById("call").style.display = "block"; // Here's where you ask user permission to access the camera and microphone streams navigator.mozGetUserMedia({video:true, audio:true}, function(stream) { document.getElementById("localvideo").mozSrcObject = stream; document.getElementById("localvideo").play(); document.getElementById("localvideo").muted = true; // Here's where you set up a Firefox PeerConnection var pc = new mozRTCPeerConnection(); pc.addStream(stream); pc.onaddstream = function(obj) { document.getElementById("remotevideo").mozSrcObject = obj.stream; document.getElementById("remotevideo").play(); document.getElementById("dialing").style.display = "none"; document.getElementById("hangup").style.display = "block"; }; pc.setRemoteDescription(JSON.parse(offer.offer), function() { log("setRemoteDescription, creating answer"); pc.createAnswer(function(answer) { pc.setLocalDescription(answer, function() { // Send answer to remote end. log("created Answer and setLocalDescription " + JSON.stringify(answer)); peerc = pc; jQuery.post( "answer", { to: offer.from, from: offer.to, answer: JSON.stringify(answer) }, function() { console.log("Answer sent!"); } ).error(error); }, error); }, error); }, error); }, error); } function endCall() { log("Ending call"); document.getElementById("call").style.display = "none"; document.getElementById("main").style.display = "block"; document.getElementById("localvideo").mozSrcObject.stop(); document.getElementById("localvideo").mozSrcObject = null; document.getElementById("remotevideo").mozSrcObject = null; peerc.close(); peerc = null; }

You’ll notice that Firefox still prefixes the RTCPeerConnection API call as mozRTCPeerConnection because the standards committee is not yet done defining it. Chrome prefixes it as webkitRTCPeerConnection. Once the standards committee finishes its work, we will remove the prefixes and use the same API, but in the meantime, you’ll want to support both prefixes so that your app works in both browsers.

Trying Interop Yourself

For those eager to give interop a try, here are instructions and information about “trying this at home”.

This is Firefox’s and Chrome’s first version of PeerConnection interoperability. As with most early releases, there are still bugs to fix, and interop isn’t supported yet in every network environment. But this is a major step forward for this new web feature and for the Web itself. We thank the standards groups and every contributor to the WebRTC community. While there’s more work to do, we hope you’ll agree that the Web is about to get a lot more awesome.