Current DirectX capturer cannot capture multiple video cards or monitors. But according to DXGI desktop duplication sample (https://goo.gl/An0L9l), we can capture multiple video cards and monitors by duplicating them one by one. So instead of one IDXGIOutputDuplication instance, this change creates an IDXGIOutputDuplication instance for each monitor, and merge the output into one DesktopFrame. Several other changes are also included, 1. Add supports to DXGI_OUTDUPL_DESC.DesktopImageInSystemMemory. When this flag is true, we won't copy its content to staging buffer. 2. Capture one monitor instead of entire screen. Above changes make the logic complex. But with some refactor work, the logic is not disordered. Please refer to the doc @ https://goo.gl/hU1ifG. BUG=314516 Review-Url: https://codereview.webrtc.org/2099123002 Cr-Commit-Position: refs/heads/master@{#13684}
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
/*
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
|
|
#define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
|
|
|
|
#include <comdef.h>
|
|
#include <wrl/client.h>
|
|
#include <D3D11.h>
|
|
#include <DXGI.h>
|
|
|
|
#include <vector>
|
|
|
|
namespace webrtc {
|
|
|
|
// A wrapper of ID3D11Device and its corresponding context and IDXGIAdapter.
|
|
// This class represents one video card in the system.
|
|
class D3dDevice {
|
|
public:
|
|
~D3dDevice();
|
|
|
|
ID3D11Device* d3d_device() const { return d3d_device_.Get(); }
|
|
|
|
ID3D11DeviceContext* context() const { return context_.Get(); }
|
|
|
|
IDXGIDevice* dxgi_device() const { return dxgi_device_.Get(); }
|
|
|
|
IDXGIAdapter* dxgi_adapter() const { return dxgi_adapter_.Get(); }
|
|
|
|
// Returns all D3dDevice instances on the system. Returns an empty vector if
|
|
// anything wrong.
|
|
static std::vector<D3dDevice> EnumDevices();
|
|
|
|
private:
|
|
// Instances of D3dDevice should only be created by EnumDevices() static
|
|
// function.
|
|
D3dDevice();
|
|
|
|
// Initialize the D3dDevice from an IDXGIAdapter.
|
|
bool Initialize(const Microsoft::WRL::ComPtr<IDXGIAdapter>& adapter);
|
|
|
|
Microsoft::WRL::ComPtr<ID3D11Device> d3d_device_;
|
|
Microsoft::WRL::ComPtr<ID3D11DeviceContext> context_;
|
|
Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device_;
|
|
Microsoft::WRL::ComPtr<IDXGIAdapter> dxgi_adapter_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_D3D_DEVICE_H_
|