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.
5 #ifndef MEDIA_MOJO_SERVICES_CDM_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_CDM_SERVICE_H_
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"
21 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
22 #include "media/cdm/cdm_host_file.h"
29 class MEDIA_MOJO_EXPORT CdmService final : public mojom::CdmService {
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;
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;
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)
52 CdmService(std::unique_ptr<Client> client,
53 mojo::PendingReceiver<mojom::CdmService> receiver);
54 CdmService(const CdmService&) = delete;
55 CdmService operator=(const CdmService&) = delete;
58 size_t BoundCdmFactorySizeForTesting() const {
59 return cdm_factory_receivers_.size();
62 size_t UnboundCdmFactorySizeForTesting() const {
63 return cdm_factory_receivers_.unbound_size();
66 // mojom::CdmService implementation.
67 void CreateCdmFactory(
68 mojo::PendingReceiver<mojom::CdmFactory> receiver,
69 mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) final;
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_;
80 #endif // MEDIA_MOJO_SERVICES_CDM_SERVICE_H_