Address CL comments from 200161.

This is a follow up to
https://webrtc-review.googlesource.com/c/src/+/200161

I forgot to actually upload the code that addressed reviewer's comments,
and since they were minor comments I went ahead and completed the CL
before I realized.

Fortunately no harm done because all of this code is behind a disabled
build flag. This is a great example of move fast, make mistakes. Lesson
learned.

Bug: webrtc:9273
Change-Id: I5e35b31719b264855568de4b5e595fe0f192654e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/204420
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Commit-Queue: Austin Orion <auorion@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#33095}
This commit is contained in:
Austin Orion
2021-01-28 12:18:26 -08:00
committed by Commit Bot
parent 79f645237d
commit 8bd0f97fe6
5 changed files with 14 additions and 17 deletions

View File

@ -23,8 +23,6 @@
#if defined(RTC_ENABLE_WIN_WGC)
#include "modules/desktop_capture/win/wgc_capturer_win.h"
#include "rtc_base/win/windows_version.h"
const bool kUseWinWgcCapturer = false;
#endif // defined(RTC_ENABLE_WIN_WGC)
namespace webrtc {
@ -59,8 +57,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
// TODO(bugs.webrtc.org/11760): Add a WebRTC field trial (or similar
// mechanism) check here that leads to use of the WGC capturer once it is
// fully implemented.
if (kUseWinWgcCapturer &&
rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
return WgcCapturerWin::CreateRawWindowCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)
@ -86,8 +83,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateScreenCapturer(
// TODO(bugs.webrtc.org/11760): Add a WebRTC field trial (or similar
// mechanism) check here that leads to use of the WGC capturer once it is
// fully implemented.
if (kUseWinWgcCapturer &&
rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
if (rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) {
return WgcCapturerWin::CreateRawScreenCapturer(options);
}
#endif // defined(RTC_ENABLE_WIN_WGC)

View File

@ -32,8 +32,10 @@ BOOL CALLBACK GetMonitorListHandler(HMONITOR monitor,
// Get the name of the monitor.
MONITORINFOEXA monitor_info;
monitor_info.cbSize = sizeof(MONITORINFOEXA);
if (!GetMonitorInfoA(monitor, &monitor_info))
return FALSE;
if (!GetMonitorInfoA(monitor, &monitor_info)) {
// Continue the enumeration, but don't add this monitor to |monitor_list|.
return TRUE;
}
DesktopCapturer::Source monitor_source;
monitor_source.id = reinterpret_cast<intptr_t>(monitor);

View File

@ -19,7 +19,7 @@
namespace webrtc {
// Output the HMONITOR values of all display monitors into |monitors|. Returns
// Outputs the HMONITOR values of all display monitors into |monitors|. Returns
// true if succeeded, or false if it fails to enumerate the display monitors.
bool GetMonitorList(DesktopCapturer::SourceList* monitors);

View File

@ -14,6 +14,7 @@
#include <vector>
#include "modules/desktop_capture/desktop_capturer.h"
#include "rtc_base/logging.h"
#include "test/gtest.h"
namespace webrtc {
@ -33,14 +34,16 @@ TEST(ScreenCaptureUtilsTest, GetMonitorList) {
DesktopCapturer::SourceList monitors;
ASSERT_TRUE(GetMonitorList(&monitors));
ASSERT_GT(monitors.size(), 0ULL);
}
TEST(ScreenCaptureUtilsTest, IsMonitorValid) {
DesktopCapturer::SourceList monitors;
ASSERT_TRUE(GetMonitorList(&monitors));
ASSERT_GT(monitors.size(), 0ULL);
if (monitors.size() == 0) {
RTC_LOG(LS_INFO) << "Skip screen capture test on systems with no monitors.";
GTEST_SKIP();
}
ASSERT_TRUE(IsMonitorValid(monitors[0].id));
}

View File

@ -116,10 +116,8 @@ HRESULT WgcCaptureSession::StartCapture() {
return hr;
hr = session_->StartCapture();
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "Failed to start CaptureSession: " << hr;
if (FAILED(hr))
return hr;
}
is_capture_started_ = true;
return hr;
@ -138,10 +136,8 @@ HRESULT WgcCaptureSession::GetFrame(
ComPtr<WGC::IDirect3D11CaptureFrame> capture_frame;
HRESULT hr = frame_pool_->TryGetNextFrame(&capture_frame);
if (FAILED(hr)) {
RTC_LOG(LS_ERROR) << "TryGetNextFrame failed: " << hr;
if (FAILED(hr))
return hr;
}
if (!capture_frame)
return hr;