Bug 1037408 - webrtcUI's activeStreams getter should be able to return lists for a specific device type, r=dolske.

This commit is contained in:
Florian Quèze 2014-07-19 02:49:19 +02:00
parent 522e7af0ea
commit 802e1cdb49
2 changed files with 12 additions and 2 deletions

View File

@ -23,7 +23,7 @@ let WebrtcIndicator = {
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");

View File

@ -38,12 +38,22 @@ this.webrtcUI = {
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 &&