Commit 825ea585 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Change ImageCapture to operate over MediaStreamComponent

... instead of WebMediaStreamTrack.

CL also converts ImageCaptureFrameGragger for the same.

This is part of the effort to reduce the needless use of
public Blink APIs (wrappers) within renderer/modules.

BUG=704136
R=guidou@chromium.org

Change-Id: I432385671c44a6700316db6b58bf5c190cfba3ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248062Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#779921}
parent 9b81a636
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-blink.h" #include "third_party/blink/public/mojom/permissions/permission_status.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h" #include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_media_track_capabilities.h"
...@@ -28,6 +27,7 @@ ...@@ -28,6 +27,7 @@
#include "third_party/blink/renderer/modules/permissions/permission_utils.h" #include "third_party/blink/renderer/modules/permissions/permission_utils.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mojo/mojo_helper.h" #include "third_party/blink/renderer/platform/mojo/mojo_helper.h"
#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/functional.h"
...@@ -300,11 +300,10 @@ ScriptPromise ImageCapture::grabFrame(ScriptState* script_state) { ...@@ -300,11 +300,10 @@ ScriptPromise ImageCapture::grabFrame(ScriptState* script_state) {
return promise; return promise;
} }
// The platform does not know about MediaStreamTrack, so we wrap it up.
WebMediaStreamTrack track(stream_track_->Component());
auto resolver_callback_adapter = auto resolver_callback_adapter =
std::make_unique<CallbackPromiseAdapter<ImageBitmap, void>>(resolver); std::make_unique<CallbackPromiseAdapter<ImageBitmap, void>>(resolver);
frame_grabber_->GrabFrame(&track, std::move(resolver_callback_adapter), frame_grabber_->GrabFrame(stream_track_->Component(),
std::move(resolver_callback_adapter),
ExecutionContext::From(script_state) ExecutionContext::From(script_state)
->GetTaskRunner(TaskType::kDOMManipulation)); ->GetTaskRunner(TaskType::kDOMManipulation));
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#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_media_stream_source.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/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_source.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.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/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"
...@@ -187,14 +187,14 @@ ImageCaptureFrameGrabber::~ImageCaptureFrameGrabber() { ...@@ -187,14 +187,14 @@ ImageCaptureFrameGrabber::~ImageCaptureFrameGrabber() {
} }
void ImageCaptureFrameGrabber::GrabFrame( void ImageCaptureFrameGrabber::GrabFrame(
WebMediaStreamTrack* track, MediaStreamComponent* component,
std::unique_ptr<ImageCaptureGrabFrameCallbacks> 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);
DCHECK(track && !track->IsNull() && track->GetPlatformTrack()); DCHECK(component && component->GetPlatformTrack());
DCHECK_EQ(WebMediaStreamSource::kTypeVideo, track->Source().GetType()); DCHECK_EQ(MediaStreamSource::kTypeVideo, component->Source()->GetType());
if (frame_grab_in_progress_) { if (frame_grab_in_progress_) {
// Reject grabFrame()s too close back to back. // Reject grabFrame()s too close back to back.
...@@ -212,7 +212,7 @@ void ImageCaptureFrameGrabber::GrabFrame( ...@@ -212,7 +212,7 @@ void ImageCaptureFrameGrabber::GrabFrame(
// https://crbug.com/623042. // https://crbug.com/623042.
frame_grab_in_progress_ = true; frame_grab_in_progress_ = true;
MediaStreamVideoSink::ConnectToTrack( MediaStreamVideoSink::ConnectToTrack(
*track, component,
ConvertToBaseRepeatingCallback(CrossThreadBindRepeating( ConvertToBaseRepeatingCallback(CrossThreadBindRepeating(
&SingleShotFrameHandler::OnVideoFrameOnIOThread, &SingleShotFrameHandler::OnVideoFrameOnIOThread,
base::MakeRefCounted<SingleShotFrameHandler>(), base::MakeRefCounted<SingleShotFrameHandler>(),
......
...@@ -22,7 +22,7 @@ class SkImage; ...@@ -22,7 +22,7 @@ class SkImage;
namespace blink { namespace blink {
class ImageBitmap; class ImageBitmap;
class WebMediaStreamTrack; class MediaStreamComponent;
// A ScopedWebCallbacks is a move-only scoper which helps manage the lifetime of // A ScopedWebCallbacks is a move-only scoper which helps manage the lifetime of
// a blink::WebCallbacks object. This is particularly useful when you're // a blink::WebCallbacks object. This is particularly useful when you're
...@@ -130,7 +130,7 @@ class ImageCaptureFrameGrabber final : public MediaStreamVideoSink { ...@@ -130,7 +130,7 @@ class ImageCaptureFrameGrabber final : public MediaStreamVideoSink {
ImageCaptureFrameGrabber(); ImageCaptureFrameGrabber();
~ImageCaptureFrameGrabber() override; ~ImageCaptureFrameGrabber() override;
void GrabFrame(WebMediaStreamTrack* track, void GrabFrame(MediaStreamComponent* component,
std::unique_ptr<ImageCaptureGrabFrameCallbacks> callbacks, std::unique_ptr<ImageCaptureGrabFrameCallbacks> callbacks,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); scoped_refptr<base::SingleThreadTaskRunner> task_runner);
......
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