Commit ac94dafa authored by Christian Fremerey's avatar Christian Fremerey Committed by Commit Bot

Reland [Video Capture Service] Inject GPU dependencies when starting service via extension

Patchset 1 is the reverted CL as previously reviewed.
Patchset 2 is the fix.

The reason for the revert was a linker error for component builds.
The fix is to add a missing CONTENT_EXPORT.

---

Original CL description:

The video capture service requires GPU dependencies to be injected after startup
in order to enable accelerated MJPEG decoding. This CL adds this injection call
where the service is started from the media_perception_private extension.

The injected dependencies use classes that used to live in
content/browser/renderer_host/media. To be able to reuse them for the
extension, this CL moves them to a location that is accessible to both
usage sites, i.e. to content/browser/gpu with a public interface in
content/public/browser.

TBR=jam@chromium.org

Bug: 877690
Change-Id: Ibeb29361c762d8366f1433d918e8abead0a39173
Reviewed-on: https://chromium-review.googlesource.com/1208821Reviewed-by: default avatarChristian Fremerey <chfremer@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Christian Fremerey <chfremer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589242}
parent 2203ab11
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.h" #include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/connector.h"
#include "services/video_capture/public/mojom/constants.mojom.h" #include "services/video_capture/public/mojom/constants.mojom.h"
#include "services/video_capture/public/mojom/device_factory.mojom.h" #include "services/video_capture/public/mojom/device_factory.mojom.h"
...@@ -78,6 +80,13 @@ void MediaPerceptionAPIDelegateChromeOS:: ...@@ -78,6 +80,13 @@ void MediaPerceptionAPIDelegateChromeOS::
if (!connector) if (!connector)
return; return;
connector->BindInterface(video_capture::mojom::kServiceName, provider); connector->BindInterface(video_capture::mojom::kServiceName, provider);
video_capture::mojom::AcceleratorFactoryPtr accelerator_factory;
mojo::MakeStrongBinding(
std::make_unique<
content::DelegateToBrowserGpuServiceAcceleratorFactory>(),
mojo::MakeRequest(&accelerator_factory));
(*provider)->InjectGpuDependencies(std::move(accelerator_factory));
} }
} // namespace extensions } // namespace extensions
...@@ -887,6 +887,7 @@ jumbo_source_set("browser") { ...@@ -887,6 +887,7 @@ jumbo_source_set("browser") {
"gpu/browser_gpu_client_delegate.h", "gpu/browser_gpu_client_delegate.h",
"gpu/compositor_util.cc", "gpu/compositor_util.cc",
"gpu/compositor_util.h", "gpu/compositor_util.h",
"gpu/delegate_to_browser_gpu_service_accelerator_factory.cc",
"gpu/gpu_client.cc", "gpu/gpu_client.cc",
"gpu/gpu_data_manager_impl.cc", "gpu/gpu_data_manager_impl.cc",
"gpu/gpu_data_manager_impl.h", "gpu/gpu_data_manager_impl.h",
...@@ -904,6 +905,8 @@ jumbo_source_set("browser") { ...@@ -904,6 +905,8 @@ jumbo_source_set("browser") {
"gpu/gpu_process_host.h", "gpu/gpu_process_host.h",
"gpu/shader_cache_factory.cc", "gpu/shader_cache_factory.cc",
"gpu/shader_cache_factory.h", "gpu/shader_cache_factory.h",
"gpu/video_capture_dependencies.cc",
"gpu/video_capture_dependencies.h",
"histogram_controller.cc", "histogram_controller.cc",
"histogram_controller.h", "histogram_controller.h",
"histogram_subscriber.h", "histogram_subscriber.h",
...@@ -1446,8 +1449,6 @@ jumbo_source_set("browser") { ...@@ -1446,8 +1449,6 @@ jumbo_source_set("browser") {
"renderer_host/media/video_capture_controller.cc", "renderer_host/media/video_capture_controller.cc",
"renderer_host/media/video_capture_controller.h", "renderer_host/media/video_capture_controller.h",
"renderer_host/media/video_capture_controller_event_handler.h", "renderer_host/media/video_capture_controller_event_handler.h",
"renderer_host/media/video_capture_dependencies.cc",
"renderer_host/media/video_capture_dependencies.h",
"renderer_host/media/video_capture_device_launch_observer.h", "renderer_host/media/video_capture_device_launch_observer.h",
"renderer_host/media/video_capture_factory_delegate.cc", "renderer_host/media/video_capture_factory_delegate.cc",
"renderer_host/media/video_capture_factory_delegate.h", "renderer_host/media/video_capture_factory_delegate.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h"
#include "content/browser/gpu/video_capture_dependencies.h"
namespace content {
void DelegateToBrowserGpuServiceAcceleratorFactory::CreateJpegDecodeAccelerator(
media::mojom::JpegDecodeAcceleratorRequest jda_request) {
VideoCaptureDependencies::CreateJpegDecodeAccelerator(std::move(jda_request));
}
} // namespace content
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/renderer_host/media/video_capture_dependencies.h" #include "content/browser/gpu/video_capture_dependencies.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace content { namespace content {
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEPENDENCIES_H_ #ifndef CONTENT_BROWSER_GPU_VIDEO_CAPTURE_DEPENDENCIES_H_
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEPENDENCIES_H_ #define CONTENT_BROWSER_GPU_VIDEO_CAPTURE_DEPENDENCIES_H_
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "services/video_capture/public/mojom/device_factory.mojom.h"
#include "services/viz/privileged/interfaces/gl/gpu_service.mojom.h" #include "services/viz/privileged/interfaces/gl/gpu_service.mojom.h"
namespace content { namespace content {
// Browser-provided GPU dependencies for video capture. // Browser-process-provided GPU dependencies for video capture.
class CONTENT_EXPORT VideoCaptureDependencies { class CONTENT_EXPORT VideoCaptureDependencies {
public: public:
static void CreateJpegDecodeAccelerator( static void CreateJpegDecodeAccelerator(
...@@ -22,4 +21,4 @@ class CONTENT_EXPORT VideoCaptureDependencies { ...@@ -22,4 +21,4 @@ class CONTENT_EXPORT VideoCaptureDependencies {
} // namespace content } // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_DEPENDENCIES_H_ #endif // CONTENT_BROWSER_GPU_VIDEO_CAPTURE_DEPENDENCIES_H_
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/gpu/video_capture_dependencies.h"
#include "content/browser/renderer_host/media/in_process_launched_video_capture_device.h" #include "content/browser/renderer_host/media/in_process_launched_video_capture_device.h"
#include "content/browser/renderer_host/media/video_capture_controller.h" #include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/browser/renderer_host/media/video_capture_dependencies.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/video_capture_dependencies.h"
#include "content/browser/renderer_host/media/audio_input_device_manager.h" #include "content/browser/renderer_host/media/audio_input_device_manager.h"
#include "content/browser/renderer_host/media/audio_service_listener.h" #include "content/browser/renderer_host/media/audio_service_listener.h"
#include "content/browser/renderer_host/media/in_process_video_capture_provider.h" #include "content/browser/renderer_host/media/in_process_video_capture_provider.h"
...@@ -36,7 +37,6 @@ ...@@ -36,7 +37,6 @@
#include "content/browser/renderer_host/media/media_devices_manager.h" #include "content/browser/renderer_host/media/media_devices_manager.h"
#include "content/browser/renderer_host/media/media_stream_ui_proxy.h" #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
#include "content/browser/renderer_host/media/service_video_capture_provider.h" #include "content/browser/renderer_host/media/service_video_capture_provider.h"
#include "content/browser/renderer_host/media/video_capture_dependencies.h"
#include "content/browser/renderer_host/media/video_capture_manager.h" #include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/browser/renderer_host/media/video_capture_provider_switcher.h" #include "content/browser/renderer_host/media/video_capture_provider_switcher.h"
#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h"
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#include "content/browser/renderer_host/media/service_video_capture_provider.h" #include "content/browser/renderer_host/media/service_video_capture_provider.h"
#include "content/browser/renderer_host/media/service_video_capture_device_launcher.h" #include "content/browser/renderer_host/media/service_video_capture_device_launcher.h"
#include "content/browser/renderer_host/media/video_capture_dependencies.h"
#include "content/browser/renderer_host/media/video_capture_factory_delegate.h" #include "content/browser/renderer_host/media/video_capture_factory_delegate.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/delegate_to_browser_gpu_service_accelerator_factory.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/callback_helpers.h" #include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
...@@ -47,19 +47,10 @@ class ServiceConnectorImpl ...@@ -47,19 +47,10 @@ class ServiceConnectorImpl
std::unique_ptr<service_manager::Connector> connector_; std::unique_ptr<service_manager::Connector> connector_;
}; };
class DelegateToBrowserGpuServiceAcceleratorFactory
: public video_capture::mojom::AcceleratorFactory {
public:
void CreateJpegDecodeAccelerator(
media::mojom::JpegDecodeAcceleratorRequest jda_request) override {
content::VideoCaptureDependencies::CreateJpegDecodeAccelerator(
std::move(jda_request));
}
};
std::unique_ptr<video_capture::mojom::AcceleratorFactory> std::unique_ptr<video_capture::mojom::AcceleratorFactory>
CreateAcceleratorFactory() { CreateAcceleratorFactory() {
return std::make_unique<DelegateToBrowserGpuServiceAcceleratorFactory>(); return std::make_unique<
content::DelegateToBrowserGpuServiceAcceleratorFactory>();
} }
} // anonymous namespace } // anonymous namespace
......
...@@ -102,6 +102,7 @@ jumbo_source_set("browser_sources") { ...@@ -102,6 +102,7 @@ jumbo_source_set("browser_sources") {
"content_browser_client.h", "content_browser_client.h",
"context_factory.h", "context_factory.h",
"cookie_store_factory.h", "cookie_store_factory.h",
"delegate_to_browser_gpu_service_accelerator_factory.h",
"desktop_capture.cc", "desktop_capture.cc",
"desktop_capture.h", "desktop_capture.h",
"desktop_media_id.cc", "desktop_media_id.cc",
......
...@@ -11,6 +11,7 @@ include_rules = [ ...@@ -11,6 +11,7 @@ include_rules = [
"+services/network/public/cpp", "+services/network/public/cpp",
"+services/service_manager/sandbox", "+services/service_manager/sandbox",
"+services/resource_coordinator/public", "+services/resource_coordinator/public",
"+services/video_capture/public/mojom",
"+services/ws/public/mojom", "+services/ws/public/mojom",
] ]
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_DELEGATE_TO_BROWSER_GPU_SERVICE_ACCELERATOR_FACTORY_H_
#define CONTENT_PUBLIC_BROWSER_DELEGATE_TO_BROWSER_GPU_SERVICE_ACCELERATOR_FACTORY_H_
#include "content/common/content_export.h"
#include "services/video_capture/public/mojom/device_factory_provider.mojom.h"
namespace content {
// Implementation of video_capture::mojom::AcceleratorFactor that satisfies
// requests for a JpegDecodeAccelerator by delegating to the global instance of
// viz::mojom::GpuService that is accessible from the Browser process.
class CONTENT_EXPORT DelegateToBrowserGpuServiceAcceleratorFactory
: public video_capture::mojom::AcceleratorFactory {
public:
void CreateJpegDecodeAccelerator(
media::mojom::JpegDecodeAcceleratorRequest jda_request) override;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_DELEGATE_TO_BROWSER_GPU_SERVICE_ACCELERATOR_FACTORY_H_
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