commit | 2538ba1dc66c1a9ab694bc167c5d56293dae7e8e | [log] [tgz] |
---|---|---|
author | eric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Wed Jan 26 05:22:19 2022 +0000 |
committer | eric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Wed Jan 26 05:22:19 2022 +0000 |
tree | fc970e2ae8ee7049227f3297790a7efccbe58b48 | |
parent | 60c3f717a9141a0f8afd6e8437d26c6404e4424c [diff] |
[macOS] Add new screen and window capture backend https://bugs.webkit.org/show_bug.cgi?id=234029 Source/WebCore: rdar://problem/86347726 Reviewed by Jer Noble and Youenn Fablet. New API test: GetDisplayMediaWindowAndScreen.mm * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: * en.lproj/Localizable.strings: Add strings for window and screen prompts. * platform/mediastream/MediaConstraints.h: (WebCore::StringConstraint::getExact const): Drive-by: fix logic inversion bug. (WebCore::StringConstraint::getIdeal const): Ditto. * platform/mediastream/RealtimeMediaSource.cpp: (WebCore::RealtimeMediaSource::fitnessDistance): Assert if device ID constraint is not a string. * platform/mediastream/RealtimeMediaSourceCenter.h: (WebCore::RealtimeMediaSourceCenter::useScreenCaptureKit const): (WebCore::RealtimeMediaSourceCenter::setUseScreenCaptureKit): (WebCore::RealtimeMediaSourceCenter::useMockCaptureDevices const): (WebCore::RealtimeMediaSourceCenter::setUseMockCaptureDevices): * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.cpp: (WebCore::DisplayCaptureSourceCocoa::create): (WebCore::DisplayCaptureSourceCocoa::DisplayCaptureSourceCocoa): (WebCore::DisplayCaptureSourceCocoa::Capturer::setObserver): (WebCore::DisplayCaptureSourceCocoa::Capturer::capturerIsRunningChanged): Deleted. * platform/mediastream/cocoa/DisplayCaptureSourceCocoa.h: (WebCore::CapturerObserver::capturerIsRunningChanged): (WebCore::CapturerObserver::capturerFailed): * platform/mediastream/ios/ReplayKitCaptureSource.mm: (WebCore::ReplayKitCaptureSource::captureStateDidChange): * platform/mediastream/mac/DisplayCaptureManagerCocoa.cpp: (WebCore::DisplayCaptureManagerCocoa::updateDisplayCaptureDevices): Use ScreenCaptureKitCaptureSource when available. (WebCore::DisplayCaptureManagerCocoa::updateWindowCaptureDevices): Ditto. (WebCore::DisplayCaptureManagerCocoa::screenCaptureDeviceWithPersistentID): Ditto. (WebCore::DisplayCaptureManagerCocoa::windowCaptureDeviceWithPersistentID): Ditto. * platform/mediastream/mac/ScreenCaptureKitCaptureSource.h: Added. * platform/mediastream/mac/ScreenCaptureKitCaptureSource.mm: Added. (-[WebCoreScreenCaptureKitHelper initWithCallback:]): (-[WebCoreScreenCaptureKitHelper disconnect]): (-[WebCoreScreenCaptureKitHelper stream:didStopWithError:]): (WebCore::usingOldAPI): (WebCore::ScreenCaptureKitCaptureSource::isAvailable): (WebCore::ScreenCaptureKitCaptureSource::create): (WebCore::ScreenCaptureKitCaptureSource::ScreenCaptureKitCaptureSource): (WebCore::ScreenCaptureKitCaptureSource::~ScreenCaptureKitCaptureSource): (WebCore::ScreenCaptureKitCaptureSource::start): (WebCore::ScreenCaptureKitCaptureSource::stop): (WebCore::ScreenCaptureKitCaptureSource::streamFailedWithError): (WebCore::ScreenCaptureKitCaptureSource::generateFrame): (WebCore::ScreenCaptureKitCaptureSource::processSharableContent): (WebCore::ScreenCaptureKitCaptureSource::findShareableContent): (WebCore::ScreenCaptureKitCaptureSource::streamConfiguration): (WebCore::ScreenCaptureKitCaptureSource::startContentStream): (WebCore::ScreenCaptureKitCaptureSource::intrinsicSize const): (WebCore::ScreenCaptureKitCaptureSource::updateStreamConfiguration): (WebCore::ScreenCaptureKitCaptureSource::commitConfiguration): (WebCore::ScreenCaptureKitCaptureSource::captureQueue): (WebCore::ScreenCaptureKitCaptureSource::frameAvailableHandler): (WebCore::ScreenCaptureKitCaptureSource::deviceType const): (WebCore::ScreenCaptureKitCaptureSource::surfaceType const): (WebCore::ScreenCaptureKitCaptureSource::screenCaptureDeviceWithPersistentID): (WebCore::ScreenCaptureKitCaptureSource::screenCaptureDevices): (WebCore::ScreenCaptureKitCaptureSource::windowCaptureDeviceWithPersistentID): (WebCore::ScreenCaptureKitCaptureSource::windowCaptureDevices): (WebCore::ScreenCaptureKitCaptureSource::forEachNSWindow): * platform/mock/MockMediaDevice.h: (WebCore::MockMediaDevice::captureDevice const): Make devices enabled by default. Initialize screen and window devices with the correct type. * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::defaultDevices): Fix window device types. (WebCore::MockRealtimeMediaSourceCenter::displayDevices): * platform/mock/MockRealtimeMediaSourceCenter.h: Source/WebCore/PAL: rdar://problem/86347726 Reviewed by Jer Noble and Youenn Fablet. * PAL.xcodeproj/project.pbxproj: * pal/mac/ScreenCaptureKitSoftLink.h: Added. * pal/mac/ScreenCaptureKitSoftLink.mm: Added. Source/WebKit: rdar://problem/86347726 Reviewed by Jer Noble and Youenn Fablet. * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultScreenCaptureKitEnabled): * Shared/WebPreferencesDefaultValues.h: * SourcesCocoa.txt: * UIProcess/API/Cocoa/WKPreferences.mm: Add _useScreenCaptureKit private preference. (-[WKPreferences _useScreenCaptureKit]): (-[WKPreferences _setUseScreenCaptureKit:]): * UIProcess/API/Cocoa/WKPreferencesPrivate.h: * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Add private delegate for a getDisplayMedia-specific prompt. * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _setIndexOfGetDisplayMediaDeviceSelectedForTesting:]): Set the index of the screen or window device to return for getDisplayMedia without prompting. * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::UIClient::promptForDisplayCapturePermission): Call new screen/window capture delegate. (WebKit::UIDelegate::UIClient::decidePolicyForUserMediaPermissionRequest): * UIProcess/UserMediaPermissionRequestProxy.cpp: (WebKit::UserMediaPermissionRequestProxy::create): (WebKit::UserMediaPermissionRequestProxy::promptForGetDisplayMedia): Add parameter specifying a window or screen capture prompt. * UIProcess/UserMediaPermissionRequestProxy.h: (WebKit::UserMediaPermissionRequestProxy::create): (WebKit::UserMediaPermissionRequestProxy::manager const): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::setIndexOfGetDisplayMediaDeviceSelectedForTesting): * UIProcess/WebPageProxy.h: * UIProcess/mac/DisplayCaptureSessionManager.h: Added. (WebKit::DisplayCaptureSessionManager::setIndexOfDeviceSelectedForTesting): * UIProcess/mac/DisplayCaptureSessionManager.mm: Added. (WebKit::getMockWindowList): (WebKit::getCGWindowList): (WebKit::getWindowList): (WebKit::alertForWindowSelection): (WebKit::DisplayCaptureSessionManager::alertForGetDisplayMedia): (WebKit::DisplayCaptureSessionManager::isAvailable): (WebKit::DisplayCaptureSessionManager::singleton): (WebKit::DisplayCaptureSessionManager::DisplayCaptureSessionManager): (WebKit::DisplayCaptureSessionManager::~DisplayCaptureSessionManager): (WebKit::DisplayCaptureSessionManager::promptForGetDisplayMedia): (WebKit::DisplayCaptureSessionManager::deviceSelectedForTesting): (WebKit::DisplayCaptureSessionManager::showWindowPicker): (WebKit::DisplayCaptureSessionManager::showScreenPicker): * UIProcess/mac/UserMediaPermissionRequestProxyMac.h: Added. * UIProcess/mac/UserMediaPermissionRequestProxyMac.mm: Added. (WebKit::UserMediaPermissionRequestProxy::create): (WebKit::UserMediaPermissionRequestProxyMac::UserMediaPermissionRequestProxyMac): (WebKit::UserMediaPermissionRequestProxyMac::~UserMediaPermissionRequestProxyMac): (WebKit::UserMediaPermissionRequestProxyMac::promptForGetDisplayMedia): (WebKit::UserMediaPermissionRequestProxyMac::canPromptForGetDisplayMedia): * WebKit.xcodeproj/project.pbxproj: Source/WTF: rdar://problem/86347726 Reviewed by Jer Noble and Youenn Fablet. * Scripts/Preferences/WebPreferencesExperimental.yaml: Add UseScreenCaptureKit. * wtf/PlatformEnableCocoa.h: Define ENABLE_SCREEN_CAPTURE_KIT. * wtf/PlatformHave.h: Define HAVE_SCREEN_CAPTURE_KIT. * wtf/cocoa/SoftLinking.h: Add softlink macros that take an API_AVAILABLE check. Tools: Reviewed by Jer Noble and Youenn Fablet. * TestWebKitAPI/SourcesCocoa.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/GetDisplayMediaWindowAndScreen.mm: Added. (-[WindowAndScreenCaptureTestView haveStream:]): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewUnderPageBackgroundColor.mm: (TEST): * TestWebKitAPI/Tests/WebKitCocoa/WebProcessTerminate.mm: * TestWebKitAPI/cocoa/UserMediaCaptureUIDelegate.h: * TestWebKitAPI/cocoa/UserMediaCaptureUIDelegate.mm: (-[UserMediaCaptureUIDelegate init]): (-[UserMediaCaptureUIDelegate setGetDisplayMediaDecision:]): (-[UserMediaCaptureUIDelegate _webView:requestDisplayCapturePermissionForOrigin:initiatedByFrame:decisionHandler:]): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288604 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git@github.com:WebKit/WebKit.git WebKit
or
git clone https://github.com/WebKit/WebKit.git WebKit
If you want to be able to track Subversion revision from your git checkout, you can run the following command to do so:
Tools/Scripts/git-webkit setup-git-svn
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead.
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild
directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild
for both Products and Intermediates.
iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:
sudo Tools/Scripts/configure-xcode-for-embedded-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for embedded simulators:
Tools/Scripts/build-webkit --debug --<platform>-simulator
or embedded devices:
Tools/Scripts/build-webkit --debug --<platform>-device
where platform
is ios
, tvos
or watchos
.
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.