Commit 5345de28 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

ImageCaptureFrameGrabber post-OnionSoup clean ups

This CL:

- Moves the SkImageDeliverCB alias from ImageCaptureFrameGrabber to
  its inner class SingleShotFrameHandler.
- Stops referencing WebCallbacks in favor of CallbackPromiseAdapter
  (blink internal).

R=jbroman@chromium.org

BUG=945851,787245

Change-Id: I874d52aac7c53c8c32a77bd0f7defdaff3fac69b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582140
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653594}
parent f213ba29
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
#include "media/base/video_types.h" #include "media/base/video_types.h"
#include "media/base/video_util.h" #include "media/base/video_util.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "third_party/blink/public/platform/web_callbacks.h"
#include "third_party/blink/public/platform/web_media_stream_source.h" #include "third_party/blink/public/platform/web_media_stream_source.h"
#include "third_party/blink/public/platform/web_media_stream_track.h" #include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" #include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h"
#include "third_party/libyuv/include/libyuv.h" #include "third_party/libyuv/include/libyuv.h"
#include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkImage.h"
...@@ -22,7 +23,7 @@ namespace blink { ...@@ -22,7 +23,7 @@ namespace blink {
namespace { namespace {
void OnError(std::unique_ptr<WebImageCaptureGrabFrameCallbacks> callbacks) { void OnError(std::unique_ptr<ImageCaptureGrabFrameCallbacks> callbacks) {
callbacks->OnError(); callbacks->OnError();
} }
...@@ -51,6 +52,7 @@ class ImageCaptureFrameGrabber::SingleShotFrameHandler ...@@ -51,6 +52,7 @@ class ImageCaptureFrameGrabber::SingleShotFrameHandler
// Receives a |frame| and converts its pixels into a SkImage via an internal // Receives a |frame| and converts its pixels into a SkImage via an internal
// PaintSurface and SkPixmap. Alpha channel, if any, is copied. // PaintSurface and SkPixmap. Alpha channel, if any, is copied.
using SkImageDeliverCB = WTF::CrossThreadFunction<void(sk_sp<SkImage>)>;
void OnVideoFrameOnIOThread( void OnVideoFrameOnIOThread(
SkImageDeliverCB callback, SkImageDeliverCB callback,
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
...@@ -134,7 +136,7 @@ ImageCaptureFrameGrabber::~ImageCaptureFrameGrabber() { ...@@ -134,7 +136,7 @@ ImageCaptureFrameGrabber::~ImageCaptureFrameGrabber() {
void ImageCaptureFrameGrabber::GrabFrame( void ImageCaptureFrameGrabber::GrabFrame(
WebMediaStreamTrack* track, WebMediaStreamTrack* track,
std::unique_ptr<WebImageCaptureGrabFrameCallbacks> callbacks, std::unique_ptr<ImageCaptureGrabFrameCallbacks> callbacks,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!!callbacks); DCHECK(!!callbacks);
...@@ -170,7 +172,7 @@ void ImageCaptureFrameGrabber::GrabFrame( ...@@ -170,7 +172,7 @@ void ImageCaptureFrameGrabber::GrabFrame(
} }
void ImageCaptureFrameGrabber::OnSkImage( void ImageCaptureFrameGrabber::OnSkImage(
ScopedWebCallbacks<WebImageCaptureGrabFrameCallbacks> callbacks, ScopedWebCallbacks<ImageCaptureGrabFrameCallbacks> callbacks,
sk_sp<SkImage> image) { sk_sp<SkImage> image) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......
...@@ -12,20 +12,19 @@ ...@@ -12,20 +12,19 @@
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "third_party/blink/public/platform/scoped_web_callbacks.h" #include "third_party/blink/public/platform/scoped_web_callbacks.h"
#include "third_party/blink/public/platform/web_callbacks.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_sink.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_video_sink.h"
#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h"
#include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkRefCnt.h"
class SkImage; class SkImage;
namespace blink { namespace blink {
class ImageBitmap;
class WebMediaStreamTrack; class WebMediaStreamTrack;
// TODO(crbug.com/945851): Avoid referencing to WebCallbacks, and reference to using ImageCaptureGrabFrameCallbacks =
// CallbackPromiseAdapter directly. CallbackPromiseAdapter<ImageBitmap, void>;
using WebImageCaptureGrabFrameCallbacks = WebCallbacks<sk_sp<SkImage>, void>;
// This class grabs Video Frames from a given Media Stream Video Track, binding // This class grabs Video Frames from a given Media Stream Video Track, binding
// a method of an ephemeral SingleShotFrameHandler every time grabFrame() is // a method of an ephemeral SingleShotFrameHandler every time grabFrame() is
...@@ -34,21 +33,18 @@ using WebImageCaptureGrabFrameCallbacks = WebCallbacks<sk_sp<SkImage>, void>; ...@@ -34,21 +33,18 @@ using WebImageCaptureGrabFrameCallbacks = WebCallbacks<sk_sp<SkImage>, void>;
// OnSkBitmap(). This class is single threaded throughout. // OnSkBitmap(). This class is single threaded throughout.
class ImageCaptureFrameGrabber final : public MediaStreamVideoSink { class ImageCaptureFrameGrabber final : public MediaStreamVideoSink {
public: public:
using SkImageDeliverCB = WTF::CrossThreadFunction<void(sk_sp<SkImage>)>;
ImageCaptureFrameGrabber(); ImageCaptureFrameGrabber();
~ImageCaptureFrameGrabber() override; ~ImageCaptureFrameGrabber() override;
void GrabFrame(WebMediaStreamTrack* track, void GrabFrame(WebMediaStreamTrack* track,
std::unique_ptr<WebImageCaptureGrabFrameCallbacks> callbacks, std::unique_ptr<ImageCaptureGrabFrameCallbacks> callbacks,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner);
private: private:
// Internal class to receive, convert and forward one frame. // Internal class to receive, convert and forward one frame.
class SingleShotFrameHandler; class SingleShotFrameHandler;
void OnSkImage( void OnSkImage(ScopedWebCallbacks<ImageCaptureGrabFrameCallbacks> callbacks,
ScopedWebCallbacks<WebImageCaptureGrabFrameCallbacks> callbacks,
sk_sp<SkImage> image); sk_sp<SkImage> image);
// Flag to indicate that there is a frame grabbing in progress. // Flag to indicate that there is a frame grabbing in progress.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment