[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / mojo_video_encode_accelerator_provider_factory.cc
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.
4
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"
12
13 namespace media {
14
15 MojoVideoEncodeAcceleratorProviderFactory::
16     MojoVideoEncodeAcceleratorProviderFactory()
17     : receiver_(this) {
18   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
19 }
20
21 MojoVideoEncodeAcceleratorProviderFactory::
22     ~MojoVideoEncodeAcceleratorProviderFactory() {
23   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
24 }
25
26 void MojoVideoEncodeAcceleratorProviderFactory::BindReceiver(
27     mojo::PendingReceiver<mojom::VideoEncodeAcceleratorProviderFactory>
28         receiver) {
29   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
30   DCHECK(!receiver_.is_bound());
31   receiver_.Bind(std::move(receiver));
32 }
33
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());
45
46   video_encoder_providers_.Add(std::move(provider), std::move(receiver));
47 }
48
49 }  // namespace media