From 48fbd4741645f2518fc8138d886bddded4ba363e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sat, 3 Oct 2015 10:41:08 +0800 Subject: [PATCH] Make desktop capture API work on Windows. --- atom.gyp | 11 +++++++++++ atom/browser/api/atom_api_desktop_capturer.cc | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/atom.gyp b/atom.gyp index ed885743c6a6..77ad2e22ae39 100644 --- a/atom.gyp +++ b/atom.gyp @@ -275,8 +275,14 @@ '-lcomctl32.lib', '-lcomdlg32.lib', '-lwininet.lib', + '-lwinmm.lib', ], }, + 'defines': [ + # The usage of "webrtc/modules/desktop_capture/desktop_capture_options.h" + # is required to see this macro. + 'WEBRTC_WIN', + ], 'dependencies': [ # Node is built as static_library on Windows, so we also need to # include its dependencies here. @@ -290,6 +296,11 @@ ], }], # OS=="win" ['OS=="mac"', { + 'defines': [ + # The usage of "webrtc/modules/desktop_capture/desktop_capture_options.h" + # is required to see this macro. + 'WEBRTC_MAC', + ], 'dependencies': [ 'vendor/crashpad/client/client.gyp:crashpad_client', 'vendor/crashpad/handler/handler.gyp:crashpad_handler', diff --git a/atom/browser/api/atom_api_desktop_capturer.cc b/atom/browser/api/atom_api_desktop_capturer.cc index c3a573715703..96786d098912 100644 --- a/atom/browser/api/atom_api_desktop_capturer.cc +++ b/atom/browser/api/atom_api_desktop_capturer.cc @@ -47,10 +47,23 @@ const int kThumbnailHeight = 150; } // namespace DesktopCapturer::DesktopCapturer(bool show_screens, bool show_windows) { + webrtc::DesktopCaptureOptions options = + webrtc::DesktopCaptureOptions::CreateDefault(); + +#if defined(OS_WIN) + // On windows, desktop effects (e.g. Aero) will be disabled when the Desktop + // capture API is active by default. + // We keep the desktop effects in most times. Howerver, the screen still + // fickers when the API is capturing the window due to limitation of current + // implemetation. This is a known and wontFix issue in webrtc (see: + // http://code.google.com/p/webrtc/issues/detail?id=3373) + options.set_disable_effects(false); +#endif + scoped_ptr screen_capturer( - show_screens ? webrtc::ScreenCapturer::Create() : nullptr); + show_screens ? webrtc::ScreenCapturer::Create(options) : nullptr); scoped_ptr window_capturer( - show_windows ? webrtc::WindowCapturer::Create() : nullptr); + show_windows ? webrtc::WindowCapturer::Create(options) : nullptr); media_list_.reset(new NativeDesktopMediaList(screen_capturer.Pass(), window_capturer.Pass())); media_list_->SetThumbnailSize(gfx::Size(kThumbnailWidth, kThumbnailHeight));