Commit 12305e46 authored by Findit's avatar Findit

Revert "Onion soup canvas_capture_handler.cc/h"

This reverts commit 2f2d5d96.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 658376 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzJmMmQ1ZDk2MGE1OWE0YTUxMGM0YjBhZGZlYTNkMzQwNDk3ZGZmMWQM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.linux/Fuchsia%20ARM64/69714

Sample Failed Step: compile

Original change's description:
> Onion soup canvas_capture_handler.cc/h
> 
> This is a first step to OnionSoup content/renderer/media_capture_from_element/.
> 
> It summary, this CL
> 
> - Moves content/renderer/media_capture_from_element/canvas_capture_handler* to
>   third_party/blink/renderer/modules/mediacapturefromelement/.
> - Adapts the existing code for Blink restrictions, eg use WTF::Bind
>   instead of base::Bind.
> - Removes the code that used to plumb the creation of
>   content::CanvasCaptureHandler instances through blink::Platform, and make
>   blink::HTMLCanvasElementCapture to create it (see the second TODO
>   below).
> 
> To be done (follow up CLs):
> 
> - migrate some remaining base::Bind{Once,Repeating} uses to the
>   respective Blink/WTF alternatives. This is now blocked on having
>   a CrossThreadBindOnce implementation available (see
>   crrev.com/c/1597228).
> - eliminate blink::WebCanvasCaptureHandler
>   third_party/blink/public/platform/web_canvas_capture_handler.h.
>   Note that this is not done now because there is code in
>   third_party/blink/renderer/core/html/canvas/canvas_draw_listener.cc|h
>   that use blink::WebCanvasCaptureHandler, and can not use
>   blink::CanvasCaptureHandler directly, because core/ can not depend on
>   modules/.
> 
> R=kentaro@chromium.org, guidou@chromium.org
> 
> BUG=787261
> 
> Change-Id: Id2dc1f6441e2568c8420f0849a2cb5f87f9a6d75
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1600898
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Guido Urdaneta <guidou@chromium.org>
> Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#658376}


No-Presubmit: true
No-Tree-Checks: true
No-Try: true
BUG=787261

Change-Id: Ic421bd5c65d48ec6b9c1036833fc6e6fcb203be7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605343
Cr-Commit-Position: refs/heads/master@{#658383}
parent 5f38b3b2
......@@ -357,6 +357,8 @@ target(link_target_type, "renderer") {
"media/webrtc_local_audio_source_provider.h",
"media/webrtc_logging.cc",
"media/webrtc_logging.h",
"media_capture_from_element/canvas_capture_handler.cc",
"media_capture_from_element/canvas_capture_handler.h",
"media_capture_from_element/html_audio_element_capturer_source.cc",
"media_capture_from_element/html_audio_element_capturer_source.h",
"media_capture_from_element/html_video_element_capturer_source.cc",
......
......@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/mediacapturefromelement/canvas_capture_handler.h"
#include "content/renderer/media_capture_from_element/canvas_capture_handler.h"
#include <utility>
#include "base/base64.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/viz/common/gl_helper.h"
#include "media/base/limits.h"
#include "third_party/blink/public/platform/modules/mediastream/webrtc_uma_histograms.h"
......@@ -20,8 +22,6 @@
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_capturer_source.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_source.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/base64.h"
#include "third_party/libyuv/include/libyuv.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
......@@ -29,7 +29,7 @@
using media::VideoFrame;
namespace blink {
namespace content {
namespace {
......@@ -64,9 +64,9 @@ class VideoCapturerSource : public media::VideoCapturerSource {
media::VideoCaptureFormats GetPreferredFormats() override {
DCHECK_CALLED_ON_VALID_THREAD(main_render_thread_checker_);
media::VideoCaptureFormats formats;
formats.push_back(media::VideoCaptureFormat(gfx::Size(size_), frame_rate_,
formats.push_back(media::VideoCaptureFormat(size_, frame_rate_,
media::PIXEL_FORMAT_I420));
formats.push_back(media::VideoCaptureFormat(gfx::Size(size_), frame_rate_,
formats.push_back(media::VideoCaptureFormat(size_, frame_rate_,
media::PIXEL_FORMAT_I420A));
return formats;
}
......@@ -185,8 +185,7 @@ void CanvasCaptureHandler::SendNewFrame(
SendFrame(ConvertToYUVFrame(image->isOpaque(), false,
static_cast<const uint8_t*>(pixmap.addr(0, 0)),
gfx::Size(pixmap.width(), pixmap.height()),
static_cast<int>(pixmap.rowBytes()),
pixmap.colorType()),
pixmap.rowBytes(), pixmap.colorType()),
timestamp, GetImageYUVColorSpace(image));
return;
}
......@@ -308,9 +307,9 @@ void CanvasCaptureHandler::ReadARGBPixelsAsync(
context_provider->GetGLHelper()->ReadbackTextureAsync(
texture_info.fID, image_size,
temp_argb_frame->visible_data(VideoFrame::kARGBPlane), kN32_SkColorType,
WTF::Bind(&CanvasCaptureHandler::OnARGBPixelsReadAsync,
weak_ptr_factory_.GetWeakPtr(), image, temp_argb_frame,
timestamp, surface_origin != kTopLeft_GrSurfaceOrigin));
base::BindOnce(&CanvasCaptureHandler::OnARGBPixelsReadAsync,
weak_ptr_factory_.GetWeakPtr(), image, temp_argb_frame,
timestamp, surface_origin != kTopLeft_GrSurfaceOrigin));
}
void CanvasCaptureHandler::ReadYUVPixelsAsync(
......@@ -347,9 +346,9 @@ void CanvasCaptureHandler::ReadYUVPixelsAsync(
output_frame->visible_data(media::VideoFrame::kUPlane),
output_frame->stride(media::VideoFrame::kVPlane),
output_frame->visible_data(media::VideoFrame::kVPlane), gfx::Point(0, 0),
WTF::Bind(&CanvasCaptureHandler::OnYUVPixelsReadAsync,
weak_ptr_factory_.GetWeakPtr(), image, output_frame,
timestamp));
base::BindOnce(&CanvasCaptureHandler::OnYUVPixelsReadAsync,
weak_ptr_factory_.GetWeakPtr(), image, output_frame,
timestamp));
}
void CanvasCaptureHandler::OnARGBPixelsReadAsync(
......@@ -480,10 +479,9 @@ void CanvasCaptureHandler::SendFrame(scoped_refptr<VideoFrame> video_frame,
void CanvasCaptureHandler::AddVideoCapturerSourceToVideoTrack(
std::unique_ptr<media::VideoCapturerSource> source,
blink::WebMediaStreamTrack* web_track) {
Vector<char> base64_track_id;
Base64Encode(base::RandBytesAsString(64).c_str(), base64_track_id);
const auto track_id =
WebString::FromUTF8(base64_track_id.data(), base64_track_id.size());
std::string str_track_id;
base::Base64Encode(base::RandBytesAsString(64), &str_track_id);
const blink::WebString track_id = blink::WebString::FromASCII(str_track_id);
media::VideoCaptureFormats preferred_formats = source->GetPreferredFormats();
blink::MediaStreamVideoSource* media_stream_source =
new blink::MediaStreamVideoCapturerSource(
......@@ -504,4 +502,4 @@ void CanvasCaptureHandler::AddVideoCapturerSourceToVideoTrack(
true));
}
} // namespace blink
} // namespace content
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIACAPTUREFROMELEMENT_CANVAS_CAPTURE_HANDLER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIACAPTUREFROMELEMENT_CANVAS_CAPTURE_HANDLER_H_
#ifndef CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_CANVAS_CAPTURE_HANDLER_H_
#define CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_CANVAS_CAPTURE_HANDLER_H_
#include <stddef.h>
#include <stdint.h>
......@@ -11,21 +11,21 @@
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
#include "media/base/video_frame_pool.h"
#include "media/capture/video_capturer_source.h"
#include "third_party/blink/public/platform/web_canvas_capture_handler.h"
#include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/skia/include/core/SkImageInfo.h"
class SkImage;
namespace blink {
namespace content {
// CanvasCaptureHandler acts as the link between Blink side HTMLCanvasElement
// and Chrome side VideoCapturerSource. It is responsible for handling
......@@ -36,7 +36,7 @@ namespace blink {
// All methods are called on the same thread as construction and destruction,
// i.e. the Main Render thread. Note that a CanvasCaptureHandlerDelegate is
// used to send back frames to |io_task_runner_|, i.e. IO thread.
class MODULES_EXPORT CanvasCaptureHandler final
class CONTENT_EXPORT CanvasCaptureHandler final
: public blink::WebCanvasCaptureHandler {
public:
~CanvasCaptureHandler() override;
......@@ -127,6 +127,6 @@ class MODULES_EXPORT CanvasCaptureHandler final
DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler);
};
} // namespace blink
} // namespace content
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIACAPTUREFROMELEMENT_CANVAS_CAPTURE_HANDLER_H_
#endif // CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_CANVAS_CAPTURE_HANDLER_H_
......@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/mediacapturefromelement/canvas_capture_handler.h"
#include "content/renderer/media_capture_from_element/canvas_capture_handler.h"
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "content/child/child_process.h"
#include "media/base/limits.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -15,7 +17,6 @@
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_capturer_source.h"
#include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkRefCnt.h"
......@@ -26,7 +27,7 @@ using ::testing::SaveArg;
using ::testing::Test;
using ::testing::TestWithParam;
namespace blink {
namespace content {
namespace {
......@@ -48,7 +49,9 @@ ACTION_P(RunClosure, closure) {
class CanvasCaptureHandlerTest
: public TestWithParam<testing::tuple<bool, int, int>> {
public:
CanvasCaptureHandlerTest() = default;
CanvasCaptureHandlerTest()
: scoped_task_environment_(
base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
void SetUp() override {
canvas_capture_handler_ = CanvasCaptureHandler::CreateCanvasCaptureHandler(
......@@ -128,7 +131,11 @@ class CanvasCaptureHandlerTest
return ms_source->GetSourceForTesting();
}
ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform_;
// A ChildProcess is needed to fool the Tracks and Sources believing they are
// on the right threads. A ScopedTaskEnvironment must be instantiated before
// ChildProcess to prevent it from leaking a ThreadPool.
base::test::ScopedTaskEnvironment scoped_task_environment_;
ChildProcess child_process_;
private:
DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandlerTest);
......@@ -183,8 +190,7 @@ TEST_P(CanvasCaptureHandlerTest, GetFormatsStartAndStop) {
params,
base::BindRepeating(&CanvasCaptureHandlerTest::OnDeliverFrame,
base::Unretained(this)),
base::BindRepeating(&CanvasCaptureHandlerTest::OnRunning,
base::Unretained(this)));
base::Bind(&CanvasCaptureHandlerTest::OnRunning, base::Unretained(this)));
canvas_capture_handler_->SendNewFrame(
GenerateTestImage(testing::get<0>(GetParam()),
testing::get<1>(GetParam()),
......@@ -241,4 +247,4 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(kTestCanvasCaptureFrameEvenSize,
kTestCanvasCaptureFrameOddSize)));
} // namespace blink
} // namespace content
......@@ -55,6 +55,7 @@
#include "content/renderer/media/audio_decoder.h"
#include "content/renderer/media/renderer_webaudiodevice_impl.h"
#include "content/renderer/media/webrtc/transmission_encoding_info_handler.h"
#include "content/renderer/media_capture_from_element/canvas_capture_handler.h"
#include "content/renderer/media_capture_from_element/html_audio_element_capturer_source.h"
#include "content/renderer/media_capture_from_element/html_video_element_capturer_source.h"
#include "content/renderer/media_recorder/media_recorder_handler.h"
......@@ -128,6 +129,7 @@ using blink::Platform;
using blink::WebAudioDevice;
using blink::WebAudioLatencyHint;
using blink::WebBlobRegistry;
using blink::WebCanvasCaptureHandler;
using blink::WebDatabaseObserver;
using blink::WebMediaPlayer;
using blink::WebMediaRecorderHandler;
......@@ -757,6 +759,17 @@ RendererBlinkPlatformImpl::CreateWebRtcAsyncResolverFactory() {
//------------------------------------------------------------------------------
std::unique_ptr<WebCanvasCaptureHandler>
RendererBlinkPlatformImpl::CreateCanvasCaptureHandler(
const WebSize& size,
double frame_rate,
WebMediaStreamTrack* track) {
return CanvasCaptureHandler::CreateCanvasCaptureHandler(
size, frame_rate, RenderThread::Get()->GetIOTaskRunner(), track);
}
//------------------------------------------------------------------------------
void RendererBlinkPlatformImpl::CreateHTMLVideoElementCapturer(
WebMediaStream* web_media_stream,
WebMediaPlayer* web_media_player,
......
......@@ -39,6 +39,7 @@ namespace blink {
namespace scheduler {
class WebThreadScheduler;
}
class WebCanvasCaptureHandler;
class WebGraphicsContext3DProvider;
class WebMediaPlayer;
class WebMediaRecorderHandler;
......@@ -159,6 +160,10 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
blink::WebLocalFrame* frame) override;
std::unique_ptr<webrtc::AsyncResolverFactory>
CreateWebRtcAsyncResolverFactory() override;
std::unique_ptr<blink::WebCanvasCaptureHandler> CreateCanvasCaptureHandler(
const blink::WebSize& size,
double frame_rate,
blink::WebMediaStreamTrack* track) override;
void CreateHTMLVideoElementCapturer(
blink::WebMediaStream* web_media_stream,
blink::WebMediaPlayer* web_media_player,
......
......@@ -1865,6 +1865,7 @@ test("content_unittests") {
"../renderer/media/webrtc/webrtc_set_description_observer_unittest.cc",
"../renderer/media/webrtc/webrtc_video_track_source_unittest.cc",
"../renderer/media/webrtc_local_audio_source_provider_unittest.cc",
"../renderer/media_capture_from_element/canvas_capture_handler_unittest.cc",
"../renderer/media_capture_from_element/html_audio_element_capturer_source_unittest.cc",
"../renderer/media_capture_from_element/html_video_element_capturer_source_unittest.cc",
"../renderer/media_recorder/audio_track_recorder_unittest.cc",
......
......@@ -105,6 +105,7 @@ struct ThreadCreationParams;
class WebAudioBus;
class WebAudioLatencyHint;
class WebBlobRegistry;
class WebCanvasCaptureHandler;
class WebCookieJar;
class WebCrypto;
class WebDatabaseObserver;
......@@ -116,6 +117,7 @@ class WebMediaPlayer;
class WebMediaRecorderHandler;
class WebMediaStream;
class WebMediaStreamCenter;
class WebMediaStreamTrack;
class WebPrescientNetworking;
class WebPublicSuffixList;
class WebPushProvider;
......@@ -132,6 +134,7 @@ class WebTransmissionEncodingInfoHandler;
class WebURLLoaderMockFactory;
class WebURLResponse;
class WebURLResponse;
struct WebSize;
namespace scheduler {
class WebThreadScheduler;
......@@ -637,6 +640,10 @@ class BLINK_PLATFORM_EXPORT Platform {
virtual std::unique_ptr<webrtc::AsyncResolverFactory>
CreateWebRtcAsyncResolverFactory();
// Creates a WebCanvasCaptureHandler to capture Canvas output.
virtual std::unique_ptr<WebCanvasCaptureHandler>
CreateCanvasCaptureHandler(const WebSize&, double, WebMediaStreamTrack*);
// Fills in the WebMediaStream to capture from the WebMediaPlayer identified
// by the second parameter.
virtual void CreateHTMLVideoElementCapturer(
......
......@@ -323,7 +323,6 @@ jumbo_source_set("unit_tests") {
"media_controls/media_controls_impl_test.cc",
"media_controls/media_controls_orientation_lock_delegate_test.cc",
"media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc",
"mediacapturefromelement/canvas_capture_handler_unittest.cc",
"mediastream/media_constraints_test.cc",
"mediastream/media_devices_test.cc",
"mediastream/media_stream_video_capturer_source_test.cc",
......
......@@ -8,8 +8,6 @@ blink_modules_sources("mediacapturefromelement") {
sources = [
"auto_canvas_draw_listener.cc",
"auto_canvas_draw_listener.h",
"canvas_capture_handler.cc",
"canvas_capture_handler.h",
"canvas_capture_media_stream_track.cc",
"canvas_capture_media_stream_track.h",
"html_canvas_element_capture.cc",
......@@ -21,11 +19,4 @@ blink_modules_sources("mediacapturefromelement") {
"timed_canvas_draw_listener.cc",
"timed_canvas_draw_listener.h",
]
deps = [
"//components/viz/common",
"//media",
"//skia",
"//third_party/libyuv",
]
}
......@@ -3,17 +3,4 @@ include_rules = [
"+third_party/blink/renderer/modules/encryptedmedia",
"+third_party/blink/renderer/modules/mediacapturefromelement",
"+third_party/blink/renderer/modules/mediastream",
"+third_party/blink/renderer/modules/modules_export.h",
"+components/viz/common",
"+media/base",
"+media/capture",
"+third_party/libyuv",
"+ui/gfx/color_space.h",
]
specific_include_rules = {
"canvas_capture_handler_unittest\.cc" : [
"+base/run_loop.h",
],
}
......@@ -6,10 +6,10 @@
#include <memory>
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_canvas_capture_handler.h"
#include "third_party/blink/public/platform/web_media_stream.h"
#include "third_party/blink/public/platform/web_media_stream_track.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/modules/mediacapturefromelement/canvas_capture_handler.h"
#include "third_party/blink/renderer/modules/mediacapturefromelement/canvas_capture_media_stream_track.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream.h"
......@@ -57,12 +57,11 @@ MediaStream* HTMLCanvasElementCapture::captureStream(
const WebSize size(element.width(), element.height());
std::unique_ptr<WebCanvasCaptureHandler> handler;
if (given_frame_rate) {
handler = CanvasCaptureHandler::CreateCanvasCaptureHandler(
size, frame_rate, Platform::Current()->GetIOTaskRunner(), &track);
handler = Platform::Current()->CreateCanvasCaptureHandler(size, frame_rate,
&track);
} else {
handler = CanvasCaptureHandler::CreateCanvasCaptureHandler(
size, kDefaultFrameRate, Platform::Current()->GetIOTaskRunner(),
&track);
handler = Platform::Current()->CreateCanvasCaptureHandler(
size, kDefaultFrameRate, &track);
}
if (!handler) {
......
......@@ -40,6 +40,7 @@
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/platform/interface_provider.h"
#include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h"
#include "third_party/blink/public/platform/web_canvas_capture_handler.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/public/platform/web_media_recorder_handler.h"
#include "third_party/blink/public/platform/web_media_stream_center.h"
......@@ -333,6 +334,13 @@ std::unique_ptr<WebMediaStreamCenter> Platform::CreateMediaStreamCenter() {
return nullptr;
}
std::unique_ptr<WebCanvasCaptureHandler> Platform::CreateCanvasCaptureHandler(
const WebSize&,
double,
WebMediaStreamTrack*) {
return nullptr;
}
std::unique_ptr<webrtc::RtpCapabilities> Platform::GetRtpSenderCapabilities(
const WebString& kind) {
return nullptr;
......
......@@ -184,7 +184,6 @@ _CONFIG = [
'base::RandGenerator',
'base::RandDouble',
'base::RandBytes',
'base::RandBytesAsString',
# Feature list checking.
'base::Feature.*',
......@@ -549,15 +548,6 @@ _CONFIG = [
'media::.+',
]
},
{
'paths': [
'third_party/blink/renderer/modules/mediacapturefromelement/',
],
'allowed': [
'media::.+',
'libyuv::.+',
]
},
{
'paths': [
'third_party/blink/renderer/modules/mediastream/',
......
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