WindowCapturerWinGdi shouldn't deliver SUCCESS and nullptr.

Consumers expect the frame to be valid if Result::SUCCESS is delivered.
If the frame is nullptr, we should deliver ERROR_TEMPORARY instead.

Bug: webrtc:14265
Change-Id: If94a3ead38d7657d7b90bbe046256be697312216
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269223
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Reviewed-by: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#37590}
This commit is contained in:
Austin Orion 2022-07-21 10:21:02 -07:00 committed by WebRTC LUCI CQ
parent 32632a80e3
commit de4fd2f9ef

View File

@ -160,17 +160,17 @@ void WindowCapturerWinGdi::CaptureFrame() {
int64_t capture_start_time_nanos = rtc::TimeNanos();
CaptureResults results = CaptureFrame(/*capture_owned_windows*/ true);
if (results.frame) {
int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec;
RTC_HISTOGRAM_COUNTS_1000(
"WebRTC.DesktopCapture.Win.WindowGdiCapturerFrameTime",
capture_time_ms);
results.frame->set_capture_time_ms(capture_time_ms);
results.frame->set_capturer_id(DesktopCapturerId::kWindowCapturerWinGdi);
if (!results.frame) {
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}
int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) /
rtc::kNumNanosecsPerMillisec;
RTC_HISTOGRAM_COUNTS_1000(
"WebRTC.DesktopCapture.Win.WindowGdiCapturerFrameTime", capture_time_ms);
results.frame->set_capture_time_ms(capture_time_ms);
results.frame->set_capturer_id(DesktopCapturerId::kWindowCapturerWinGdi);
callback_->OnCaptureResult(results.result, std::move(results.frame));
}