Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox 22 mozGetUserMedia using 'screen' as device source

There have been some buzz in the air for the WebRTC support in Firefox 22. This is for someone who's in the know about Firefox development: Are there any support in Firefox for desktop screen capture todate?

The technology does exist for Chrome 26+, which provides experimental support for screen capturing (using 'screen' as device source); the code (snippet) for making this happen is:

   // select any supported getUserMedia function
   navigator.getMedia = (navigator.getUserMedia || 
                         navigator.webkitGetUserMedia ||
                         navigator.mozGetUserMedia ||
                         navigator.msGetUserMedia);

  // if getUserMedia is not supported, do nothing 
  if( !navigator.getMedia ) return;

  // request for user media
  navigator.getMedia(
  {
     video : {
        mandatory : {
           // request 'screen' as a source media
           chromeMediaSource : 'screen'
        }
     }
  },

  // success
  function( localMediaStream )
  {
     // process local media stream...
  },

  // failure
  function( error )
  {
     // error handling
  });

Looking at W3C docs, the objects MediaSourceConstraints, MediaTrackConstraints, MediaTrackConstraintsSet have not yet been standardized. It might simply be that the API is all too foggy for this feature to appear in Firefox production. It would just be good to know the current state of support.

like image 641
knight Avatar asked Jun 27 '13 19:06

knight


1 Answers

This is now possible in Firefox, however due to security concerns, support is hidden behind some preferences. Specifically the media.getusermedia.* preferences under about:config.

This comment on a Mozilla bug report illustrates some of those concerns:

Now that we've redesigned <input type="file"> to not draw the full path on the screen, things are better. We still have problems with things like drawing cross-origin images and <iframe>s.

Even with user opt-in, I'd worry about situations like "user loads app page A in one tab and app page B in another tab, page B asks for permission to screen-share page A which looks fine, user accepts, then app swaps an <iframe> of FB or gmail or whatever into page A and grabs the contents.

Though media.getusermedia.screensharing.enabled is currently true by default in the release channel, only those domains whitelisted under media.getusermedia.screensharing.allowed_domains are actually allowed to use it.

If your domain is on the allowed list, you can use it by using the following keys in the video property.

video: {
    mozMediaSource: "screen",
    mediaSource: "screen"
}

Mozilla hosts a getUserMedia Test Page, on a domain that is white-listed by Firefox Nightly and Firefox Developer Edition. If you use either of these versions of Firefox, you can see it in action. Alternately you could add the domain to the whitelist under about:config and use it in the release and beta channels.

like image 66
Alexander O'Mara Avatar answered Nov 14 '22 22:11

Alexander O'Mara