From 199942f3e6d4739b6c25e67ac340a3a479951ca2 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Tue, 12 Dec 2017 10:31:19 +0000 Subject: [PATCH] Disable coregraphics built-in mouse capture in ScreenCapturerMac When calling CGDisplayStreamCreate(properties = nullptr) this causes kCGDisplayStreamShowCursor to default to kCFBooleanTrue. This CL set it to false always as it was assumed. Also if true this causes some lags when moving the mouse pointer on the capture side and in any case webrtc::MouseCursorMonitorMac already implements a custom way to capture the mouse. Which appears to be more efficient in this usecase. Bug: webrtc:8625 Change-Id: Id0fae38fa47503d87d1890213706149762fa67fb Reviewed-on: https://webrtc-review.googlesource.com/30902 Commit-Queue: Julien Isorce Reviewed-by: Zijie He Cr-Commit-Position: refs/heads/master@{#21231} --- modules/desktop_capture/BUILD.gn | 1 + modules/desktop_capture/DEPS | 6 ++++++ modules/desktop_capture/screen_capturer_mac.mm | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 0ae0548674..efe44f90fa 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -176,6 +176,7 @@ if (is_mac) { ":primitives", "../../rtc_base:rtc_base", "../../rtc_base:rtc_base_approved", + "../../sdk:common_objc", ] libs = [ "AppKit.framework", diff --git a/modules/desktop_capture/DEPS b/modules/desktop_capture/DEPS index 3314b8cdfd..3b8a639f5e 100644 --- a/modules/desktop_capture/DEPS +++ b/modules/desktop_capture/DEPS @@ -2,3 +2,9 @@ include_rules = [ "+system_wrappers", "+third_party/libyuv", ] + +specific_include_rules = { + "screen_capturer_mac\.mm": [ + "+sdk/objc", + ], +} diff --git a/modules/desktop_capture/screen_capturer_mac.mm b/modules/desktop_capture/screen_capturer_mac.mm index 01911e1ceb..6f2690f285 100644 --- a/modules/desktop_capture/screen_capturer_mac.mm +++ b/modules/desktop_capture/screen_capturer_mac.mm @@ -35,6 +35,7 @@ #include "rtc_base/logging.h" #include "rtc_base/macutils.h" #include "rtc_base/timeutils.h" +#include "sdk/objc/Framework/Classes/Common/scoped_cftyperef.h" namespace webrtc { @@ -445,7 +446,7 @@ bool ScreenCapturerMac::GetSourceList(SourceList* screens) { for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin(); it != desktop_config_.displays.end(); ++it) { - screens->push_back({it->id}); + screens->push_back({it->id, std::string()}); } return true; } @@ -674,8 +675,17 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() { ScreenRefresh(count, rects, display_origin); } }; + + rtc::ScopedCFTypeRef properties_dict( + CFDictionaryCreate(kCFAllocatorDefault, + (const void* []){kCGDisplayStreamShowCursor}, + (const void* []){kCFBooleanFalse}, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks)); + CGDisplayStreamRef display_stream = CGDisplayStreamCreate( - display_id, pixel_width, pixel_height, 'BGRA', nullptr, handler); + display_id, pixel_width, pixel_height, 'BGRA', properties_dict.get(), handler); if (display_stream) { CGError error = CGDisplayStreamStart(display_stream);