-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MediaStream] Add support for ImageCapture.getPhotoSettings
https://bugs.webkit.org/show_bug.cgi?id=262466 rdar://116322614 Reviewed by Youenn Fablet. Add ImageCapture.getPhotoSettings and implement support in MockRealtimeVideoSource and AVVideoCaptureSource. * LayoutTests/fast/mediastream/image-capture-get-photo-settings-expected.txt: Added. * LayoutTests/fast/mediastream/image-capture-get-photo-settings.html: Added. * Source/WebCore/DerivedSources.make: * Source/WebCore/Modules/mediastream/ImageCapture.cpp: (WebCore::ImageCapture::getPhotoSettings): * Source/WebCore/Modules/mediastream/ImageCapture.h: * Source/WebCore/Modules/mediastream/ImageCapture.idl: * Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::getPhotoSettings const): * Source/WebCore/Modules/mediastream/MediaStreamTrack.h: * Source/WebCore/Modules/mediastream/PhotoSettings.idl: Added. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp: (WebCore::MediaStreamTrackPrivate::getPhotoSettings): * Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h: * Source/WebCore/platform/mediastream/PhotoSettings.h: Added. * Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp: (WebCore::RealtimeMediaSource::getPhotoSettings): * Source/WebCore/platform/mediastream/RealtimeMediaSource.h: (WebCore::PhotoSettingsOrError::PhotoSettingsOrError): (WebCore::PhotoSettingsOrError::operator bool const): * Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h: * Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::toFillLightMode): (WebCore::AVVideoCaptureSource::getPhotoSettings): * Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::getPhotoSettings): (WebCore::MockRealtimeVideoSource::settingsDidChange): * Source/WebCore/platform/mock/MockRealtimeVideoSource.h: * Source/WebKit/Scripts/webkit/messages.py: (headers_for_type): * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::SourceProxy::getPhotoSettings): (WebKit::UserMediaCaptureManagerProxy::getPhotoSettings): * Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: * Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSource.cpp: (WebKit::RemoteRealtimeMediaSource::getPhotoSettings): * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSource.h: * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp: (WebKit::RemoteRealtimeMediaSourceProxy::getPhotoSettings): * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.h: Canonical link: https://commits.webkit.org/268945@main
- Loading branch information
1 parent
d386e12
commit e3abeff
Showing
30 changed files
with
335 additions
and
3 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
LayoutTests/fast/mediastream/image-capture-get-photo-settings-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,6 @@ | ||
|
||
|
||
PASS getPhotoSettings() on an 'ended' track should throw "InvalidStateError" | ||
PASS "OperationError" should be thrown if the track ends before the promise resolves | ||
PASS Check getPhotoSettings() | ||
|
62 changes: 62 additions & 0 deletions
62
LayoutTests/fast/mediastream/image-capture-get-photo-settings.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,62 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset='utf-8'> | ||
<title>ImageCapture getPhotoSettings</title> | ||
<script src='../../resources/testharness.js'></script> | ||
<script src='../../resources/testharnessreport.js'></script> | ||
</head> | ||
<body> | ||
<video controls autoplay width=640 height=480 playsInline id='video'></video> | ||
<script> | ||
|
||
promise_test(async (test) => { | ||
const stream = await navigator.mediaDevices.getUserMedia({ video: { width : 640 } }); | ||
const [track] = stream.getVideoTracks(); | ||
|
||
assert_equals(track.readyState, 'live'); | ||
track.stop(); | ||
assert_equals(track.readyState, 'ended'); | ||
|
||
const imageCapture = new ImageCapture(track); | ||
return promise_rejects_dom(test, 'InvalidStateError', imageCapture.getPhotoSettings()) | ||
|
||
}, `getPhotoSettings() on an 'ended' track should throw "InvalidStateError"`); | ||
|
||
promise_test(async (test) => { | ||
const stream = await navigator.mediaDevices.getUserMedia({ video: { width : 640 } }); | ||
const [track] = stream.getVideoTracks(); | ||
|
||
assert_equals(track.readyState, 'live'); | ||
|
||
const imageCapture = new ImageCapture(track); | ||
const promise = imageCapture.getPhotoSettings(); | ||
|
||
track.stop(); | ||
assert_equals(track.readyState, 'ended'); | ||
|
||
return promise_rejects_dom(test, 'OperationError', promise); | ||
|
||
}, `"OperationError" should be thrown if the track ends before the promise resolves`); | ||
|
||
promise_test(async (test) => { | ||
const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 640, torch : true } }); | ||
const [track] = stream.getVideoTracks(); | ||
|
||
const imageCapture = new ImageCapture(track); | ||
let photoSettings = await imageCapture.getPhotoSettings(); | ||
const trackSettings = track.getSettings(); | ||
|
||
assert_equals(photoSettings.imageHeight, trackSettings.height); | ||
assert_equals(photoSettings.imageWidth, trackSettings.width); | ||
assert_equals(photoSettings.fillLightMode, 'flash'); | ||
|
||
await track.applyConstraints({ torch : false }); | ||
photoSettings = await imageCapture.getPhotoSettings(); | ||
assert_equals(photoSettings.fillLightMode, 'off'); | ||
|
||
}, `Check getPhotoSettings()`); | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY | ||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
// https://w3c.github.io/mediacapture-image/#photosettings-section | ||
|
||
[ | ||
Conditional=MEDIA_STREAM, | ||
JSGenerateToJSObject | ||
] dictionary PhotoSettings { | ||
FillLightMode fillLightMode; | ||
double imageHeight; | ||
double imageWidth; | ||
boolean redEyeReduction; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY | ||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(MEDIA_STREAM) | ||
|
||
#include <optional> | ||
|
||
namespace WebCore { | ||
|
||
enum class FillLightMode : uint8_t; | ||
|
||
struct PhotoSettings { | ||
std::optional<FillLightMode> fillLightMode; | ||
std::optional<double> imageHeight; | ||
std::optional<double> imageWidth; | ||
std::optional<bool> redEyeReduction; | ||
}; | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.