Add desktop-capture option for ScreenCaptureKit on macOS.
This option will allow clients to control which ScreenCapturer is used, for versions of macOS that support ScreenCaptureKit. The default is to use the previous code, to avoid breaking current users of the module. Bug: chromium:327458809 Change-Id: Ib0f9390c85d726016a39eea4fda9b8bd14a094c3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/355020 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Commit-Queue: Lambros Lambrou <lambroslambrou@chromium.org> Cr-Commit-Position: refs/heads/main@{#42518}
This commit is contained in:
parent
dedb03e782
commit
3069c60ada
@ -72,6 +72,13 @@ class RTC_EXPORT DesktopCaptureOptions {
|
|||||||
|
|
||||||
bool allow_iosurface() const { return allow_iosurface_; }
|
bool allow_iosurface() const { return allow_iosurface_; }
|
||||||
void set_allow_iosurface(bool allow) { allow_iosurface_ = allow; }
|
void set_allow_iosurface(bool allow) { allow_iosurface_ = allow; }
|
||||||
|
|
||||||
|
// If this flag is set, and the system supports it, ScreenCaptureKit will be
|
||||||
|
// used for desktop capture.
|
||||||
|
// TODO: crbug.com/327458809 - Force the use of SCK and ignore this flag in
|
||||||
|
// new versions of macOS that remove support for the CGDisplay-based APIs.
|
||||||
|
bool allow_sck_capturer() const { return allow_sck_capturer_; }
|
||||||
|
void set_allow_sck_capturer(bool allow) { allow_sck_capturer_ = allow; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const rtc::scoped_refptr<FullScreenWindowDetector>&
|
const rtc::scoped_refptr<FullScreenWindowDetector>&
|
||||||
@ -235,6 +242,7 @@ class RTC_EXPORT DesktopCaptureOptions {
|
|||||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||||
rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
|
rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor_;
|
||||||
bool allow_iosurface_ = false;
|
bool allow_iosurface_ = false;
|
||||||
|
bool allow_sck_capturer_ = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rtc::scoped_refptr<FullScreenWindowDetector> full_screen_window_detector_;
|
rtc::scoped_refptr<FullScreenWindowDetector> full_screen_window_detector_;
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "modules/desktop_capture/mac/screen_capturer_mac.h"
|
#include "modules/desktop_capture/mac/screen_capturer_mac.h"
|
||||||
|
#include "modules/desktop_capture/mac/screen_capturer_sck.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -21,9 +22,17 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ScreenCapturerMac> capturer(new ScreenCapturerMac(
|
if (options.allow_sck_capturer()) {
|
||||||
options.configuration_monitor(), options.detect_updated_region(), options.allow_iosurface()));
|
// This will return nullptr on systems that don't support ScreenCaptureKit.
|
||||||
if (!capturer.get()->Init()) {
|
std::unique_ptr<DesktopCapturer> sck_capturer = CreateScreenCapturerSck(options);
|
||||||
|
if (sck_capturer) {
|
||||||
|
return sck_capturer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto capturer = std::make_unique<ScreenCapturerMac>(
|
||||||
|
options.configuration_monitor(), options.detect_updated_region(), options.allow_iosurface());
|
||||||
|
if (!capturer->Init()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user