[Chromoting] Improve DirectX capturer to support multiple outputs
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}
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
@ -75,8 +76,8 @@ ACTION_P(SaveUniquePtrArg, dest) {
|
||||
TEST_F(ScreenCapturerTest, GetScreenListAndSelectScreen) {
|
||||
webrtc::ScreenCapturer::ScreenList screens;
|
||||
EXPECT_TRUE(capturer_->GetScreenList(&screens));
|
||||
for(webrtc::ScreenCapturer::ScreenList::iterator it = screens.begin();
|
||||
it != screens.end(); ++it) {
|
||||
for (webrtc::ScreenCapturer::ScreenList::iterator it = screens.begin();
|
||||
it != screens.end(); ++it) {
|
||||
EXPECT_TRUE(capturer_->SelectScreen(it->id));
|
||||
}
|
||||
}
|
||||
@ -144,6 +145,40 @@ TEST_F(ScreenCapturerTest, UseMagnifier) {
|
||||
ASSERT_TRUE(frame);
|
||||
}
|
||||
|
||||
TEST_F(ScreenCapturerTest, UseDirectxCapturer) {
|
||||
DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
|
||||
options.set_allow_directx_capturer(true);
|
||||
capturer_.reset(ScreenCapturer::Create(options));
|
||||
|
||||
std::unique_ptr<DesktopFrame> frame;
|
||||
EXPECT_CALL(callback_,
|
||||
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
|
||||
.WillOnce(SaveUniquePtrArg(&frame));
|
||||
|
||||
capturer_->Start(&callback_);
|
||||
capturer_->Capture(DesktopRegion());
|
||||
ASSERT_TRUE(frame);
|
||||
}
|
||||
|
||||
TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) {
|
||||
DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
|
||||
options.set_allow_directx_capturer(true);
|
||||
capturer_.reset(ScreenCapturer::Create(options));
|
||||
|
||||
std::unique_ptr<DesktopFrame> frame;
|
||||
EXPECT_CALL(callback_,
|
||||
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
|
||||
.WillOnce(SaveUniquePtrArg(&frame));
|
||||
|
||||
capturer_->Start(&callback_);
|
||||
capturer_->SetSharedMemoryFactory(
|
||||
std::unique_ptr<SharedMemoryFactory>(new FakeSharedMemoryFactory()));
|
||||
capturer_->Capture(DesktopRegion());
|
||||
ASSERT_TRUE(frame);
|
||||
ASSERT_TRUE(frame->shared_memory());
|
||||
EXPECT_EQ(frame->shared_memory()->id(), kTestSharedMemoryId);
|
||||
}
|
||||
|
||||
#endif // defined(WEBRTC_WIN)
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user