2019-04-17 21:10:04 +00:00
|
|
|
// Copyright (c) 2019 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2020-04-13 23:39:26 +00:00
|
|
|
#include <string>
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
#include "base/callback.h"
|
|
|
|
#include "base/memory/weak_ptr.h"
|
|
|
|
#include "components/viz/host/client_frame_sink_video_capturer.h"
|
2022-01-10 22:31:39 +00:00
|
|
|
#include "media/capture/mojom/video_capture_buffer.mojom-forward.h"
|
2020-02-27 19:00:07 +00:00
|
|
|
#include "media/capture/mojom/video_capture_types.mojom.h"
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
class OffScreenRenderWidgetHostView;
|
|
|
|
|
2019-05-03 19:08:41 +00:00
|
|
|
typedef base::RepeatingCallback<void(const gfx::Rect&, const SkBitmap&)>
|
|
|
|
OnPaintCallback;
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer {
|
|
|
|
public:
|
|
|
|
OffScreenVideoConsumer(OffScreenRenderWidgetHostView* view,
|
|
|
|
OnPaintCallback callback);
|
|
|
|
~OffScreenVideoConsumer() override;
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
OffScreenVideoConsumer(const OffScreenVideoConsumer&) = delete;
|
|
|
|
OffScreenVideoConsumer& operator=(const OffScreenVideoConsumer&) = delete;
|
|
|
|
|
2019-04-17 21:10:04 +00:00
|
|
|
void SetActive(bool active);
|
|
|
|
void SetFrameRate(int frame_rate);
|
2022-05-05 13:53:39 +00:00
|
|
|
void SizeChanged(const gfx::Size& size_in_pixels);
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// viz::mojom::FrameSinkVideoConsumer implementation.
|
|
|
|
void OnFrameCaptured(
|
2022-01-10 22:31:39 +00:00
|
|
|
::media::mojom::VideoBufferHandlePtr data,
|
2019-04-17 21:10:04 +00:00
|
|
|
::media::mojom::VideoFrameInfoPtr info,
|
|
|
|
const gfx::Rect& content_rect,
|
2020-02-27 19:00:07 +00:00
|
|
|
mojo::PendingRemote<viz::mojom::FrameSinkVideoConsumerFrameCallbacks>
|
|
|
|
callbacks) override;
|
2022-07-13 21:26:16 +00:00
|
|
|
void OnNewCropVersion(uint32_t crop_version) override;
|
2022-02-25 18:17:35 +00:00
|
|
|
void OnFrameWithEmptyRegionCapture() override;
|
2019-04-17 21:10:04 +00:00
|
|
|
void OnStopped() override;
|
2020-04-13 23:39:26 +00:00
|
|
|
void OnLog(const std::string& message) override;
|
2019-04-17 21:10:04 +00:00
|
|
|
|
|
|
|
bool CheckContentRect(const gfx::Rect& content_rect);
|
|
|
|
|
|
|
|
OnPaintCallback callback_;
|
|
|
|
|
|
|
|
OffScreenRenderWidgetHostView* view_;
|
|
|
|
std::unique_ptr<viz::ClientFrameSinkVideoCapturer> video_capturer_;
|
|
|
|
|
2021-01-26 18:16:21 +00:00
|
|
|
base::WeakPtrFactory<OffScreenVideoConsumer> weak_ptr_factory_{this};
|
2019-04-17 21:10:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_OSR_OSR_VIDEO_CONSUMER_H_
|