| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ |
| 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ |
| 13 | 13 |
| 14 #include <memory> |
| 15 |
| 14 #include <windows.h> | 16 #include <windows.h> |
| 15 #include <magnification.h> | 17 #include <magnification.h> |
| 16 #include <wincodec.h> | 18 #include <wincodec.h> |
| 17 | 19 |
| 18 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
| 19 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" |
| 20 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" | 22 #include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h" |
| 21 #include "webrtc/modules/desktop_capture/screen_capturer.h" | 23 #include "webrtc/modules/desktop_capture/screen_capturer.h" |
| 22 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" | 24 #include "webrtc/modules/desktop_capture/screen_capturer_helper.h" |
| 23 #include "webrtc/modules/desktop_capture/win/scoped_thread_desktop.h" | 25 #include "webrtc/modules/desktop_capture/win/scoped_thread_desktop.h" |
| 24 #include "webrtc/system_wrappers/include/atomic32.h" | 26 #include "webrtc/system_wrappers/include/atomic32.h" |
| 25 | 27 |
| 26 namespace webrtc { | 28 namespace webrtc { |
| 27 | 29 |
| 28 class DesktopFrame; | 30 class DesktopFrame; |
| 29 class DesktopRect; | 31 class DesktopRect; |
| 30 class Differ; | 32 class Differ; |
| 31 | 33 |
| 32 // Captures the screen using the Magnification API to support window exclusion. | 34 // Captures the screen using the Magnification API to support window exclusion. |
| 33 // Each capturer must run on a dedicated thread because it uses thread local | 35 // Each capturer must run on a dedicated thread because it uses thread local |
| 34 // storage for redirecting the library callback. Also the thread must have a UI | 36 // storage for redirecting the library callback. Also the thread must have a UI |
| 35 // message loop to handle the window messages for the magnifier window. | 37 // message loop to handle the window messages for the magnifier window. |
| 36 class ScreenCapturerWinMagnifier : public ScreenCapturer { | 38 class ScreenCapturerWinMagnifier : public ScreenCapturer { |
| 37 public: | 39 public: |
| 38 // |fallback_capturer| will be used to capture the screen if a non-primary | 40 // |fallback_capturer| will be used to capture the screen if a non-primary |
| 39 // screen is being captured, or the OS does not support Magnification API, or | 41 // screen is being captured, or the OS does not support Magnification API, or |
| 40 // the magnifier capturer fails (e.g. in Windows8 Metro mode). | 42 // the magnifier capturer fails (e.g. in Windows8 Metro mode). |
| 41 explicit ScreenCapturerWinMagnifier( | 43 explicit ScreenCapturerWinMagnifier( |
| 42 rtc::scoped_ptr<ScreenCapturer> fallback_capturer); | 44 std::unique_ptr<ScreenCapturer> fallback_capturer); |
| 43 virtual ~ScreenCapturerWinMagnifier(); | 45 virtual ~ScreenCapturerWinMagnifier(); |
| 44 | 46 |
| 45 // Overridden from ScreenCapturer: | 47 // Overridden from ScreenCapturer: |
| 46 void Start(Callback* callback) override; | 48 void Start(Callback* callback) override; |
| 47 void SetSharedMemoryFactory( | 49 void SetSharedMemoryFactory( |
| 48 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) override; | 50 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory) override; |
| 49 void Capture(const DesktopRegion& region) override; | 51 void Capture(const DesktopRegion& region) override; |
| 50 bool GetScreenList(ScreenList* screens) override; | 52 bool GetScreenList(ScreenList* screens) override; |
| 51 bool SelectScreen(ScreenId id) override; | 53 bool SelectScreen(ScreenId id) override; |
| 52 void SetExcludedWindow(WindowId window) override; | 54 void SetExcludedWindow(WindowId window) override; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void OnCaptured(void* data, const MAGIMAGEHEADER& header); | 98 void OnCaptured(void* data, const MAGIMAGEHEADER& header); |
| 97 | 99 |
| 98 // Makes sure the current frame exists and matches |size|. | 100 // Makes sure the current frame exists and matches |size|. |
| 99 void CreateCurrentFrameIfNecessary(const DesktopSize& size); | 101 void CreateCurrentFrameIfNecessary(const DesktopSize& size); |
| 100 | 102 |
| 101 // Start the fallback capturer and select the screen. | 103 // Start the fallback capturer and select the screen. |
| 102 void StartFallbackCapturer(); | 104 void StartFallbackCapturer(); |
| 103 | 105 |
| 104 static Atomic32 tls_index_; | 106 static Atomic32 tls_index_; |
| 105 | 107 |
| 106 rtc::scoped_ptr<ScreenCapturer> fallback_capturer_; | 108 std::unique_ptr<ScreenCapturer> fallback_capturer_; |
| 107 bool fallback_capturer_started_; | 109 bool fallback_capturer_started_; |
| 108 Callback* callback_; | 110 Callback* callback_; |
| 109 rtc::scoped_ptr<SharedMemoryFactory> shared_memory_factory_; | 111 std::unique_ptr<SharedMemoryFactory> shared_memory_factory_; |
| 110 ScreenId current_screen_id_; | 112 ScreenId current_screen_id_; |
| 111 std::wstring current_device_key_; | 113 std::wstring current_device_key_; |
| 112 HWND excluded_window_; | 114 HWND excluded_window_; |
| 113 | 115 |
| 114 // A thread-safe list of invalid rectangles, and the size of the most | 116 // A thread-safe list of invalid rectangles, and the size of the most |
| 115 // recently captured screen. | 117 // recently captured screen. |
| 116 ScreenCapturerHelper helper_; | 118 ScreenCapturerHelper helper_; |
| 117 | 119 |
| 118 // Queue of the frames buffers. | 120 // Queue of the frames buffers. |
| 119 ScreenCaptureFrameQueue queue_; | 121 ScreenCaptureFrameQueue queue_; |
| 120 | 122 |
| 121 // Class to calculate the difference between two screen bitmaps. | 123 // Class to calculate the difference between two screen bitmaps. |
| 122 rtc::scoped_ptr<Differ> differ_; | 124 std::unique_ptr<Differ> differ_; |
| 123 | 125 |
| 124 // Used to suppress duplicate logging of SetThreadExecutionState errors. | 126 // Used to suppress duplicate logging of SetThreadExecutionState errors. |
| 125 bool set_thread_execution_state_failed_; | 127 bool set_thread_execution_state_failed_; |
| 126 | 128 |
| 127 ScopedThreadDesktop desktop_; | 129 ScopedThreadDesktop desktop_; |
| 128 | 130 |
| 129 // Used for getting the screen dpi. | 131 // Used for getting the screen dpi. |
| 130 HDC desktop_dc_; | 132 HDC desktop_dc_; |
| 131 | 133 |
| 132 HMODULE mag_lib_handle_; | 134 HMODULE mag_lib_handle_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 147 // True if the last OnMagImageScalingCallback was called and handled | 149 // True if the last OnMagImageScalingCallback was called and handled |
| 148 // successfully. Reset at the beginning of each CaptureImage call. | 150 // successfully. Reset at the beginning of each CaptureImage call. |
| 149 bool magnifier_capture_succeeded_; | 151 bool magnifier_capture_succeeded_; |
| 150 | 152 |
| 151 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinMagnifier); | 153 RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWinMagnifier); |
| 152 }; | 154 }; |
| 153 | 155 |
| 154 } // namespace webrtc | 156 } // namespace webrtc |
| 155 | 157 |
| 156 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ | 158 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_MAGNIFIER_H_ |
| OLD | NEW |