Remove all VideoDecoderImplementation usage
This used to be the mechanism by which D3D11 vs DXVA was created on windows for hardware accelerated video. Now that DXVA is only being used in locations where D3D11 isn't (win7, d3d11_disabled_by_workaround, d3d11_disabled_by_flag), there isn't a point anymore. By proxy, this also removes the SupportedVideoDecoderConfigMap and just goes back to using SupportedVideoDecoderConfigs. R=liberato Bug: 1181358 Change-Id: I3b1a9620a487c94598c048a6b511c9dcf8da7d69 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2952240 Commit-Queue: Ted Meyer <tmathmeyer@chromium.org> Reviewed-by: Frank Liberato <liberato@chromium.org> Reviewed-by: Johannes Kron <kron@chromium.org> Reviewed-by: Chrome Cunningham <chcunningham@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Kenneth MacKay <kmackay@chromium.org> Reviewed-by: Matthew Denton <mpdenton@chromium.org> Cr-Commit-Position: refs/heads/master@{#892243}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
25b30316ed
commit
4041de9d04
chrome/browser/thumbnail/generator/android
chromecast/media/gpu
content
browser
renderer
test
data
media
base
mojo
clients
mojom
services
gpu_mojo_media_client.ccgpu_mojo_media_client.hmojo_media_client.ccmojo_media_client.hmojo_video_decoder_service.ccmojo_video_decoder_service.h
test
video
third_party/blink/renderer
modules
media_capabilities
webcodecs
platform
tools/metrics/histograms/histograms_xml/media
@ -219,7 +219,6 @@ void ThumbnailMediaParserImpl::DecodeVideoFrame() {
|
||||
auto mojo_decoder = std::make_unique<media::MojoVideoDecoder>(
|
||||
base::ThreadTaskRunnerHandle::Get(), gpu_factories_.get(), this,
|
||||
std::move(video_decoder_remote),
|
||||
media::VideoDecoderImplementation::kDefault,
|
||||
base::BindRepeating(&OnRequestOverlayInfo), gfx::ColorSpace());
|
||||
|
||||
decoder_ = std::make_unique<media::VideoThumbnailDecoder>(
|
||||
|
@ -102,7 +102,6 @@ std::unique_ptr<::media::VideoDecoder>
|
||||
CastGpuFactoryImpl::CreateVideoDecoder() {
|
||||
DCHECK(mojo_task_runner_->BelongsToCurrentThread());
|
||||
return CreateVideoDecoder(media_log_.get(),
|
||||
::media::VideoDecoderImplementation::kDefault,
|
||||
base::BindRepeating(&OnRequestOverlayInfo));
|
||||
}
|
||||
|
||||
@ -137,10 +136,9 @@ int32_t CastGpuFactoryImpl::GetCommandBufferRouteId() {
|
||||
}
|
||||
|
||||
// Return true if |config| is potentially supported by a decoder created with
|
||||
// CreateVideoDecoder() using |implementation|.
|
||||
// CreateVideoDecoder().
|
||||
::media::GpuVideoAcceleratorFactories::Supported
|
||||
CastGpuFactoryImpl::IsDecoderConfigSupported(
|
||||
::media::VideoDecoderImplementation implementation,
|
||||
const ::media::VideoDecoderConfig& config) {
|
||||
if (config.codec() == ::media::VideoCodec::kCodecH264) {
|
||||
return Supported::kTrue;
|
||||
@ -159,7 +157,6 @@ void CastGpuFactoryImpl::NotifyDecoderSupportKnown(base::OnceClosure callback) {
|
||||
|
||||
std::unique_ptr<::media::VideoDecoder> CastGpuFactoryImpl::CreateVideoDecoder(
|
||||
::media::MediaLog* media_log,
|
||||
::media::VideoDecoderImplementation implementation,
|
||||
::media::RequestOverlayInfoCB request_overlay_info_cb) {
|
||||
DCHECK(mojo_task_runner_->BelongsToCurrentThread());
|
||||
DCHECK(media_interface_factory_.is_bound());
|
||||
@ -173,7 +170,7 @@ std::unique_ptr<::media::VideoDecoder> CastGpuFactoryImpl::CreateVideoDecoder(
|
||||
video_decoder.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<::media::MojoVideoDecoder>(
|
||||
mojo_task_runner_, this, media_log, std::move(video_decoder),
|
||||
implementation, request_overlay_info_cb, gfx::ColorSpace::CreateSRGB());
|
||||
request_overlay_info_cb, gfx::ColorSpace::CreateSRGB());
|
||||
}
|
||||
|
||||
absl::optional<::media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
|
@ -56,13 +56,11 @@ class CastGpuFactoryImpl : public CastGpuFactory,
|
||||
base::UnguessableToken GetChannelToken() override;
|
||||
int32_t GetCommandBufferRouteId() override;
|
||||
::media::GpuVideoAcceleratorFactories::Supported IsDecoderConfigSupported(
|
||||
::media::VideoDecoderImplementation implementation,
|
||||
const ::media::VideoDecoderConfig& config) override;
|
||||
bool IsDecoderSupportKnown() override;
|
||||
void NotifyDecoderSupportKnown(base::OnceClosure) override;
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
::media::MediaLog* media_log,
|
||||
::media::VideoDecoderImplementation implementation,
|
||||
::media::RequestOverlayInfoCB request_overlay_info_cb) override;
|
||||
absl::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
GetVideoEncodeAcceleratorSupportedProfiles() override;
|
||||
|
@ -101,7 +101,6 @@ int32_t BrowserGpuVideoAcceleratorFactories::GetCommandBufferRouteId() {
|
||||
|
||||
media::GpuVideoAcceleratorFactories::Supported
|
||||
BrowserGpuVideoAcceleratorFactories::IsDecoderConfigSupported(
|
||||
media::VideoDecoderImplementation implementation,
|
||||
const media::VideoDecoderConfig& config) {
|
||||
// Tell the caller to just try it, there are no other decoders to fall back on
|
||||
// anyway.
|
||||
@ -121,7 +120,6 @@ void BrowserGpuVideoAcceleratorFactories::NotifyDecoderSupportKnown(
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
BrowserGpuVideoAcceleratorFactories::CreateVideoDecoder(
|
||||
media::MediaLog* media_log,
|
||||
media::VideoDecoderImplementation implementation,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -29,13 +29,11 @@ class BrowserGpuVideoAcceleratorFactories
|
||||
base::UnguessableToken GetChannelToken() override;
|
||||
int32_t GetCommandBufferRouteId() override;
|
||||
Supported IsDecoderConfigSupported(
|
||||
media::VideoDecoderImplementation implementation,
|
||||
const media::VideoDecoderConfig& config) override;
|
||||
bool IsDecoderSupportKnown() override;
|
||||
void NotifyDecoderSupportKnown(base::OnceClosure) override;
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
media::MediaLog* media_log,
|
||||
media::VideoDecoderImplementation implementation,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb) override;
|
||||
absl::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
GetVideoEncodeAcceleratorSupportedProfiles() override;
|
||||
|
@ -206,7 +206,7 @@ void GpuVideoAcceleratorFactoriesImpl::NotifyDecoderSupportKnown(
|
||||
}
|
||||
|
||||
void GpuVideoAcceleratorFactoriesImpl::OnSupportedDecoderConfigs(
|
||||
const media::SupportedVideoDecoderConfigMap& supported_configs) {
|
||||
const media::SupportedVideoDecoderConfigs& supported_configs) {
|
||||
base::AutoLock lock(supported_profiles_lock_);
|
||||
video_decoder_.reset();
|
||||
supported_decoder_configs_ = supported_configs;
|
||||
@ -218,7 +218,7 @@ void GpuVideoAcceleratorFactoriesImpl::OnDecoderSupportFailed() {
|
||||
video_decoder_.reset();
|
||||
if (decoder_support_notifier_.is_notified())
|
||||
return;
|
||||
supported_decoder_configs_ = media::SupportedVideoDecoderConfigMap();
|
||||
supported_decoder_configs_ = media::SupportedVideoDecoderConfigs();
|
||||
decoder_support_notifier_.Notify();
|
||||
}
|
||||
|
||||
@ -302,7 +302,6 @@ int32_t GpuVideoAcceleratorFactoriesImpl::GetCommandBufferRouteId() {
|
||||
|
||||
media::GpuVideoAcceleratorFactories::Supported
|
||||
GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
|
||||
media::VideoDecoderImplementation implementation,
|
||||
const media::VideoDecoderConfig& config) {
|
||||
// There is no support for alpha channel hardware decoding yet.
|
||||
if (config.alpha_mode() == media::VideoDecoderConfig::AlphaMode::kHasAlpha) {
|
||||
@ -318,14 +317,8 @@ GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
|
||||
if (!supported_decoder_configs_)
|
||||
return Supported::kUnknown;
|
||||
|
||||
auto iter = supported_decoder_configs_->find(implementation);
|
||||
// If the decoder implementation wasn't listed, then fail. This means that
|
||||
// there is no such decoder implementation.
|
||||
if (iter == supported_decoder_configs_->end())
|
||||
return Supported::kFalse;
|
||||
|
||||
// Iterate over the supported configs for |impl|.
|
||||
for (const auto& supported : iter->second) {
|
||||
// Iterate over the supported configs.
|
||||
for (const auto& supported : *supported_decoder_configs_) {
|
||||
if (supported.Matches(config))
|
||||
return Supported::kTrue;
|
||||
}
|
||||
@ -335,7 +328,6 @@ GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
|
||||
std::unique_ptr<media::VideoDecoder>
|
||||
GpuVideoAcceleratorFactoriesImpl::CreateVideoDecoder(
|
||||
media::MediaLog* media_log,
|
||||
media::VideoDecoderImplementation implementation,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb) {
|
||||
DCHECK(video_accelerator_enabled_);
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
@ -349,7 +341,7 @@ GpuVideoAcceleratorFactoriesImpl::CreateVideoDecoder(
|
||||
interface_factory_->CreateVideoDecoder(
|
||||
video_decoder.InitWithNewPipeAndPassReceiver());
|
||||
return std::make_unique<media::MojoVideoDecoder>(
|
||||
task_runner_, this, media_log, std::move(video_decoder), implementation,
|
||||
task_runner_, this, media_log, std::move(video_decoder),
|
||||
std::move(request_overlay_info_cb), rendering_color_space_);
|
||||
#else
|
||||
return nullptr;
|
||||
|
@ -78,13 +78,11 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
base::UnguessableToken GetChannelToken() override;
|
||||
int32_t GetCommandBufferRouteId() override;
|
||||
Supported IsDecoderConfigSupported(
|
||||
media::VideoDecoderImplementation implementation,
|
||||
const media::VideoDecoderConfig& config) override;
|
||||
bool IsDecoderSupportKnown() override;
|
||||
void NotifyDecoderSupportKnown(base::OnceClosure callback) override;
|
||||
std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
media::MediaLog* media_log,
|
||||
media::VideoDecoderImplementation implementation,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb) override;
|
||||
absl::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
GetVideoEncodeAcceleratorSupportedProfiles() override;
|
||||
@ -172,7 +170,7 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
void SetContextProviderLostOnMainThread();
|
||||
|
||||
void OnSupportedDecoderConfigs(
|
||||
const media::SupportedVideoDecoderConfigMap& supported_configs);
|
||||
const media::SupportedVideoDecoderConfigs& supported_configs);
|
||||
void OnDecoderSupportFailed();
|
||||
|
||||
void OnGetVideoEncodeAcceleratorSupportedProfiles(
|
||||
@ -217,8 +215,8 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
|
||||
// If the Optional is empty, then we have not yet gotten the configs. If the
|
||||
// Optional contains an empty vector, then we have gotten the result and there
|
||||
// are no supported configs.
|
||||
absl::optional<media::SupportedVideoDecoderConfigMap>
|
||||
supported_decoder_configs_ GUARDED_BY(supported_profiles_lock_);
|
||||
absl::optional<media::SupportedVideoDecoderConfigs> supported_decoder_configs_
|
||||
GUARDED_BY(supported_profiles_lock_);
|
||||
Notifier decoder_support_notifier_ GUARDED_BY(supported_profiles_lock_);
|
||||
|
||||
absl::optional<media::VideoEncodeAccelerator::SupportedProfiles>
|
||||
|
@ -768,16 +768,19 @@
|
||||
.then(function(report) {
|
||||
var numCodecs = 0;
|
||||
var hasH264 = false;
|
||||
var supported_codecs = [];
|
||||
report.forEach(stats => {
|
||||
if (stats.type == 'codec') {
|
||||
numCodecs++;
|
||||
supported_codecs.push(stats.mimeType);
|
||||
if (stats.mimeType == 'video/H264') {
|
||||
hasH264 = true;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
assertEquals(1, numCodecs);
|
||||
assertTrue(hasH264);
|
||||
assertTrue(hasH264, JSON.stringify(supported_codecs));
|
||||
reportTestSuccess();
|
||||
})
|
||||
.catch(failTest);
|
||||
|
@ -128,9 +128,6 @@ IPC_ENUM_TRAITS_MIN_MAX_VALUE(media::VideoCodecProfile,
|
||||
media::VIDEO_CODEC_PROFILE_MIN,
|
||||
media::VIDEO_CODEC_PROFILE_MAX)
|
||||
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(media::VideoDecoderImplementation,
|
||||
media::VideoDecoderImplementation::kMaxValue)
|
||||
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(media::VideoDecoderType,
|
||||
media::VideoDecoderType::kMaxValue)
|
||||
|
||||
|
@ -58,20 +58,8 @@ struct MEDIA_EXPORT SupportedVideoDecoderConfig {
|
||||
// Allow copy and assignment.
|
||||
};
|
||||
|
||||
// Enumeration of possible implementations for (Mojo)VideoDecoders.
|
||||
enum class VideoDecoderImplementation {
|
||||
kDefault = 0,
|
||||
kAlternate = 1,
|
||||
kMaxValue = kAlternate
|
||||
};
|
||||
|
||||
using SupportedVideoDecoderConfigs = std::vector<SupportedVideoDecoderConfig>;
|
||||
|
||||
// Map of mojo VideoDecoder implementations to the vector of configs that they
|
||||
// (probably) support.
|
||||
using SupportedVideoDecoderConfigMap =
|
||||
base::flat_map<VideoDecoderImplementation, SupportedVideoDecoderConfigs>;
|
||||
|
||||
// Helper method to determine if |config| is supported by |supported_configs|.
|
||||
MEDIA_EXPORT bool IsVideoDecoderConfigSupported(
|
||||
const SupportedVideoDecoderConfigs& supported_configs,
|
||||
|
@ -50,29 +50,13 @@ void MojoDecoderFactory::CreateVideoDecoders(
|
||||
std::vector<std::unique_ptr<VideoDecoder>>* video_decoders) {
|
||||
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// If the D3D11VideoDecoder is enabled, then push a kAlternate decoder ahead
|
||||
// of the default one.
|
||||
if (base::FeatureList::IsEnabled(media::kD3D11VideoDecoder)) {
|
||||
mojo::PendingRemote<mojom::VideoDecoder> d3d11_video_decoder_remote;
|
||||
interface_factory_->CreateVideoDecoder(
|
||||
d3d11_video_decoder_remote.InitWithNewPipeAndPassReceiver());
|
||||
|
||||
video_decoders->push_back(std::make_unique<MojoVideoDecoder>(
|
||||
task_runner, gpu_factories, media_log,
|
||||
std::move(d3d11_video_decoder_remote),
|
||||
VideoDecoderImplementation::kAlternate, request_overlay_info_cb,
|
||||
target_color_space));
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
mojo::PendingRemote<mojom::VideoDecoder> video_decoder_remote;
|
||||
interface_factory_->CreateVideoDecoder(
|
||||
video_decoder_remote.InitWithNewPipeAndPassReceiver());
|
||||
|
||||
video_decoders->push_back(std::make_unique<MojoVideoDecoder>(
|
||||
task_runner, gpu_factories, media_log, std::move(video_decoder_remote),
|
||||
VideoDecoderImplementation::kDefault, std::move(request_overlay_info_cb),
|
||||
target_color_space));
|
||||
std::move(request_overlay_info_cb), target_color_space));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ MojoVideoDecoder::MojoVideoDecoder(
|
||||
GpuVideoAcceleratorFactories* gpu_factories,
|
||||
MediaLog* media_log,
|
||||
mojo::PendingRemote<mojom::VideoDecoder> pending_remote_decoder,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space)
|
||||
: task_runner_(task_runner),
|
||||
@ -114,8 +113,7 @@ MojoVideoDecoder::MojoVideoDecoder(
|
||||
media_log_service_(media_log),
|
||||
media_log_receiver_(&media_log_service_),
|
||||
request_overlay_info_cb_(std::move(request_overlay_info_cb)),
|
||||
target_color_space_(target_color_space),
|
||||
video_decoder_implementation_(implementation) {
|
||||
target_color_space_(target_color_space) {
|
||||
DVLOG(1) << __func__;
|
||||
DETACH_FROM_SEQUENCE(sequence_checker_);
|
||||
weak_this_ = weak_factory_.GetWeakPtr();
|
||||
@ -162,8 +160,7 @@ void MojoVideoDecoder::Initialize(const VideoDecoderConfig& config,
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
// Fail immediately if we know that the remote side cannot support |config|.
|
||||
if (gpu_factories_ && gpu_factories_->IsDecoderConfigSupported(
|
||||
video_decoder_implementation_, config) ==
|
||||
if (gpu_factories_ && gpu_factories_->IsDecoderConfigSupported(config) ==
|
||||
GpuVideoAcceleratorFactories::Supported::kFalse) {
|
||||
FailInit(std::move(init_cb), StatusCode::kDecoderUnsupportedConfig);
|
||||
return;
|
||||
@ -397,12 +394,11 @@ void MojoVideoDecoder::BindRemoteDecoder() {
|
||||
}
|
||||
}
|
||||
|
||||
remote_decoder_->Construct(
|
||||
client_receiver_.BindNewEndpointAndPassRemote(),
|
||||
media_log_receiver_.BindNewEndpointAndPassRemote(),
|
||||
std::move(video_frame_handle_releaser_receiver),
|
||||
std::move(remote_consumer_handle), std::move(command_buffer_id),
|
||||
video_decoder_implementation_, target_color_space_);
|
||||
remote_decoder_->Construct(client_receiver_.BindNewEndpointAndPassRemote(),
|
||||
media_log_receiver_.BindNewEndpointAndPassRemote(),
|
||||
std::move(video_frame_handle_releaser_receiver),
|
||||
std::move(remote_consumer_handle),
|
||||
std::move(command_buffer_id), target_color_space_);
|
||||
}
|
||||
|
||||
void MojoVideoDecoder::OnWaiting(WaitingReason reason) {
|
||||
|
@ -53,7 +53,6 @@ class MojoVideoDecoder final : public VideoDecoder,
|
||||
GpuVideoAcceleratorFactories* gpu_factories,
|
||||
MediaLog* media_log,
|
||||
mojo::PendingRemote<mojom::VideoDecoder> pending_remote_decoder,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space);
|
||||
~MojoVideoDecoder() final;
|
||||
@ -157,8 +156,6 @@ class MojoVideoDecoder final : public VideoDecoder,
|
||||
int total_frames_decoded_ = 0;
|
||||
int32_t max_decode_requests_ = 1;
|
||||
|
||||
VideoDecoderImplementation video_decoder_implementation_;
|
||||
|
||||
base::WeakPtr<MojoVideoDecoder> weak_this_;
|
||||
base::WeakPtrFactory<MojoVideoDecoder> weak_factory_{this};
|
||||
|
||||
|
@ -334,10 +334,6 @@ mojom("mojom") {
|
||||
mojom = "media.mojom.SupportedVideoDecoderConfig"
|
||||
cpp = "::media::SupportedVideoDecoderConfig"
|
||||
},
|
||||
{
|
||||
mojom = "media.mojom.VideoDecoderImplementation"
|
||||
cpp = "::media::VideoDecoderImplementation"
|
||||
},
|
||||
{
|
||||
mojom = "media.mojom.VideoDecoderType"
|
||||
cpp = "::media::VideoDecoderType"
|
||||
|
@ -53,24 +53,16 @@ interface VideoFrameHandleReleaser {
|
||||
gpu.mojom.SyncToken release_sync_token);
|
||||
};
|
||||
|
||||
// Identifier to select between multiple underlying VideoDecoder implementations
|
||||
// to back a mojo VideoDecoder service.
|
||||
[Native]
|
||||
enum VideoDecoderImplementation;
|
||||
|
||||
// A Mojo equivalent of media::VideoDecoder. In practice, this is used for
|
||||
// hardware decode offloading; in this case the client is a <video> tag running
|
||||
// in a renderer, and the implementation is running in the GPU process.
|
||||
interface VideoDecoder {
|
||||
// Returns a list of supported configs. It is expected that Initialize() will
|
||||
// fail for any config that does not match an entry in this list. Note that
|
||||
// this returns a map for all VideoDecoderImplementation types, since it's
|
||||
// much more convenient; we always want all of them.
|
||||
// fail for any config that does not match an entry in this list.
|
||||
//
|
||||
// May be called before Construct().
|
||||
GetSupportedConfigs() =>
|
||||
(map<VideoDecoderImplementation,
|
||||
array<SupportedVideoDecoderConfig>> supported_configs);
|
||||
(array<SupportedVideoDecoderConfig> supported_configs);
|
||||
|
||||
// Initialize the decoder. This must be called before any method other than
|
||||
// GetSupportedConfigs().
|
||||
@ -105,7 +97,6 @@ interface VideoDecoder {
|
||||
pending_receiver<VideoFrameHandleReleaser> video_frame_handle_releaser,
|
||||
handle<data_pipe_consumer> decoder_buffer_pipe,
|
||||
CommandBufferId? command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
gfx.mojom.ColorSpace target_color_space);
|
||||
|
||||
// Configure (or reconfigure) the decoder. This must be called before decoding
|
||||
|
@ -41,6 +41,7 @@
|
||||
#endif // defined(OS_ANDROID)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/win/windows_version.h"
|
||||
#include "media/gpu/windows/d3d11_video_decoder.h"
|
||||
#include "ui/gl/direct_composition_surface_win.h"
|
||||
#include "ui/gl/gl_angle_util_win.h"
|
||||
@ -151,55 +152,38 @@ std::unique_ptr<AudioDecoder> GpuMojoMediaClient::CreateAudioDecoder(
|
||||
#endif // defined(OS_ANDROID)
|
||||
}
|
||||
|
||||
SupportedVideoDecoderConfigMap
|
||||
SupportedVideoDecoderConfigs
|
||||
GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() {
|
||||
#if defined(OS_ANDROID)
|
||||
static SupportedVideoDecoderConfigMap supported_configs{
|
||||
{VideoDecoderImplementation::kDefault,
|
||||
MediaCodecVideoDecoder::GetSupportedConfigs()},
|
||||
};
|
||||
return supported_configs;
|
||||
static SupportedVideoDecoderConfigs configs =
|
||||
MediaCodecVideoDecoder::GetSupportedConfigs();
|
||||
return configs;
|
||||
#else
|
||||
SupportedVideoDecoderConfigMap supported_config_map;
|
||||
SupportedVideoDecoderConfigs supported_configs;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Start with the configurations supported by D3D11VideoDecoder.
|
||||
// VdaVideoDecoder is still used as a fallback.
|
||||
|
||||
if (base::FeatureList::IsEnabled(kD3D11VideoDecoder)) {
|
||||
if (!base::FeatureList::IsEnabled(kD3D11VideoDecoder) ||
|
||||
gpu_workarounds_.disable_d3d11_video_decoder ||
|
||||
base::win::GetVersion() == base::win::Version::WIN7) {
|
||||
if (gpu_workarounds_.disable_dxva_video_decoder)
|
||||
return supported_configs;
|
||||
} else {
|
||||
if (!d3d11_supported_configs_) {
|
||||
d3d11_supported_configs_ =
|
||||
D3D11VideoDecoder::GetSupportedVideoDecoderConfigs(
|
||||
gpu_preferences_, gpu_workarounds_, GetD3D11DeviceCallback());
|
||||
}
|
||||
supported_config_map[VideoDecoderImplementation::kAlternate] =
|
||||
*d3d11_supported_configs_;
|
||||
return *d3d11_supported_configs_;
|
||||
}
|
||||
|
||||
#elif BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
|
||||
if (ShouldUseChromeOSDirectVideoDecoder(gpu_preferences_)) {
|
||||
if (!cros_supported_configs_) {
|
||||
cros_supported_configs_ =
|
||||
ChromeosVideoDecoderFactory::GetSupportedConfigs(gpu_workarounds_);
|
||||
}
|
||||
|
||||
supported_config_map[VideoDecoderImplementation::kDefault] =
|
||||
*cros_supported_configs_;
|
||||
return supported_config_map;
|
||||
return *cros_supported_configs_;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN)
|
||||
if (gpu_workarounds_.disable_dxva_video_decoder) {
|
||||
// If DXVA isn't supported, then return without any supported configs for
|
||||
// the |kDefault| decoder.
|
||||
return supported_config_map;
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
auto& default_configs =
|
||||
supported_config_map[VideoDecoderImplementation::kDefault];
|
||||
|
||||
// VdaVideoDecoder will be used to wrap a VDA. Add the configs supported
|
||||
// by the VDA implementation.
|
||||
// TODO(sandersd): Move conversion code into VdaVideoDecoder.
|
||||
@ -210,12 +194,8 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() {
|
||||
bool allow_encrypted =
|
||||
capabilities.flags &
|
||||
VideoDecodeAccelerator::Capabilities::SUPPORTS_ENCRYPTED_STREAMS;
|
||||
SupportedVideoDecoderConfigs supported_configs = ConvertFromSupportedProfiles(
|
||||
capabilities.supported_profiles, allow_encrypted);
|
||||
default_configs.insert(default_configs.end(), supported_configs.begin(),
|
||||
supported_configs.end());
|
||||
|
||||
return supported_config_map;
|
||||
return ConvertFromSupportedProfiles(capabilities.supported_profiles,
|
||||
allow_encrypted);
|
||||
#endif // defined(OS_ANDROID)
|
||||
}
|
||||
|
||||
@ -223,115 +203,101 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
MediaLog* media_log,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space) {
|
||||
// All implementations require a command buffer.
|
||||
if (!command_buffer_id)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<VideoDecoder> video_decoder;
|
||||
|
||||
switch (implementation) {
|
||||
case VideoDecoderImplementation::kDefault: {
|
||||
#if defined(OS_ANDROID)
|
||||
auto get_stub_cb = base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id);
|
||||
std::unique_ptr<SharedImageVideoProvider> image_provider =
|
||||
std::make_unique<DirectSharedImageVideoProvider>(gpu_task_runner_,
|
||||
get_stub_cb);
|
||||
if (base::FeatureList::IsEnabled(kUsePooledSharedImageVideoProvider)) {
|
||||
// Wrap |image_provider| in a pool.
|
||||
image_provider = PooledSharedImageVideoProvider::Create(
|
||||
gpu_task_runner_, get_stub_cb, std::move(image_provider));
|
||||
}
|
||||
// TODO(liberato): Create this only if we're using Vulkan, else it's
|
||||
// ignored. If we can tell that here, then VideoFrameFactory can use it
|
||||
// as a signal about whether it's supposed to get YCbCrInfo rather than
|
||||
// requiring the provider to set |is_vulkan| in the ImageRecord.
|
||||
auto frame_info_helper =
|
||||
FrameInfoHelper::Create(gpu_task_runner_, std::move(get_stub_cb));
|
||||
video_decoder = MediaCodecVideoDecoder::Create(
|
||||
gpu_preferences_, gpu_feature_info_, media_log->Clone(),
|
||||
DeviceInfo::GetInstance(),
|
||||
CodecAllocator::GetInstance(gpu_task_runner_),
|
||||
std::make_unique<AndroidVideoSurfaceChooserImpl>(
|
||||
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
|
||||
android_overlay_factory_cb_, std::move(request_overlay_info_cb),
|
||||
std::make_unique<VideoFrameFactoryImpl>(
|
||||
gpu_task_runner_, gpu_preferences_, std::move(image_provider),
|
||||
MaybeRenderEarlyManager::Create(gpu_task_runner_),
|
||||
std::move(frame_info_helper)));
|
||||
auto get_stub_cb = base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id);
|
||||
std::unique_ptr<SharedImageVideoProvider> image_provider =
|
||||
std::make_unique<DirectSharedImageVideoProvider>(gpu_task_runner_,
|
||||
get_stub_cb);
|
||||
if (base::FeatureList::IsEnabled(kUsePooledSharedImageVideoProvider)) {
|
||||
// Wrap |image_provider| in a pool.
|
||||
image_provider = PooledSharedImageVideoProvider::Create(
|
||||
gpu_task_runner_, get_stub_cb, std::move(image_provider));
|
||||
}
|
||||
// TODO(liberato): Create this only if we're using Vulkan, else it's
|
||||
// ignored. If we can tell that here, then VideoFrameFactory can use it
|
||||
// as a signal about whether it's supposed to get YCbCrInfo rather than
|
||||
// requiring the provider to set |is_vulkan| in the ImageRecord.
|
||||
auto frame_info_helper =
|
||||
FrameInfoHelper::Create(gpu_task_runner_, std::move(get_stub_cb));
|
||||
return MediaCodecVideoDecoder::Create(
|
||||
gpu_preferences_, gpu_feature_info_, media_log->Clone(),
|
||||
DeviceInfo::GetInstance(), CodecAllocator::GetInstance(gpu_task_runner_),
|
||||
std::make_unique<AndroidVideoSurfaceChooserImpl>(
|
||||
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
|
||||
android_overlay_factory_cb_, std::move(request_overlay_info_cb),
|
||||
std::make_unique<VideoFrameFactoryImpl>(
|
||||
gpu_task_runner_, gpu_preferences_, std::move(image_provider),
|
||||
MaybeRenderEarlyManager::Create(gpu_task_runner_),
|
||||
std::move(frame_info_helper)));
|
||||
|
||||
#elif BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
|
||||
if (ShouldUseChromeOSDirectVideoDecoder(gpu_preferences_)) {
|
||||
auto frame_pool = std::make_unique<PlatformVideoFramePool>(
|
||||
gpu_memory_buffer_factory_);
|
||||
auto frame_converter = MailboxVideoFrameConverter::Create(
|
||||
base::BindRepeating(&PlatformVideoFramePool::UnwrapFrame,
|
||||
base::Unretained(frame_pool.get())),
|
||||
gpu_task_runner_,
|
||||
base::BindRepeating(&GetCommandBufferStub, gpu_task_runner_,
|
||||
media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token,
|
||||
command_buffer_id->route_id));
|
||||
video_decoder = ChromeosVideoDecoderFactory::Create(
|
||||
task_runner, std::move(frame_pool), std::move(frame_converter),
|
||||
media_log->Clone());
|
||||
} else {
|
||||
video_decoder = VdaVideoDecoder::Create(
|
||||
task_runner, gpu_task_runner_, media_log->Clone(),
|
||||
target_color_space, gpu_preferences_, gpu_workarounds_,
|
||||
base::BindRepeating(&GetCommandBufferStub, gpu_task_runner_,
|
||||
media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token,
|
||||
command_buffer_id->route_id));
|
||||
}
|
||||
|
||||
if (ShouldUseChromeOSDirectVideoDecoder(gpu_preferences_)) {
|
||||
auto frame_pool =
|
||||
std::make_unique<PlatformVideoFramePool>(gpu_memory_buffer_factory_);
|
||||
auto frame_converter = MailboxVideoFrameConverter::Create(
|
||||
base::BindRepeating(&PlatformVideoFramePool::UnwrapFrame,
|
||||
base::Unretained(frame_pool.get())),
|
||||
gpu_task_runner_,
|
||||
base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id));
|
||||
return ChromeosVideoDecoderFactory::Create(
|
||||
task_runner, std::move(frame_pool), std::move(frame_converter),
|
||||
media_log->Clone());
|
||||
} else {
|
||||
return VdaVideoDecoder::Create(
|
||||
task_runner, gpu_task_runner_, media_log->Clone(), target_color_space,
|
||||
gpu_preferences_, gpu_workarounds_,
|
||||
base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id));
|
||||
}
|
||||
#elif defined(OS_MAC) || defined(OS_WIN) || defined(OS_LINUX) || \
|
||||
defined(OS_CHROMEOS)
|
||||
#if defined(OS_WIN)
|
||||
// Don't instantiate the DXVA decoder if it's not supported.
|
||||
if (gpu_workarounds_.disable_dxva_video_decoder)
|
||||
return nullptr;
|
||||
// Windows tries dxva (vda) only if d3d11 is not an option. And it also has
|
||||
// to check if there are driver bug workarounds.
|
||||
if (!base::FeatureList::IsEnabled(kD3D11VideoDecoder) ||
|
||||
gpu_workarounds_.disable_d3d11_video_decoder ||
|
||||
base::win::GetVersion() == base::win::Version::WIN7) {
|
||||
if (gpu_workarounds_.disable_dxva_video_decoder)
|
||||
return nullptr;
|
||||
// Falls out of the ifdef(OS_WIN) section.
|
||||
} else if (base::FeatureList::IsEnabled(kD3D11VideoDecoder)) {
|
||||
// If nothing has cached the configs yet, then do so now.
|
||||
if (!d3d11_supported_configs_)
|
||||
GetSupportedVideoDecoderConfigs();
|
||||
|
||||
const bool enable_hdr =
|
||||
gl::DirectCompositionSurfaceWin::IsHDRSupported() ||
|
||||
base::FeatureList::IsEnabled(kD3D11VideoDecoderForceEnableHDR);
|
||||
return D3D11VideoDecoder::Create(
|
||||
gpu_task_runner_, media_log->Clone(), gpu_preferences_,
|
||||
gpu_workarounds_,
|
||||
base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id),
|
||||
GetD3D11DeviceCallback(), *d3d11_supported_configs_, enable_hdr);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
video_decoder = VdaVideoDecoder::Create(
|
||||
task_runner, gpu_task_runner_, media_log->Clone(), target_color_space,
|
||||
gpu_preferences_, gpu_workarounds_,
|
||||
base::BindRepeating(&GetCommandBufferStub, gpu_task_runner_,
|
||||
media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token,
|
||||
command_buffer_id->route_id));
|
||||
return VdaVideoDecoder::Create(
|
||||
task_runner, gpu_task_runner_, media_log->Clone(), target_color_space,
|
||||
gpu_preferences_, gpu_workarounds_,
|
||||
base::BindRepeating(
|
||||
&GetCommandBufferStub, gpu_task_runner_, media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token, command_buffer_id->route_id));
|
||||
#else
|
||||
// not android, windows, chromeos, linux, or mac.
|
||||
return nullptr;
|
||||
#endif // defined(OS_ANDROID)
|
||||
} break;
|
||||
|
||||
case VideoDecoderImplementation::kAlternate:
|
||||
#if defined(OS_WIN)
|
||||
if (base::FeatureList::IsEnabled(kD3D11VideoDecoder)) {
|
||||
// If nothing has cached the configs yet, then do so now.
|
||||
if (!d3d11_supported_configs_)
|
||||
GetSupportedVideoDecoderConfigs();
|
||||
|
||||
const bool enable_hdr =
|
||||
gl::DirectCompositionSurfaceWin::IsHDRSupported() ||
|
||||
base::FeatureList::IsEnabled(kD3D11VideoDecoderForceEnableHDR);
|
||||
|
||||
video_decoder = D3D11VideoDecoder::Create(
|
||||
gpu_task_runner_, media_log->Clone(), gpu_preferences_,
|
||||
gpu_workarounds_,
|
||||
base::BindRepeating(&GetCommandBufferStub, gpu_task_runner_,
|
||||
media_gpu_channel_manager_,
|
||||
command_buffer_id->channel_token,
|
||||
command_buffer_id->route_id),
|
||||
GetD3D11DeviceCallback(), *d3d11_supported_configs_, enable_hdr);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
break;
|
||||
}; // switch
|
||||
|
||||
// |video_decoder| may be null if we don't support |implementation|.
|
||||
return video_decoder;
|
||||
}
|
||||
|
||||
std::unique_ptr<CdmFactory> GpuMojoMediaClient::CreateCdmFactory(
|
||||
|
@ -44,14 +44,13 @@ class GpuMojoMediaClient final : public MojoMediaClient {
|
||||
~GpuMojoMediaClient() final;
|
||||
|
||||
// MojoMediaClient implementation.
|
||||
SupportedVideoDecoderConfigMap GetSupportedVideoDecoderConfigs() final;
|
||||
SupportedVideoDecoderConfigs GetSupportedVideoDecoderConfigs() final;
|
||||
std::unique_ptr<AudioDecoder> CreateAudioDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner) final;
|
||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
MediaLog* media_log,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space) final;
|
||||
std::unique_ptr<CdmFactory> CreateCdmFactory(
|
||||
|
@ -24,7 +24,7 @@ std::unique_ptr<AudioDecoder> MojoMediaClient::CreateAudioDecoder(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SupportedVideoDecoderConfigMap
|
||||
SupportedVideoDecoderConfigs
|
||||
MojoMediaClient::GetSupportedVideoDecoderConfigs() {
|
||||
return {};
|
||||
}
|
||||
@ -33,7 +33,6 @@ std::unique_ptr<VideoDecoder> MojoMediaClient::CreateVideoDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
MediaLog* media_log,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space) {
|
||||
return nullptr;
|
||||
|
@ -36,12 +36,6 @@ class MediaLog;
|
||||
class Renderer;
|
||||
class VideoDecoder;
|
||||
|
||||
// Map of mojo VideoDecoder implementations to the vector of configs that they
|
||||
// (probably) support.
|
||||
using SupportedVideoDecoderConfigMap =
|
||||
base::flat_map<VideoDecoderImplementation,
|
||||
std::vector<SupportedVideoDecoderConfig>>;
|
||||
|
||||
// Provides a way for MediaService to create concrete (e.g. platform specific)
|
||||
// media components’ implementations. When MediaService is created, a
|
||||
// MojoMediaClient must be passed in so that MediaService knows how to create
|
||||
@ -59,13 +53,13 @@ class MEDIA_MOJO_EXPORT MojoMediaClient {
|
||||
virtual std::unique_ptr<AudioDecoder> CreateAudioDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
||||
|
||||
virtual SupportedVideoDecoderConfigMap GetSupportedVideoDecoderConfigs();
|
||||
virtual std::vector<SupportedVideoDecoderConfig>
|
||||
GetSupportedVideoDecoderConfigs();
|
||||
|
||||
virtual std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
MediaLog* media_log,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space);
|
||||
|
||||
|
@ -47,14 +47,9 @@ const char kInitializeTraceName[] = "MojoVideoDecoderService::Initialize";
|
||||
const char kDecodeTraceName[] = "MojoVideoDecoderService::Decode";
|
||||
const char kResetTraceName[] = "MojoVideoDecoderService::Reset";
|
||||
|
||||
void RecordTimingHistogram(VideoDecoderImplementation impl,
|
||||
const char* method,
|
||||
base::TimeDelta elapsed) {
|
||||
void RecordTimingHistogram(const char* method, base::TimeDelta elapsed) {
|
||||
base::UmaHistogramTimes(
|
||||
base::StringPrintf("Media.MojoVideoDecoderServiceTiming.%s.%s",
|
||||
impl == VideoDecoderImplementation::kDefault
|
||||
? "Default"
|
||||
: "Alternate",
|
||||
base::StringPrintf("Media.MojoVideoDecoderServiceTiming.Default.%s",
|
||||
method),
|
||||
elapsed);
|
||||
}
|
||||
@ -145,8 +140,8 @@ MojoVideoDecoderService::~MojoVideoDecoderService() {
|
||||
weak_factory_.InvalidateWeakPtrs();
|
||||
decoder_.reset();
|
||||
|
||||
if (implementation_)
|
||||
RecordTimingHistogram(*implementation_, "Destruct", elapsed.Elapsed());
|
||||
if (decoder_)
|
||||
RecordTimingHistogram("Destruct", elapsed.Elapsed());
|
||||
}
|
||||
|
||||
void MojoVideoDecoderService::GetSupportedConfigs(
|
||||
@ -165,7 +160,6 @@ void MojoVideoDecoderService::Construct(
|
||||
video_frame_handle_releaser_receiver,
|
||||
mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
const gfx::ColorSpace& target_color_space) {
|
||||
DVLOG(1) << __func__;
|
||||
TRACE_EVENT0("media", "MojoVideoDecoderService::Construct");
|
||||
@ -176,8 +170,6 @@ void MojoVideoDecoderService::Construct(
|
||||
}
|
||||
|
||||
base::ElapsedTimer elapsed;
|
||||
implementation_ = implementation;
|
||||
|
||||
client_.Bind(std::move(client));
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
||||
@ -195,12 +187,11 @@ void MojoVideoDecoderService::Construct(
|
||||
|
||||
decoder_ = mojo_media_client_->CreateVideoDecoder(
|
||||
task_runner, media_log_.get(), std::move(command_buffer_id),
|
||||
implementation,
|
||||
base::BindRepeating(
|
||||
&MojoVideoDecoderService::OnDecoderRequestedOverlayInfo, weak_this_),
|
||||
target_color_space);
|
||||
|
||||
RecordTimingHistogram(*implementation_, "Construct", elapsed.Elapsed());
|
||||
RecordTimingHistogram("Construct", elapsed.Elapsed());
|
||||
}
|
||||
|
||||
void MojoVideoDecoderService::Initialize(
|
||||
|
@ -52,7 +52,6 @@ class MEDIA_MOJO_EXPORT MojoVideoDecoderService final
|
||||
video_frame_handle_receiver,
|
||||
mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
const gfx::ColorSpace& target_color_space) final;
|
||||
void Initialize(const VideoDecoderConfig& config,
|
||||
bool low_delay,
|
||||
@ -87,9 +86,6 @@ class MEDIA_MOJO_EXPORT MojoVideoDecoderService final
|
||||
bool restart_for_transitions,
|
||||
ProvideOverlayInfoCB provide_overlay_info_cb);
|
||||
|
||||
// Implementation value provided at the time of Construct().
|
||||
absl::optional<VideoDecoderImplementation> implementation_;
|
||||
|
||||
// Whether this instance is active (Decode() was called at least once).
|
||||
bool is_active_instance_ = false;
|
||||
|
||||
|
@ -185,7 +185,6 @@ class FakeMojoMediaClient : public MojoMediaClient {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
MediaLog* media_log,
|
||||
mojom::CommandBufferIdPtr command_buffer_id,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space) override {
|
||||
return create_video_decoder_cb_.Run(media_log);
|
||||
@ -233,8 +232,7 @@ class MojoVideoDecoderIntegrationTest : public ::testing::Test {
|
||||
// be tested.
|
||||
client_ = std::make_unique<MojoVideoDecoder>(
|
||||
base::ThreadTaskRunnerHandle::Get(), nullptr, &client_media_log_,
|
||||
CreateRemoteVideoDecoder(), VideoDecoderImplementation::kDefault,
|
||||
RequestOverlayInfoCB(), gfx::ColorSpace());
|
||||
CreateRemoteVideoDecoder(), RequestOverlayInfoCB(), gfx::ColorSpace());
|
||||
if (writer_capacity_)
|
||||
client_->set_writer_capacity_for_testing(writer_capacity_);
|
||||
}
|
||||
|
@ -7,26 +7,11 @@
|
||||
namespace media {
|
||||
|
||||
GpuVideoAcceleratorFactories::Supported
|
||||
GpuVideoAcceleratorFactories::IsDecoderConfigSupported(
|
||||
GpuVideoAcceleratorFactories::IsDecoderConfigSupportedOrUnknown(
|
||||
const VideoDecoderConfig& config) {
|
||||
if (!IsDecoderSupportKnown())
|
||||
return Supported::kUnknown;
|
||||
|
||||
static_assert(media::VideoDecoderImplementation::kAlternate ==
|
||||
media::VideoDecoderImplementation::kMaxValue,
|
||||
"Keep the array below in sync.");
|
||||
VideoDecoderImplementation decoder_impls[] = {
|
||||
VideoDecoderImplementation::kDefault,
|
||||
VideoDecoderImplementation::kAlternate};
|
||||
Supported supported = Supported::kUnknown;
|
||||
for (const auto& impl : decoder_impls) {
|
||||
supported = IsDecoderConfigSupported(impl, config);
|
||||
DCHECK_NE(supported, Supported::kUnknown);
|
||||
if (supported == Supported::kTrue)
|
||||
break;
|
||||
}
|
||||
|
||||
return supported;
|
||||
return IsDecoderConfigSupported(config);
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
@ -95,18 +95,13 @@ class MEDIA_EXPORT GpuVideoAcceleratorFactories {
|
||||
// TODO(sandersd): Switch to bool if/when all clients check
|
||||
// IsDecoderSupportKnown().
|
||||
virtual Supported IsDecoderConfigSupported(
|
||||
VideoDecoderImplementation implementation,
|
||||
const VideoDecoderConfig& config) = 0;
|
||||
|
||||
// Helper function that merges IsDecoderConfigSupported() results across all
|
||||
// VideoDecoderImplementations. Returns kTrue if any of the implementations
|
||||
// support the config.
|
||||
//
|
||||
// Callers must verify IsDecoderSupportKnown() prior to using this, or they
|
||||
// will immediately receive a kUnknown.
|
||||
//
|
||||
// May be called on any thread.
|
||||
Supported IsDecoderConfigSupported(const VideoDecoderConfig& config);
|
||||
Supported IsDecoderConfigSupportedOrUnknown(const VideoDecoderConfig& config);
|
||||
|
||||
// Returns true if IsDecoderConfigSupported() is ready to answer queries.
|
||||
// Once decoder support is known, it remains known for the lifetime of |this|.
|
||||
@ -126,7 +121,6 @@ class MEDIA_EXPORT GpuVideoAcceleratorFactories {
|
||||
|
||||
virtual std::unique_ptr<media::VideoDecoder> CreateVideoDecoder(
|
||||
MediaLog* media_log,
|
||||
VideoDecoderImplementation implementation,
|
||||
RequestOverlayInfoCB request_overlay_info_cb) = 0;
|
||||
|
||||
// Returns the supported codec profiles of video encode accelerator.
|
||||
|
@ -31,14 +31,11 @@ class MockGpuVideoAcceleratorFactories : public GpuVideoAcceleratorFactories {
|
||||
MOCK_METHOD0(GetChannelToken, base::UnguessableToken());
|
||||
MOCK_METHOD0(GetCommandBufferRouteId, int32_t());
|
||||
|
||||
MOCK_METHOD2(IsDecoderConfigSupported,
|
||||
Supported(VideoDecoderImplementation,
|
||||
const VideoDecoderConfig&));
|
||||
MOCK_METHOD1(IsDecoderConfigSupported, Supported(const VideoDecoderConfig&));
|
||||
MOCK_METHOD0(IsDecoderSupportKnown, bool());
|
||||
MOCK_METHOD1(NotifyDecoderSupportKnown, void(base::OnceClosure));
|
||||
MOCK_METHOD3(CreateVideoDecoder,
|
||||
MOCK_METHOD2(CreateVideoDecoder,
|
||||
std::unique_ptr<media::VideoDecoder>(MediaLog*,
|
||||
VideoDecoderImplementation,
|
||||
RequestOverlayInfoCB));
|
||||
|
||||
MOCK_METHOD0(IsEncoderSupportKnown, bool());
|
||||
|
@ -1366,7 +1366,7 @@ void MediaCapabilities::GetGpuFactoriesSupport(
|
||||
media::EmptyExtraData(), encryption_scheme);
|
||||
|
||||
OnGpuFactoriesSupport(
|
||||
callback_id, gpu_factories->IsDecoderConfigSupported(config) ==
|
||||
callback_id, gpu_factories->IsDecoderConfigSupportedOrUnknown(config) ==
|
||||
media::GpuVideoAcceleratorFactories::Supported::kTrue);
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ TEST(MediaCapabilitiesTests, PredictPowerEfficientWithGpuFactories) {
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderSupportKnown())
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_, _))
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_))
|
||||
.WillOnce(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kTrue));
|
||||
}
|
||||
@ -723,7 +723,7 @@ TEST(MediaCapabilitiesTests, PredictPowerEfficientWithGpuFactories) {
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderSupportKnown())
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_, _))
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_))
|
||||
.WillRepeatedly(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kFalse));
|
||||
|
||||
@ -1000,7 +1000,7 @@ void RunCallbackPermutationTest(std::vector<PredictionType> callback_order) {
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderSupportKnown())
|
||||
.Times(2)
|
||||
.WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_, _))
|
||||
EXPECT_CALL(*mock_gpu_factories, IsDecoderConfigSupported(_))
|
||||
.WillRepeatedly(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kFalse));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void DecoderSupport_OnKnown(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories) {
|
||||
DCHECK(gpu_factories->IsDecoderSupportKnown());
|
||||
support->setSupported(
|
||||
gpu_factories->IsDecoderConfigSupported(*media_config) ==
|
||||
gpu_factories->IsDecoderConfigSupportedOrUnknown(*media_config) ==
|
||||
media::GpuVideoAcceleratorFactories::Supported::kTrue);
|
||||
resolver->Resolve(support);
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ class FakeMojoMediaClient : public media::MojoMediaClient {
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
media::MediaLog* media_log,
|
||||
media::mojom::CommandBufferIdPtr command_buffer_id,
|
||||
media::VideoDecoderImplementation implementation,
|
||||
media::RequestOverlayInfoCB request_overlay_info_cb,
|
||||
const gfx::ColorSpace& target_color_space) override {
|
||||
return std::make_unique<FakeGpuVideoDecoder>();
|
||||
@ -238,7 +237,7 @@ class VideoDecoderBrokerTest : public testing::Test {
|
||||
std::make_unique<media::MockGpuVideoAcceleratorFactories>(nullptr);
|
||||
EXPECT_CALL(*gpu_factories_, GetTaskRunner())
|
||||
.WillRepeatedly(Return(media_thread_->task_runner()));
|
||||
EXPECT_CALL(*gpu_factories_, IsDecoderConfigSupported(_, _))
|
||||
EXPECT_CALL(*gpu_factories_, IsDecoderConfigSupported(_))
|
||||
.WillRepeatedly(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kTrue));
|
||||
}
|
||||
|
@ -124,19 +124,6 @@ void RecordReinitializationLatency(base::TimeDelta latency) {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
std::vector<media::VideoDecoderImplementation>
|
||||
RTCVideoDecoderAdapter::SupportedImplementations() {
|
||||
#if defined(OS_WIN)
|
||||
if (base::FeatureList::IsEnabled(media::kD3D11VideoDecoder)) {
|
||||
// Push alternate ahead of default to prefer D3D11 decoders over DXVA.
|
||||
return {media::VideoDecoderImplementation::kAlternate,
|
||||
media::VideoDecoderImplementation::kDefault};
|
||||
}
|
||||
#endif
|
||||
return {media::VideoDecoderImplementation::kDefault};
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<RTCVideoDecoderAdapter> RTCVideoDecoderAdapter::Create(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
@ -163,21 +150,19 @@ std::unique_ptr<RTCVideoDecoderAdapter> RTCVideoDecoderAdapter::Create(
|
||||
kDefaultSize, media::EmptyExtraData(),
|
||||
media::EncryptionScheme::kUnencrypted);
|
||||
|
||||
for (auto impl : SupportedImplementations()) {
|
||||
std::unique_ptr<RTCVideoDecoderAdapter> rtc_video_decoder_adapter;
|
||||
if (gpu_factories->IsDecoderConfigSupported(impl, config) !=
|
||||
media::GpuVideoAcceleratorFactories::Supported::kFalse) {
|
||||
// Synchronously verify that the decoder can be initialized.
|
||||
rtc_video_decoder_adapter = base::WrapUnique(
|
||||
new RTCVideoDecoderAdapter(gpu_factories, config, format, impl));
|
||||
if (rtc_video_decoder_adapter->InitializeSync(config)) {
|
||||
return rtc_video_decoder_adapter;
|
||||
}
|
||||
// Initialization failed - post delete task and try next supported
|
||||
// implementation, if any.
|
||||
gpu_factories->GetTaskRunner()->DeleteSoon(
|
||||
FROM_HERE, std::move(rtc_video_decoder_adapter));
|
||||
std::unique_ptr<RTCVideoDecoderAdapter> rtc_video_decoder_adapter;
|
||||
if (gpu_factories->IsDecoderConfigSupported(config) !=
|
||||
media::GpuVideoAcceleratorFactories::Supported::kFalse) {
|
||||
// Synchronously verify that the decoder can be initialized.
|
||||
rtc_video_decoder_adapter = base::WrapUnique(
|
||||
new RTCVideoDecoderAdapter(gpu_factories, config, format));
|
||||
if (rtc_video_decoder_adapter->InitializeSync(config)) {
|
||||
return rtc_video_decoder_adapter;
|
||||
}
|
||||
// Initialization failed - post delete task and try next supported
|
||||
// implementation, if any.
|
||||
gpu_factories->GetTaskRunner()->DeleteSoon(
|
||||
FROM_HERE, std::move(rtc_video_decoder_adapter));
|
||||
}
|
||||
|
||||
// To mirror what RTCVideoDecoderStreamAdapter does a little more closely,
|
||||
@ -190,12 +175,10 @@ std::unique_ptr<RTCVideoDecoderAdapter> RTCVideoDecoderAdapter::Create(
|
||||
RTCVideoDecoderAdapter::RTCVideoDecoderAdapter(
|
||||
media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
const media::VideoDecoderConfig& config,
|
||||
const webrtc::SdpVideoFormat& format,
|
||||
media::VideoDecoderImplementation implementation)
|
||||
const webrtc::SdpVideoFormat& format)
|
||||
: media_task_runner_(gpu_factories->GetTaskRunner()),
|
||||
gpu_factories_(gpu_factories),
|
||||
format_(format),
|
||||
implementation_(implementation),
|
||||
config_(config) {
|
||||
DVLOG(1) << __func__;
|
||||
DETACH_FROM_SEQUENCE(decoding_sequence_checker_);
|
||||
@ -456,8 +439,7 @@ void RTCVideoDecoderAdapter::InitializeOnMediaThread(
|
||||
media_log_ = std::make_unique<media::NullMediaLog>();
|
||||
|
||||
video_decoder_ = gpu_factories_->CreateVideoDecoder(
|
||||
media_log_.get(), implementation_,
|
||||
WTF::BindRepeating(&OnRequestOverlayInfo));
|
||||
media_log_.get(), WTF::BindRepeating(&OnRequestOverlayInfo));
|
||||
|
||||
if (!video_decoder_) {
|
||||
PostCrossThreadTask(*media_task_runner_.get(), FROM_HERE,
|
||||
|
@ -69,11 +69,6 @@ class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder {
|
||||
// resolution streams, but they'll fall back if they adapt below the limit.
|
||||
static constexpr int32_t kMaxDecoderInstances = 8;
|
||||
|
||||
// Lists which implementations can be queried, this can vary based on platform
|
||||
// and enabled features.
|
||||
static std::vector<media::VideoDecoderImplementation>
|
||||
SupportedImplementations();
|
||||
|
||||
// Creates and initializes an RTCVideoDecoderAdapter. Returns nullptr if
|
||||
// |format| cannot be supported.
|
||||
// Called on the worker thread.
|
||||
@ -120,8 +115,7 @@ class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder {
|
||||
// Called on the worker thread.
|
||||
RTCVideoDecoderAdapter(media::GpuVideoAcceleratorFactories* gpu_factories,
|
||||
const media::VideoDecoderConfig& config,
|
||||
const webrtc::SdpVideoFormat& format,
|
||||
media::VideoDecoderImplementation implementation);
|
||||
const webrtc::SdpVideoFormat& format);
|
||||
|
||||
bool InitializeSync(const media::VideoDecoderConfig& config);
|
||||
void InitializeOnMediaThread(const media::VideoDecoderConfig& config,
|
||||
@ -142,7 +136,6 @@ class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder {
|
||||
const scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
|
||||
media::GpuVideoAcceleratorFactories* const gpu_factories_;
|
||||
const webrtc::SdpVideoFormat format_;
|
||||
const media::VideoDecoderImplementation implementation_;
|
||||
media::VideoDecoderConfig config_;
|
||||
|
||||
// Media thread members.
|
||||
|
@ -118,16 +118,14 @@ class RTCVideoDecoderAdapterTest : public ::testing::Test {
|
||||
.WillByDefault(Return(media_thread_.task_runner()));
|
||||
EXPECT_CALL(gpu_factories_, GetTaskRunner()).Times(AtLeast(0));
|
||||
|
||||
ON_CALL(gpu_factories_, IsDecoderConfigSupported(_, _))
|
||||
ON_CALL(gpu_factories_, IsDecoderConfigSupported(_))
|
||||
.WillByDefault(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kTrue));
|
||||
EXPECT_CALL(gpu_factories_, IsDecoderConfigSupported(_, _))
|
||||
.Times(AtLeast(0));
|
||||
EXPECT_CALL(gpu_factories_, IsDecoderConfigSupported(_)).Times(AtLeast(0));
|
||||
|
||||
ON_CALL(gpu_factories_, CreateVideoDecoder(_, _, _))
|
||||
ON_CALL(gpu_factories_, CreateVideoDecoder(_, _))
|
||||
.WillByDefault(
|
||||
[this](media::MediaLog* media_log,
|
||||
media::VideoDecoderImplementation impl,
|
||||
const media::RequestOverlayInfoCB& request_overlay_info_cb) {
|
||||
// If gpu factories tries to get a second video decoder, for
|
||||
// testing purposes we will just return null.
|
||||
@ -135,7 +133,7 @@ class RTCVideoDecoderAdapterTest : public ::testing::Test {
|
||||
// decoder is null.
|
||||
return std::move(owned_video_decoder_);
|
||||
});
|
||||
EXPECT_CALL(gpu_factories_, CreateVideoDecoder(_, _, _)).Times(AtLeast(0));
|
||||
EXPECT_CALL(gpu_factories_, CreateVideoDecoder(_, _)).Times(AtLeast(0));
|
||||
}
|
||||
|
||||
~RTCVideoDecoderAdapterTest() {
|
||||
@ -271,7 +269,7 @@ TEST_F(RTCVideoDecoderAdapterTest, Create_UnknownFormat) {
|
||||
}
|
||||
|
||||
TEST_F(RTCVideoDecoderAdapterTest, Create_UnsupportedFormat) {
|
||||
EXPECT_CALL(gpu_factories_, IsDecoderConfigSupported(_, _))
|
||||
EXPECT_CALL(gpu_factories_, IsDecoderConfigSupported(_))
|
||||
.WillRepeatedly(
|
||||
Return(media::GpuVideoAcceleratorFactories::Supported::kFalse));
|
||||
rtc_video_decoder_adapter_ = RTCVideoDecoderAdapter::Create(
|
||||
|
@ -237,14 +237,10 @@ RTCVideoDecoderFactory::GetSupportedFormats() const {
|
||||
|
||||
// The RTCVideoDecoderAdapter is for HW decoders only, so ignore it if there
|
||||
// are no gpu_factories_.
|
||||
if (gpu_factories_) {
|
||||
for (auto impl : RTCVideoDecoderAdapter::SupportedImplementations()) {
|
||||
if (gpu_factories_->IsDecoderConfigSupported(impl, config) ==
|
||||
if (gpu_factories_ &&
|
||||
gpu_factories_->IsDecoderConfigSupported(config) ==
|
||||
media::GpuVideoAcceleratorFactories::Supported::kTrue) {
|
||||
format = VdcToWebRtcFormat(config);
|
||||
break;
|
||||
}
|
||||
}
|
||||
format = VdcToWebRtcFormat(config);
|
||||
}
|
||||
|
||||
if (base::FeatureList::IsEnabled(media::kUseDecoderStreamForWebRTC) &&
|
||||
@ -308,11 +304,9 @@ RTCVideoDecoderFactory::QueryCodecSupport(
|
||||
webrtc::VideoDecoderFactory::CodecSupport codec_support;
|
||||
// Check gpu_factories for powerEfficient.
|
||||
if (gpu_factories_) {
|
||||
for (auto impl : RTCVideoDecoderAdapter::SupportedImplementations()) {
|
||||
if (gpu_factories_->IsDecoderConfigSupported(impl, config) ==
|
||||
media::GpuVideoAcceleratorFactories::Supported::kTrue) {
|
||||
codec_support.is_power_efficient = true;
|
||||
}
|
||||
if (gpu_factories_->IsDecoderConfigSupported(config) ==
|
||||
media::GpuVideoAcceleratorFactories::Supported::kTrue) {
|
||||
codec_support.is_power_efficient = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2853,7 +2853,12 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
|
||||
</summary>
|
||||
<token key="Impl">
|
||||
<variant name="Alternate"
|
||||
summary="Timing for the kAlternate media::VideoDecoderImplementation."/>
|
||||
summary="Timing for the kAlternate media::VideoDecoderImplementation.">
|
||||
<obsolete>
|
||||
Removed when D3D11/DXVA VideoDecoder implementations became mutually
|
||||
exclusive in M93.
|
||||
</obsolete>
|
||||
</variant>
|
||||
<variant name="Default"
|
||||
summary="Timing for the kDefault media::VideoDecoderImplementation."/>
|
||||
</token>
|
||||
|
Reference in New Issue
Block a user