1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/mojo/services/mojo_video_encode_accelerator_provider_factory.h"
6 #include "gpu/config/gpu_driver_bug_workarounds.h"
7 #include "gpu/config/gpu_info.h"
8 #include "gpu/config/gpu_preferences.h"
9 #include "media/base/media_log.h"
10 #include "media/gpu/gpu_video_encode_accelerator_factory.h"
11 #include "media/mojo/services/mojo_video_encode_accelerator_provider.h"
15 MojoVideoEncodeAcceleratorProviderFactory::
16 MojoVideoEncodeAcceleratorProviderFactory()
18 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
21 MojoVideoEncodeAcceleratorProviderFactory::
22 ~MojoVideoEncodeAcceleratorProviderFactory() {
23 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
26 void MojoVideoEncodeAcceleratorProviderFactory::BindReceiver(
27 mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProviderFactory>
29 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
30 DCHECK(!receiver_.is_bound());
31 receiver_.Bind(std::move(receiver));
34 void MojoVideoEncodeAcceleratorProviderFactory::
35 CreateVideoEncodeAcceleratorProvider(
36 mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProvider> receiver) {
37 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
38 // TODO(b/248540499): pass useful gpu::GpuPreferences,
39 // gpu::GpuDriverBugWorkarounds, and gpu::GPUInfo::GPUDevice instances.
40 std::unique_ptr<mojom::VideoEncodeAcceleratorProvider> provider =
41 std::make_unique<MojoVideoEncodeAcceleratorProvider>(
42 base::BindRepeating(&GpuVideoEncodeAcceleratorFactory::CreateVEA),
43 gpu::GpuPreferences(), gpu::GpuDriverBugWorkarounds(),
44 gpu::GPUInfo::GPUDevice());
46 video_encoder_providers_.Add(std::move(provider), std::move(receiver));