Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Default camera whose facingMode is unknown should be selected by getU…
…serMedia if there is no facingMode constraint https://bugs.webkit.org/show_bug.cgi?id=255451 rdar://problem/108045715 Reviewed by Eric Carlson. Remove the facingMode constraint that was added by default to favor user facing cameras. Instead, we now rely on the order of camera devices, which should favor the front camera over the background cameras by default. If another camera becomes the default camera, we will favor this camera. Selection of the default camera in case fitness distance is the same is guaranteed by the fact we are using a stable sort. We update RealtimeMediaSource::selectSettings as not setting anymore the facing mode might end up with empty candidates in RealtimeMediaSource::selectSettings in the case there is no provided mandatory constraints but advanced constraints are added. In this case, we should not have empty candidates but all possible candidates, hence why we remove the early return defined in the spec. Update test infrastructure so that adding a mock camera that has an unknown facing mode will make this camera the default camera. Covered by LayoutTests/fast/mediastream/default-camera-test.html. Updating LayoutTests/fast/mediastream/getUserMedia-default.html to expect 60fps since ideal is set to 60 fps and this constraint no longer competes with facingMode constraint. * LayoutTests/fast/mediastream/default-camera-test-expected.txt: Added. * LayoutTests/fast/mediastream/default-camera-test.html: Added. * LayoutTests/fast/mediastream/getUserMedia-default.html: * Source/WebCore/platform/mediastream/MediaConstraints.cpp: (WebCore::addDefaultVideoConstraints): (WebCore::MediaConstraints::setDefaultVideoConstraints): * Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp: (WebCore::RealtimeMediaSource::selectSettings): * Source/WebCore/platform/mock/MockMediaDevice.h: (WebCore::MockMediaDevice::cameraProperties const): * Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::createMockDevice): (WebCore::MockRealtimeMediaSourceCenter::setDevices): (WebCore::shouldBeDefaultDevice): (WebCore::MockRealtimeMediaSourceCenter::addDevice): Canonical link: https://commits.webkit.org/263022@main
- Loading branch information
Showing
7 changed files
with
70 additions
and
21 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
LayoutTests/fast/mediastream/default-camera-test-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
PASS Check default cameras in case of default device having an unknown facing mode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id="video"></video> | ||
<script> | ||
let setup = async (test) => { | ||
if (!window.testRunner) | ||
return Promise.reject("test requires internal API"); | ||
|
||
test.add_cleanup(() => { | ||
testRunner.resetMockMediaDevices(); | ||
}); | ||
} | ||
|
||
promise_test(async (test) => { | ||
await setup(test); | ||
|
||
// camera device should be the default device. | ||
testRunner.addMockCameraDevice("myCamera", "my new camera", { facingMode: "unknown", fillColor: "green" }); | ||
|
||
let stream = await navigator.mediaDevices.getUserMedia({ video: true }); | ||
assert_equals(stream.getVideoTracks()[0].label, "my new camera"); | ||
|
||
stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'user' } }); | ||
assert_equals(stream.getVideoTracks()[0].label, "Mock video device 1"); | ||
|
||
stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } }); | ||
assert_equals(stream.getVideoTracks()[0].label, "Mock video device 2"); | ||
}, "Check default cameras in case of default device having an unknown facing mode"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters