aura_desktop_capturer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2014 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_CHROMEOS_AURA_DESKTOP_CAPTURER_H_
  5. #define REMOTING_HOST_CHROMEOS_AURA_DESKTOP_CAPTURER_H_
  6. #include <memory>
  7. #include "base/memory/weak_ptr.h"
  8. #include "remoting/host/chromeos/ash_display_util.h"
  9. #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
  10. namespace remoting {
  11. // A webrtc::DesktopCapturer that captures pixels from the primary display.
  12. // The resulting screen capture will use the display's native resolution.
  13. // This is implemented through the abstractions provided by |AshDisplayUtil|,
  14. // allowing us to mock display interactions during unittests.
  15. // Start() and CaptureFrame() must be called on the Browser UI thread.
  16. class AuraDesktopCapturer : public webrtc::DesktopCapturer {
  17. public:
  18. AuraDesktopCapturer();
  19. explicit AuraDesktopCapturer(AshDisplayUtil& display_util);
  20. AuraDesktopCapturer(const AuraDesktopCapturer&) = delete;
  21. AuraDesktopCapturer& operator=(const AuraDesktopCapturer&) = delete;
  22. ~AuraDesktopCapturer() override;
  23. // webrtc::DesktopCapturer implementation.
  24. void Start(webrtc::DesktopCapturer::Callback* callback) override;
  25. void CaptureFrame() override;
  26. bool GetSourceList(SourceList* sources) override;
  27. bool SelectSource(SourceId id) override;
  28. private:
  29. // Called when a copy of the layer is captured.
  30. void OnFrameCaptured(std::unique_ptr<webrtc::DesktopFrame> frame);
  31. const display::Display* GetSourceDisplay() const;
  32. AshDisplayUtil& util_;
  33. // Points to the callback passed to webrtc::DesktopCapturer::Start().
  34. webrtc::DesktopCapturer::Callback* callback_ = nullptr;
  35. // The id of the display we're currently capturing.
  36. DisplayId source_display_id_;
  37. base::WeakPtrFactory<AuraDesktopCapturer> weak_factory_{this};
  38. };
  39. } // namespace remoting
  40. #endif // REMOTING_HOST_CHROMEOS_AURA_DESKTOP_CAPTURER_H_