osr_video_consumer.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2019 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_
  5. #define ATOM_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_
  6. #include <memory>
  7. #include "base/callback.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "components/viz/host/client_frame_sink_video_capturer.h"
  10. namespace atom {
  11. class OffScreenRenderWidgetHostView;
  12. typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
  13. class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer {
  14. public:
  15. OffScreenVideoConsumer(OffScreenRenderWidgetHostView* view,
  16. OnPaintCallback callback);
  17. ~OffScreenVideoConsumer() override;
  18. void SetActive(bool active);
  19. void SetFrameRate(int frame_rate);
  20. void SizeChanged();
  21. private:
  22. // viz::mojom::FrameSinkVideoConsumer implementation.
  23. void OnFrameCaptured(
  24. base::ReadOnlySharedMemoryRegion data,
  25. ::media::mojom::VideoFrameInfoPtr info,
  26. const gfx::Rect& update_rect,
  27. const gfx::Rect& content_rect,
  28. viz::mojom::FrameSinkVideoConsumerFrameCallbacksPtr callbacks) override;
  29. void OnStopped() override;
  30. bool CheckContentRect(const gfx::Rect& content_rect);
  31. OnPaintCallback callback_;
  32. OffScreenRenderWidgetHostView* view_;
  33. std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
  34. base::WeakPtrFactory<OffScreenVideoConsumer> weak_ptr_factory_;
  35. DISALLOW_COPY_AND_ASSIGN(OffScreenVideoConsumer);
  36. };
  37. } // namespace atom
  38. #endif // ATOM_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_