ipc_video_frame_capturer.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #ifndef REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
  5. #define REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "remoting/protocol/desktop_capturer.h"
  11. #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
  12. namespace remoting {
  13. class DesktopSessionProxy;
  14. // Routes webrtc::DesktopCapturer calls though the IPC channel to the desktop
  15. // session agent running in the desktop integration process.
  16. // GetSourceList() and SelectSource() functions are not implemented, they always
  17. // return false.
  18. class IpcVideoFrameCapturer : public DesktopCapturer {
  19. public:
  20. explicit IpcVideoFrameCapturer(
  21. scoped_refptr<DesktopSessionProxy> desktop_session_proxy);
  22. IpcVideoFrameCapturer(const IpcVideoFrameCapturer&) = delete;
  23. IpcVideoFrameCapturer& operator=(const IpcVideoFrameCapturer&) = delete;
  24. ~IpcVideoFrameCapturer() override;
  25. // webrtc::DesktopCapturer interface.
  26. void Start(Callback* callback) override;
  27. void CaptureFrame() override;
  28. bool GetSourceList(SourceList* sources) override;
  29. bool SelectSource(SourceId id) override;
  30. // Called when a video |frame| has been captured.
  31. void OnCaptureResult(webrtc::DesktopCapturer::Result result,
  32. std::unique_ptr<webrtc::DesktopFrame> frame);
  33. private:
  34. // Points to the callback passed to webrtc::DesktopCapturer::Start().
  35. raw_ptr<webrtc::DesktopCapturer::Callback> callback_;
  36. // Wraps the IPC channel to the desktop session agent.
  37. scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
  38. // Set to true when a frame is being captured.
  39. bool capture_pending_;
  40. // Used to cancel tasks pending on the capturer when it is stopped.
  41. base::WeakPtrFactory<IpcVideoFrameCapturer> weak_factory_{this};
  42. };
  43. } // namespace remoting
  44. #endif // REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_