WebRTC for desktop is now in Firefox Nightly and is also in Firefox Aurora, though Nightly has the hottest up-to-date fixes.
We support mozGetUserMedia
, mozRTCPeerConnection
and DataChannels
. We have a basic UI for mozGetUserMedia
which we expect to be updating in the
coming weeks.
Enabling WebRTC in Firefox
The code is behind a pref for now, pending more testing. To enable our WebRTC code in Firefox’s Nightly desktop build, browse to about:config
and change the media.peerconnection.enabled
preference to true
.
Here are the 3 relevant prefs to getUserMedia()
and mozRTCPeerConnection()
:
media.navigator.enabled
enables calls tomozGetUserMedia()
onlymedia.navigator.permission.disabled
automatically gives permission to access the camera/microphone and bypasses the permission/selection dialogmedia.peerconnection.enabled
enables use ofmozRTCPeerConnection()
Note: media.peerconnection.enabled
implies media.navigator.enabled
has been set to true
.
Demos & upcoming changes
There’s a lot you can do with these APIs, even today. For examples, check out our test landing page on GitHub. We’ll try and put up notices if you’re running an out-of-date browser — as well as news updates about important bug fixes and API changes there!
Upcoming changes include:
- Support for constraints (to getUserMedia and createOffer/Answer)
- Control of bandwidth, resolution, echo cancellation, etc.
- Statistics
- TURN support (to allow connections between devices behind symmetric NATs)
- Fixes for audio drift (progressive loss of A/V sync)
- Trickle ICE, rtcp-mux and BUNDLE support
- getUserMedia() UI updates
- And many bugfixes
To give you an idea of the power of these APIs, in a couple of days our team whipped up a Social API integration demo that allows you to video +
text chat with your friends, drag-and-drop files to each other, drop links, tabs, etc, all making simple use of the DataChannel API.
The DataChannel API is quite simple on the surface, and has an API very similar to WebSockets. A quick example:
/**
* Assume we've connected a PeerConnection with a friend - usually with audio
* and/or video. For the time being, always at least include a 'fake' audio
* stream - this will be fixed soon.
*
* connectDataConnection is a temporary function that will soon disappear.
* The two sides need to use inverted copies of the two numbers (eg. 5000, 5001
* on one side, 5001, 5000 on the other)
*/
pc.connectDataConnection(5001, 5000);
function handle_new(channel) {
channel.binaryType = "blob";
channel.onmessage = function(evt) {
if (evt.data instanceof Blob) {
console.log("I received a blob");
// assign data to an image, save in a file, etc
} else {
console.log("I got a message: " + evt.data);
}
};
channel.onopen = function() {
// We can now send, like WebSockets
channel.send("The channel is open!");
};
channel.onclose = function() {
console.log("pc1 onclose fired");
};
};
/* For when the other side creates a channel */
pc.onDataChannel = handle_new;
channel = pc.createDataChannel("My Datastream",{});
if (channel) {
handle_new(channel);
}
Filing bugs & moving forward
Progress on WebRTC (and bug-fixing) is rapid, and we encourage you to try it out and submit bugs. (We have plenty! But we’re nailing them as fast as we can, so make sure you’re on nightly and update regularly.)
Bug reports are highly appreciated. Please file them on
Bugzilla under “Product:Core”, “Component:WebRTC”.
The team is both excited by all the progress, and exhausted. The work so far represents tons of hours of work from so many people on the Firefox team (too many people to name — especially because we don’t want to forget
someone — but you know who you are!). Thank you to everyone who helped us land this “747″ on the flight deck.
We’ll continue to blog regularly on our progress as we work to make this a great product feature for Firefox and the web.
About Anant Narayanan
@anantn is a hacker at Mozilla Labs who specializes in generalism. He has previously worked on Weave, Jetpack, Account Manager, and Rainbow among other projects. He is currently fiddling with Open Web Apps and Real-time communication for the Web.
More articles by Anant Narayanan…
About Robin Hawkes
Robin thrives on solving problems through code. He's a Digital Tinkerer, Head of Developer Relations at Pusher, former Evangelist at Mozilla, book author, and a Brit.
40 comments