Commit 8e6c2815 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

Revert "content/renderer/media: Query GPU process HW encoder capabilities"

This reverts commit 139567ba.

Reason for revert: Regression, HW encoder is not utilized on sarien b/148625570

Original change's description:
> content/renderer/media: Query GPU process HW encoder capabilities
>
> Originally GpuVideoAcceleratorFactoriesImpl get HW encoder
> capabilities by referencing values stored GpuInfo instance.
> However, the values are not updated after GPU process boots up.
> Even if a new hw encoder is available after GPU process is
> initialized, the hw encoder is not detected.
>
> This fixes the problem by querying GPU process the hw encoder
> capabilities when a render process is created. e.g. open the
> page.
>
> Bug: b:147404923
> Test: HW encoder is used at appr.tc
> Test: tast run webrtc.* on krane
> Change-Id: Ibca82b6e54e9b5d585037c8e63f4c663d085db0e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994849
> Reviewed-by: Dominick Ng <dominickn@chromium.org>
> Reviewed-by: Dan Sanders <sandersd@chromium.org>
> Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#735339}

TBR=sandersd@chromium.org,dominickn@chromium.org,hiroh@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: b:147404923
Bug: b:148625570
Change-Id: I75bfe87b97505f400d1fb5c27facff507495cfb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032454Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737242}
parent 61f12810
......@@ -97,6 +97,12 @@ GpuVideoAcceleratorFactoriesImpl::GpuVideoAcceleratorFactoriesImpl(
video_accelerator_enabled_(enable_video_accelerator),
gpu_memory_buffer_manager_(
RenderThreadImpl::current()->GetGpuMemoryBufferManager()),
supported_vea_profiles_(
enable_video_accelerator
? media::GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(
gpu_channel_host_->gpu_info()
.video_encode_accelerator_supported_profiles)
: media::VideoEncodeAccelerator::SupportedProfiles()),
thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) {
DCHECK(main_thread_task_runner_);
DCHECK(gpu_channel_host_);
......@@ -130,11 +136,6 @@ void GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner(
context_provider_->AddObserver(this);
vea_provider_->GetVideoEncodeAcceleratorSupportedProfiles(
base::BindOnce(&GpuVideoAcceleratorFactoriesImpl::
OnGetVideoEncodeAcceleratorSupportedProfiles,
base::Unretained(this)));
#if BUILDFLAG(ENABLE_MOJO_VIDEO_DECODER)
// Note: This is a bit of a hack, since we don't specify the implementation
// before asking for the map of supported configs. We do this because it
......@@ -151,19 +152,11 @@ void GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner(
void GpuVideoAcceleratorFactoriesImpl::OnSupportedDecoderConfigs(
const media::SupportedVideoDecoderConfigMap& supported_configs) {
base::AutoLock lock(supported_profiles_lock_);
base::AutoLock lock(supported_decoder_configs_lock_);
supported_decoder_configs_ = supported_configs;
video_decoder_.reset();
}
void GpuVideoAcceleratorFactoriesImpl::
OnGetVideoEncodeAcceleratorSupportedProfiles(
const media::VideoEncodeAccelerator::SupportedProfiles&
supported_profiles) {
base::AutoLock lock(supported_profiles_lock_);
supported_vea_profiles_ = supported_profiles;
}
bool GpuVideoAcceleratorFactoriesImpl::CheckContextLost() {
DCHECK(task_runner_->BelongsToCurrentThread());
if (context_provider_lost_on_media_thread_)
......@@ -223,7 +216,7 @@ GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
return Supported::kFalse;
}
base::AutoLock lock(supported_profiles_lock_);
base::AutoLock lock(supported_decoder_configs_lock_);
// If GetSupportedConfigs() has not completed (or was never started), report
// that all configs are supported. Clients will find out that configs are not
......@@ -277,16 +270,6 @@ GpuVideoAcceleratorFactoriesImpl::CreateVideoEncodeAccelerator() {
if (CheckContextLost())
return nullptr;
base::AutoLock lock(supported_profiles_lock_);
// When |supported_vea_profiles_| is empty, no hw encoder is available or
// we have not yet gotten the supported profiles.
if (!supported_vea_profiles_) {
DVLOG(2) << "VEA's profiles have not yet been gotten";
} else if (supported_vea_profiles_->empty()) {
// There is no profile supported by VEA.
return nullptr;
}
mojo::PendingRemote<media::mojom::VideoEncodeAccelerator> vea;
vea_provider_->CreateVideoEncodeAccelerator(
vea.InitWithNewPipeAndPassReceiver());
......@@ -295,10 +278,8 @@ GpuVideoAcceleratorFactoriesImpl::CreateVideoEncodeAccelerator() {
return nullptr;
return std::unique_ptr<media::VideoEncodeAccelerator>(
new media::MojoVideoEncodeAccelerator(
std::move(vea),
supported_vea_profiles_.value_or(
media::VideoEncodeAccelerator::SupportedProfiles())));
new media::MojoVideoEncodeAccelerator(std::move(vea),
supported_vea_profiles_));
}
std::unique_ptr<gfx::GpuMemoryBuffer>
......@@ -408,9 +389,7 @@ GpuVideoAcceleratorFactoriesImpl::GetTaskRunner() {
media::VideoEncodeAccelerator::SupportedProfiles
GpuVideoAcceleratorFactoriesImpl::GetVideoEncodeAcceleratorSupportedProfiles() {
base::AutoLock lock(supported_profiles_lock_);
return supported_vea_profiles_.value_or(
media::VideoEncodeAccelerator::SupportedProfiles());
return supported_vea_profiles_;
}
scoped_refptr<viz::ContextProvider>
......
......@@ -154,9 +154,6 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
void OnSupportedDecoderConfigs(
const media::SupportedVideoDecoderConfigMap& supported_configs);
void OnGetVideoEncodeAcceleratorSupportedProfiles(
const media::VideoEncodeAccelerator::SupportedProfiles&
supported_profiles);
const scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......@@ -189,17 +186,16 @@ class CONTENT_EXPORT GpuVideoAcceleratorFactoriesImpl
// SupportedDecoderConfigs state.
mojo::Remote<media::mojom::VideoDecoder> video_decoder_;
base::Lock supported_profiles_lock_;
base::Lock supported_decoder_configs_lock_;
// 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.
base::Optional<media::SupportedVideoDecoderConfigMap>
supported_decoder_configs_ GUARDED_BY(supported_profiles_lock_);
supported_decoder_configs_ GUARDED_BY(supported_decoder_configs_lock_);
const media::VideoEncodeAccelerator::SupportedProfiles
supported_vea_profiles_;
base::Optional<media::VideoEncodeAccelerator::SupportedProfiles>
supported_vea_profiles_ GUARDED_BY(supported_profiles_lock_);
// For sending requests to allocate shared memory in the Browser process.
scoped_refptr<ThreadSafeSender> thread_safe_sender_;
......
......@@ -33,25 +33,10 @@ import "media/mojo/mojom/video_encoder_info.mojom";
// time the Client can send a RequestEncodingParametersChange() to the VEA. None
// of these messages are acknowledged.
struct VideoEncodeAcceleratorSupportedProfile {
VideoCodecProfile profile;
gfx.mojom.Size min_resolution;
gfx.mojom.Size max_resolution;
uint32 max_framerate_numerator;
uint32 max_framerate_denominator;
};
// A renderer process calls this interface's functions. GPU process implements
// this interface.
interface VideoEncodeAcceleratorProvider {
// Creates a VideoEncodeAccelerator bound to |receiver|.
CreateVideoEncodeAccelerator(
pending_receiver<VideoEncodeAccelerator> receiver);
// Get a VideoEncodeAccelerator supported profiles.
GetVideoEncodeAcceleratorSupportedProfiles()
=> (array<VideoEncodeAcceleratorSupportedProfile> profiles);
};
// Class that describes how video bitrate, in bps, is allocated across temporal
......
......@@ -31,6 +31,5 @@ type_mappings = [
"media.mojom.VideoBitrateAllocation=::media::VideoBitrateAllocation",
"media.mojom.VideoEncodeAccelerator.Error=::media::VideoEncodeAccelerator::Error",
"media.mojom.VideoEncodeAcceleratorConfig=::media::VideoEncodeAccelerator::Config",
"media.mojom.VideoEncodeAcceleratorSupportedProfile=::media::VideoEncodeAccelerator::SupportedProfile",
"media.mojom.Vp8Metadata=::media::Vp8Metadata",
]
......@@ -11,22 +11,6 @@
namespace mojo {
// static
bool StructTraits<media::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
media::VideoEncodeAccelerator::SupportedProfile>::
Read(media::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
media::VideoEncodeAccelerator::SupportedProfile* out) {
if (!data.ReadMinResolution(&out->min_resolution) ||
!data.ReadMaxResolution(&out->max_resolution) ||
!data.ReadProfile(&out->profile)) {
return false;
}
out->max_framerate_numerator = data.max_framerate_numerator();
out->max_framerate_denominator = data.max_framerate_denominator();
return true;
}
// static
media::mojom::VideoEncodeAccelerator::Error
EnumTraits<media::mojom::VideoEncodeAccelerator::Error,
......
......@@ -13,40 +13,6 @@
namespace mojo {
template <>
struct StructTraits<
media::mojom::VideoEncodeAcceleratorSupportedProfileDataView,
media::VideoEncodeAccelerator::SupportedProfile> {
static media::VideoCodecProfile profile(
const media::VideoEncodeAccelerator::SupportedProfile& profile) {
return profile.profile;
}
static const gfx::Size& min_resolution(
const media::VideoEncodeAccelerator::SupportedProfile& profile) {
return profile.min_resolution;
}
static const gfx::Size& max_resolution(
const media::VideoEncodeAccelerator::SupportedProfile& profile) {
return profile.max_resolution;
}
static uint32_t max_framerate_numerator(
const media::VideoEncodeAccelerator::SupportedProfile& profile) {
return profile.max_framerate_numerator;
}
static uint32_t max_framerate_denominator(
const media::VideoEncodeAccelerator::SupportedProfile& profile) {
return profile.max_framerate_denominator;
}
static bool Read(
media::mojom::VideoEncodeAcceleratorSupportedProfileDataView data,
media::VideoEncodeAccelerator::SupportedProfile* out);
};
template <>
struct EnumTraits<media::mojom::VideoEncodeAccelerator::Error,
media::VideoEncodeAccelerator::Error> {
......
......@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/limits.h"
#include "media/gpu/gpu_video_encode_accelerator_factory.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/platform_handle.h"
......@@ -44,11 +43,4 @@ void MojoVideoEncodeAcceleratorProvider::CreateVideoEncodeAccelerator(
std::move(receiver), create_vea_callback_, gpu_preferences_);
}
void MojoVideoEncodeAcceleratorProvider::
GetVideoEncodeAcceleratorSupportedProfiles(
GetVideoEncodeAcceleratorSupportedProfilesCallback callback) {
std::move(callback).Run(
GpuVideoEncodeAcceleratorFactory::GetSupportedProfiles(gpu_preferences_));
}
} // namespace media
......@@ -42,8 +42,6 @@ class MEDIA_MOJO_EXPORT MojoVideoEncodeAcceleratorProvider
// mojom::VideoEncodeAcceleratorProvider impl.
void CreateVideoEncodeAccelerator(
mojo::PendingReceiver<mojom::VideoEncodeAccelerator> receiver) override;
void GetVideoEncodeAcceleratorSupportedProfiles(
GetVideoEncodeAcceleratorSupportedProfilesCallback callback) override;
private:
const CreateAndInitializeVideoEncodeAcceleratorCallback create_vea_callback_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment