Some callback wrappers set the callback_ member at the start, but most set it after calling any owned implementation of Start(). Setting it after the call means that the callback_ is not set up for any callbacks that happen during the call. This cl fixes that by setting the callback_ member before any calls are made in Start(). Bug: chromium:916961 Change-Id: Id26f8cc98377ef217f928095834162f5526c1fdf Reviewed-on: https://webrtc-review.googlesource.com/c/117040 Reviewed-by: Brave Yao <braveyao@webrtc.org> Commit-Queue: Gary Kacmarcik <garykac@chromium.org> Cr-Commit-Position: refs/heads/master@{#26231}
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2017 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.
|
|
*/
|
|
|
|
#include "modules/desktop_capture/capture_result_desktop_capturer_wrapper.h"
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
namespace webrtc {
|
|
|
|
CaptureResultDesktopCapturerWrapper::CaptureResultDesktopCapturerWrapper(
|
|
std::unique_ptr<DesktopCapturer> base_capturer,
|
|
ResultObserver* observer)
|
|
: DesktopCapturerWrapper(std::move(base_capturer)), observer_(observer) {
|
|
RTC_DCHECK(observer_);
|
|
}
|
|
|
|
CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() =
|
|
default;
|
|
|
|
void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) {
|
|
if ((callback_ == nullptr) != (callback == nullptr)) {
|
|
if (callback) {
|
|
callback_ = callback;
|
|
base_capturer_->Start(this);
|
|
} else {
|
|
base_capturer_->Start(nullptr);
|
|
}
|
|
}
|
|
callback_ = callback;
|
|
}
|
|
|
|
void CaptureResultDesktopCapturerWrapper::OnCaptureResult(
|
|
Result result,
|
|
std::unique_ptr<DesktopFrame> frame) {
|
|
observer_->Observe(&result, &frame);
|
|
callback_->OnCaptureResult(result, std::move(frame));
|
|
}
|
|
|
|
} // namespace webrtc
|