Progress update on WebRTC for Firefox on desktop

 

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 to mozGetUserMedia() only
  • media.navigator.permission.disabled automatically gives permission to access the camera/microphone and bypasses the permission/selection dialog
  • media.peerconnection.enabled enables use of mozRTCPeerConnection()

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
/**
* 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);
}
view raw datachannels.js hosted with ❤ by GitHub

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.

此条目发表在 未分类 分类目录。将固定链接加入收藏夹。

评论功能已关闭。