ipc_video_frame_capturer.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "remoting/host/ipc_video_frame_capturer.h"
  5. #include "base/check.h"
  6. #include "base/notreached.h"
  7. #include "remoting/host/desktop_session_proxy.h"
  8. #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
  9. namespace remoting {
  10. IpcVideoFrameCapturer::IpcVideoFrameCapturer(
  11. scoped_refptr<DesktopSessionProxy> desktop_session_proxy)
  12. : callback_(nullptr),
  13. desktop_session_proxy_(desktop_session_proxy),
  14. capture_pending_(false) {}
  15. IpcVideoFrameCapturer::~IpcVideoFrameCapturer() = default;
  16. void IpcVideoFrameCapturer::Start(Callback* callback) {
  17. DCHECK(!callback_);
  18. DCHECK(callback);
  19. callback_ = callback;
  20. desktop_session_proxy_->SetVideoCapturer(weak_factory_.GetWeakPtr());
  21. }
  22. void IpcVideoFrameCapturer::CaptureFrame() {
  23. DCHECK(!capture_pending_);
  24. capture_pending_ = true;
  25. desktop_session_proxy_->CaptureFrame();
  26. }
  27. void IpcVideoFrameCapturer::OnCaptureResult(
  28. webrtc::DesktopCapturer::Result result,
  29. std::unique_ptr<webrtc::DesktopFrame> frame) {
  30. DCHECK(capture_pending_);
  31. capture_pending_ = false;
  32. callback_->OnCaptureResult(result, std::move(frame));
  33. }
  34. bool IpcVideoFrameCapturer::GetSourceList(SourceList* sources) {
  35. NOTIMPLEMENTED();
  36. return false;
  37. }
  38. bool IpcVideoFrameCapturer::SelectSource(SourceId id) {
  39. desktop_session_proxy_->SelectSource(id);
  40. return true;
  41. }
  42. } // namespace remoting