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:


/**
 * 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.

More articles by Robin Hawkes…


40 comments

  1. Pascal Rettig

    This is awesome – what’s the spec that the DataChannel is based on and does it support UDP?

    Last I came across the DataChannel API (at Google I/O and http://www.webrtc.org/faq-recent-topics) it was still being spec’d out – is this implementation FF specific or should it be compatible with what’s in WebKit?

    November 5th, 2012 at 08:09

    1. Anant Narayanan

      The implementation is based on the latest editor’s draft: http://dev.w3.org/2011/webrtc/editor/webrtc.html

      There are a few Firefox’isms in the current implementation (notably the connectDataConnection method), but when webkit does their implementation no doubt we will converge in short order.

      November 5th, 2012 at 08:22

  2. Drazick

    This is great!
    Thank you for your hard work.
    WebRTC is the killer feature everyone is looking forward for.

    November 5th, 2012 at 09:00

    1. Robert Nyman

      Thank you! And yes, WebRTC is definitely a game changer!

      November 5th, 2012 at 09:18

  3. Felipe Reyes

    This is great news!, I’m playing with the WebRTC, but I was looking forward to have my experiments working on Firefox (the best web browser ever!)

    November 5th, 2012 at 09:25

    1. Robert Nyman

      Sounds good. :-)

      November 5th, 2012 at 09:48

  4. Tom

    The releasenotes link on the page where Aurora FF18 is offered points to the “what’s new” page of FF 17. The Feedbackformular which I wanted to use to report this wouldn’t work(current nightly FF).

    November 5th, 2012 at 12:43

    1. Robert Nyman

      Thanks for the heads-up!

      November 5th, 2012 at 15:41

      1. Tom

        Feedback now seems to work again from inside the browser.

        November 5th, 2012 at 16:52

  5. Sam Dutton

    Great stuff! Congratulations to all concerned.

    November 7th, 2012 at 04:13

    1. Robert Nyman

      Thank you, Sam!

      November 7th, 2012 at 06:48

  6. Mark

    Thanks for the update! Is it expected at this point to interoperate with Chrome 23’s WebRTC support? (using VP8 + G.711 I assume)

    November 7th, 2012 at 22:45

    1. Robert Nyman

      You’re welcome!
      As Anant mentioned above, when there are differences, we definitely talk to each other and try to find the best solution.

      November 8th, 2012 at 01:39

    2. Maire Reavy

      At this point, we don’t interoperate with Chrome 23, but we and the Chrome WebRTC team have already started the effort to get WebRTC interop working between Firefox and Chrome. It is a priority for both teams. Stay tuned.

      November 8th, 2012 at 02:06

  7. Gonzalo Gasca

    What codec does FF supports now? Vp8 or H.264?

    November 9th, 2012 at 10:59

    1. Anant Narayanan

      We support VP8 at this point (as does Chrome). A mandatory-to-implement codec has not yet been selected by the IETF.

      November 9th, 2012 at 14:59

    2. Robert Nyman

      To my knowledge, right now the support is for WebM (VP8 codec). With regards, to H.264, I’m not sure at this time how that will evolve.

      November 9th, 2012 at 15:04

  8. Hadar Weiss

    This is amazing. Thanks for you progress. Looking forward to implement cool apps on top of it.

    November 11th, 2012 at 19:49

    1. Robert Nyman

      And we’re looking forward to seeing a lot of those cool apps!

      November 12th, 2012 at 06:00

  9. Scott Wharton

    Thanks for the great info and congrats on this milestone. Is there a target date for firefox WebRTC GA? Now that Chrome is out of beta, I’m sure the Firefox community is itching to get their version out to the world too

    November 20th, 2012 at 20:36

    1. Robert Nyman

      Thank you!

      We talked about it a couple of months ago in Full WebRTC support is soon coming to a web browser near you!, and the goal has been Firefox 18, in the beginning of January next year. Hopefully we can live up to that :-)

      November 21st, 2012 at 03:10

  10. Jonathan Chetwynd

    Is there a very simple working example demonstrating udp data as in say utf-8 possibly with createDataChannel between server and client? p2p could be good, but the example above is too vague for me to implement as is: Assume we’ve connected a PeerConnection… well given a time transport mechanism…
    seriously a great start, but can I implement it today?

    November 23rd, 2012 at 12:42

    1. Robert Nyman

      Perhaps the examples in the WebRTC test landing page helps? Or maybe the Real-time communication without plugins article by Sam Dutton is useful?

      November 24th, 2012 at 04:01

  11. Randell Jesup

    The test landing page demo will definitely help. If you want UDP-like unreliable data, replace “{}” with “{outOfOrderAllowed: true, maxRetransmitNum: 0 }” to the createDataChannel call.

    November 24th, 2012 at 05:43

  12. Jonathan Chetwynd

    Randell & Robert, following your encouraging comments, filed bug 814871 “Intermittent connection”, webrtc uses UDP, so why the use of UDP-like? tested and wfm.

    November 24th, 2012 at 10:25

  13. Randell Jesup

    DataChannels runs over SCTP over DTLS over UDP (phew!) (with ICE/STUN/TURN)

    DTLS provides security

    SCTP is a multi-channel network layer that runs over a single port/connection, and can provide partial or full reliability (or no reliability).

    DataChannels is a small protocol for opening/closing channels and transferring larger blobs/arrays that runs on top of SCTP.

    We can choose reliability options on a per-DataChannel basis using the dictionary in createDataChannel.

    November 24th, 2012 at 10:30

  14. Derick Eppendahl

    Hi there,
    I am looking for someone to help developping a webrtc based application.
    Contact me on derick@eppendahl.com
    have a nice day…

    December 3rd, 2012 at 03:38

  15. Rod

    http://www.h-online.com/open/news/item/Firefox-beta-introduces-Social-API-with-Facebook-Messenger-1734250.html =

    “22 October 2012, 17:04
    Firefox beta introduces Social API with Facebook Messenger

    The interface for the new Social API takes the form of a sidebar Zoom
    Source: Mozilla

    Mozilla is introducing a new Social API in the latest beta version of Firefox, which provides the browser with the ability to integrate with social media sites. When enabled, the new social functions are displayed in a permanent sidebar alongside the usual page content. ”

    Does _permanent sidebar_ mean it can NOT be turned off/will always be displayed in the browser? I sure hope not!

    December 10th, 2012 at 19:31

    1. Robert Nyman

      No, it’s completely optional. More information at How does Facebook Messenger for Firefox work?.

      December 11th, 2012 at 03:20

  16. David Gausmann

    I am very confused about getUserMedia in Firefox:
    In Firefox 16 I was able to use getUserMedia. I’ve tested it with some example pages on the web and the test was successful (e. g. my Webcam has been used to display a video of me).

    But after the update to Firefox 17 it doesn’t work anymore, although I find nothing in the internet about this “downgrade”. Have these features been disabled from Firefox 16 to Firefox 17?
    And how to enable them again? Setting “media.navigator.enabled” doesn’t work on my computer!

    Kind Regards
    David Gausmann

    December 12th, 2012 at 12:07

    1. Robert Nyman

      To my knowledge, it should be working. Please file a bug as described in the blog post, and hopefully it helps!

      December 12th, 2012 at 12:54

    2. Cooper

      I had trouble before, and learnt that Mozilla has change on GetUserMedia interface. I am not sure if it’s same thing:

      function mozSuccess(stream) {
      // Cooper: Mozilla update the interface, from “src” to “mozSrcObject”
      video.mozSrcObject=stream;
      video.play();
      originalStartUp();
      }

      window.onload = function() {
      if( navigator.webkitGetUserMedia ) {
      navigator.webkitGetUserMedia({video:true, audio:true}, webkitSuccess, fallback);
      } else {
      navigator.mozGetUserMedia({video:true}, mozSuccess, fallback);
      }
      }

      December 18th, 2012 at 18:13

  17. Michael Adeyeye

    You might also be interested in the below blog posts. I had earlier provided WebRTC-like services in 2009, when I first integrated SIP into Firefox.
    There are some demos here –
    http://www.ngportal.com/micadeyeye/index.php/2009/09/13/projects-videos/

    In addition, I quite agree with everyone that WebRTC might be a threat to mobile operators and online service providers. Here are my presentation slides at a research institute (called CSIR) – http://www.ngportal.com/micadeyeye/index.php/2012/09/09/webrtc-another-nightmare-for-telecom-providers/.

    Michael Adeyeye (Ph.D)

    December 14th, 2012 at 09:45

  18. MisterXYZ

    I REALLY LOVE this webrtc technology !
    near the day where we can very easliy video chat with everyone on everyplatform !!

    bye bye msn, skype & co !!!

    THANKS TO ALL WEBRTC DEV !

    January 13th, 2013 at 11:55

  19. Andre Natal

    Any progress on b2g? When will be available?

    February 1st, 2013 at 08:33

    1. Robert Nyman [Editor]

      When WebRTC will be available in Firefox OS? That’s still to be decided.

      February 4th, 2013 at 02:56

  20. Appie Mastenrbroek

    Can this be disabled?

    I don’t really like the possibilty of being spied on through some trojan or rogue FF plugin.

    Given the current securtiy issues with the browser this seems really stupid

    February 5th, 2013 at 11:04

    1. Robert Nyman [Editor]

      Every request to, for instance, your camera needs explicit approval from you. Just like geolocation, storing files offline etc.

      February 5th, 2013 at 13:08

  21. Scott

    It seems that the WebRTC features are disabled in FF 19.0. I had to manually go to about:config and enable them. When will media.navigator.enabled be turned on by default? Also will there be options under the Privacy tab to enable/disable these features?

    February 18th, 2013 at 21:23

    1. Robert Nyman [Editor]

      It’s disabled for now, and it’s planned to be enabled by default in the near future. I can’t say about Privacy tab, but in general – like many other APIs such as geolocation, offline storage – they’re all presented with dialogs that users need to approve their usage.

      February 19th, 2013 at 01:54

Comments are closed for this article.