#include "third_party/blink/renderer/modules/mediacapturefromelement/canvas_capture_handler.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/rand_util.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "media/base/limits.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_capturer_source.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/static_bitmap_image_to_video_frame_copier.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component_impl.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_source.h"
#include "third_party/blink/renderer/platform/mediastream/webrtc_uma_histograms.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h"
namespace blink {
class CanvasVideoCapturerSource : public VideoCapturerSource { … };
class CanvasCaptureHandler::CanvasCaptureHandlerDelegate { … };
CanvasCaptureHandler::CanvasCaptureHandler(
LocalFrame* frame,
const gfx::Size& size,
double frame_rate,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
MediaStreamComponent** component)
: … { … }
CanvasCaptureHandler::~CanvasCaptureHandler() { … }
std::unique_ptr<CanvasCaptureHandler>
CanvasCaptureHandler::CreateCanvasCaptureHandler(
LocalFrame* frame,
const gfx::Size& size,
double frame_rate,
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
MediaStreamComponent** component) { … }
CanvasCaptureHandler::NewFrameCallback
CanvasCaptureHandler::GetNewFrameCallback() { … }
void CanvasCaptureHandler::OnNewFrameCallback(
base::ScopedClosureRunner decrement_runner,
base::TimeTicks this_frame_ticks,
const gfx::ColorSpace& color_space,
scoped_refptr<media::VideoFrame> video_frame) { … }
bool CanvasCaptureHandler::NeedsNewFrame() const { … }
void CanvasCaptureHandler::StartVideoCapture(
const media::VideoCaptureParams& params,
const VideoCaptureDeliverFrameCB& new_frame_callback,
const VideoCapturerSource::RunningCallback& running_callback) { … }
void CanvasCaptureHandler::RequestRefreshFrame() { … }
void CanvasCaptureHandler::StopVideoCapture() { … }
void CanvasCaptureHandler::SendFrame(
base::TimeTicks this_frame_ticks,
const gfx::ColorSpace& color_space,
scoped_refptr<media::VideoFrame> video_frame) { … }
void CanvasCaptureHandler::AddVideoCapturerSourceToVideoTrack(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
LocalFrame* frame,
std::unique_ptr<VideoCapturerSource> source,
MediaStreamComponent** component) { … }
void CanvasCaptureHandler::SendRefreshFrame() { … }
}