OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_ADAPTER_DUPLICATOR_H_ |
| 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_ADAPTER_DUPLICATOR_H_ |
| 13 |
| 14 #include <wrl/client.h> |
| 15 |
| 16 #include <vector> |
| 17 |
| 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 19 #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 20 #include "webrtc/modules/desktop_capture/desktop_region.h" |
| 21 #include "webrtc/modules/desktop_capture/win/d3d_device.h" |
| 22 #include "webrtc/modules/desktop_capture/win/dxgi_output_duplicator.h" |
| 23 |
| 24 namespace webrtc { |
| 25 |
| 26 // A container of DxgiOutputDuplicators to duplicate monitors attached to a |
| 27 // single video card. |
| 28 class DxgiAdapterDuplicator { |
| 29 public: |
| 30 struct Context { |
| 31 // Child DxgiOutputDuplicator::Context belongs to this |
| 32 // DxgiAdapterDuplicator::Context. |
| 33 std::vector<DxgiOutputDuplicator::Context> contexts; |
| 34 }; |
| 35 |
| 36 // Creates an instance of DxgiAdapterDuplicator from a D3dDevice. Only |
| 37 // DxgiDuplicatorController can create an instance. |
| 38 explicit DxgiAdapterDuplicator(const D3dDevice& device); |
| 39 |
| 40 // Move constructor, to make it possible to store instances of |
| 41 // DxgiAdapterDuplicator in std::vector<>. |
| 42 DxgiAdapterDuplicator(DxgiAdapterDuplicator&& other); |
| 43 |
| 44 // Initializes the DxgiAdapterDuplicator from a D3dDevice. |
| 45 bool Initialize(); |
| 46 |
| 47 // Sequential calls Duplicate function of all the DxgiOutputDuplicators owned |
| 48 // by this instance. |
| 49 bool Duplicate(Context* context, |
| 50 const DesktopFrame* last_frame, |
| 51 DesktopFrame* target); |
| 52 |
| 53 // Captures one monitor and writes into target. |monitor_id| should be between |
| 54 // [0, screen_count()). |
| 55 bool DuplicateMonitor(Context* context, |
| 56 int monitor_id, |
| 57 const DesktopFrame* last_frame, |
| 58 DesktopFrame* target); |
| 59 |
| 60 // Returns desktop rect covered by this DxgiAdapterDuplicator. |
| 61 DesktopRect desktop_rect() const { return desktop_rect_; } |
| 62 |
| 63 // Returns the size of one screen owned by this DxgiAdapterDuplicator. |id| |
| 64 // should be between [0, screen_count()). |
| 65 DesktopRect ScreenRect(int id) const; |
| 66 |
| 67 // Returns the count of screens owned by this DxgiAdapterDuplicator. These |
| 68 // screens can be retrieved by an interger in the range of |
| 69 // [0, screen_count()). |
| 70 int screen_count() const { return static_cast<int>(duplicators_.size()); } |
| 71 |
| 72 private: |
| 73 friend class DxgiDuplicatorController; |
| 74 |
| 75 bool DoInitialize(); |
| 76 |
| 77 void Setup(Context* context); |
| 78 |
| 79 void Unregister(const Context* const context); |
| 80 |
| 81 const D3dDevice device_; |
| 82 std::vector<DxgiOutputDuplicator> duplicators_; |
| 83 DesktopRect desktop_rect_; |
| 84 }; |
| 85 |
| 86 } // namespace webrtc |
| 87 |
| 88 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_DXGI_ADAPTER_DUPLICATOR_H_ |
OLD | NEW |