Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not take into account device orientation for cameras whose positio…
…n is unspecified https://bugs.webkit.org/show_bug.cgi?id=255448 rdar://problem/108043783 Reviewed by Eric Carlson. Skip orientation monitoring in case facing mode is unspecified, as this means the sensor is not guaranteed to be attached to the device. Update mock infrastructure accordingly and allow to add cameras with undefined facing mode. Covered by added test. * LayoutTests/fast/mediastream/camera-unknown-facing-mode-expected.txt: Added. * LayoutTests/fast/mediastream/camera-unknown-facing-mode.html: Added. * Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::AVVideoCaptureSource::monitorOrientation): * Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::capabilities): (WebCore::MockRealtimeVideoSource::settings): (WebCore::MockRealtimeVideoSource::monitorOrientation): * Source/WebKit/UIProcess/API/C/WKMockMediaDevice.cpp: (WKAddMockMediaDevice): * Source/WebKit/UIProcess/API/C/WKMockMediaDevice.h: * Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::addMockMediaDevice): (WTR::TestRunner::addMockCameraDevice): (WTR::TestRunner::addMockMicrophoneDevice): (WTR::TestRunner::addMockScreenDevice): * Tools/WebKitTestRunner/InjectedBundle/TestRunner.h: * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::addMockMediaDevice): * Tools/WebKitTestRunner/TestController.h: * Tools/WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): Canonical link: https://commits.webkit.org/263018@main
- Loading branch information
Showing
12 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
LayoutTests/fast/mediastream/camera-unknown-facing-mode-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,5 @@ | ||
|
||
|
||
PASS Width and height before and after rotation with default device | ||
PASS Width and height before and after rotation with new device | ||
|
79 changes: 79 additions & 0 deletions
79
LayoutTests/fast/mediastream/camera-unknown-facing-mode.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!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(); | ||
testRunner.setMockCameraOrientation(0); | ||
}); | ||
} | ||
|
||
async function getSettingsBeforeAndAfterRotation(deviceId) | ||
{ | ||
testRunner.setMockCameraOrientation(0); | ||
|
||
const stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId } }); | ||
video.srcObject = stream; | ||
await video.play(); | ||
|
||
const track = stream.getVideoTracks()[0]; | ||
const initialSettings = track.getSettings(); | ||
|
||
video.srcObject = null; | ||
|
||
testRunner.setMockCameraOrientation(90); | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
|
||
video.srcObject = stream; | ||
await video.play(); | ||
|
||
return [initialSettings, track.getSettings()]; | ||
} | ||
|
||
promise_test(async (test) => { | ||
await setup(test); | ||
|
||
const results = await getSettingsBeforeAndAfterRotation("default"); | ||
|
||
assert_equals(results[0].facingMode, "user"); | ||
assert_equals(results[0].width, 640, "initial width"); | ||
assert_equals(results[0].height, 480, "initial height"); | ||
assert_equals(results[1].width, 480, "final width"); | ||
assert_equals(results[1].height, 640, "final height"); | ||
}, "Width and height before and after rotation with default device"); | ||
|
||
promise_test(async (test) => { | ||
await setup(test); | ||
|
||
testRunner.addMockCameraDevice("myCamera", "my new camera", { facingMode: "unknown", fillColor: "green" }); | ||
const stream = await navigator.mediaDevices.getUserMedia({ video: true }); | ||
|
||
const devices = await navigator.mediaDevices.enumerateDevices(); | ||
let deviceId = ""; | ||
devices.forEach(device => { | ||
if (device.label == "my new camera") | ||
deviceId = device.deviceId; | ||
}); | ||
stream.getVideoTracks()[0].stop(); | ||
|
||
const results = await getSettingsBeforeAndAfterRotation(deviceId); | ||
|
||
assert_equals(results[0].facingMode, undefined); | ||
assert_equals(results[0].width, 640, "initial width"); | ||
assert_equals(results[0].height, 480, "initial height"); | ||
assert_equals(results[1].width, 640, "final width"); | ||
assert_equals(results[1].height, 480, "final height"); | ||
}, "Width and height before and after rotation with new device"); | ||
</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
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