[Cast Streaming] Migrate GVAFImpl to MojoGVAF
This patch moves the GpuVideoAcceleratorImpl to media/mojo/clients and renames it to MojoGpuVideoAccelerator. This class can now be used both in content and in components/mirroring. Cast Streaming will be updated to use this implementation to enable hardware mirroring in the media::cast::MediaVideoEncoderWrapper implementation. Googlers may view the related design doc at: http://go/cast-streaming-media-videoencoder Publicly published design documentation available at: https://tinyurl.com/cast-streaming-mvew Bug: 282984511 Change-Id: I91bba38ea55007d3f3626027308d800aeda0a383 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6095257 Commit-Queue: Jordan Bayles <jophba@chromium.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Frank Liberato <liberato@chromium.org> Cr-Commit-Position: refs/heads/main@{#1398421}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
72aded0322
commit
27c3106041
content
media
fuchsia
video
mojo
clients
BUILD.gnDEPSmojo_codec_factory.ccmojo_codec_factory.hmojo_codec_factory_fuchsia.ccmojo_codec_factory_fuchsia.hmojo_codec_factory_mojo_decoder.ccmojo_codec_factory_mojo_decoder.hmojo_gpu_video_accelerator_factories.ccmojo_gpu_video_accelerator_factories.hmojo_gpu_video_accelerator_factories_unittest.cc
@ -76,12 +76,6 @@ target(link_target_type, "renderer") {
|
||||
"media/audio_decoder.h",
|
||||
"media/batching_media_log.cc",
|
||||
"media/batching_media_log.h",
|
||||
"media/codec_factory.cc",
|
||||
"media/codec_factory.h",
|
||||
"media/codec_factory_mojo.cc",
|
||||
"media/codec_factory_mojo.h",
|
||||
"media/gpu/gpu_video_accelerator_factories_impl.cc",
|
||||
"media/gpu/gpu_video_accelerator_factories_impl.h",
|
||||
"media/inspector_media_event_handler.cc",
|
||||
"media/inspector_media_event_handler.h",
|
||||
"media/media_factory.cc",
|
||||
@ -364,11 +358,7 @@ target(link_target_type, "renderer") {
|
||||
}
|
||||
|
||||
if (is_fuchsia) {
|
||||
sources += [
|
||||
"media/codec_factory_fuchsia.cc",
|
||||
"media/codec_factory_fuchsia.h",
|
||||
"renderer_main_platform_delegate_fuchsia.cc",
|
||||
]
|
||||
sources += [ "renderer_main_platform_delegate_fuchsia.cc" ]
|
||||
public_deps += [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mediacodec:fuchsia.mediacodec_hlcpp" ]
|
||||
|
||||
deps += [
|
||||
|
@ -96,8 +96,6 @@
|
||||
#include "content/renderer/agent_scheduling_group.h"
|
||||
#include "content/renderer/browser_exposed_renderer_interfaces.h"
|
||||
#include "content/renderer/effective_connection_type_helper.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h"
|
||||
#include "content/renderer/media/media_factory.h"
|
||||
#include "content/renderer/media/render_media_client.h"
|
||||
#include "content/renderer/net_info_helper.h"
|
||||
@ -127,6 +125,8 @@
|
||||
#include "media/base/media.h"
|
||||
#include "media/base/media_switches.h"
|
||||
#include "media/media_buildflags.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/mojo/clients/mojo_gpu_video_accelerator_factories.h"
|
||||
#include "media/renderers/default_decoder_factory.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
#include "mojo/public/cpp/bindings/binder_map.h"
|
||||
@ -216,12 +216,12 @@
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
|
||||
#include "content/renderer/media/codec_factory_mojo.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_mojo_decoder.h"
|
||||
#include "media/mojo/mojom/interface_factory.mojom.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
#include "content/renderer/media/codec_factory_fuchsia.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_fuchsia.h"
|
||||
#include "media/mojo/mojom/fuchsia_media.mojom.h"
|
||||
#endif
|
||||
|
||||
@ -1014,7 +1014,7 @@ media::GpuVideoAcceleratorFactories* RenderThreadImpl::GetGpuFactories() {
|
||||
|
||||
GetMediaSequencedTaskRunner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&GpuVideoAcceleratorFactoriesImpl::DestroyContext,
|
||||
base::BindOnce(&media::MojoGpuVideoAcceleratorFactories::DestroyContext,
|
||||
base::Unretained(gpu_factories_.back().get())));
|
||||
}
|
||||
|
||||
@ -1081,16 +1081,16 @@ media::GpuVideoAcceleratorFactories* RenderThreadImpl::GetGpuFactories() {
|
||||
gpu_channel_host->gpu_info().overlay_info.supports_overlays);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
auto codec_factory = CreateMediaCodecFactory(media_context_provider,
|
||||
enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator);
|
||||
gpu_factories_.push_back(GpuVideoAcceleratorFactoriesImpl::Create(
|
||||
auto codec_factory = CreateMediaMojoCodecFactory(
|
||||
media_context_provider, enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator);
|
||||
gpu_factories_.push_back(media::MojoGpuVideoAcceleratorFactories::Create(
|
||||
std::move(gpu_channel_host),
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault(),
|
||||
GetMediaSequencedTaskRunner(), std::move(media_context_provider),
|
||||
std::move(codec_factory), enable_video_gpu_memory_buffers,
|
||||
enable_media_stream_gpu_memory_buffers, enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator));
|
||||
std::move(codec_factory), GetGpuMemoryBufferManager(),
|
||||
enable_video_gpu_memory_buffers, enable_media_stream_gpu_memory_buffers,
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator));
|
||||
|
||||
gpu_factories_.back()->SetRenderingColorSpace(rendering_color_space_);
|
||||
return gpu_factories_.back().get();
|
||||
@ -1842,7 +1842,8 @@ gfx::ColorSpace RenderThreadImpl::GetRenderingColorSpace() {
|
||||
return rendering_color_space_;
|
||||
}
|
||||
|
||||
std::unique_ptr<CodecFactory> RenderThreadImpl::CreateMediaCodecFactory(
|
||||
std::unique_ptr<media::MojoCodecFactory>
|
||||
RenderThreadImpl::CreateMediaMojoCodecFactory(
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator) {
|
||||
@ -1863,7 +1864,7 @@ std::unique_ptr<CodecFactory> RenderThreadImpl::CreateMediaCodecFactory(
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
|
||||
mojo::PendingRemote<media::mojom::InterfaceFactory> interface_factory;
|
||||
BindHostReceiver(interface_factory.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<CodecFactoryMojo>(
|
||||
return std::make_unique<media::MojoCodecFactoryMojoDecoder>(
|
||||
GetMediaSequencedTaskRunner(), context_provider,
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator,
|
||||
std::move(vea_provider), std::move(interface_factory));
|
||||
@ -1871,12 +1872,12 @@ std::unique_ptr<CodecFactory> RenderThreadImpl::CreateMediaCodecFactory(
|
||||
mojo::PendingRemote<media::mojom::FuchsiaMediaCodecProvider>
|
||||
media_codec_provider;
|
||||
BindHostReceiver(media_codec_provider.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<CodecFactoryFuchsia>(
|
||||
return std::make_unique<media::MojoCodecFactoryFuchsia>(
|
||||
GetMediaSequencedTaskRunner(), context_provider,
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator,
|
||||
std::move(vea_provider), std::move(media_codec_provider));
|
||||
#else
|
||||
return std::make_unique<CodecFactoryDefault>(
|
||||
return std::make_unique<media::MojoCodecFactoryDefault>(
|
||||
GetMediaSequencedTaskRunner(), context_provider,
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator,
|
||||
std::move(vea_provider));
|
||||
|
@ -43,10 +43,10 @@
|
||||
#include "content/common/renderer_host.mojom.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
#include "content/renderer/discardable_memory_utils.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "gpu/ipc/client/gpu_channel_host.h"
|
||||
#include "ipc/ipc_sync_channel.h"
|
||||
#include "media/media_buildflags.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
|
||||
@ -87,7 +87,7 @@ class ClientSharedImageInterface;
|
||||
}
|
||||
|
||||
namespace media {
|
||||
class GpuVideoAcceleratorFactories;
|
||||
class MojoGpuVideoAcceleratorFactories;
|
||||
}
|
||||
|
||||
namespace mojo {
|
||||
@ -102,7 +102,6 @@ class RasterContextProvider;
|
||||
|
||||
namespace content {
|
||||
class AgentSchedulingGroup;
|
||||
class GpuVideoAcceleratorFactoriesImpl;
|
||||
class RenderFrameImpl;
|
||||
class RenderThreadObserver;
|
||||
class RendererBlinkPlatformImpl;
|
||||
@ -463,7 +462,7 @@ class CONTENT_EXPORT RenderThreadImpl
|
||||
void OnRendererInterfaceReceiver(
|
||||
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
|
||||
|
||||
std::unique_ptr<CodecFactory> CreateMediaCodecFactory(
|
||||
std::unique_ptr<media::MojoCodecFactory> CreateMediaMojoCodecFactory(
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator);
|
||||
@ -515,7 +514,8 @@ class CONTENT_EXPORT RenderThreadImpl
|
||||
// TODO(dcastagna): This should be just one scoped_ptr once
|
||||
// http://crbug.com/580386 is fixed.
|
||||
// NOTE(dcastagna): At worst this accumulates a few bytes per context lost.
|
||||
std::vector<std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>> gpu_factories_;
|
||||
std::vector<std::unique_ptr<media::MojoGpuVideoAcceleratorFactories>>
|
||||
gpu_factories_;
|
||||
|
||||
// Thread or sequenced task runner (depending on
|
||||
// kBlinkMediaIsPooledSequencedTaskRunner) for running multimedia operations
|
||||
|
@ -2940,7 +2940,6 @@ test("content_unittests") {
|
||||
"../renderer/accessibility/annotations/ax_image_stopwords_unittest.cc",
|
||||
"../renderer/content_security_policy_util_unittest.cc",
|
||||
"../renderer/media/batching_media_log_unittest.cc",
|
||||
"../renderer/media/gpu/gpu_video_accelerator_factories_impl_unittest.cc",
|
||||
"../renderer/media/inspector_media_event_handler_unittest.cc",
|
||||
"../renderer/media/renderer_webaudiodevice_impl_unittest.cc",
|
||||
"../renderer/render_thread_impl_unittest.cc",
|
||||
|
@ -9,6 +9,7 @@ source_set("video") {
|
||||
":unittests",
|
||||
"//content/renderer/*",
|
||||
"//media/gpu/*",
|
||||
"//media/mojo/clients/*",
|
||||
"//third_party/blink/renderer/modules/webcodecs/*",
|
||||
]
|
||||
public = [
|
||||
|
@ -40,12 +40,18 @@ source_set("clients") {
|
||||
"mojo_cdm.h",
|
||||
"mojo_cdm_factory.cc",
|
||||
"mojo_cdm_factory.h",
|
||||
"mojo_codec_factory.cc",
|
||||
"mojo_codec_factory.h",
|
||||
"mojo_codec_factory_mojo_decoder.cc",
|
||||
"mojo_codec_factory_mojo_decoder.h",
|
||||
"mojo_decoder_factory.cc",
|
||||
"mojo_decoder_factory.h",
|
||||
"mojo_decryptor.cc",
|
||||
"mojo_decryptor.h",
|
||||
"mojo_demuxer_stream_impl.cc",
|
||||
"mojo_demuxer_stream_impl.h",
|
||||
"mojo_gpu_video_accelerator_factories.cc",
|
||||
"mojo_gpu_video_accelerator_factories.h",
|
||||
"mojo_media_log_service.cc",
|
||||
"mojo_media_log_service.h",
|
||||
"mojo_renderer.cc",
|
||||
@ -84,6 +90,7 @@ source_set("clients") {
|
||||
"//mojo/public/cpp/bindings",
|
||||
"//mojo/public/cpp/system",
|
||||
"//services/service_manager/public/mojom",
|
||||
"//services/viz/public/cpp/gpu:gpu",
|
||||
]
|
||||
|
||||
deps = [
|
||||
@ -110,11 +117,16 @@ source_set("clients") {
|
||||
|
||||
if (is_fuchsia) {
|
||||
sources += [
|
||||
"mojo_codec_factory_fuchsia.cc",
|
||||
"mojo_codec_factory_fuchsia.h",
|
||||
"mojo_fuchsia_cdm_provider.cc",
|
||||
"mojo_fuchsia_cdm_provider.h",
|
||||
]
|
||||
|
||||
deps += [ "//third_party/blink/public:blink_headers" ]
|
||||
deps += [
|
||||
"//media/fuchsia/video",
|
||||
"//third_party/blink/public:blink_headers",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +152,7 @@ source_set("unit_tests") {
|
||||
"mojo_audio_encoder_unittest.cc",
|
||||
"mojo_cdm_unittest.cc",
|
||||
"mojo_decryptor_unittest.cc",
|
||||
"mojo_gpu_video_accelerator_factories_unittest.cc",
|
||||
"mojo_renderer_unittest.cc",
|
||||
"mojo_video_encode_accelerator_unittest.cc",
|
||||
"mojo_video_encoder_metrics_provider_unittest.cc",
|
||||
@ -152,6 +165,8 @@ source_set("unit_tests") {
|
||||
deps = [
|
||||
"//base",
|
||||
"//base/test:test_support",
|
||||
"//gpu:test_support",
|
||||
"//gpu/ipc/common:test_support",
|
||||
"//media:test_support",
|
||||
"//media/mojo:test_support",
|
||||
"//testing/gmock",
|
||||
|
@ -1,3 +1,7 @@
|
||||
include_rules = [
|
||||
"+components/viz/common/gpu"
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
"mojo_fuchsia_cdm_provider\.cc": [
|
||||
"+third_party/blink/public/platform/browser_interface_broker_proxy.h",
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@ -19,9 +19,9 @@
|
||||
#include "media/mojo/clients/mojo_video_encode_accelerator.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
CodecFactory::CodecFactory(
|
||||
MojoCodecFactory::MojoCodecFactory(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -33,14 +33,14 @@ CodecFactory::CodecFactory(
|
||||
video_decode_accelerator_enabled_(video_decode_accelerator_enabled),
|
||||
video_encode_accelerator_enabled_(video_encode_accelerator_enabled) {
|
||||
media_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&CodecFactory::BindOnTaskRunner, base::Unretained(this),
|
||||
std::move(pending_vea_provider_remote)));
|
||||
FROM_HERE, base::BindOnce(&MojoCodecFactory::BindOnTaskRunner,
|
||||
base::Unretained(this),
|
||||
std::move(pending_vea_provider_remote)));
|
||||
}
|
||||
CodecFactory::~CodecFactory() = default;
|
||||
MojoCodecFactory::~MojoCodecFactory() = default;
|
||||
|
||||
std::unique_ptr<media::VideoEncodeAccelerator>
|
||||
CodecFactory::CreateVideoEncodeAccelerator() {
|
||||
MojoCodecFactory::CreateVideoEncodeAccelerator() {
|
||||
DCHECK(video_encode_accelerator_enabled_);
|
||||
DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
|
||||
DCHECK(vea_provider_.is_bound());
|
||||
@ -72,47 +72,47 @@ CodecFactory::CreateVideoEncodeAccelerator() {
|
||||
new media::MojoVideoEncodeAccelerator(std::move(vea)));
|
||||
}
|
||||
|
||||
media::VideoDecoderType CodecFactory::GetVideoDecoderType() {
|
||||
media::VideoDecoderType MojoCodecFactory::GetVideoDecoderType() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
return video_decoder_type_;
|
||||
}
|
||||
|
||||
std::optional<media::SupportedVideoDecoderConfigs>
|
||||
CodecFactory::GetSupportedVideoDecoderConfigs() {
|
||||
MojoCodecFactory::GetSupportedVideoDecoderConfigs() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
return supported_decoder_configs_;
|
||||
}
|
||||
|
||||
std::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
CodecFactory::GetVideoEncodeAcceleratorSupportedProfiles() {
|
||||
MojoCodecFactory::GetVideoEncodeAcceleratorSupportedProfiles() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
return supported_vea_profiles_;
|
||||
}
|
||||
|
||||
bool CodecFactory::IsDecoderSupportKnown() {
|
||||
bool MojoCodecFactory::IsDecoderSupportKnown() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
return decoder_support_notifier_.is_notified();
|
||||
}
|
||||
|
||||
bool CodecFactory::IsEncoderSupportKnown() {
|
||||
bool MojoCodecFactory::IsEncoderSupportKnown() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
return encoder_support_notifier_.is_notified();
|
||||
}
|
||||
|
||||
void CodecFactory::NotifyDecoderSupportKnown(base::OnceClosure callback) {
|
||||
void MojoCodecFactory::NotifyDecoderSupportKnown(base::OnceClosure callback) {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
decoder_support_notifier_.Register(
|
||||
base::BindPostTaskToCurrentDefault(std::move(callback)));
|
||||
}
|
||||
|
||||
void CodecFactory::NotifyEncoderSupportKnown(base::OnceClosure callback) {
|
||||
void MojoCodecFactory::NotifyEncoderSupportKnown(base::OnceClosure callback) {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
encoder_support_notifier_.Register(
|
||||
base::BindPostTaskToCurrentDefault(std::move(callback)));
|
||||
}
|
||||
|
||||
void CodecFactory::OnChannelTokenReady(const base::UnguessableToken& token,
|
||||
int32_t route_id) {
|
||||
void MojoCodecFactory::OnChannelTokenReady(const base::UnguessableToken& token,
|
||||
int32_t route_id) {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
channel_token_ = token;
|
||||
route_id_ = route_id;
|
||||
@ -123,10 +123,10 @@ void CodecFactory::OnChannelTokenReady(const base::UnguessableToken& token,
|
||||
}
|
||||
}
|
||||
|
||||
CodecFactory::Notifier::Notifier() = default;
|
||||
CodecFactory::Notifier::~Notifier() = default;
|
||||
MojoCodecFactory::Notifier::Notifier() = default;
|
||||
MojoCodecFactory::Notifier::~Notifier() = default;
|
||||
|
||||
void CodecFactory::Notifier::Register(base::OnceClosure callback) {
|
||||
void MojoCodecFactory::Notifier::Register(base::OnceClosure callback) {
|
||||
if (is_notified_) {
|
||||
std::move(callback).Run();
|
||||
return;
|
||||
@ -134,7 +134,7 @@ void CodecFactory::Notifier::Register(base::OnceClosure callback) {
|
||||
callbacks_.push_back(std::move(callback));
|
||||
}
|
||||
|
||||
void CodecFactory::Notifier::Notify() {
|
||||
void MojoCodecFactory::Notifier::Notify() {
|
||||
DCHECK(!is_notified_);
|
||||
is_notified_ = true;
|
||||
while (!callbacks_.empty()) {
|
||||
@ -143,7 +143,7 @@ void CodecFactory::Notifier::Notify() {
|
||||
}
|
||||
}
|
||||
|
||||
void CodecFactory::OnDecoderSupportFailed() {
|
||||
void MojoCodecFactory::OnDecoderSupportFailed() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
if (decoder_support_notifier_.is_notified()) {
|
||||
return;
|
||||
@ -152,12 +152,12 @@ void CodecFactory::OnDecoderSupportFailed() {
|
||||
decoder_support_notifier_.Notify();
|
||||
}
|
||||
|
||||
void CodecFactory::OnGetSupportedDecoderConfigs() {
|
||||
void MojoCodecFactory::OnGetSupportedDecoderConfigs() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
decoder_support_notifier_.Notify();
|
||||
}
|
||||
|
||||
void CodecFactory::OnEncoderSupportFailed() {
|
||||
void MojoCodecFactory::OnEncoderSupportFailed() {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
if (encoder_support_notifier_.is_notified()) {
|
||||
return;
|
||||
@ -166,7 +166,7 @@ void CodecFactory::OnEncoderSupportFailed() {
|
||||
encoder_support_notifier_.Notify();
|
||||
}
|
||||
|
||||
void CodecFactory::OnGetVideoEncodeAcceleratorSupportedProfiles(
|
||||
void MojoCodecFactory::OnGetVideoEncodeAcceleratorSupportedProfiles(
|
||||
const media::VideoEncodeAccelerator::SupportedProfiles&
|
||||
supported_profiles) {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
@ -176,11 +176,11 @@ void CodecFactory::OnGetVideoEncodeAcceleratorSupportedProfiles(
|
||||
}
|
||||
}
|
||||
|
||||
bool CodecFactory::IsEncoderReady() {
|
||||
bool MojoCodecFactory::IsEncoderReady() {
|
||||
return supported_vea_profiles_ && !channel_token_.is_empty();
|
||||
}
|
||||
|
||||
void CodecFactory::BindOnTaskRunner(
|
||||
void MojoCodecFactory::BindOnTaskRunner(
|
||||
mojo::PendingRemote<media::mojom::VideoEncodeAcceleratorProvider>
|
||||
pending_vea_provider_remote) {
|
||||
DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
|
||||
@ -200,12 +200,12 @@ void CodecFactory::BindOnTaskRunner(
|
||||
// example a GPU driver failure. Set a disconnect handler to watch these
|
||||
// types of failures and treat them as if there are no supported encoder
|
||||
// profiles.
|
||||
// Unretained is safe since CodecFactory is never destroyed.
|
||||
// Unretained is safe since MojoCodecFactory is never destroyed.
|
||||
// It lives until the process shuts down.
|
||||
vea_provider_.set_disconnect_handler(base::BindOnce(
|
||||
&CodecFactory::OnEncoderSupportFailed, base::Unretained(this)));
|
||||
&MojoCodecFactory::OnEncoderSupportFailed, base::Unretained(this)));
|
||||
vea_provider_->GetVideoEncodeAcceleratorSupportedProfiles(base::BindOnce(
|
||||
&CodecFactory::OnGetVideoEncodeAcceleratorSupportedProfiles,
|
||||
&MojoCodecFactory::OnGetVideoEncodeAcceleratorSupportedProfiles,
|
||||
base::Unretained(this)));
|
||||
} else {
|
||||
OnEncoderSupportFailed();
|
||||
@ -216,33 +216,34 @@ void CodecFactory::BindOnTaskRunner(
|
||||
}
|
||||
}
|
||||
|
||||
CodecFactoryDefault::CodecFactoryDefault(
|
||||
MojoCodecFactoryDefault::MojoCodecFactoryDefault(
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
bool video_encode_accelerator_enabled,
|
||||
mojo::PendingRemote<media::mojom::VideoEncodeAcceleratorProvider>
|
||||
pending_vea_provider_remote)
|
||||
: CodecFactory(std::move(task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
: MojoCodecFactory(std::move(task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
// There is no decoder provider.
|
||||
OnDecoderSupportFailed();
|
||||
}
|
||||
|
||||
CodecFactoryDefault::~CodecFactoryDefault() = default;
|
||||
MojoCodecFactoryDefault::~MojoCodecFactoryDefault() = default;
|
||||
|
||||
std::unique_ptr<media::VideoDecoder> CodecFactoryDefault::CreateVideoDecoder(
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
MojoCodecFactoryDefault::CreateVideoDecoder(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
media::MediaLog* media_log,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& rendering_color_space) {
|
||||
NOTIMPLEMENTED()
|
||||
<< "CodecFactoryDefault does not have a provider to create a "
|
||||
<< "MojoCodecFactoryDefault does not have a provider to create a "
|
||||
"hardware video decoder.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
@ -2,14 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_MEDIA_CODEC_FACTORY_H_
|
||||
#define CONTENT_RENDERER_MEDIA_CODEC_FACTORY_H_
|
||||
#ifndef MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_H_
|
||||
#define MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "media/base/decoder.h"
|
||||
#include "media/base/media_log.h"
|
||||
#include "media/base/overlay_info.h"
|
||||
@ -21,15 +20,15 @@
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
// Assists to GpuVideoAcceleratorFactoriesImpl on hardware decoder and encoder
|
||||
// functionalities.
|
||||
// Assists the MojoGpuVideoAcceleratorFactories class with hardware decoder and
|
||||
// encoder functionalities.
|
||||
//
|
||||
// It is a base class that handles the encoder resources
|
||||
// via media::mojom::VideoEncodeAcceleratorProvider. Its derived classes need
|
||||
// to implement how to connect to hardware decoder resources.
|
||||
class CONTENT_EXPORT CodecFactory {
|
||||
// via media::mojom::VideoEncodeAcceleratorProvider. Its derived classes
|
||||
// implement how to connect to hardware decoder resources.
|
||||
class MojoCodecFactory {
|
||||
public:
|
||||
// `media_task_runner` - task runner for running multi-media operations.
|
||||
// `context_provider` - context provider for creating a video decoder.
|
||||
@ -39,7 +38,7 @@ class CONTENT_EXPORT CodecFactory {
|
||||
// is enabled.
|
||||
// `pending_vea_provider_remote` - bound pending
|
||||
// media::mojom::VideoEncodeAcceleratorProvider remote.
|
||||
CodecFactory(
|
||||
MojoCodecFactory(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -47,9 +46,9 @@ class CONTENT_EXPORT CodecFactory {
|
||||
mojo::PendingRemote<media::mojom::VideoEncodeAcceleratorProvider>
|
||||
pending_vea_provider_remote);
|
||||
|
||||
CodecFactory(const CodecFactory&) = delete;
|
||||
CodecFactory& operator=(const CodecFactory&) = delete;
|
||||
virtual ~CodecFactory();
|
||||
MojoCodecFactory(const MojoCodecFactory&) = delete;
|
||||
MojoCodecFactory& operator=(const MojoCodecFactory&) = delete;
|
||||
virtual ~MojoCodecFactory();
|
||||
|
||||
// `gpu_factories` - pointer to the GpuVideoAcceleratorFactories that
|
||||
// owns |this|.
|
||||
@ -178,19 +177,19 @@ class CONTENT_EXPORT CodecFactory {
|
||||
int32_t route_id_;
|
||||
};
|
||||
|
||||
// CodecFactoryDefault is the default derived class, which has no
|
||||
// MojoCodecFactoryDefault is the default derived class, which has no
|
||||
// decoder provider. It does not have any supported video decoder configs and
|
||||
// returns a null pointer when creating a hardware video decoder.
|
||||
class CONTENT_EXPORT CodecFactoryDefault final : public CodecFactory {
|
||||
class MojoCodecFactoryDefault final : public MojoCodecFactory {
|
||||
public:
|
||||
CodecFactoryDefault(
|
||||
MojoCodecFactoryDefault(
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
bool video_encode_accelerator_enabled,
|
||||
mojo::PendingRemote<media::mojom::VideoEncodeAcceleratorProvider>
|
||||
pending_vea_provider_remote);
|
||||
~CodecFactoryDefault() override;
|
||||
~MojoCodecFactoryDefault() override;
|
||||
|
||||
// Returns nullptr since there is no decoder provider.
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
@ -200,6 +199,6 @@ class CONTENT_EXPORT CodecFactoryDefault final : public CodecFactory {
|
||||
const gfx::ColorSpace& rendering_color_space) override;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
||||
|
||||
#endif // CONTENT_RENDERER_MEDIA_CODEC_FACTORY_H_
|
||||
#endif // MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_H_
|
39
content/renderer/media/codec_factory_fuchsia.cc → media/mojo/clients/mojo_codec_factory_fuchsia.cc
39
content/renderer/media/codec_factory_fuchsia.cc → media/mojo/clients/mojo_codec_factory_fuchsia.cc
@ -2,24 +2,24 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/media/codec_factory_fuchsia.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_fuchsia.h"
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/base/decoder.h"
|
||||
#include "media/base/overlay_info.h"
|
||||
#include "media/base/supported_video_decoder_config.h"
|
||||
#include "media/base/video_decoder.h"
|
||||
#include "media/fuchsia/video/fuchsia_video_decoder.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/mojo/mojom/fuchsia_media.mojom.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
CodecFactoryFuchsia::CodecFactoryFuchsia(
|
||||
MojoCodecFactoryFuchsia::MojoCodecFactoryFuchsia(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -28,20 +28,21 @@ CodecFactoryFuchsia::CodecFactoryFuchsia(
|
||||
pending_vea_provider_remote,
|
||||
mojo::PendingRemote<media::mojom::FuchsiaMediaCodecProvider>
|
||||
pending_media_codec_provider_remote)
|
||||
: CodecFactory(std::move(media_task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
: MojoCodecFactory(std::move(media_task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
media_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&CodecFactoryFuchsia::BindOnTaskRunner,
|
||||
base::BindOnce(&MojoCodecFactoryFuchsia::BindOnTaskRunner,
|
||||
base::Unretained(this),
|
||||
std::move(pending_media_codec_provider_remote)));
|
||||
}
|
||||
CodecFactoryFuchsia::~CodecFactoryFuchsia() = default;
|
||||
MojoCodecFactoryFuchsia::~MojoCodecFactoryFuchsia() = default;
|
||||
|
||||
std::unique_ptr<media::VideoDecoder> CodecFactoryFuchsia::CreateVideoDecoder(
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
MojoCodecFactoryFuchsia::CreateVideoDecoder(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
media::MediaLog* media_log,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb,
|
||||
@ -53,7 +54,7 @@ std::unique_ptr<media::VideoDecoder> CodecFactoryFuchsia::CreateVideoDecoder(
|
||||
/*allow_overlays=*/true);
|
||||
}
|
||||
|
||||
void CodecFactoryFuchsia::BindOnTaskRunner(
|
||||
void MojoCodecFactoryFuchsia::BindOnTaskRunner(
|
||||
mojo::PendingRemote<media::mojom::FuchsiaMediaCodecProvider>
|
||||
media_codec_provider_remote) {
|
||||
DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
|
||||
@ -69,25 +70,25 @@ void CodecFactoryFuchsia::BindOnTaskRunner(
|
||||
// example a decoder driver failure. Set a disconnect handler to watch these
|
||||
// types of failures and treat them as if there are no supported decoder
|
||||
// configs.
|
||||
// Unretained is safe since CodecFactory is never destroyed.
|
||||
// Unretained is safe since MojoCodecFactory is never destroyed.
|
||||
// It lives until the process shuts down.
|
||||
media_codec_provider_.set_disconnect_handler(
|
||||
base::BindOnce(&CodecFactoryFuchsia::OnDecoderSupportFailed,
|
||||
base::BindOnce(&MojoCodecFactoryFuchsia::OnDecoderSupportFailed,
|
||||
base::Unretained(this)),
|
||||
media_task_runner_);
|
||||
media_codec_provider_->GetSupportedVideoDecoderConfigs(
|
||||
base::BindOnce(&CodecFactoryFuchsia::OnGetSupportedDecoderConfigs,
|
||||
base::BindOnce(&MojoCodecFactoryFuchsia::OnGetSupportedDecoderConfigs,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void CodecFactoryFuchsia::OnGetSupportedDecoderConfigs(
|
||||
void MojoCodecFactoryFuchsia::OnGetSupportedDecoderConfigs(
|
||||
const media::SupportedVideoDecoderConfigs& supported_configs) {
|
||||
{
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
supported_decoder_configs_.emplace(supported_configs);
|
||||
video_decoder_type_ = media::VideoDecoderType::kFuchsia;
|
||||
}
|
||||
CodecFactory::OnGetSupportedDecoderConfigs();
|
||||
MojoCodecFactory::OnGetSupportedDecoderConfigs();
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
@ -2,30 +2,29 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_MEDIA_CODEC_FACTORY_FUCHSIA_H_
|
||||
#define CONTENT_RENDERER_MEDIA_CODEC_FACTORY_FUCHSIA_H_
|
||||
#ifndef MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_FUCHSIA_H_
|
||||
#define MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_FUCHSIA_H_
|
||||
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/base/overlay_info.h"
|
||||
#include "media/base/video_decoder.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/mojo/mojom/fuchsia_media.mojom.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
#include "mojo/public/cpp/bindings/shared_remote.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
// CodecFactoryFuchsia gets hardware decoder resources
|
||||
// MojoCodecFactoryFuchsia gets hardware decoder resources
|
||||
// via media::mojom::FuchsiaMediaCodecProvider.
|
||||
//
|
||||
// Codec-related services on Fuchsia are used directly from the renderer process
|
||||
// after the browser process provides a connection to the FIDL protocol via
|
||||
// media::mojom::FuchsiaMediaCodecProvider. This can improve performance by
|
||||
// avoiding the need to hop through the browser process.
|
||||
class CONTENT_EXPORT CodecFactoryFuchsia final : public CodecFactory {
|
||||
class MojoCodecFactoryFuchsia final : public media::MojoCodecFactory {
|
||||
public:
|
||||
CodecFactoryFuchsia(
|
||||
MojoCodecFactoryFuchsia(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -34,7 +33,7 @@ class CONTENT_EXPORT CodecFactoryFuchsia final : public CodecFactory {
|
||||
pending_vea_provider_remote,
|
||||
mojo::PendingRemote<media::mojom::FuchsiaMediaCodecProvider>
|
||||
pending_media_codec_provider_remote);
|
||||
~CodecFactoryFuchsia() override;
|
||||
~MojoCodecFactoryFuchsia() override;
|
||||
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
@ -53,6 +52,6 @@ class CONTENT_EXPORT CodecFactoryFuchsia final : public CodecFactory {
|
||||
media_codec_provider_;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
||||
|
||||
#endif // CONTENT_RENDERER_MEDIA_CODEC_FACTORY_FUCHSIA_H_
|
||||
#endif // MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_FUCHSIA_H_
|
53
content/renderer/media/codec_factory_mojo.cc → media/mojo/clients/mojo_codec_factory_mojo_decoder.cc
53
content/renderer/media/codec_factory_mojo.cc → media/mojo/clients/mojo_codec_factory_mojo_decoder.cc
@ -2,13 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/media/codec_factory_mojo.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_mojo_decoder.h"
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/base/overlay_info.h"
|
||||
#include "media/mojo/clients/mojo_video_decoder.h"
|
||||
#include "media/mojo/mojom/interface_factory.mojom.h"
|
||||
@ -21,9 +20,9 @@
|
||||
#include "media/mojo/clients/mojo_stable_video_decoder.h"
|
||||
#endif // BUILDFLAG(ALLOW_OOP_VIDEO_DECODER)
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
CodecFactoryMojo::CodecFactoryMojo(
|
||||
MojoCodecFactoryMojoDecoder::MojoCodecFactoryMojoDecoder(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -32,19 +31,20 @@ CodecFactoryMojo::CodecFactoryMojo(
|
||||
pending_vea_provider_remote,
|
||||
mojo::PendingRemote<media::mojom::InterfaceFactory>
|
||||
pending_interface_factory_remote)
|
||||
: CodecFactory(std::move(media_task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
: MojoCodecFactory(std::move(media_task_runner),
|
||||
std::move(context_provider),
|
||||
video_decode_accelerator_enabled,
|
||||
video_encode_accelerator_enabled,
|
||||
std::move(pending_vea_provider_remote)) {
|
||||
media_task_runner_->PostTask(
|
||||
FROM_HERE, base::BindOnce(&CodecFactoryMojo::BindOnTaskRunner,
|
||||
FROM_HERE, base::BindOnce(&MojoCodecFactoryMojoDecoder::BindOnTaskRunner,
|
||||
base::Unretained(this),
|
||||
std::move(pending_interface_factory_remote)));
|
||||
}
|
||||
CodecFactoryMojo::~CodecFactoryMojo() = default;
|
||||
MojoCodecFactoryMojoDecoder::~MojoCodecFactoryMojoDecoder() = default;
|
||||
|
||||
std::unique_ptr<media::VideoDecoder> CodecFactoryMojo::CreateVideoDecoder(
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
MojoCodecFactoryMojoDecoder::CreateVideoDecoder(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
media::MediaLog* media_log,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb,
|
||||
@ -77,7 +77,7 @@ std::unique_ptr<media::VideoDecoder> CodecFactoryMojo::CreateVideoDecoder(
|
||||
std::move(request_overlay_info_cb), rendering_color_space);
|
||||
}
|
||||
|
||||
void CodecFactoryMojo::BindOnTaskRunner(
|
||||
void MojoCodecFactoryMojoDecoder::BindOnTaskRunner(
|
||||
mojo::PendingRemote<media::mojom::InterfaceFactory>
|
||||
interface_factory_remote) {
|
||||
DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
|
||||
@ -98,7 +98,7 @@ void CodecFactoryMojo::BindOnTaskRunner(
|
||||
// example a GPU driver failure. Set a disconnect handler to watch these
|
||||
// types of failures and treat them as if there are no supported decoder
|
||||
// configs.
|
||||
// Unretained is safe since CodecFactory is never destroyed.
|
||||
// Unretained is safe since MojoCodecFactory is never destroyed.
|
||||
// It lives until the process shuts down.
|
||||
|
||||
#if BUILDFLAG(ALLOW_OOP_VIDEO_DECODER)
|
||||
@ -108,11 +108,12 @@ void CodecFactoryMojo::BindOnTaskRunner(
|
||||
stable_video_decoder;
|
||||
interface_factory_->CreateStableVideoDecoder(
|
||||
stable_video_decoder.BindNewPipeAndPassReceiver());
|
||||
stable_video_decoder.set_disconnect_handler(base::BindOnce(
|
||||
&CodecFactoryMojo::OnDecoderSupportFailed, base::Unretained(this)));
|
||||
stable_video_decoder->GetSupportedConfigs(
|
||||
base::BindOnce(&CodecFactoryMojo::OnGetSupportedDecoderConfigs,
|
||||
stable_video_decoder.set_disconnect_handler(
|
||||
base::BindOnce(&MojoCodecFactoryMojoDecoder::OnDecoderSupportFailed,
|
||||
base::Unretained(this)));
|
||||
stable_video_decoder->GetSupportedConfigs(base::BindOnce(
|
||||
&MojoCodecFactoryMojoDecoder::OnGetSupportedDecoderConfigs,
|
||||
base::Unretained(this)));
|
||||
video_decoder_
|
||||
.emplace<mojo::Remote<media::stable::mojom::StableVideoDecoder>>(
|
||||
std::move(stable_video_decoder));
|
||||
@ -127,15 +128,17 @@ void CodecFactoryMojo::BindOnTaskRunner(
|
||||
mojo::Remote<media::mojom::VideoDecoder> video_decoder;
|
||||
interface_factory_->CreateVideoDecoder(
|
||||
video_decoder.BindNewPipeAndPassReceiver(), /*dst_video_decoder=*/{});
|
||||
video_decoder.set_disconnect_handler(base::BindOnce(
|
||||
&CodecFactoryMojo::OnDecoderSupportFailed, base::Unretained(this)));
|
||||
video_decoder->GetSupportedConfigs(base::BindOnce(
|
||||
&CodecFactoryMojo::OnGetSupportedDecoderConfigs, base::Unretained(this)));
|
||||
video_decoder.set_disconnect_handler(
|
||||
base::BindOnce(&MojoCodecFactoryMojoDecoder::OnDecoderSupportFailed,
|
||||
base::Unretained(this)));
|
||||
video_decoder->GetSupportedConfigs(
|
||||
base::BindOnce(&MojoCodecFactoryMojoDecoder::OnGetSupportedDecoderConfigs,
|
||||
base::Unretained(this)));
|
||||
video_decoder_.emplace<mojo::Remote<media::mojom::VideoDecoder>>(
|
||||
std::move(video_decoder));
|
||||
}
|
||||
|
||||
void CodecFactoryMojo::OnGetSupportedDecoderConfigs(
|
||||
void MojoCodecFactoryMojoDecoder::OnGetSupportedDecoderConfigs(
|
||||
const media::SupportedVideoDecoderConfigs& supported_configs,
|
||||
media::VideoDecoderType decoder_type) {
|
||||
{
|
||||
@ -144,7 +147,7 @@ void CodecFactoryMojo::OnGetSupportedDecoderConfigs(
|
||||
supported_decoder_configs_.emplace(supported_configs);
|
||||
video_decoder_type_ = decoder_type;
|
||||
}
|
||||
CodecFactory::OnGetSupportedDecoderConfigs();
|
||||
MojoCodecFactory::OnGetSupportedDecoderConfigs();
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
21
content/renderer/media/codec_factory_mojo.h → media/mojo/clients/mojo_codec_factory_mojo_decoder.h
21
content/renderer/media/codec_factory_mojo.h → media/mojo/clients/mojo_codec_factory_mojo_decoder.h
@ -2,31 +2,30 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_MEDIA_CODEC_FACTORY_MOJO_H_
|
||||
#define CONTENT_RENDERER_MEDIA_CODEC_FACTORY_MOJO_H_
|
||||
#ifndef MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_MOJO_DECODER_H_
|
||||
#define MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_MOJO_DECODER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/base/decoder.h"
|
||||
#include "media/base/overlay_info.h"
|
||||
#include "media/base/video_decoder.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/mojo/mojom/interface_factory.mojom.h"
|
||||
#include "media/mojo/mojom/stable/stable_video_decoder.mojom.h"
|
||||
#include "media/mojo/mojom/video_decoder.mojom.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
// CodecFactoryMojo gets hardware decoder resources
|
||||
// MojoCodecFactoryMojoDecoder gets hardware decoder resources
|
||||
// via media::mojom::InterfaceFactory. Use it when mojo-based video decoder is
|
||||
// enabled.
|
||||
class CONTENT_EXPORT CodecFactoryMojo final : public CodecFactory {
|
||||
class MojoCodecFactoryMojoDecoder final : public media::MojoCodecFactory {
|
||||
public:
|
||||
CodecFactoryMojo(
|
||||
MojoCodecFactoryMojoDecoder(
|
||||
scoped_refptr<base::SequencedTaskRunner> media_task_runner,
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool video_decode_accelerator_enabled,
|
||||
@ -35,7 +34,7 @@ class CONTENT_EXPORT CodecFactoryMojo final : public CodecFactory {
|
||||
pending_vea_provider_remote,
|
||||
mojo::PendingRemote<media::mojom::InterfaceFactory>
|
||||
pending_interface_factory_remote);
|
||||
~CodecFactoryMojo() override;
|
||||
~MojoCodecFactoryMojoDecoder() override;
|
||||
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
@ -57,6 +56,6 @@ class CONTENT_EXPORT CodecFactoryMojo final : public CodecFactory {
|
||||
video_decoder_;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
||||
|
||||
#endif // CONTENT_RENDERER_MEDIA_CODEC_FACTORY_MOJO_H_
|
||||
#endif // MEDIA_MOJO_CLIENTS_MOJO_CODEC_FACTORY_MOJO_DECODER_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h"
|
||||
#include "media/mojo/clients/mojo_gpu_video_accelerator_factories.h"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
@ -18,9 +18,6 @@
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "content/renderer/render_thread_impl.h"
|
||||
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
|
||||
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
|
||||
#include "gpu/ipc/client/gpu_channel_host.h"
|
||||
@ -28,11 +25,12 @@
|
||||
#include "media/base/media_switches.h"
|
||||
#include "media/base/supported_video_decoder_config.h"
|
||||
#include "media/mojo/buildflags.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/video/video_encode_accelerator.h"
|
||||
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
|
||||
#include "third_party/skia/include/core/SkTypes.h"
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
namespace {
|
||||
@ -49,39 +47,19 @@ BASE_FEATURE(kUseNV12OutputFormat,
|
||||
#endif
|
||||
|
||||
// static
|
||||
std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>
|
||||
GpuVideoAcceleratorFactoriesImpl::Create(
|
||||
std::unique_ptr<MojoGpuVideoAcceleratorFactories>
|
||||
MojoGpuVideoAcceleratorFactories::Create(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
bool enable_video_gpu_memory_buffers,
|
||||
bool enable_media_stream_gpu_memory_buffers,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator) {
|
||||
return base::WrapUnique(new GpuVideoAcceleratorFactoriesImpl(
|
||||
std::move(gpu_channel_host), main_thread_task_runner, task_runner,
|
||||
std::move(context_provider), std::move(codec_factory),
|
||||
RenderThreadImpl::current()->GetGpuMemoryBufferManager(),
|
||||
enable_video_gpu_memory_buffers, enable_media_stream_gpu_memory_buffers,
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator));
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateForTesting(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
std::unique_ptr<MojoCodecFactory> codec_factory,
|
||||
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
|
||||
bool enable_video_gpu_memory_buffers,
|
||||
bool enable_media_stream_gpu_memory_buffers,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator) {
|
||||
return base::WrapUnique(new GpuVideoAcceleratorFactoriesImpl(
|
||||
return base::WrapUnique(new MojoGpuVideoAcceleratorFactories(
|
||||
std::move(gpu_channel_host), main_thread_task_runner, task_runner,
|
||||
std::move(context_provider), std::move(codec_factory),
|
||||
std::move(gpu_memory_buffer_manager), enable_video_gpu_memory_buffers,
|
||||
@ -89,12 +67,12 @@ GpuVideoAcceleratorFactoriesImpl::CreateForTesting(
|
||||
enable_video_encode_accelerator));
|
||||
}
|
||||
|
||||
GpuVideoAcceleratorFactoriesImpl::GpuVideoAcceleratorFactoriesImpl(
|
||||
MojoGpuVideoAcceleratorFactories::MojoGpuVideoAcceleratorFactories(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
std::unique_ptr<MojoCodecFactory> codec_factory,
|
||||
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
|
||||
bool enable_video_gpu_memory_buffers,
|
||||
bool enable_media_stream_gpu_memory_buffers,
|
||||
@ -116,13 +94,15 @@ GpuVideoAcceleratorFactoriesImpl::GpuVideoAcceleratorFactoriesImpl(
|
||||
|
||||
task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner,
|
||||
base::BindOnce(&MojoGpuVideoAcceleratorFactories::BindOnTaskRunner,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
GpuVideoAcceleratorFactoriesImpl::~GpuVideoAcceleratorFactoriesImpl() {}
|
||||
MojoGpuVideoAcceleratorFactories::~MojoGpuVideoAcceleratorFactories() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner() {
|
||||
void MojoGpuVideoAcceleratorFactories::BindOnTaskRunner() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
DCHECK(context_provider_);
|
||||
|
||||
@ -136,32 +116,33 @@ void GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner() {
|
||||
|
||||
// Request the channel token.
|
||||
context_provider_->GetCommandBufferProxy()->GetGpuChannel().GetChannelToken(
|
||||
base::BindOnce(&GpuVideoAcceleratorFactoriesImpl::OnChannelTokenReady,
|
||||
base::BindOnce(&MojoGpuVideoAcceleratorFactories::OnChannelTokenReady,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
bool GpuVideoAcceleratorFactoriesImpl::IsDecoderSupportKnown() {
|
||||
bool MojoGpuVideoAcceleratorFactories::IsDecoderSupportKnown() {
|
||||
return codec_factory_->IsDecoderSupportKnown();
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::NotifyDecoderSupportKnown(
|
||||
void MojoGpuVideoAcceleratorFactories::NotifyDecoderSupportKnown(
|
||||
base::OnceClosure callback) {
|
||||
codec_factory_->NotifyDecoderSupportKnown(std::move(callback));
|
||||
}
|
||||
|
||||
bool GpuVideoAcceleratorFactoriesImpl::IsEncoderSupportKnown() {
|
||||
bool MojoGpuVideoAcceleratorFactories::IsEncoderSupportKnown() {
|
||||
return codec_factory_->IsEncoderSupportKnown();
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::NotifyEncoderSupportKnown(
|
||||
void MojoGpuVideoAcceleratorFactories::NotifyEncoderSupportKnown(
|
||||
base::OnceClosure callback) {
|
||||
codec_factory_->NotifyEncoderSupportKnown(std::move(callback));
|
||||
}
|
||||
|
||||
bool GpuVideoAcceleratorFactoriesImpl::CheckContextLost() {
|
||||
bool MojoGpuVideoAcceleratorFactories::CheckContextLost() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
if (context_provider_lost_on_media_thread_)
|
||||
if (context_provider_lost_on_media_thread_) {
|
||||
return true;
|
||||
}
|
||||
if (context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
|
||||
GL_NO_ERROR) {
|
||||
OnContextLost();
|
||||
@ -170,25 +151,26 @@ bool GpuVideoAcceleratorFactoriesImpl::CheckContextLost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::DestroyContext() {
|
||||
void MojoGpuVideoAcceleratorFactories::DestroyContext() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
DCHECK(context_provider_lost_on_media_thread_);
|
||||
|
||||
if (!context_provider_)
|
||||
if (!context_provider_) {
|
||||
return;
|
||||
}
|
||||
|
||||
context_provider_->RemoveObserver(this);
|
||||
context_provider_ = nullptr;
|
||||
}
|
||||
|
||||
bool GpuVideoAcceleratorFactoriesImpl::IsGpuVideoDecodeAcceleratorEnabled() {
|
||||
bool MojoGpuVideoAcceleratorFactories::IsGpuVideoDecodeAcceleratorEnabled() {
|
||||
return video_decode_accelerator_enabled_;
|
||||
}
|
||||
bool GpuVideoAcceleratorFactoriesImpl::IsGpuVideoEncodeAcceleratorEnabled() {
|
||||
bool MojoGpuVideoAcceleratorFactories::IsGpuVideoEncodeAcceleratorEnabled() {
|
||||
return video_encode_accelerator_enabled_;
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::GetChannelToken(
|
||||
void MojoGpuVideoAcceleratorFactories::GetChannelToken(
|
||||
gpu::mojom::GpuChannel::GetChannelTokenCallback cb) {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
if (CheckContextLost()) {
|
||||
@ -206,7 +188,7 @@ void GpuVideoAcceleratorFactoriesImpl::GetChannelToken(
|
||||
channel_token_callbacks_.AddUnsafe(std::move(cb));
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::OnChannelTokenReady(
|
||||
void MojoGpuVideoAcceleratorFactories::OnChannelTokenReady(
|
||||
const base::UnguessableToken& token) {
|
||||
channel_token_ = token;
|
||||
channel_token_callbacks_.Notify(channel_token_);
|
||||
@ -215,15 +197,16 @@ void GpuVideoAcceleratorFactoriesImpl::OnChannelTokenReady(
|
||||
token, context_provider_->GetCommandBufferProxy()->route_id());
|
||||
}
|
||||
|
||||
int32_t GpuVideoAcceleratorFactoriesImpl::GetCommandBufferRouteId() {
|
||||
int32_t MojoGpuVideoAcceleratorFactories::GetCommandBufferRouteId() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
if (CheckContextLost())
|
||||
if (CheckContextLost()) {
|
||||
return 0;
|
||||
}
|
||||
return context_provider_->GetCommandBufferProxy()->route_id();
|
||||
}
|
||||
|
||||
media::GpuVideoAcceleratorFactories::Supported
|
||||
GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
|
||||
MojoGpuVideoAcceleratorFactories::IsDecoderConfigSupported(
|
||||
const media::VideoDecoderConfig& config) {
|
||||
// There is no support for alpha channel hardware decoding yet.
|
||||
// HEVC is the codec that only has platform hardware decoder support, and
|
||||
@ -242,55 +225,61 @@ GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
|
||||
|
||||
// Iterate over the supported configs.
|
||||
for (const auto& supported : *supported_decoder_configs) {
|
||||
if (supported.Matches(config))
|
||||
if (supported.Matches(config)) {
|
||||
return Supported::kTrue;
|
||||
}
|
||||
}
|
||||
return Supported::kFalse;
|
||||
}
|
||||
|
||||
media::VideoDecoderType GpuVideoAcceleratorFactoriesImpl::GetDecoderType() {
|
||||
media::VideoDecoderType MojoGpuVideoAcceleratorFactories::GetDecoderType() {
|
||||
return codec_factory_->GetVideoDecoderType();
|
||||
}
|
||||
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateVideoDecoder(
|
||||
MojoGpuVideoAcceleratorFactories::CreateVideoDecoder(
|
||||
media::MediaLog* media_log,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb) {
|
||||
DCHECK(video_decode_accelerator_enabled_);
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
if (CheckContextLost())
|
||||
if (CheckContextLost()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return codec_factory_->CreateVideoDecoder(
|
||||
this, media_log, request_overlay_info_cb, rendering_color_space_);
|
||||
}
|
||||
|
||||
std::unique_ptr<media::VideoEncodeAccelerator>
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateVideoEncodeAccelerator() {
|
||||
MojoGpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator() {
|
||||
DCHECK(video_encode_accelerator_enabled_);
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
if (CheckContextLost())
|
||||
if (CheckContextLost()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return codec_factory_->CreateVideoEncodeAccelerator();
|
||||
}
|
||||
|
||||
std::unique_ptr<gfx::GpuMemoryBuffer>
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateGpuMemoryBuffer(
|
||||
MojoGpuVideoAcceleratorFactories::CreateGpuMemoryBuffer(
|
||||
const gfx::Size& size,
|
||||
gfx::BufferFormat format,
|
||||
gfx::BufferUsage usage) {
|
||||
return gpu_memory_buffer_manager_->CreateGpuMemoryBuffer(
|
||||
size, format, usage, gpu::kNullSurfaceHandle, nullptr);
|
||||
if (gpu_memory_buffer_manager_) {
|
||||
return gpu_memory_buffer_manager_->CreateGpuMemoryBuffer(
|
||||
size, format, usage, gpu::kNullSurfaceHandle, nullptr);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
bool GpuVideoAcceleratorFactoriesImpl::ShouldUseGpuMemoryBuffersForVideoFrames(
|
||||
bool MojoGpuVideoAcceleratorFactories::ShouldUseGpuMemoryBuffersForVideoFrames(
|
||||
bool for_media_stream) const {
|
||||
return for_media_stream ? enable_media_stream_gpu_memory_buffers_
|
||||
: enable_video_gpu_memory_buffers_;
|
||||
}
|
||||
|
||||
media::GpuVideoAcceleratorFactories::OutputFormat
|
||||
GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormat(
|
||||
MojoGpuVideoAcceleratorFactories::VideoFrameOutputFormat(
|
||||
media::VideoPixelFormat pixel_format) {
|
||||
auto format = VideoFrameOutputFormatImpl(pixel_format);
|
||||
UMA_HISTOGRAM_ENUMERATION("Media.GPU.OutputFormat", format);
|
||||
@ -298,7 +287,7 @@ GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormat(
|
||||
}
|
||||
|
||||
media::GpuVideoAcceleratorFactories::OutputFormat
|
||||
GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormatImpl(
|
||||
MojoGpuVideoAcceleratorFactories::VideoFrameOutputFormatImpl(
|
||||
media::VideoPixelFormat pixel_format) {
|
||||
using OutputFormat = media::GpuVideoAcceleratorFactories::OutputFormat;
|
||||
|
||||
@ -387,68 +376,68 @@ GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormatImpl(
|
||||
}
|
||||
|
||||
gpu::SharedImageInterface*
|
||||
GpuVideoAcceleratorFactoriesImpl::SharedImageInterface() {
|
||||
MojoGpuVideoAcceleratorFactories::SharedImageInterface() {
|
||||
return CheckContextLost() ? nullptr
|
||||
: context_provider_->SharedImageInterface();
|
||||
}
|
||||
|
||||
gpu::GpuMemoryBufferManager*
|
||||
GpuVideoAcceleratorFactoriesImpl::GpuMemoryBufferManager() {
|
||||
MojoGpuVideoAcceleratorFactories::GpuMemoryBufferManager() {
|
||||
return gpu_memory_buffer_manager_;
|
||||
}
|
||||
|
||||
base::UnsafeSharedMemoryRegion
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateSharedMemoryRegion(size_t size) {
|
||||
MojoGpuVideoAcceleratorFactories::CreateSharedMemoryRegion(size_t size) {
|
||||
// If necessary, this call will make a synchronous request to a privileged
|
||||
// process to create the shared region.
|
||||
return base::UnsafeSharedMemoryRegion::Create(size);
|
||||
}
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner>
|
||||
GpuVideoAcceleratorFactoriesImpl::GetTaskRunner() {
|
||||
MojoGpuVideoAcceleratorFactories::GetTaskRunner() {
|
||||
return task_runner_;
|
||||
}
|
||||
|
||||
std::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
GpuVideoAcceleratorFactoriesImpl::GetVideoEncodeAcceleratorSupportedProfiles() {
|
||||
MojoGpuVideoAcceleratorFactories::GetVideoEncodeAcceleratorSupportedProfiles() {
|
||||
return codec_factory_->GetVideoEncodeAcceleratorSupportedProfiles();
|
||||
}
|
||||
|
||||
std::optional<media::SupportedVideoDecoderConfigs>
|
||||
GpuVideoAcceleratorFactoriesImpl::GetSupportedVideoDecoderConfigs() {
|
||||
MojoGpuVideoAcceleratorFactories::GetSupportedVideoDecoderConfigs() {
|
||||
return codec_factory_->GetSupportedVideoDecoderConfigs();
|
||||
}
|
||||
|
||||
viz::RasterContextProvider*
|
||||
GpuVideoAcceleratorFactoriesImpl::GetMediaContextProvider() {
|
||||
MojoGpuVideoAcceleratorFactories::GetMediaContextProvider() {
|
||||
return CheckContextLost() ? nullptr : context_provider_.get();
|
||||
}
|
||||
|
||||
const gpu::Capabilities*
|
||||
GpuVideoAcceleratorFactoriesImpl::ContextCapabilities() {
|
||||
MojoGpuVideoAcceleratorFactories::ContextCapabilities() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
return CheckContextLost() ? nullptr
|
||||
: &(context_provider_->ContextCapabilities());
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::SetRenderingColorSpace(
|
||||
void MojoGpuVideoAcceleratorFactories::SetRenderingColorSpace(
|
||||
const gfx::ColorSpace& color_space) {
|
||||
rendering_color_space_ = color_space;
|
||||
}
|
||||
|
||||
const gfx::ColorSpace&
|
||||
GpuVideoAcceleratorFactoriesImpl::GetRenderingColorSpace() const {
|
||||
MojoGpuVideoAcceleratorFactories::GetRenderingColorSpace() const {
|
||||
return rendering_color_space_;
|
||||
}
|
||||
|
||||
bool GpuVideoAcceleratorFactoriesImpl::CheckContextProviderLostOnMainThread() {
|
||||
bool MojoGpuVideoAcceleratorFactories::CheckContextProviderLostOnMainThread() {
|
||||
DCHECK(main_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
return context_provider_lost_;
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::OnContextLost() {
|
||||
void MojoGpuVideoAcceleratorFactories::OnContextLost() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
TRACE_EVENT0("media", "GpuVideoAcceleratorFactoriesImpl::OnContextLost");
|
||||
TRACE_EVENT0("media", "MojoGpuVideoAcceleratorFactories::OnContextLost");
|
||||
|
||||
// Don't delete the |context_provider_| here, we could be in the middle of
|
||||
// it notifying about the loss, and we'd be destroying it while it's on
|
||||
@ -459,13 +448,13 @@ void GpuVideoAcceleratorFactoriesImpl::OnContextLost() {
|
||||
main_thread_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
&GpuVideoAcceleratorFactoriesImpl::SetContextProviderLostOnMainThread,
|
||||
&MojoGpuVideoAcceleratorFactories::SetContextProviderLostOnMainThread,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::SetContextProviderLostOnMainThread() {
|
||||
void MojoGpuVideoAcceleratorFactories::SetContextProviderLostOnMainThread() {
|
||||
DCHECK(main_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
context_provider_lost_ = true;
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
@ -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 CONTENT_RENDERER_MEDIA_GPU_GPU_VIDEO_ACCELERATOR_FACTORIES_IMPL_H_
|
||||
#define CONTENT_RENDERER_MEDIA_GPU_GPU_VIDEO_ACCELERATOR_FACTORIES_IMPL_H_
|
||||
#ifndef MEDIA_MOJO_CLIENTS_MOJO_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
|
||||
#define MEDIA_MOJO_CLIENTS_MOJO_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -18,9 +18,8 @@
|
||||
#include "base/unguessable_token.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/viz/common/gpu/context_lost_observer.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "media/mojo/buildflags.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/video/gpu_video_accelerator_factories.h"
|
||||
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
@ -40,40 +39,29 @@ namespace viz {
|
||||
class ContextProviderCommandBuffer;
|
||||
} // namespace viz
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
// Default implementation of the GpuVideoAcceleratorFactories implementation,
|
||||
// to allow various media/video classes to access necessary GPU functionality.
|
||||
// Glue code to expose functionality needed by media::GpuVideoAccelerator to
|
||||
// RenderViewImpl. This class is entirely an implementation detail of
|
||||
// RenderViewImpl and only has its own header to allow extraction of its
|
||||
// implementation from render_view_impl.cc which is already far too large.
|
||||
//
|
||||
// The GpuVideoAcceleratorFactoriesImpl can be constructed on any thread,
|
||||
// The MojoGpuVideoAcceleratorFactories can be constructed on any thread,
|
||||
// but subsequent calls to all public methods of the class must be called from
|
||||
// the |task_runner_|, as provided during construction.
|
||||
// |context_provider| should not support locking and will be bound to
|
||||
// |task_runner_| where all the operations on the context should also happen.
|
||||
class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
class MojoGpuVideoAcceleratorFactories
|
||||
: public media::GpuVideoAcceleratorFactories,
|
||||
public viz::ContextLostObserver {
|
||||
public:
|
||||
// Takes a ref on |gpu_channel_host| and tests |context| for loss before each
|
||||
// use. Safe to call from any thread.
|
||||
static std::unique_ptr<GpuVideoAcceleratorFactoriesImpl> Create(
|
||||
static std::unique_ptr<MojoGpuVideoAcceleratorFactories> Create(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
bool enable_video_gpu_memory_buffers,
|
||||
bool enable_media_stream_gpu_memory_buffers,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator);
|
||||
static std::unique_ptr<GpuVideoAcceleratorFactoriesImpl> CreateForTesting(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
std::unique_ptr<MojoCodecFactory> codec_factory,
|
||||
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
|
||||
bool enable_video_gpu_memory_buffers,
|
||||
bool enable_media_stream_gpu_memory_buffers,
|
||||
@ -141,20 +129,20 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
// with a new ContextProvider.
|
||||
bool CheckContextProviderLostOnMainThread();
|
||||
|
||||
GpuVideoAcceleratorFactoriesImpl(const GpuVideoAcceleratorFactoriesImpl&) =
|
||||
MojoGpuVideoAcceleratorFactories(const MojoGpuVideoAcceleratorFactories&) =
|
||||
delete;
|
||||
GpuVideoAcceleratorFactoriesImpl& operator=(
|
||||
const GpuVideoAcceleratorFactoriesImpl&) = delete;
|
||||
MojoGpuVideoAcceleratorFactories& operator=(
|
||||
const MojoGpuVideoAcceleratorFactories&) = delete;
|
||||
|
||||
~GpuVideoAcceleratorFactoriesImpl() override;
|
||||
~MojoGpuVideoAcceleratorFactories() override;
|
||||
|
||||
private:
|
||||
GpuVideoAcceleratorFactoriesImpl(
|
||||
MojoGpuVideoAcceleratorFactories(
|
||||
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
|
||||
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
|
||||
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
|
||||
std::unique_ptr<CodecFactory> codec_factory,
|
||||
std::unique_ptr<MojoCodecFactory> codec_factory,
|
||||
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
|
||||
bool enable_gpu_memory_buffer_video_frames_for_video,
|
||||
bool enable_gpu_memory_buffer_video_frames_for_media_stream,
|
||||
@ -176,7 +164,7 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
const scoped_refptr<base::SequencedTaskRunner> task_runner_;
|
||||
const scoped_refptr<gpu::GpuChannelHost> gpu_channel_host_;
|
||||
|
||||
const std::unique_ptr<CodecFactory> codec_factory_;
|
||||
const std::unique_ptr<MojoCodecFactory> codec_factory_;
|
||||
|
||||
// Shared pointer to a shared context provider. It is initially set on main
|
||||
// thread, but all subsequent access and destruction should happen only on the
|
||||
@ -204,6 +192,6 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
const raw_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_;
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
||||
|
||||
#endif // CONTENT_RENDERER_MEDIA_GPU_GPU_VIDEO_ACCELERATOR_FACTORIES_IMPL_H_
|
||||
#endif // MEDIA_MOJO_CLIENTS_MOJO_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h"
|
||||
#include "media/mojo/clients/mojo_gpu_video_accelerator_factories.h"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
@ -17,13 +17,12 @@
|
||||
#include "build/build_config.h"
|
||||
#include "components/viz/common/gpu/context_cache_controller.h"
|
||||
#include "components/viz/common/gpu/context_lost_observer.h"
|
||||
#include "content/public/common/gpu_stream_constants.h"
|
||||
#include "content/renderer/media/codec_factory.h"
|
||||
#include "gpu/command_buffer/client/gles2_interface_stub.h"
|
||||
#include "gpu/command_buffer/client/test_gpu_memory_buffer_manager.h"
|
||||
#include "gpu/command_buffer/common/capabilities.h"
|
||||
#include "gpu/command_buffer/common/context_creation_attribs.h"
|
||||
#include "gpu/command_buffer/common/context_result.h"
|
||||
#include "gpu/command_buffer/common/scheduling_priority.h"
|
||||
#include "gpu/config/gpu_feature_info.h"
|
||||
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
|
||||
#include "gpu/ipc/client/gpu_channel_host.h"
|
||||
@ -35,6 +34,7 @@
|
||||
#include "media/base/video_codecs.h"
|
||||
#include "media/base/video_decoder_config.h"
|
||||
#include "media/mojo/buildflags.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory.h"
|
||||
#include "media/mojo/mojom/video_encode_accelerator.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
@ -45,8 +45,8 @@
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
|
||||
#include "content/renderer/media/codec_factory_mojo.h"
|
||||
#include "media/filters/fake_video_decoder.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_mojo_decoder.h"
|
||||
#include "media/mojo/mojom/interface_factory.mojom.h"
|
||||
#include "media/mojo/services/mojo_cdm_service_context.h"
|
||||
#include "media/mojo/services/mojo_media_client.h"
|
||||
@ -55,7 +55,7 @@
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_FUCHSIA)
|
||||
#include "content/renderer/media/codec_factory_fuchsia.h"
|
||||
#include "media/mojo/clients/mojo_codec_factory_fuchsia.h"
|
||||
#include "media/mojo/mojom/fuchsia_media.mojom.h"
|
||||
#endif
|
||||
|
||||
@ -65,7 +65,7 @@ using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
namespace content {
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
|
||||
@ -73,6 +73,9 @@ constexpr gfx::Size kCodedSize(320, 240);
|
||||
constexpr gfx::Rect kVisibleRect(320, 240);
|
||||
constexpr gfx::Size kNaturalSize(320, 240);
|
||||
|
||||
constexpr auto kGpuStreamPriorityDefault = gpu::SchedulingPriority::kNormal;
|
||||
constexpr int kGpuStreamIdDefault = 0;
|
||||
|
||||
const media::SupportedVideoDecoderConfig kH264MaxSupportedVideoDecoderConfig =
|
||||
media::SupportedVideoDecoderConfig(
|
||||
media::VideoCodecProfile::H264PROFILE_MIN,
|
||||
@ -148,8 +151,8 @@ class MockContextProviderCommandBuffer
|
||||
scoped_refptr<gpu::GpuChannelHost> channel)
|
||||
: viz::ContextProviderCommandBuffer(
|
||||
std::move(channel),
|
||||
content::kGpuStreamIdDefault,
|
||||
content::kGpuStreamPriorityDefault,
|
||||
kGpuStreamIdDefault,
|
||||
kGpuStreamPriorityDefault,
|
||||
GURL(),
|
||||
false,
|
||||
true,
|
||||
@ -202,6 +205,10 @@ class FakeVEAProviderImpl
|
||||
receiver_.Bind(std::move(receiver));
|
||||
}
|
||||
|
||||
void SetDisconnectHandler(base::OnceClosure handler) {
|
||||
receiver_.set_disconnect_handler(std::move(handler));
|
||||
}
|
||||
|
||||
void SetVideoEncodeAcceleratorSupportedProfiles(
|
||||
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
|
||||
supported_profile) {
|
||||
@ -382,15 +389,15 @@ class FakeFuchsiaMediaCodecProvide
|
||||
};
|
||||
#endif // BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
class MojoGpuVideoAcceleratorFactoriesTest : public testing::Test {
|
||||
public:
|
||||
GpuVideoAcceleratorFactoriesImplTest()
|
||||
MojoGpuVideoAcceleratorFactoriesTest()
|
||||
: gpu_channel_host_(
|
||||
base::MakeRefCounted<TestGpuChannelHost>(mock_gpu_channel_)),
|
||||
mock_context_provider_(
|
||||
base::MakeRefCounted<NiceMock<MockContextProviderCommandBuffer>>(
|
||||
gpu_channel_host_)) {}
|
||||
~GpuVideoAcceleratorFactoriesImplTest() override = default;
|
||||
~MojoGpuVideoAcceleratorFactoriesTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
MockGpuChannel();
|
||||
@ -398,7 +405,11 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
task_environment_.RunUntilIdle();
|
||||
// Ensure that the factories' `vea_provider_` destructor is called, to
|
||||
// avoid a memory leak.
|
||||
fake_vea_provider_.SetDisconnectHandler(task_environment_.QuitClosure());
|
||||
task_environment_.RunUntilQuit();
|
||||
|
||||
ASSERT_TRUE(testing::Mock::VerifyAndClear(&mock_context_provider_));
|
||||
ASSERT_TRUE(testing::Mock::VerifyAndClear(&mock_context_gl_));
|
||||
ASSERT_TRUE(testing::Mock::VerifyAndClear(&mock_gpu_channel_));
|
||||
@ -444,16 +455,16 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
.WillByDefault(Return(&mock_context_gl_));
|
||||
|
||||
gpu_command_buffer_proxy_ = std::make_unique<gpu::CommandBufferProxyImpl>(
|
||||
gpu_channel_host_, content::kGpuStreamIdDefault,
|
||||
gpu_channel_host_, kGpuStreamIdDefault,
|
||||
task_environment_.GetMainThreadTaskRunner());
|
||||
gpu_command_buffer_proxy_->Initialize(
|
||||
nullptr, content::kGpuStreamPriorityDefault,
|
||||
gpu::ContextCreationAttribs(), GURL());
|
||||
gpu_command_buffer_proxy_->Initialize(nullptr, kGpuStreamPriorityDefault,
|
||||
gpu::ContextCreationAttribs(),
|
||||
GURL());
|
||||
ON_CALL(*mock_context_provider_, GetCommandBufferProxy())
|
||||
.WillByDefault(Return(gpu_command_buffer_proxy_.get()));
|
||||
}
|
||||
|
||||
std::unique_ptr<CodecFactory> CreateCodecFactory(
|
||||
std::unique_ptr<MojoCodecFactory> CreateMojoCodecFactory(
|
||||
scoped_refptr<viz::ContextProviderCommandBuffer> context_provider,
|
||||
bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator) {
|
||||
@ -465,7 +476,7 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
mojo::PendingRemote<media::mojom::InterfaceFactory> interface_factory;
|
||||
fake_media_codec_provider_.Bind(
|
||||
interface_factory.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<CodecFactoryMojo>(
|
||||
return std::make_unique<MojoCodecFactoryMojoDecoder>(
|
||||
task_environment_.GetMainThreadTaskRunner(),
|
||||
std::move(context_provider), enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator, std::move(vea_provider),
|
||||
@ -475,26 +486,26 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
media_codec_provider;
|
||||
fake_media_codec_provider_.Bind(
|
||||
media_codec_provider.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<CodecFactoryFuchsia>(
|
||||
return std::make_unique<MojoCodecFactoryFuchsia>(
|
||||
task_environment_.GetMainThreadTaskRunner(),
|
||||
std::move(context_provider), enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator, std::move(vea_provider),
|
||||
std::move(media_codec_provider));
|
||||
#else
|
||||
return std::make_unique<CodecFactoryDefault>(
|
||||
return std::make_unique<MojoCodecFactoryDefault>(
|
||||
task_environment_.GetMainThreadTaskRunner(),
|
||||
std::move(context_provider), enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator, std::move(vea_provider));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>
|
||||
std::unique_ptr<MojoGpuVideoAcceleratorFactories>
|
||||
CreateGpuVideoAcceleratorFactories(bool enable_video_decode_accelerator,
|
||||
bool enable_video_encode_accelerator) {
|
||||
std::unique_ptr<CodecFactory> codec_factory = CreateCodecFactory(
|
||||
std::unique_ptr<MojoCodecFactory> codec_factory = CreateMojoCodecFactory(
|
||||
mock_context_provider_, enable_video_decode_accelerator,
|
||||
enable_video_encode_accelerator);
|
||||
auto gpu_factories = GpuVideoAcceleratorFactoriesImpl::CreateForTesting(
|
||||
auto gpu_factories = MojoGpuVideoAcceleratorFactories::Create(
|
||||
gpu_channel_host_, task_environment_.GetMainThreadTaskRunner(),
|
||||
task_environment_.GetMainThreadTaskRunner(), mock_context_provider_,
|
||||
std::move(codec_factory), &gpu_memory_buffer_manager_,
|
||||
@ -502,16 +513,23 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
true, /* enable_media_stream_gpu_memory_buffers */
|
||||
enable_video_decode_accelerator, enable_video_encode_accelerator);
|
||||
|
||||
// Wait until all async IO messages (e.g. Mojo and FIDL) to be delieved
|
||||
// and handled.
|
||||
task_environment_.RunUntilIdle();
|
||||
// Make sure the factories object is initialized before returning.
|
||||
gpu_factories->NotifyEncoderSupportKnown(task_environment_.QuitClosure());
|
||||
task_environment_.RunUntilQuit();
|
||||
gpu_factories->NotifyDecoderSupportKnown(task_environment_.QuitClosure());
|
||||
task_environment_.RunUntilQuit();
|
||||
EXPECT_TRUE(gpu_factories->IsEncoderSupportKnown());
|
||||
EXPECT_TRUE(gpu_factories->IsDecoderSupportKnown());
|
||||
|
||||
return gpu_factories;
|
||||
}
|
||||
|
||||
protected:
|
||||
base::test::SingleThreadTaskEnvironment task_environment_{
|
||||
base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
|
||||
base::test::TaskEnvironment task_environment_{
|
||||
base::test::TaskEnvironment::MainThreadType::IO,
|
||||
base::test::TaskEnvironment::TimeSource::MOCK_TIME,
|
||||
// Necessary for using RunUntilQuit() plus a QuitClosure().
|
||||
base::test::TaskEnvironment::ThreadingMode::MULTIPLE_THREADS};
|
||||
|
||||
NiceMock<gpu::MockGpuChannel> mock_gpu_channel_;
|
||||
NiceMock<MockGLESInterface> mock_context_gl_;
|
||||
@ -519,7 +537,6 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
scoped_refptr<TestGpuChannelHost> gpu_channel_host_;
|
||||
scoped_refptr<MockContextProviderCommandBuffer> mock_context_provider_;
|
||||
std::unique_ptr<gpu::CommandBufferProxyImpl> gpu_command_buffer_proxy_;
|
||||
|
||||
FakeVEAProviderImpl fake_vea_provider_;
|
||||
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
|
||||
@ -529,13 +546,12 @@ class GpuVideoAcceleratorFactoriesImplTest : public testing::Test {
|
||||
#endif
|
||||
};
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, VideoDecoderAcceleratorDisabled) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, VideoDecoderAcceleratorDisabled) {
|
||||
auto gpu_video_accelerator_factories =
|
||||
CreateGpuVideoAcceleratorFactories(false, false);
|
||||
|
||||
EXPECT_FALSE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoDecodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsDecoderSupportKnown());
|
||||
EXPECT_EQ(gpu_video_accelerator_factories->IsDecoderConfigSupported(
|
||||
kH264BaseConfig),
|
||||
media::GpuVideoAcceleratorFactories::Supported::kFalse);
|
||||
@ -546,16 +562,15 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, VideoDecoderAcceleratorDisabled) {
|
||||
testing::Mock::VerifyAndClearExpectations(&mock_context_provider_));
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, VideoEncoderAcceleratorDisabled) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, VideoEncoderAcceleratorDisabled) {
|
||||
auto gpu_video_accelerator_factories =
|
||||
CreateGpuVideoAcceleratorFactories(false, false);
|
||||
|
||||
EXPECT_FALSE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoEncodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsEncoderSupportKnown());
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, EncoderConfigsIsSupported) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, EncoderConfigsIsSupported) {
|
||||
fake_vea_provider_.SetVideoEncodeAcceleratorSupportedProfiles(
|
||||
{media::VideoEncodeAccelerator::SupportedProfile(
|
||||
media::VideoCodecProfile::VP9PROFILE_MAX, kCodedSize)});
|
||||
@ -564,7 +579,6 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, EncoderConfigsIsSupported) {
|
||||
|
||||
EXPECT_TRUE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoEncodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsEncoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyEncoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -575,14 +589,13 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, EncoderConfigsIsSupported) {
|
||||
EXPECT_EQ(supported_profiles->size(), static_cast<size_t>(1));
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, EncoderConfigsIsNotSupported) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, EncoderConfigsIsNotSupported) {
|
||||
fake_vea_provider_.SetVideoEncodeAcceleratorSupportedProfiles({});
|
||||
auto gpu_video_accelerator_factories =
|
||||
CreateGpuVideoAcceleratorFactories(false, true);
|
||||
|
||||
EXPECT_TRUE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoEncodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsEncoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyEncoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -593,7 +606,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, EncoderConfigsIsNotSupported) {
|
||||
EXPECT_TRUE(supported_profiles->empty());
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, CreateVideoEncodeAccelerator) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, CreateVideoEncodeAccelerator) {
|
||||
fake_vea_provider_.SetVideoEncodeAcceleratorSupportedProfiles(
|
||||
{media::VideoEncodeAccelerator::SupportedProfile(
|
||||
media::VideoCodecProfile::VP9PROFILE_MAX, kCodedSize)});
|
||||
@ -605,10 +618,10 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, CreateVideoEncodeAccelerator) {
|
||||
}
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
using GpuVideoAcceleratorFactoriesImplDeathTest =
|
||||
GpuVideoAcceleratorFactoriesImplTest;
|
||||
using MojoGpuVideoAcceleratorFactoriesDeathTest =
|
||||
MojoGpuVideoAcceleratorFactoriesTest;
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplDeathTest,
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesDeathTest,
|
||||
CreateVideoEncodeAcceleratorFailed) {
|
||||
auto gpu_video_accelerator_factories =
|
||||
CreateGpuVideoAcceleratorFactories(false, false);
|
||||
@ -619,7 +632,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplDeathTest,
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplDeathTest, CreateVideoDecoderFailed) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesDeathTest, CreateVideoDecoderFailed) {
|
||||
testing::StrictMock<MockOverlayInfoCbHandler> cb_handler;
|
||||
media::RequestOverlayInfoCB mock_cb = base::BindRepeating(
|
||||
&MockOverlayInfoCbHandler::Call, base::Unretained(&cb_handler));
|
||||
@ -635,7 +648,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplDeathTest, CreateVideoDecoderFailed) {
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER) || BUILDFLAG(IS_FUCHSIA)
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsSupported) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, DecoderConfigIsSupported) {
|
||||
fake_media_codec_provider_.SetSupportedVideoDecoderConfigs(
|
||||
{kH264MaxSupportedVideoDecoderConfig});
|
||||
|
||||
@ -644,7 +657,6 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsSupported) {
|
||||
|
||||
EXPECT_TRUE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoDecodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsDecoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyDecoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -656,7 +668,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsSupported) {
|
||||
media::VideoDecoderType::kUnknown);
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsNotSupported) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, DecoderConfigIsNotSupported) {
|
||||
fake_media_codec_provider_.SetSupportedVideoDecoderConfigs(
|
||||
{kH264MaxSupportedVideoDecoderConfig});
|
||||
|
||||
@ -665,7 +677,6 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsNotSupported) {
|
||||
|
||||
EXPECT_TRUE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoDecodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsDecoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyDecoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -675,7 +686,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, DecoderConfigIsNotSupported) {
|
||||
media::GpuVideoAcceleratorFactories::Supported::kFalse);
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, GetSupportedVideoDecoderConfigs) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, GetSupportedVideoDecoderConfigs) {
|
||||
fake_media_codec_provider_.SetSupportedVideoDecoderConfigs(
|
||||
{kH264MaxSupportedVideoDecoderConfig
|
||||
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
|
||||
@ -689,7 +700,6 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, GetSupportedVideoDecoderConfigs) {
|
||||
|
||||
EXPECT_TRUE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoDecodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsDecoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyDecoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -710,7 +720,7 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, GetSupportedVideoDecoderConfigs) {
|
||||
#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
|
||||
}
|
||||
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, CreateVideoDecoder) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, CreateVideoDecoder) {
|
||||
testing::StrictMock<MockOverlayInfoCbHandler> cb_handler;
|
||||
media::RequestOverlayInfoCB mock_cb = base::BindRepeating(
|
||||
&MockOverlayInfoCbHandler::Call, base::Unretained(&cb_handler));
|
||||
@ -722,13 +732,12 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, CreateVideoDecoder) {
|
||||
nullptr);
|
||||
}
|
||||
#else
|
||||
TEST_F(GpuVideoAcceleratorFactoriesImplTest, DefaultCodecFactory) {
|
||||
TEST_F(MojoGpuVideoAcceleratorFactoriesTest, DefaultMojoCodecFactory) {
|
||||
auto gpu_video_accelerator_factories =
|
||||
CreateGpuVideoAcceleratorFactories(false, false);
|
||||
|
||||
EXPECT_FALSE(
|
||||
gpu_video_accelerator_factories->IsGpuVideoDecodeAcceleratorEnabled());
|
||||
EXPECT_TRUE(gpu_video_accelerator_factories->IsDecoderSupportKnown());
|
||||
base::test::TestFuture<void> future;
|
||||
gpu_video_accelerator_factories->NotifyDecoderSupportKnown(
|
||||
future.GetCallback());
|
||||
@ -739,4 +748,4 @@ TEST_F(GpuVideoAcceleratorFactoriesImplTest, DefaultCodecFactory) {
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER) || BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
} // namespace content
|
||||
} // namespace media
|
Reference in New Issue
Block a user