[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / cdm_service_broker.h
1 // Copyright 2021 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_BROKER_H_
6 #define MEDIA_MOJO_SERVICES_CDM_SERVICE_BROKER_H_
7
8 #include <memory>
9
10 #include "build/build_config.h"
11 #include "media/mojo/mojom/cdm_service.mojom.h"
12 #include "media/mojo/services/cdm_service.h"
13 #include "media/mojo/services/media_mojo_export.h"
14 #include "mojo/public/cpp/bindings/pending_receiver.h"
15 #include "mojo/public/cpp/bindings/pending_remote.h"
16 #include "mojo/public/cpp/bindings/receiver.h"
17
18 namespace media {
19
20 class MEDIA_MOJO_EXPORT CdmServiceBroker final
21     : public mojom::CdmServiceBroker {
22  public:
23   CdmServiceBroker(std::unique_ptr<CdmService::Client> client,
24                    mojo::PendingReceiver<mojom::CdmServiceBroker> receiver);
25   CdmServiceBroker(const CdmServiceBroker&) = delete;
26   CdmServiceBroker operator=(const CdmServiceBroker&) = delete;
27   ~CdmServiceBroker() final;
28
29   // mojom::CdmServiceBroker implementation:
30   void GetService(
31       const base::FilePath& cdm_path,
32 #if BUILDFLAG(IS_MAC)
33       mojo::PendingRemote<mojom::SeatbeltExtensionTokenProvider> token_provider,
34 #endif  // BUILDFLAG(IS_MAC)
35       mojo::PendingReceiver<mojom::CdmService> service_receiver) final;
36
37  private:
38   // Initializes CdmModule and make sure the sandbox is sealed. Returns whether
39   // the initialization succeeded or not. In all cases, the process is sandboxed
40   // after this call.
41   bool InitializeAndEnsureSandboxed(
42 #if BUILDFLAG(IS_MAC)
43       mojo::PendingRemote<mojom::SeatbeltExtensionTokenProvider> token_provider,
44 #endif  // BUILDFLAG(IS_MAC)
45       const base::FilePath& cdm_path);
46
47   std::unique_ptr<CdmService::Client> client_;
48   mojo::Receiver<mojom::CdmServiceBroker> receiver_;
49   std::unique_ptr<CdmService> cdm_service_;
50 };
51
52 }  // namespace media
53
54 #endif  // MEDIA_MOJO_SERVICES_CDM_SERVICE_BROKER_H_