Skip to content

Commit

Permalink
[MediaStream] Add support for ImageCapture.getPhotoSettings
Browse files Browse the repository at this point in the history
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
eric-carlson committed Oct 5, 2023
1 parent d386e12 commit e3abeff
Show file tree
Hide file tree
Showing 30 changed files with 335 additions and 3 deletions.
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 LayoutTests/fast/mediastream/image-capture-get-photo-settings.html
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>
1 change: 1 addition & 0 deletions Source/WebCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ set(WebCore_NON_SVG_IDL_FILES
Modules/mediastream/OverconstrainedError.idl
Modules/mediastream/OverconstrainedErrorEvent.idl
Modules/mediastream/PhotoCapabilities.idl
Modules/mediastream/PhotoSettings.idl
Modules/mediastream/RTCAnswerOptions.idl
Modules/mediastream/RTCCertificate.idl
Modules/mediastream/RTCConfiguration.idl
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ JS_BINDING_IDLS := \
$(WebCore)/Modules/mediastream/OverconstrainedError.idl \
$(WebCore)/Modules/mediastream/OverconstrainedErrorEvent.idl \
$(WebCore)/Modules/mediastream/PhotoCapabilities.idl \
$(WebCore)/Modules/mediastream/PhotoSettings.idl \
$(WebCore)/Modules/mediastream/RedEyeReduction.idl \
$(WebCore)/Modules/mediastream/RTCAnswerOptions.idl \
$(WebCore)/Modules/mediastream/RTCCertificate.idl \
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/Headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/mediastream/MediaStreamTrackPrivate.h
platform/mediastream/MeteringMode.h
platform/mediastream/PhotoCapabilities.h
platform/mediastream/PhotoSettings.h
platform/mediastream/RedEyeReduction.h
platform/mediastream/RTCDataChannelHandler.h
platform/mediastream/RTCDataChannelHandlerClient.h
Expand Down
13 changes: 13 additions & 0 deletions Source/WebCore/Modules/mediastream/ImageCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ void ImageCapture::getPhotoCapabilities(PhotoCapabilitiesPromise&& promise)
m_track->getPhotoCapabilities(WTFMove(promise));
}

void ImageCapture::getPhotoSettings(PhotoSettingsPromise&& promise)
{
if (m_track->readyState() == MediaStreamTrack::State::Ended) {
// https://w3c.github.io/mediacapture-image/#ref-for-dom-imagecapture-getphotosettings②
// If the readyState of track provided in the constructor is not live, return a promise
// rejected with a new DOMException whose name is InvalidStateError, and abort these steps.
promise.reject(Exception { InvalidStateError, "Track has ended"_s });
return;
}

m_track->getPhotoSettings(WTFMove(promise));
}

const char* ImageCapture::activeDOMObjectName() const
{
return "ImageCapture";
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/Modules/mediastream/ImageCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "JSDOMPromiseDeferred.h"
#include "MediaStreamTrack.h"
#include "PhotoCapabilities.h"
#include "PhotoSettings.h"

namespace WebCore {

Expand All @@ -45,6 +46,9 @@ class ImageCapture : public RefCounted<ImageCapture>, public ActiveDOMObject {
using PhotoCapabilitiesPromise = DOMPromiseDeferred<IDLDictionary<PhotoCapabilities>>;
void getPhotoCapabilities(PhotoCapabilitiesPromise&&);

using PhotoSettingsPromise = DOMPromiseDeferred<IDLDictionary<PhotoSettings>>;
void getPhotoSettings(PhotoSettingsPromise&&);

Ref<MediaStreamTrack> track() const { return m_track; }

private:
Expand Down
3 changes: 1 addition & 2 deletions Source/WebCore/Modules/mediastream/ImageCapture.idl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=262467
// Promise<Blob> takePhoto(optional PhotoSettings photoSettings = {});

// FIXME: https://bugs.webkit.org/show_bug.cgi?id=262466
// Promise<PhotoSettings> getPhotoSettings();
Promise<PhotoSettings> getPhotoSettings();

readonly attribute MediaStreamTrack track;
};
27 changes: 27 additions & 0 deletions Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "JSMeteringMode.h"
#include "JSOverconstrainedError.h"
#include "JSPhotoCapabilities.h"
#include "JSPhotoSettings.h"
#include "LocalFrame.h"
#include "Logging.h"
#include "MediaConstraints.h"
Expand All @@ -58,6 +59,7 @@
#include "WebAudioSourceProvider.h"
#include <wtf/CompletionHandler.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/NativePromise.h>
#include <wtf/NeverDestroyed.h>

namespace WebCore {
Expand Down Expand Up @@ -323,11 +325,36 @@ void MediaStreamTrack::getPhotoCapabilities(DOMPromiseDeferred<IDLDictionary<Pho
promise.reject(Exception { OperationError, WTFMove(result.errorMessage) });
return;
}
if (protectedThis->m_readyState != State::Live) {
promise.reject(Exception { OperationError, "Track has ended"_s });
return;
}

promise.resolve(WTFMove(*result.capabilities));
});
}

void MediaStreamTrack::getPhotoSettings(DOMPromiseDeferred<IDLDictionary<PhotoSettings>>&& promise) const
{
m_private->getPhotoSettings()->whenSettled(RunLoop::main(), [protectedThis = Ref { *this }, promise = WTFMove(promise)] (auto&& result) mutable {

// https://w3c.github.io/mediacapture-image/#ref-for-dom-imagecapture-getphotosettings②
// If the data cannot be gathered for any reason (for example, the MediaStreamTrack being ended
// asynchronously), then reject p with a new DOMException whose name is OperationError, and
// abort these steps.
if (!result) {
promise.reject(Exception { OperationError, WTFMove(result.error()) });
return;
}
if (protectedThis->m_readyState != State::Live) {
promise.reject(Exception { OperationError, "Track has ended"_s });
return;
}

promise.resolve(WTFMove(result.value()));
});
}

static MediaConstraints createMediaConstraints(const std::optional<MediaTrackConstraints>& constraints)
{
if (!constraints) {
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "MediaTrackCapabilities.h"
#include "MediaTrackConstraints.h"
#include "PhotoCapabilities.h"
#include "PhotoSettings.h"
#include "PlatformMediaSession.h"
#include <wtf/LoggerHelper.h>

Expand Down Expand Up @@ -130,6 +131,7 @@ class MediaStreamTrack
TrackCapabilities getCapabilities() const;

void getPhotoCapabilities(DOMPromiseDeferred<IDLDictionary<PhotoCapabilities>>&&) const;
void getPhotoSettings(DOMPromiseDeferred<IDLDictionary<PhotoSettings>>&&) const;

const MediaTrackConstraints& getConstraints() const { return m_constraints; }
void setConstraints(MediaTrackConstraints&& constraints) { m_constraints = WTFMove(constraints); }
Expand Down
35 changes: 35 additions & 0 deletions Source/WebCore/Modules/mediastream/PhotoSettings.idl
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;
};
1 change: 1 addition & 0 deletions Source/WebCore/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3966,6 +3966,7 @@ JSPermissionState.cpp
JSPermissionStatus.cpp
JSPermissions.cpp
JSPhotoCapabilities.cpp
JSPhotoSettings.cpp
JSPictureInPictureEvent.cpp
JSPictureInPictureWindow.cpp
JSPlaneLayout.cpp
Expand Down
12 changes: 12 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
073930DC2AC6452800C1D1B1 /* MeteringMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 073930DB2AC6452700C1D1B1 /* MeteringMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
073930DE2AC6478C00C1D1B1 /* MediaSettingsRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 073930DD2AC6478B00C1D1B1 /* MediaSettingsRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
073930E02AC6490B00C1D1B1 /* PhotoCapabilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 073930DF2AC6490B00C1D1B1 /* PhotoCapabilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
073931172ACC6D1E00C1D1B1 /* PhotoSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 073931162ACC6D1D00C1D1B1 /* PhotoSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
0739311A2ACCBF3C00C1D1B1 /* JSPhotoSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 073931182ACCBF3B00C1D1B1 /* JSPhotoSettings.h */; };
073955BB27AB277F009A08D2 /* ScreenCaptureKitSharingSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 07035D3227A9B60B00FB03E4 /* ScreenCaptureKitSharingSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
073B87671E4385AC0071C0EC /* AudioSampleBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87631E43859D0071C0EC /* AudioSampleBufferList.h */; settings = {ATTRIBUTES = (Private, ); }; };
073B87691E4385AC0071C0EC /* AudioSampleDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 073B87651E43859D0071C0EC /* AudioSampleDataSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -6735,6 +6737,10 @@
073930DB2AC6452700C1D1B1 /* MeteringMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeteringMode.h; sourceTree = "<group>"; };
073930DD2AC6478B00C1D1B1 /* MediaSettingsRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSettingsRange.h; sourceTree = "<group>"; };
073930DF2AC6490B00C1D1B1 /* PhotoCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoCapabilities.h; sourceTree = "<group>"; };
073931142ACC6CEE00C1D1B1 /* PhotoSettings.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PhotoSettings.idl; sourceTree = "<group>"; };
073931162ACC6D1D00C1D1B1 /* PhotoSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoSettings.h; sourceTree = "<group>"; };
073931182ACCBF3B00C1D1B1 /* JSPhotoSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSPhotoSettings.h; path = JSPhotoSettings.h; sourceTree = "<group>"; };
073931192ACCBF3B00C1D1B1 /* JSPhotoSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSPhotoSettings.cpp; path = JSPhotoSettings.cpp; sourceTree = "<group>"; };
073B87561E40DCE50071C0EC /* AudioStreamDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioStreamDescription.h; sourceTree = "<group>"; };
073B87571E40DCFD0071C0EC /* CAAudioStreamDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CAAudioStreamDescription.cpp; sourceTree = "<group>"; };
073B87581E40DCFD0071C0EC /* CAAudioStreamDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAAudioStreamDescription.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -20493,6 +20499,7 @@
41E408381DCB747900EFCE19 /* PeerConnectionBackend.cpp */,
5E2C434D1BCEE2E50001E2BC /* PeerConnectionBackend.h */,
073FF3A12AC4C96D0099275E /* PhotoCapabilities.idl */,
073931142ACC6CEE00C1D1B1 /* PhotoSettings.idl */,
073FF37F2AC3ADED0099275E /* RedEyeReduction.idl */,
316DCB2B1E78F3A9001B5F87 /* RTCAnswerOptions.h */,
316DCB2C1E78F3A9001B5F87 /* RTCAnswerOptions.idl */,
Expand Down Expand Up @@ -20720,6 +20727,7 @@
073930DB2AC6452700C1D1B1 /* MeteringMode.h */,
5EBB89381C77BDA400C65D41 /* PeerMediaDescription.h */,
073930DF2AC6490B00C1D1B1 /* PhotoCapabilities.h */,
073931162ACC6D1D00C1D1B1 /* PhotoSettings.h */,
41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */,
41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */,
5CDD83391E4324BB00621E92 /* RealtimeIncomingVideoSource.cpp */,
Expand Down Expand Up @@ -20916,6 +20924,8 @@
0704A4141D6F39FB0086DCDB /* JSOverconstrainedErrorEvent.h */,
073930BB2AC4D2CA00C1D1B1 /* JSPhotoCapabilities.cpp */,
073930B72AC4D29E00C1D1B1 /* JSPhotoCapabilities.h */,
073931192ACCBF3B00C1D1B1 /* JSPhotoSettings.cpp */,
073931182ACCBF3B00C1D1B1 /* JSPhotoSettings.h */,
073FF3862AC4825E0099275E /* JSRedEyeReduction.cpp */,
073FF3872AC4825E0099275E /* JSRedEyeReduction.h */,
316DCB2D1E78F496001B5F87 /* JSRTCAnswerOptions.cpp */,
Expand Down Expand Up @@ -39630,6 +39640,7 @@
8A9A588811E84F37008ACFD1 /* JSPerformanceTiming.h in Headers */,
FDEA6247152102FC00479DF0 /* JSPeriodicWave.h in Headers */,
073930B92AC4D29F00C1D1B1 /* JSPhotoCapabilities.h in Headers */,
0739311A2ACCBF3C00C1D1B1 /* JSPhotoSettings.h in Headers */,
1D0026A42374D62400CA6CDF /* JSPictureInPictureWindow.h in Headers */,
712BE4891FE86875002031CC /* JSPlaybackDirection.h in Headers */,
93B70D6C09EB0C7C009D8468 /* JSPluginElementFunctions.h in Headers */,
Expand Down Expand Up @@ -40628,6 +40639,7 @@
93B0A65626CDD14100AA21E4 /* PermissionStatus.h in Headers */,
49D5DC2E0F423A73008F20FD /* PerspectiveTransformOperation.h in Headers */,
073930E02AC6490B00C1D1B1 /* PhotoCapabilities.h in Headers */,
073931172ACC6D1E00C1D1B1 /* PhotoSettings.h in Headers */,
1D2F8E042344751600993B68 /* PictureInPictureEvent.h in Headers */,
1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */,
1D2C82B7236A3F6A0055D6C5 /* PictureInPictureSupport.h in Headers */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "IntRect.h"
#include "Logging.h"
#include "PlatformMediaSessionManager.h"
#include <wtf/NativePromise.h>
#include <wtf/UUID.h>

#if PLATFORM(COCOA)
Expand Down Expand Up @@ -188,6 +189,11 @@ void MediaStreamTrackPrivate::getPhotoCapabilities(RealtimeMediaSource::PhotoCap
m_source->getPhotoCapabilities(WTFMove(completion));
}

Ref<RealtimeMediaSource::PhotoSettingsNativePromise> MediaStreamTrackPrivate::getPhotoSettings()
{
return m_source->getPhotoSettings();
}

void MediaStreamTrackPrivate::applyConstraints(const MediaConstraints& constraints, RealtimeMediaSource::ApplyConstraintsHandler&& completionHandler)
{
m_source->applyConstraints(constraints, WTFMove(completionHandler));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class MediaStreamTrackPrivate final
const RealtimeMediaSourceCapabilities& capabilities() const;

void getPhotoCapabilities(RealtimeMediaSource::PhotoCapabilitiesHandler&&);
Ref<RealtimeMediaSource::PhotoSettingsNativePromise> getPhotoSettings();

void applyConstraints(const MediaConstraints&, RealtimeMediaSource::ApplyConstraintsHandler&&);

Expand Down
44 changes: 44 additions & 0 deletions Source/WebCore/platform/mediastream/PhotoSettings.h
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
Loading

0 comments on commit e3abeff

Please sign in to comment.