#include "media/mojo/services/gpu_mojo_media_client.h"
#include <optional>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "gpu/ipc/service/gpu_channel.h"
#include "media/base/audio_decoder.h"
#include "media/base/audio_encoder.h"
#include "media/base/cdm_factory.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/video_decoder.h"
#include "media/gpu/gpu_video_accelerator_util.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/ipc/service/media_gpu_channel_manager.h"
#include "media/mojo/mojom/video_decoder.mojom.h"
#include "media/video/video_decode_accelerator.h"
namespace media {
namespace {
gpu::CommandBufferStub* GetCommandBufferStub(
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
base::WeakPtr<MediaGpuChannelManager> media_gpu_channel_manager,
base::UnguessableToken channel_token,
int32_t route_id) { … }
}
std::unique_ptr<GpuMojoMediaClient> CreateGpuMediaService(
GpuMojoMediaClientTraits& traits);
VideoDecoderTraits::~VideoDecoderTraits() = default;
VideoDecoderTraits::VideoDecoderTraits(
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::unique_ptr<MediaLog> media_log,
RequestOverlayInfoCB request_overlay_info_cb,
const gfx::ColorSpace* target_color_space,
GetConfigCacheCB get_cached_configs_cb,
GetCommandBufferStubCB get_command_buffer_stub_cb,
mojo::PendingRemote<stable::mojom::StableVideoDecoder> oop_video_decoder)
: … { … }
GpuMojoMediaClientTraits::~GpuMojoMediaClientTraits() = default;
GpuMojoMediaClientTraits::GpuMojoMediaClientTraits(
const gpu::GpuPreferences& gpu_preferences,
const gpu::GpuDriverBugWorkarounds& gpu_workarounds,
const gpu::GpuFeatureInfo& gpu_feature_info,
const gpu::GPUInfo& gpu_info,
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
AndroidOverlayMojoFactoryCB android_overlay_factory_cb,
base::WeakPtr<MediaGpuChannelManager> media_gpu_channel_manager)
: … { … }
std::unique_ptr<GpuMojoMediaClient> GpuMojoMediaClient::Create(
GpuMojoMediaClientTraits& traits) { … }
GpuMojoMediaClient::GpuMojoMediaClient(GpuMojoMediaClientTraits& traits)
: … { … }
GpuMojoMediaClient::~GpuMojoMediaClient() = default;
std::unique_ptr<AudioDecoder> GpuMojoMediaClient::CreateAudioDecoder(
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::unique_ptr<MediaLog> media_log) { … }
std::unique_ptr<AudioEncoder> GpuMojoMediaClient::CreateAudioEncoder(
scoped_refptr<base::SequencedTaskRunner> task_runner) { … }
VideoDecoderType GpuMojoMediaClient::GetDecoderImplementationType() { … }
SupportedAudioDecoderConfigs
GpuMojoMediaClient::GetSupportedAudioDecoderConfigs() { … }
SupportedVideoDecoderConfigs
GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() { … }
#if BUILDFLAG(ALLOW_OOP_VIDEO_DECODER)
void GpuMojoMediaClient::NotifyDecoderSupportKnown(
mojo::PendingRemote<stable::mojom::StableVideoDecoder> oop_video_decoder,
base::OnceCallback<
void(mojo::PendingRemote<stable::mojom::StableVideoDecoder>)> cb) { … }
#endif
std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
scoped_refptr<base::SequencedTaskRunner> task_runner,
MediaLog* media_log,
mojom::CommandBufferIdPtr command_buffer_id,
RequestOverlayInfoCB request_overlay_info_cb,
const gfx::ColorSpace& target_color_space,
mojo::PendingRemote<stable::mojom::StableVideoDecoder> oop_video_decoder) { … }
std::unique_ptr<CdmFactory> GpuMojoMediaClient::CreateCdmFactory(
mojom::FrameInterfaceFactory* frame_interfaces) { … }
std::unique_ptr<AudioDecoder> GpuMojoMediaClient::CreatePlatformAudioDecoder(
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::unique_ptr<MediaLog> media_log) { … }
std::unique_ptr<AudioEncoder> GpuMojoMediaClient::CreatePlatformAudioEncoder(
scoped_refptr<base::SequencedTaskRunner> task_runner) { … }
std::unique_ptr<CdmFactory> GpuMojoMediaClient::CreatePlatformCdmFactory(
mojom::FrameInterfaceFactory* frame_interfaces) { … }
std::optional<SupportedAudioDecoderConfigs>
GpuMojoMediaClient::GetPlatformSupportedAudioDecoderConfigs() { … }
}