Skip to content

Commit

Permalink
Remove all VideoDecoderImplementation usage
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
tm-chromium authored and Chromium LUCI CQ committed Jun 14, 2021
1 parent 25b3031 commit 4041de9
Show file tree
Hide file tree
Showing 34 changed files with 174 additions and 352 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
7 changes: 2 additions & 5 deletions chromecast/media/gpu/cast_gpu_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand All @@ -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>
Expand Down
2 changes: 0 additions & 2 deletions chromecast/media/gpu/cast_gpu_factory_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 5 additions & 13 deletions content/renderer/media/gpu/gpu_video_accelerator_factories_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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());
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion content/test/data/media/peerconnection-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions media/base/ipc/media_param_traits_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 0 additions & 12 deletions media/base/supported_video_decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 1 addition & 17 deletions media/mojo/clients/mojo_decoder_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 7 additions & 11 deletions media/mojo/clients/mojo_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions media/mojo/clients/mojo_video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};

Expand Down
4 changes: 0 additions & 4 deletions media/mojo/mojom/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 2 additions & 11 deletions media/mojo/mojom/video_decoder.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4041de9

Please sign in to comment.