diff --git a/browser/base/content/test/webrtc/head.js b/browser/base/content/test/webrtc/head.js index c033152f637d..c02174dbb835 100644 --- a/browser/base/content/test/webrtc/head.js +++ b/browser/base/content/test/webrtc/head.js @@ -5,6 +5,7 @@ const PREF_PERMISSION_FAKE = "media.navigator.permission.fake"; const PREF_AUDIO_LOOPBACK = "media.audio_loopback_dev"; const PREF_VIDEO_LOOPBACK = "media.video_loopback_dev"; const PREF_FAKE_STREAMS = "media.navigator.streams.fake"; +const PREF_FOCUS_SOURCE = "media.getusermedia.window.focus_source.enabled"; const CONTENT_SCRIPT_HELPER = getRootDirectory(gTestPath) + "get_user_media_content_script.js"; const STATE_CAPTURE_ENABLED = Ci.nsIMediaManagerService.STATE_CAPTURE_ENABLED; @@ -574,7 +575,8 @@ async function runTests(tests, options = {}) { [PREF_PERMISSION_FAKE, true], [PREF_AUDIO_LOOPBACK, ""], [PREF_VIDEO_LOOPBACK, ""], - [PREF_FAKE_STREAMS, true] + [PREF_FAKE_STREAMS, true], + [PREF_FOCUS_SOURCE, false] ]; await SpecialPowers.pushPrefEnv({"set": prefs}); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 681f47d99c04..ab7fd9900266 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1636,7 +1636,8 @@ public: MediaEnginePrefs& aPrefs, const ipc::PrincipalInfo& aPrincipalInfo, bool aIsChrome, - MediaManager::SourceSet* aSourceSet) + MediaManager::SourceSet* aSourceSet, + bool aShouldFocusSource) : Runnable("GetUserMediaTask") , mConstraints(aConstraints) , mOnSuccess(aOnSuccess) @@ -1647,6 +1648,7 @@ public: , mPrefs(aPrefs) , mPrincipalInfo(aPrincipalInfo) , mIsChrome(aIsChrome) + , mShouldFocusSource(aShouldFocusSource) , mDeviceChosen(false) , mSourceSet(aSourceSet) , mManager(MediaManager::GetInstance()) @@ -1719,9 +1721,12 @@ public: } } else { if (!mIsChrome) { - rv = mVideoDevice->FocusOnSelectedSource(); - if (NS_FAILED(rv)) { - LOG(("FocusOnSelectedSource failed")); + if (mShouldFocusSource) { + rv = mVideoDevice->FocusOnSelectedSource(); + + if (NS_FAILED(rv)) { + LOG(("FocusOnSelectedSource failed")); + } } } } @@ -1833,6 +1838,7 @@ private: MediaEnginePrefs mPrefs; ipc::PrincipalInfo mPrincipalInfo; bool mIsChrome; + bool mShouldFocusSource; bool mDeviceChosen; public: @@ -2889,6 +2895,9 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, } } + bool focusSource; + focusSource = mozilla::Preferences::GetBool("media.getusermedia.window.focus_source.enabled", true); + // Pass callbacks and listeners along to GetUserMediaTask. RefPtr task (new GetUserMediaTask(c, onSuccess, @@ -2899,7 +2908,8 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow, prefs, principalInfo, isChrome, - devices->release())); + devices->release(), + focusSource)); // Store the task w/callbacks. self->mActiveCallbacks.Put(callID, task.forget()); diff --git a/dom/media/tests/mochitest/head.js b/dom/media/tests/mochitest/head.js index 8798795f2d0d..6fd80abba209 100644 --- a/dom/media/tests/mochitest/head.js +++ b/dom/media/tests/mochitest/head.js @@ -418,8 +418,9 @@ function setupEnvironment() { // If either fake audio or video is desired we enable fake streams. // If loopback devices are set they will be chosen instead of fakes in gecko. ['media.navigator.streams.fake', WANT_FAKE_AUDIO || WANT_FAKE_VIDEO], - ['media.getusermedia.screensharing.enabled', true], ['media.getusermedia.audiocapture.enabled', true], + ['media.getusermedia.screensharing.enabled', true], + ['media.getusermedia.window.focus_source.enabled', false], ['media.recorder.audio_node.enabled', true], ['media.webaudio.audiocontextoptions-samplerate.enabled', true] ]