Commit 57673f4d authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Rename AVDACodecAllocator to CodecAllocator.

Since AVDA is on it's way out... this also replaces all instances of
base::Bind with the appropriate version (generally base::BindOnce).

BUG=none
TEST=bots
R=liberato

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I75f8dd4895f7404fe752cf02d495a198b8a78a6a
Reviewed-on: https://chromium-review.googlesource.com/1252961
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595323}
parent f0ac64f0
......@@ -157,8 +157,6 @@ component("gpu") {
"android/android_video_surface_chooser.h",
"android/android_video_surface_chooser_impl.cc",
"android/android_video_surface_chooser_impl.h",
"android/avda_codec_allocator.cc",
"android/avda_codec_allocator.h",
"android/avda_codec_image.cc",
"android/avda_codec_image.h",
"android/avda_picture_buffer_manager.cc",
......@@ -168,6 +166,8 @@ component("gpu") {
"android/avda_state_provider.h",
"android/avda_surface_bundle.cc",
"android/avda_surface_bundle.h",
"android/codec_allocator.cc",
"android/codec_allocator.h",
"android/codec_image.cc",
"android/codec_image.h",
"android/codec_image_group.cc",
......@@ -438,7 +438,7 @@ source_set("android_video_decode_accelerator_unittests") {
sources = [
"android/android_video_decode_accelerator_unittest.cc",
"android/android_video_surface_chooser_impl_unittest.cc",
"android/avda_codec_allocator_unittest.cc",
"android/codec_allocator_unittest.cc",
"android/codec_image_group_unittest.cc",
"android/codec_image_unittest.cc",
"android/codec_wrapper_unittest.cc",
......
......@@ -118,7 +118,7 @@ constexpr base::TimeDelta IdleTimerTimeOut = base::TimeDelta::FromSeconds(1);
// On low end devices (< KitKat is always low-end due to buggy MediaCodec),
// defer the surface creation until the codec is actually used if we know no
// software fallback exists.
bool ShouldDeferSurfaceCreation(AVDACodecAllocator* codec_allocator,
bool ShouldDeferSurfaceCreation(CodecAllocator* codec_allocator,
const OverlayInfo& overlay_info,
VideoCodec codec,
DeviceInfo* device_info) {
......@@ -259,7 +259,7 @@ AndroidVideoDecodeAccelerator::BitstreamRecord::BitstreamRecord(
AndroidVideoDecodeAccelerator::BitstreamRecord::~BitstreamRecord() {}
AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
AVDACodecAllocator* codec_allocator,
CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
const MakeGLContextCurrentCallback& make_context_current_cb,
const GetContextGroupCallback& get_context_group_cb,
......
......@@ -22,9 +22,9 @@
#include "media/base/android/media_crypto_context.h"
#include "media/base/android_overlay_mojo_factory.h"
#include "media/base/content_decryption_module.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/avda_picture_buffer_manager.h"
#include "media/gpu/android/avda_state_provider.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/device_info.h"
#include "media/gpu/android/surface_chooser_helper.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h"
......@@ -44,13 +44,13 @@ class PromotionHintAggregator;
class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
: public VideoDecodeAccelerator,
public AVDAStateProvider,
public AVDACodecAllocatorClient {
public CodecAllocatorClient {
public:
static VideoDecodeAccelerator::Capabilities GetCapabilities(
const gpu::GpuPreferences& gpu_preferences);
AndroidVideoDecodeAccelerator(
AVDACodecAllocator* codec_allocator,
CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
const MakeGLContextCurrentCallback& make_context_current_cb,
const GetContextGroupCallback& get_context_group_cb,
......@@ -83,7 +83,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
void NotifyError(Error error) override;
PromotionHintAggregator::NotifyPromotionHintCB GetPromotionHintCB() override;
// AVDACodecAllocatorClient implementation:
// CodecAllocatorClient implementation:
void OnCodecConfigured(
std::unique_ptr<MediaCodecBridge> media_codec,
scoped_refptr<AVDASurfaceBundle> surface_bundle) override;
......@@ -266,7 +266,7 @@ class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator
// To expose client callbacks from VideoDecodeAccelerator.
Client* client_;
AVDACodecAllocator* codec_allocator_;
CodecAllocator* codec_allocator_;
// Callback to set the correct gl context.
MakeGLContextCurrentCallback make_context_current_cb_;
......
......@@ -26,7 +26,7 @@
#include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/android_video_decode_accelerator.h"
#include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/fake_codec_allocator.h"
#include "media/gpu/android/mock_android_video_surface_chooser.h"
#include "media/gpu/android/mock_device_info.h"
......
......@@ -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 MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_
#define MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_
#ifndef MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
#define MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
#include <stddef.h>
......@@ -34,7 +34,7 @@
namespace media {
// For TaskRunnerFor. These are used as vector indices, so please update
// AVDACodecAllocator's constructor if you add / change them.
// CodecAllocator's constructor if you add / change them.
enum TaskType {
// Task for an autodetected MediaCodec instance.
AUTO_CODEC = 0,
......@@ -104,7 +104,7 @@ class AVDASurfaceAllocatorClient {
~AVDASurfaceAllocatorClient() {}
};
class AVDACodecAllocatorClient {
class CodecAllocatorClient {
public:
// Called on the main thread when a new MediaCodec is configured.
// |media_codec| will be null if configuration failed.
......@@ -113,16 +113,16 @@ class AVDACodecAllocatorClient {
scoped_refptr<AVDASurfaceBundle> surface_bundle) = 0;
protected:
~AVDACodecAllocatorClient() {}
~CodecAllocatorClient() {}
};
// AVDACodecAllocator manages threads for allocating and releasing MediaCodec
// CodecAllocator manages threads for allocating and releasing MediaCodec
// instances. These activities can hang, depending on android version, due
// to mediaserver bugs. AVDACodecAllocator detects these cases, and reports
// to mediaserver bugs. CodecAllocator detects these cases, and reports
// on them to allow software fallback if the HW path is hung up.
class MEDIA_GPU_EXPORT AVDACodecAllocator {
class MEDIA_GPU_EXPORT CodecAllocator {
public:
static AVDACodecAllocator* GetInstance(
static CodecAllocator* GetInstance(
scoped_refptr<base::SequencedTaskRunner> task_runner);
using CodecFactoryCB =
......@@ -141,8 +141,8 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Make sure the construction threads are started for |client|. If the
// threads fail to start, then codec allocation may fail.
virtual void StartThread(AVDACodecAllocatorClient* client);
virtual void StopThread(AVDACodecAllocatorClient* client);
virtual void StartThread(CodecAllocatorClient* client);
virtual void StopThread(CodecAllocatorClient* client);
// Create and configure a MediaCodec synchronously.
virtual std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync(
......@@ -150,8 +150,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Create and configure a MediaCodec asynchronously. The result is delivered
// via OnCodecConfigured().
virtual void CreateMediaCodecAsync(
base::WeakPtr<AVDACodecAllocatorClient> client,
virtual void CreateMediaCodecAsync(base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config);
// Asynchronously release |media_codec| with the attached surface. We will
......@@ -177,11 +176,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
protected:
// |tick_clock| and |stop_event| are for tests only.
AVDACodecAllocator(AVDACodecAllocator::CodecFactoryCB factory_cb,
CodecAllocator(CodecAllocator::CodecFactoryCB factory_cb,
scoped_refptr<base::SequencedTaskRunner> task_runner,
const base::TickClock* tick_clock = nullptr,
base::WaitableEvent* stop_event = nullptr);
virtual ~AVDACodecAllocator();
virtual ~CodecAllocator();
// Struct to own a codec and surface bundle, with a custom deleter to post
// destruction to the right thread.
......@@ -199,7 +198,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// It may only reference |client| from |client_task_runner|.
void ForwardOrDropCodec(
scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client,
base::WeakPtr<CodecAllocatorClient> client,
TaskType task_type,
scoped_refptr<AVDASurfaceBundle> surface_bundle,
std::unique_ptr<MediaCodecBridge> media_codec);
......@@ -207,11 +206,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// Forward |surface_bundle| and |media_codec| to |client| on the right thread
// to access |client|.
void ForwardOrDropCodecOnClientThread(
base::WeakPtr<AVDACodecAllocatorClient> client,
base::WeakPtr<CodecAllocatorClient> client,
std::unique_ptr<MediaCodecAndSurface> codec_and_surface);
private:
friend class AVDACodecAllocatorTest;
friend class CodecAllocatorTest;
struct OwnerRecord {
AVDASurfaceAllocatorClient* owner = nullptr;
......@@ -249,7 +248,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
// which it should post the reply to |client|.
void CreateMediaCodecAsyncInternal(
scoped_refptr<base::SequencedTaskRunner> client_task_runner,
base::WeakPtr<AVDACodecAllocatorClient> client,
base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> codec_config);
// Return the task type to use for a new codec allocation, or nullopt if
......@@ -275,7 +274,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
const scoped_refptr<base::SequencedTaskRunner> task_runner_;
// All registered AVDAs.
std::set<AVDACodecAllocatorClient*> clients_;
std::set<CodecAllocatorClient*> clients_;
// Waitable events for ongoing release tasks indexed by overlay so we can
// wait on the codec release if the surface attached to it is being destroyed.
......@@ -297,11 +296,11 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator {
CodecFactoryCB factory_cb_;
// For canceling pending StopThreadTask()s.
base::WeakPtrFactory<AVDACodecAllocator> weak_this_factory_;
base::WeakPtrFactory<CodecAllocator> weak_this_factory_;
DISALLOW_COPY_AND_ASSIGN(AVDACodecAllocator);
DISALLOW_COPY_AND_ASSIGN(CodecAllocator);
};
} // namespace media
#endif // MEDIA_GPU_ANDROID_AVDA_CODEC_ALLOCATOR_H_
#endif // MEDIA_GPU_ANDROID_CODEC_ALLOCATOR_H_
......@@ -8,7 +8,7 @@
#include "base/memory/weak_ptr.h"
#include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -16,16 +16,16 @@ namespace media {
FakeCodecAllocator::FakeCodecAllocator(
scoped_refptr<base::SequencedTaskRunner> task_runner)
: testing::NiceMock<AVDACodecAllocator>(
: testing::NiceMock<CodecAllocator>(
base::BindRepeating(&MockMediaCodecBridge::CreateVideoDecoder),
task_runner),
most_recent_config(new CodecConfig()) {}
FakeCodecAllocator::~FakeCodecAllocator() = default;
void FakeCodecAllocator::StartThread(AVDACodecAllocatorClient* client) {}
void FakeCodecAllocator::StartThread(CodecAllocatorClient* client) {}
void FakeCodecAllocator::StopThread(AVDACodecAllocatorClient* client) {}
void FakeCodecAllocator::StopThread(CodecAllocatorClient* client) {}
std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync(
scoped_refptr<CodecConfig> config) {
......@@ -47,7 +47,7 @@ std::unique_ptr<MediaCodecBridge> FakeCodecAllocator::CreateMediaCodecSync(
}
void FakeCodecAllocator::CreateMediaCodecAsync(
base::WeakPtr<AVDACodecAllocatorClient> client,
base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> config) {
// Clear |most_recent_codec| until somebody calls Provide*CodecAsync().
most_recent_codec = nullptr;
......
......@@ -9,8 +9,8 @@
#include "base/sequenced_task_runner.h"
#include "media/base/android/mock_media_codec_bridge.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/avda_surface_bundle.h"
#include "media/gpu/android/codec_allocator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/android/surface_texture.h"
......@@ -19,13 +19,13 @@ namespace media {
// A codec allocator that provides a configurable fake implementation
// and lets you set expecations on the "Mock*" methods.
class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> {
class FakeCodecAllocator : public testing::NiceMock<CodecAllocator> {
public:
FakeCodecAllocator(scoped_refptr<base::SequencedTaskRunner> task_runner);
~FakeCodecAllocator() override;
void StartThread(AVDACodecAllocatorClient* client) override;
void StopThread(AVDACodecAllocatorClient* client) override;
void StartThread(CodecAllocatorClient* client) override;
void StopThread(CodecAllocatorClient* client) override;
// These are called with some parameters of the codec config by our
// implementation of their respective functions. This allows tests to set
......@@ -41,7 +41,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> {
std::unique_ptr<MediaCodecBridge> CreateMediaCodecSync(
scoped_refptr<CodecConfig> config) override;
void CreateMediaCodecAsync(base::WeakPtr<AVDACodecAllocatorClient> client,
void CreateMediaCodecAsync(base::WeakPtr<CodecAllocatorClient> client,
scoped_refptr<CodecConfig> config) override;
void ReleaseMediaCodec(
std::unique_ptr<MediaCodecBridge> media_codec,
......@@ -82,7 +82,7 @@ class FakeCodecAllocator : public testing::NiceMock<AVDACodecAllocator> {
// Whether CreateMediaCodecAsync() has been called but a codec hasn't been
// provided yet.
bool codec_creation_pending_ = false;
base::WeakPtr<AVDACodecAllocatorClient> client_;
base::WeakPtr<CodecAllocatorClient> client_;
// The surface bundle of the pending codec creation.
scoped_refptr<AVDASurfaceBundle> pending_surface_bundle_;
......
......@@ -24,7 +24,7 @@
#include "media/base/video_frame.h"
#include "media/base/video_util.h"
#include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/media_buildflags.h"
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
......@@ -116,7 +116,7 @@ PendingDecode::~PendingDecode() = default;
MediaCodecVideoDecoder::MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences,
DeviceInfo* device_info,
AVDACodecAllocator* codec_allocator,
CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
AndroidOverlayMojoFactoryCB overlay_factory_cb,
RequestOverlayInfoCB request_overlay_info_cb,
......
......@@ -14,7 +14,7 @@
#include "media/base/overlay_info.h"
#include "media/base/video_decoder.h"
#include "media/gpu/android/android_video_surface_chooser.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/codec_wrapper.h"
#include "media/gpu/android/device_info.h"
#include "media/gpu/android/surface_chooser_helper.h"
......@@ -48,14 +48,13 @@ struct PendingDecode {
// playbacks that need them.
// TODO: Lazy initialization should be handled at a higher layer of the media
// stack for both simplicity and cross platform support.
class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
: public VideoDecoder,
public AVDACodecAllocatorClient {
class MEDIA_GPU_EXPORT MediaCodecVideoDecoder : public VideoDecoder,
public CodecAllocatorClient {
public:
MediaCodecVideoDecoder(
const gpu::GpuPreferences& gpu_preferences,
DeviceInfo* device_info,
AVDACodecAllocator* codec_allocator,
CodecAllocator* codec_allocator,
std::unique_ptr<AndroidVideoSurfaceChooser> surface_chooser,
AndroidOverlayMojoFactoryCB overlay_factory_cb,
RequestOverlayInfoCB request_overlay_info_cb,
......@@ -141,7 +140,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
// Creates a codec asynchronously.
void CreateCodec();
// AVDACodecAllocatorClient implementation.
// CodecAllocatorClient implementation.
void OnCodecConfigured(
std::unique_ptr<MediaCodecBridge> media_codec,
scoped_refptr<AVDASurfaceBundle> surface_bundle) override;
......@@ -234,7 +233,7 @@ class MEDIA_GPU_EXPORT MediaCodecVideoDecoder
std::unique_ptr<CodecWrapper> codec_;
base::ElapsedTimer idle_timer_;
base::RepeatingTimer pump_codec_timer_;
AVDACodecAllocator* codec_allocator_;
CodecAllocator* codec_allocator_;
// The current target surface that |codec_| should be rendering to. It
// reflects the latest surface choice by |surface_chooser_|. If the codec is
......
......@@ -31,7 +31,7 @@
#if defined(OS_ANDROID)
#include "media/gpu/android/android_video_decode_accelerator.h"
#include "media/gpu/android/android_video_surface_chooser_impl.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/device_info.h"
#endif
#if BUILDFLAG(USE_VAAPI)
......@@ -266,7 +266,7 @@ GpuVideoDecodeAcceleratorFactory::CreateAndroidVDA(
MediaLog* media_log) const {
std::unique_ptr<VideoDecodeAccelerator> decoder;
decoder.reset(new AndroidVideoDecodeAccelerator(
AVDACodecAllocator::GetInstance(base::ThreadTaskRunnerHandle::Get()),
CodecAllocator::GetInstance(base::ThreadTaskRunnerHandle::Get()),
std::make_unique<AndroidVideoSurfaceChooserImpl>(
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
make_context_current_cb_, get_context_group_cb_, overlay_factory_cb_,
......
......@@ -27,7 +27,7 @@
#include "media/base/android/android_cdm_factory.h"
#include "media/filters/android/media_codec_audio_decoder.h"
#include "media/gpu/android/android_video_surface_chooser_impl.h"
#include "media/gpu/android/avda_codec_allocator.h"
#include "media/gpu/android/codec_allocator.h"
#include "media/gpu/android/media_codec_video_decoder.h"
#include "media/gpu/android/video_frame_factory_impl.h"
#include "media/mojo/interfaces/media_drm_storage.mojom.h"
......@@ -138,7 +138,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
command_buffer_id->channel_token, command_buffer_id->route_id);
return std::make_unique<MediaCodecVideoDecoder>(
gpu_preferences_, DeviceInfo::GetInstance(),
AVDACodecAllocator::GetInstance(gpu_task_runner_),
CodecAllocator::GetInstance(gpu_task_runner_),
std::make_unique<AndroidVideoSurfaceChooserImpl>(
DeviceInfo::GetInstance()->IsSetOutputSurfaceSupported()),
android_overlay_factory_cb_, std::move(request_overlay_info_cb),
......
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