Bug 1037408 - webrtcUI's activeStreams getter should be able to return lists for a specific device type, r=dolske.
authorFlorian Quèze <florian@queze.net>
Sat, 19 Jul 2014 02:49:19 +0200
changeset 217101 f1b8ec714d796d7de8d2159d27787b5232a6a7ca
parent 217100 5cc2ca22144333a62e4135346e1e099ce31410b4
child 217102 fe54b4c9be09d89324975b2ee1513f0815f1c733
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1037408
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037408 - webrtcUI's activeStreams getter should be able to return lists for a specific device type, r=dolske.
browser/base/content/browser-webrtcUI.js
browser/modules/webrtcUI.jsm
--- a/browser/base/content/browser-webrtcUI.js
+++ b/browser/base/content/browser-webrtcUI.js
@@ -18,17 +18,17 @@ let WebrtcIndicator = {
   },
 
   updateButton: function () {
     this.button.hidden = !this.UIModule.showGlobalIndicator;
   },
 
   fillPopup: function (aPopup) {
     this._menuitemData = new WeakMap;
-    for (let streamData of this.UIModule.activeStreams) {
+    for (let streamData of this.UIModule.getActiveStreams(true, true, true)) {
       let pageURI = Services.io.newURI(streamData.uri, null, null);
       let menuitem = document.createElement("menuitem");
       menuitem.setAttribute("class", "menuitem-iconic");
       menuitem.setAttribute("label", streamData.browser.contentTitle || streamData.uri);
       menuitem.setAttribute("tooltiptext", streamData.uri);
       PlacesUtils.favicons.getFaviconURLForPage(pageURI, function (aURI) {
         if (aURI) {
           let iconURL = PlacesUtils.favicons.getFaviconLinkForIcon(aURI).spec;
--- a/browser/modules/webrtcUI.jsm
+++ b/browser/modules/webrtcUI.jsm
@@ -33,22 +33,32 @@ this.webrtcUI = {
     Services.obs.removeObserver(removeBrowserSpecificIndicator, "recording-window-ended");
   },
 
   showGlobalIndicator: false,
   showCameraIndicator: false,
   showMicrophoneIndicator: false,
   showScreenSharingIndicator: "", // either "Screen" or "Window"
 
-  get activeStreams() {
+  // The boolean parameters indicate which streams should be included in the result.
+  getActiveStreams: function(aCamera, aMicrophone, aScreen) {
     let contentWindowSupportsArray = MediaManagerService.activeMediaCaptureWindows;
     let count = contentWindowSupportsArray.Count();
     let activeStreams = [];
     for (let i = 0; i < count; i++) {
       let contentWindow = contentWindowSupportsArray.GetElementAt(i);
+
+      let camera = {}, microphone = {}, screen = {}, window = {};
+      MediaManagerService.mediaCaptureWindowState(contentWindow, camera,
+                                                  microphone, screen, window);
+      if (!(aCamera && camera.value ||
+            aMicrophone && microphone.value ||
+            aScreen && (screen.value || window.value)))
+        continue;
+
       let browser = getBrowserForWindow(contentWindow);
       let browserWindow = browser.ownerDocument.defaultView;
       let tab = browserWindow.gBrowser &&
                 browserWindow.gBrowser._getTabForContentWindow(contentWindow.top);
       activeStreams.push({
         uri: contentWindow.location.href,
         tab: tab,
         browser: browser