| 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> |
| 15 |
| 14 #include <memory> | 16 #include <memory> |
| 15 #include <vector> | 17 #include <vector> |
| 16 | 18 |
| 17 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
| 18 #include "webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 19 #include "webrtc/modules/desktop_capture/desktop_region.h" | 21 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 20 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" | 22 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" |
| 21 #include "webrtc/modules/desktop_capture/win/d3d_device.h" | 23 #include "webrtc/modules/desktop_capture/win/d3d_device.h" |
| 22 #include "webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.h" | 24 #include "webrtc/modules/desktop_capture/win/dxgi_adapter_duplicator.h" |
| 23 | 25 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 | 52 |
| 51 // A Context will have an exactly same |identity_| as | 53 // A Context will have an exactly same |identity_| as |
| 52 // DxgiDuplicatorController, to ensure it has been correctly setted up after | 54 // DxgiDuplicatorController, to ensure it has been correctly setted up after |
| 53 // each DxgiDuplicatorController::Initialize(). | 55 // each DxgiDuplicatorController::Initialize(). |
| 54 int identity_ = 0; | 56 int identity_ = 0; |
| 55 | 57 |
| 56 // Child DxgiAdapterDuplicator::Context belongs to this Context. | 58 // Child DxgiAdapterDuplicator::Context belongs to this Context. |
| 57 std::vector<DxgiAdapterDuplicator::Context> contexts_; | 59 std::vector<DxgiAdapterDuplicator::Context> contexts_; |
| 58 }; | 60 }; |
| 59 | 61 |
| 62 // A collection of D3d information we are interested on, which may impact |
| 63 // capturer performance or reliability. |
| 64 struct D3dInfo { |
| 65 // Each video adapter has its own D3D_FEATURE_LEVEL, so this structure |
| 66 // contains the minimum and maximium D3D_FEATURE_LEVELs current system |
| 67 // supports. |
| 68 // Both fields can be 0, which is the default value to indicate no valid |
| 69 // D3D_FEATURE_LEVEL has been retrieved from underlying OS APIs. |
| 70 D3D_FEATURE_LEVEL min_feature_level; |
| 71 D3D_FEATURE_LEVEL max_feature_level; |
| 72 |
| 73 // TODO(zijiehe): Add more fields, such as manufacturer name, mode, driver |
| 74 // version. |
| 75 }; |
| 76 |
| 60 // Returns the singleton instance of DxgiDuplicatorController. | 77 // Returns the singleton instance of DxgiDuplicatorController. |
| 61 static DxgiDuplicatorController* Instance(); | 78 static DxgiDuplicatorController* Instance(); |
| 62 | 79 |
| 63 // Destructs current instance. We need to make sure COM components and their | 80 // Destructs current instance. We need to make sure COM components and their |
| 64 // containers are destructed in correct order. | 81 // containers are destructed in correct order. |
| 65 ~DxgiDuplicatorController(); | 82 ~DxgiDuplicatorController(); |
| 66 | 83 |
| 84 // All the following functions implicitly call Initialize() function is |
| 85 // current instance has not been initialized. |
| 86 |
| 67 // Detects whether the system supports DXGI based capturer. | 87 // Detects whether the system supports DXGI based capturer. |
| 68 bool IsSupported(); | 88 bool IsSupported(); |
| 69 | 89 |
| 90 // Returns a copy of D3dInfo composed by last Initialize() function call. |
| 91 bool RetrieveD3dInfo(D3dInfo* info); |
| 92 |
| 70 // Captures current screen and writes into target. Since we are using double | 93 // Captures current screen and writes into target. Since we are using double |
| 71 // buffering, |last_frame|.updated_region() is used to represent the not | 94 // buffering, |last_frame|.updated_region() is used to represent the not |
| 72 // updated regions in current |target| frame, which should also be copied this | 95 // updated regions in current |target| frame, which should also be copied this |
| 73 // time. | 96 // time. |
| 74 // TODO(zijiehe): Windows cannot guarantee the frames returned by each | 97 // TODO(zijiehe): Windows cannot guarantee the frames returned by each |
| 75 // IDXGIOutputDuplication are synchronized. But we are using a totally | 98 // IDXGIOutputDuplication are synchronized. But we are using a totally |
| 76 // different threading model than the way Windows suggested, it's hard to | 99 // different threading model than the way Windows suggested, it's hard to |
| 77 // synchronize them manually. We should find a way to do it. | 100 // synchronize them manually. We should find a way to do it. |
| 78 bool Duplicate(Context* context, SharedDesktopFrame* target); | 101 bool Duplicate(Context* context, SharedDesktopFrame* target); |
| 79 | 102 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 169 |
| 147 // This lock must be locked whenever accessing any of the following objects. | 170 // This lock must be locked whenever accessing any of the following objects. |
| 148 rtc::CriticalSection lock_; | 171 rtc::CriticalSection lock_; |
| 149 | 172 |
| 150 // A self-incremented integer to compare with the one in Context, to | 173 // A self-incremented integer to compare with the one in Context, to |
| 151 // ensure a Context has been initialized after DxgiDuplicatorController. | 174 // ensure a Context has been initialized after DxgiDuplicatorController. |
| 152 int identity_ = 0; | 175 int identity_ = 0; |
| 153 DesktopRect desktop_rect_; | 176 DesktopRect desktop_rect_; |
| 154 DesktopVector dpi_; | 177 DesktopVector dpi_; |
| 155 std::vector<DxgiAdapterDuplicator> duplicators_; | 178 std::vector<DxgiAdapterDuplicator> duplicators_; |
| 179 D3dInfo d3d_info_; |
| 156 }; | 180 }; |
| 157 | 181 |
| 158 } // namespace webrtc | 182 } // namespace webrtc |
| 159 | 183 |
| 160 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ | 184 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_DUPLICATOR_CONTROLLER_H_ |
| OLD | NEW |