1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/desktop_capture/capture_result_desktop_capturer_wrapper.h" 12 13 #include <memory> 14 #include <utility> 15 16 #include "rtc_base/checks.h" 17 18 namespace webrtc { 19 CaptureResultDesktopCapturerWrapper(std::unique_ptr<DesktopCapturer> base_capturer,ResultObserver * observer)20CaptureResultDesktopCapturerWrapper::CaptureResultDesktopCapturerWrapper( 21 std::unique_ptr<DesktopCapturer> base_capturer, 22 ResultObserver* observer) 23 : DesktopCapturerWrapper(std::move(base_capturer)), observer_(observer) { 24 RTC_DCHECK(observer_); 25 } 26 27 CaptureResultDesktopCapturerWrapper::~CaptureResultDesktopCapturerWrapper() = 28 default; 29 Start(Callback * callback)30void CaptureResultDesktopCapturerWrapper::Start(Callback* callback) { 31 if ((callback_ == nullptr) != (callback == nullptr)) { 32 if (callback) { 33 callback_ = callback; 34 base_capturer_->Start(this); 35 } else { 36 base_capturer_->Start(nullptr); 37 } 38 } 39 callback_ = callback; 40 } 41 OnCaptureResult(Result result,std::unique_ptr<DesktopFrame> frame)42void CaptureResultDesktopCapturerWrapper::OnCaptureResult( 43 Result result, 44 std::unique_ptr<DesktopFrame> frame) { 45 observer_->Observe(&result, &frame); 46 callback_->OnCaptureResult(result, std::move(frame)); 47 } 48 49 } // namespace webrtc 50