OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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_DXGI_DUPLICATOR_CONTROLLER_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ |
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ |
13 | 13 |
14 #include <D3DCommon.h> | 14 #include <D3DCommon.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
20 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
21 #include "webrtc/modules/desktop_capture/desktop_region.h" | 21 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 22 #include "webrtc/modules/desktop_capture/resolution_change_detector.h" |
22 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" | 23 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" |
23 #include "webrtc/modules/desktop_capture/win/d3d_device.h" | 24 #include "webrtc/modules/desktop_capture/win/d3d_device.h" |
24 #include "webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.h" | 25 #include "webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.h" |
25 | 26 |
26 namespace webrtc { | 27 namespace webrtc { |
27 | 28 |
28 // A controller for all the objects we need to call Windows DirectX capture APIs | 29 // A controller for all the objects we need to call Windows DirectX capture APIs |
29 // It's a singleton because only one IDXGIOutputDuplication instance per monitor | 30 // It's a singleton because only one IDXGIOutputDuplication instance per monitor |
30 // is allowed per application. | 31 // is allowed per application. |
31 // | 32 // |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Destructs current instance. We need to make sure COM components and their | 81 // Destructs current instance. We need to make sure COM components and their |
81 // containers are destructed in correct order. | 82 // containers are destructed in correct order. |
82 ~DxgiDuplicatorController(); | 83 ~DxgiDuplicatorController(); |
83 | 84 |
84 // All the following functions implicitly call Initialize() function if | 85 // All the following functions implicitly call Initialize() function if |
85 // current instance has not been initialized. | 86 // current instance has not been initialized. |
86 | 87 |
87 // Detects whether the system supports DXGI based capturer. | 88 // Detects whether the system supports DXGI based capturer. |
88 bool IsSupported(); | 89 bool IsSupported(); |
89 | 90 |
| 91 // Calls Deinitialize() function with lock. Consumers can call this function |
| 92 // to force the DxgiDuplicatorController to be reinitialized to avoid an |
| 93 // expected failure in next Duplicate() call. |
| 94 void Reset(); |
| 95 |
90 // Returns a copy of D3dInfo composed by last Initialize() function call. | 96 // Returns a copy of D3dInfo composed by last Initialize() function call. |
91 bool RetrieveD3dInfo(D3dInfo* info); | 97 bool RetrieveD3dInfo(D3dInfo* info); |
92 | 98 |
93 // Captures current screen and writes into target. Since we are using double | 99 // Captures current screen and writes into target. Since we are using double |
94 // buffering, |last_frame|.updated_region() is used to represent the not | 100 // buffering, |last_frame|.updated_region() is used to represent the not |
95 // updated regions in current |target| frame, which should also be copied this | 101 // updated regions in current |target| frame, which should also be copied this |
96 // time. | 102 // time. |
97 // TODO(zijiehe): Windows cannot guarantee the frames returned by each | 103 // TODO(zijiehe): Windows cannot guarantee the frames returned by each |
98 // IDXGIOutputDuplication are synchronized. But we are using a totally | 104 // IDXGIOutputDuplication are synchronized. But we are using a totally |
99 // different threading model than the way Windows suggested, it's hard to | 105 // different threading model than the way Windows suggested, it's hard to |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 bool ContextExpired(const Context* const context) const; | 166 bool ContextExpired(const Context* const context) const; |
161 | 167 |
162 // Updates Context if needed. | 168 // Updates Context if needed. |
163 void Setup(Context* context); | 169 void Setup(Context* context); |
164 | 170 |
165 // Do the real duplication work. |monitor_id < 0| to capture entire screen. | 171 // Do the real duplication work. |monitor_id < 0| to capture entire screen. |
166 bool DoDuplicate(Context* context, | 172 bool DoDuplicate(Context* context, |
167 int monitor_id, | 173 int monitor_id, |
168 SharedDesktopFrame* target); | 174 SharedDesktopFrame* target); |
169 | 175 |
| 176 bool DoDuplicateUnlocked(Context* context, |
| 177 int monitor_id, |
| 178 SharedDesktopFrame* target); |
| 179 |
170 // This lock must be locked whenever accessing any of the following objects. | 180 // This lock must be locked whenever accessing any of the following objects. |
171 rtc::CriticalSection lock_; | 181 rtc::CriticalSection lock_; |
172 | 182 |
173 // A self-incremented integer to compare with the one in Context, to | 183 // A self-incremented integer to compare with the one in Context, to |
174 // ensure a Context has been initialized after DxgiDuplicatorController. | 184 // ensure a Context has been initialized after DxgiDuplicatorController. |
175 int identity_ = 0; | 185 int identity_ = 0; |
176 DesktopRect desktop_rect_; | 186 DesktopRect desktop_rect_; |
177 DesktopVector dpi_; | 187 DesktopVector dpi_; |
178 std::vector<DxgiAdapterDuplicator> duplicators_; | 188 std::vector<DxgiAdapterDuplicator> duplicators_; |
179 D3dInfo d3d_info_; | 189 D3dInfo d3d_info_; |
| 190 ResolutionChangeDetector resolution_change_detector_; |
180 }; | 191 }; |
181 | 192 |
182 } // namespace webrtc | 193 } // namespace webrtc |
183 | 194 |
184 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ | 195 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ |
OLD | NEW |