#include "content/renderer/media/gpu/gpu_video_accelerator_factories_impl.h"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <memory>
#include <optional>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/sequenced_task_runner.h"
#include "base/unguessable_token.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/public/common/content_features.h"
#include "content/renderer/media/codec_factory.h"
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "media/base/decoder.h"
#include "media/base/media_switches.h"
#include "media/base/supported_video_decoder_config.h"
#include "media/mojo/buildflags.h"
#include "media/video/video_encode_accelerator.h"
#include "services/viz/public/cpp/gpu/context_provider_command_buffer.h"
#include "third_party/skia/include/core/SkTypes.h"
namespace content {
std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>
GpuVideoAcceleratorFactoriesImpl::Create(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
std::unique_ptr<CodecFactory> codec_factory,
bool enable_video_gpu_memory_buffers,
bool enable_media_stream_gpu_memory_buffers,
bool enable_video_decode_accelerator,
bool enable_video_encode_accelerator) { … }
std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>
GpuVideoAcceleratorFactoriesImpl::CreateForTesting(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
std::unique_ptr<CodecFactory> codec_factory,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
bool enable_video_gpu_memory_buffers,
bool enable_media_stream_gpu_memory_buffers,
bool enable_video_decode_accelerator,
bool enable_video_encode_accelerator) { … }
GpuVideoAcceleratorFactoriesImpl::GpuVideoAcceleratorFactoriesImpl(
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host,
const scoped_refptr<base::SequencedTaskRunner>& main_thread_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const scoped_refptr<viz::ContextProviderCommandBuffer>& context_provider,
std::unique_ptr<CodecFactory> codec_factory,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
bool enable_video_gpu_memory_buffers,
bool enable_media_stream_gpu_memory_buffers,
bool enable_video_decode_accelerator,
bool enable_video_encode_accelerator)
: … { … }
GpuVideoAcceleratorFactoriesImpl::~GpuVideoAcceleratorFactoriesImpl() { … }
void GpuVideoAcceleratorFactoriesImpl::BindOnTaskRunner() { … }
bool GpuVideoAcceleratorFactoriesImpl::IsDecoderSupportKnown() { … }
void GpuVideoAcceleratorFactoriesImpl::NotifyDecoderSupportKnown(
base::OnceClosure callback) { … }
bool GpuVideoAcceleratorFactoriesImpl::IsEncoderSupportKnown() { … }
void GpuVideoAcceleratorFactoriesImpl::NotifyEncoderSupportKnown(
base::OnceClosure callback) { … }
bool GpuVideoAcceleratorFactoriesImpl::CheckContextLost() { … }
void GpuVideoAcceleratorFactoriesImpl::DestroyContext() { … }
bool GpuVideoAcceleratorFactoriesImpl::IsGpuVideoDecodeAcceleratorEnabled() { … }
bool GpuVideoAcceleratorFactoriesImpl::IsGpuVideoEncodeAcceleratorEnabled() { … }
void GpuVideoAcceleratorFactoriesImpl::GetChannelToken(
gpu::mojom::GpuChannel::GetChannelTokenCallback cb) { … }
void GpuVideoAcceleratorFactoriesImpl::OnChannelTokenReady(
const base::UnguessableToken& token) { … }
int32_t GpuVideoAcceleratorFactoriesImpl::GetCommandBufferRouteId() { … }
media::GpuVideoAcceleratorFactories::Supported
GpuVideoAcceleratorFactoriesImpl::IsDecoderConfigSupported(
const media::VideoDecoderConfig& config) { … }
media::VideoDecoderType GpuVideoAcceleratorFactoriesImpl::GetDecoderType() { … }
std::unique_ptr<media::VideoDecoder>
GpuVideoAcceleratorFactoriesImpl::CreateVideoDecoder(
media::MediaLog* media_log,
media::RequestOverlayInfoCB request_overlay_info_cb) { … }
std::unique_ptr<media::VideoEncodeAccelerator>
GpuVideoAcceleratorFactoriesImpl::CreateVideoEncodeAccelerator() { … }
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuVideoAcceleratorFactoriesImpl::CreateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage) { … }
bool GpuVideoAcceleratorFactoriesImpl::ShouldUseGpuMemoryBuffersForVideoFrames(
bool for_media_stream) const { … }
media::GpuVideoAcceleratorFactories::OutputFormat
GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormat(
media::VideoPixelFormat pixel_format) { … }
media::GpuVideoAcceleratorFactories::OutputFormat
GpuVideoAcceleratorFactoriesImpl::VideoFrameOutputFormatImpl(
media::VideoPixelFormat pixel_format) { … }
gpu::SharedImageInterface*
GpuVideoAcceleratorFactoriesImpl::SharedImageInterface() { … }
gpu::GpuMemoryBufferManager*
GpuVideoAcceleratorFactoriesImpl::GpuMemoryBufferManager() { … }
base::UnsafeSharedMemoryRegion
GpuVideoAcceleratorFactoriesImpl::CreateSharedMemoryRegion(size_t size) { … }
scoped_refptr<base::SequencedTaskRunner>
GpuVideoAcceleratorFactoriesImpl::GetTaskRunner() { … }
std::optional<media::VideoEncodeAccelerator::SupportedProfiles>
GpuVideoAcceleratorFactoriesImpl::GetVideoEncodeAcceleratorSupportedProfiles() { … }
viz::RasterContextProvider*
GpuVideoAcceleratorFactoriesImpl::GetMediaContextProvider() { … }
const gpu::Capabilities*
GpuVideoAcceleratorFactoriesImpl::ContextCapabilities() { … }
void GpuVideoAcceleratorFactoriesImpl::SetRenderingColorSpace(
const gfx::ColorSpace& color_space) { … }
const gfx::ColorSpace&
GpuVideoAcceleratorFactoriesImpl::GetRenderingColorSpace() const { … }
bool GpuVideoAcceleratorFactoriesImpl::CheckContextProviderLostOnMainThread() { … }
void GpuVideoAcceleratorFactoriesImpl::OnContextLost() { … }
void GpuVideoAcceleratorFactoriesImpl::SetContextProviderLostOnMainThread() { … }
}