OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "media/base/media_keys.h" | 12 #include "media/base/media_keys.h" |
13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
14 #include "media/mojo/services/mojo_cdm_promise.h" | 14 #include "media/mojo/services/mojo_cdm_promise.h" |
| 15 #include "media/mojo/services/mojo_cdm_service_context.h" |
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 16 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
16 #include "mojo/public/cpp/bindings/strong_binding.h" | 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 class CdmFactory; | 21 class CdmFactory; |
21 class MojoCdmServiceContext; | |
22 | 22 |
23 // A interfaces::ContentDecryptionModule implementation backed by a | 23 // A interfaces::ContentDecryptionModule implementation backed by a |
24 // media::MediaKeys. | 24 // media::MediaKeys. |
25 class MojoCdmService : public interfaces::ContentDecryptionModule { | 25 class MojoCdmService : public interfaces::ContentDecryptionModule { |
26 public: | 26 public: |
27 // Constructs a MojoCdmService and strongly binds it to the |request|. | 27 // Constructs a MojoCdmService and strongly binds it to the |request|. |
28 MojoCdmService( | 28 MojoCdmService( |
29 MojoCdmServiceContext* context, | 29 base::WeakPtr<MojoCdmServiceContext> context, |
30 mojo::ServiceProvider* service_provider, | 30 mojo::ServiceProvider* service_provider, |
31 CdmFactory* cdm_factory, | 31 CdmFactory* cdm_factory, |
32 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request); | 32 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request); |
33 | 33 |
34 ~MojoCdmService() final; | 34 ~MojoCdmService() final; |
35 | 35 |
36 // interfaces::ContentDecryptionModule implementation. | 36 // interfaces::ContentDecryptionModule implementation. |
37 void SetClient(interfaces::ContentDecryptionModuleClientPtr client) final; | 37 void SetClient(interfaces::ContentDecryptionModuleClientPtr client) final; |
38 void Initialize(const mojo::String& key_system, | 38 void Initialize(const mojo::String& key_system, |
39 const mojo::String& security_origin, | 39 const mojo::String& security_origin, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 CdmKeysInfo keys_info); | 91 CdmKeysInfo keys_info); |
92 void OnSessionExpirationUpdate(const std::string& session_id, | 92 void OnSessionExpirationUpdate(const std::string& session_id, |
93 const base::Time& new_expiry_time); | 93 const base::Time& new_expiry_time); |
94 void OnSessionClosed(const std::string& session_id); | 94 void OnSessionClosed(const std::string& session_id); |
95 void OnLegacySessionError(const std::string& session_id, | 95 void OnLegacySessionError(const std::string& session_id, |
96 MediaKeys::Exception exception, | 96 MediaKeys::Exception exception, |
97 uint32_t system_code, | 97 uint32_t system_code, |
98 const std::string& error_message); | 98 const std::string& error_message); |
99 | 99 |
100 mojo::StrongBinding<interfaces::ContentDecryptionModule> binding_; | 100 mojo::StrongBinding<interfaces::ContentDecryptionModule> binding_; |
101 MojoCdmServiceContext* context_; | 101 base::WeakPtr<MojoCdmServiceContext> context_; |
| 102 |
102 mojo::ServiceProvider* service_provider_; | 103 mojo::ServiceProvider* service_provider_; |
103 CdmFactory* cdm_factory_; | 104 CdmFactory* cdm_factory_; |
104 scoped_ptr<MediaKeys> cdm_; | 105 scoped_ptr<MediaKeys> cdm_; |
105 | 106 |
106 // Set to a valid CDM ID if the |cdm_| is successfully created. | 107 // Set to a valid CDM ID if the |cdm_| is successfully created. |
107 int cdm_id_; | 108 int cdm_id_; |
108 | 109 |
109 interfaces::ContentDecryptionModuleClientPtr client_; | 110 interfaces::ContentDecryptionModuleClientPtr client_; |
110 | 111 |
111 base::WeakPtr<MojoCdmService> weak_this_; | 112 base::WeakPtr<MojoCdmService> weak_this_; |
112 base::WeakPtrFactory<MojoCdmService> weak_factory_; | 113 base::WeakPtrFactory<MojoCdmService> weak_factory_; |
113 | 114 |
114 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); | 115 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); |
115 }; | 116 }; |
116 | 117 |
117 } // namespace media | 118 } // namespace media |
118 | 119 |
119 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 120 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
OLD | NEW |