[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / cdm_service.h
1 // Copyright 2014 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 #ifndef MEDIA_MOJO_SERVICES_CDM_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_CDM_SERVICE_H_
7
8 #include <memory>
9
10 #include "build/build_config.h"
11 #include "media/media_buildflags.h"
12 #include "media/mojo/mojom/cdm_service.mojom.h"
13 #include "media/mojo/mojom/content_decryption_module.mojom.h"
14 #include "media/mojo/mojom/frame_interface_factory.mojom.h"
15 #include "media/mojo/services/deferred_destroy_unique_receiver_set.h"
16 #include "media/mojo/services/media_mojo_export.h"
17 #include "mojo/public/cpp/bindings/pending_receiver.h"
18 #include "mojo/public/cpp/bindings/pending_remote.h"
19 #include "mojo/public/cpp/bindings/receiver.h"
20
21 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
22 #include "media/cdm/cdm_host_file.h"
23 #endif
24
25 namespace media {
26
27 class CdmFactory;
28
29 class MEDIA_MOJO_EXPORT CdmService final : public mojom::CdmService {
30  public:
31   class Client {
32    public:
33     virtual ~Client() {}
34
35     // Called by the MediaService to ensure the process is sandboxed. It could
36     // be a no-op if the process is already sandboxed.
37     virtual void EnsureSandboxed() = 0;
38
39     // Returns the CdmFactory to be used by MojoCdmService. |frame_interfaces|
40     // can be used to request interfaces provided remotely by the host. It may
41     // be a nullptr if the host chose not to bind the InterfacePtr.
42     virtual std::unique_ptr<CdmFactory> CreateCdmFactory(
43         mojom::FrameInterfaceFactory* frame_interfaces) = 0;
44
45 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
46     // Gets a list of CDM host file paths and put them in |cdm_host_file_paths|.
47     virtual void AddCdmHostFilePaths(
48         std::vector<CdmHostFilePath>* cdm_host_file_paths) = 0;
49 #endif  // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
50   };
51
52   CdmService(std::unique_ptr<Client> client,
53              mojo::PendingReceiver<mojom::CdmService> receiver);
54   CdmService(const CdmService&) = delete;
55   CdmService operator=(const CdmService&) = delete;
56   ~CdmService() final;
57
58   size_t BoundCdmFactorySizeForTesting() const {
59     return cdm_factory_receivers_.size();
60   }
61
62   size_t UnboundCdmFactorySizeForTesting() const {
63     return cdm_factory_receivers_.unbound_size();
64   }
65
66   // mojom::CdmService implementation.
67   void CreateCdmFactory(
68       mojo::PendingReceiver<mojom::CdmFactory> receiver,
69       mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) final;
70
71  private:
72   mojo::Receiver<mojom::CdmService> receiver_;
73   std::unique_ptr<Client> client_;
74   std::unique_ptr<CdmFactory> cdm_factory_;
75   DeferredDestroyUniqueReceiverSet<mojom::CdmFactory> cdm_factory_receivers_;
76 };
77
78 }  // namespace media
79
80 #endif  // MEDIA_MOJO_SERVICES_CDM_SERVICE_H_