OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/sequenced_task_runner_helpers.h" | 20 #include "base/sequenced_task_runner_helpers.h" |
21 #include "media/base/android/media_drm_bridge_cdm_context.h" | 21 #include "media/base/android/media_drm_bridge_cdm_context.h" |
| 22 #include "media/base/android/media_drm_storage.h" |
22 #include "media/base/cdm_promise.h" | 23 #include "media/base/cdm_promise.h" |
23 #include "media/base/cdm_promise_adapter.h" | 24 #include "media/base/cdm_promise_adapter.h" |
24 #include "media/base/content_decryption_module.h" | 25 #include "media/base/content_decryption_module.h" |
25 #include "media/base/media_export.h" | 26 #include "media/base/media_export.h" |
26 #include "media/base/player_tracker.h" | 27 #include "media/base/player_tracker.h" |
27 #include "media/base/provision_fetcher.h" | 28 #include "media/base/provision_fetcher.h" |
28 #include "media/cdm/player_tracker_impl.h" | 29 #include "media/cdm/player_tracker_impl.h" |
29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
30 | 31 |
31 namespace base { | 32 namespace base { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 static std::vector<std::string> GetPlatformKeySystemNames(); | 88 static std::vector<std::string> GetPlatformKeySystemNames(); |
88 | 89 |
89 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are | 90 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are |
90 // supported, and nullptr otherwise. The default security level will be used | 91 // supported, and nullptr otherwise. The default security level will be used |
91 // if |security_level| is SECURITY_LEVEL_DEFAULT. | 92 // if |security_level| is SECURITY_LEVEL_DEFAULT. |
92 static scoped_refptr<MediaDrmBridge> Create( | 93 static scoped_refptr<MediaDrmBridge> Create( |
93 const std::string& key_system, | 94 const std::string& key_system, |
94 const GURL& security_origin, | 95 const GURL& security_origin, |
95 SecurityLevel security_level, | 96 SecurityLevel security_level, |
96 const CreateFetcherCB& create_fetcher_cb, | 97 const CreateFetcherCB& create_fetcher_cb, |
| 98 const CreateStorageCB& create_storage_cb, |
97 const SessionMessageCB& session_message_cb, | 99 const SessionMessageCB& session_message_cb, |
98 const SessionClosedCB& session_closed_cb, | 100 const SessionClosedCB& session_closed_cb, |
99 const SessionKeysChangeCB& session_keys_change_cb, | 101 const SessionKeysChangeCB& session_keys_change_cb, |
100 const SessionExpirationUpdateCB& session_expiration_update_cb); | 102 const SessionExpirationUpdateCB& session_expiration_update_cb); |
101 | 103 |
102 // Same as Create() except that no session callbacks are provided. This is | 104 // Same as Create() except that no session callbacks are provided. This is |
103 // used when we need to use MediaDrmBridge without creating any sessions. | 105 // used when we need to use MediaDrmBridge without creating any sessions. |
104 // TODO(yucliu): Pass |security_origin| here to clear per-origin certs and | 106 // TODO(yucliu): Pass |security_origin| here to clear per-origin certs and |
105 // licenses. | 107 // licenses. |
106 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( | 108 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 236 |
235 private: | 237 private: |
236 // For DeleteSoon() in DeleteOnCorrectThread(). | 238 // For DeleteSoon() in DeleteOnCorrectThread(). |
237 friend class base::DeleteHelper<MediaDrmBridge>; | 239 friend class base::DeleteHelper<MediaDrmBridge>; |
238 | 240 |
239 static scoped_refptr<MediaDrmBridge> CreateInternal( | 241 static scoped_refptr<MediaDrmBridge> CreateInternal( |
240 const std::string& key_system, | 242 const std::string& key_system, |
241 const GURL& security_origin, | 243 const GURL& security_origin, |
242 SecurityLevel security_level, | 244 SecurityLevel security_level, |
243 const CreateFetcherCB& create_fetcher_cb, | 245 const CreateFetcherCB& create_fetcher_cb, |
| 246 const CreateStorageCB& create_storage_cb, |
244 const SessionMessageCB& session_message_cb, | 247 const SessionMessageCB& session_message_cb, |
245 const SessionClosedCB& session_closed_cb, | 248 const SessionClosedCB& session_closed_cb, |
246 const SessionKeysChangeCB& session_keys_change_cb, | 249 const SessionKeysChangeCB& session_keys_change_cb, |
247 const SessionExpirationUpdateCB& session_expiration_update_cb); | 250 const SessionExpirationUpdateCB& session_expiration_update_cb); |
248 | 251 |
249 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The | 252 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The |
250 // default security level will be used if |security_level| is | 253 // default security level will be used if |security_level| is |
251 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks | 254 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks |
252 // are null. | 255 // are null. |
253 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, | 256 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, |
254 const GURL& security_origin, | 257 const GURL& security_origin, |
255 SecurityLevel security_level, | 258 SecurityLevel security_level, |
256 const CreateFetcherCB& create_fetcher_cb, | 259 const CreateFetcherCB& create_fetcher_cb, |
| 260 const CreateStorageCB& create_storage_cb, |
257 const SessionMessageCB& session_message_cb, | 261 const SessionMessageCB& session_message_cb, |
258 const SessionClosedCB& session_closed_cb, | 262 const SessionClosedCB& session_closed_cb, |
259 const SessionKeysChangeCB& session_keys_change_cb, | 263 const SessionKeysChangeCB& session_keys_change_cb, |
260 const SessionExpirationUpdateCB& session_expiration_update_cb); | 264 const SessionExpirationUpdateCB& session_expiration_update_cb); |
261 | 265 |
262 ~MediaDrmBridge() override; | 266 ~MediaDrmBridge() override; |
263 | 267 |
264 static bool IsSecureDecoderRequired(SecurityLevel security_level); | 268 static bool IsSecureDecoderRequired(SecurityLevel security_level); |
265 | 269 |
266 // Get the security level of the media. | 270 // Get the security level of the media. |
(...skipping 26 matching lines...) Expand all Loading... |
293 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). | 297 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). |
294 // !j_media_crypto_->is_null(): | 298 // !j_media_crypto_->is_null(): |
295 // MediaCrypto creation succeeded and it has been notified. | 299 // MediaCrypto creation succeeded and it has been notified. |
296 // j_media_crypto_->is_null(): | 300 // j_media_crypto_->is_null(): |
297 // MediaCrypto creation failed and it has been notified. | 301 // MediaCrypto creation failed and it has been notified. |
298 JavaObjectPtr j_media_crypto_; | 302 JavaObjectPtr j_media_crypto_; |
299 | 303 |
300 // The callback to create a ProvisionFetcher. | 304 // The callback to create a ProvisionFetcher. |
301 CreateFetcherCB create_fetcher_cb_; | 305 CreateFetcherCB create_fetcher_cb_; |
302 | 306 |
| 307 // The callback to create a MediaDrmStorage. |
| 308 CreateStorageCB create_storage_cb_; |
| 309 |
303 // The ProvisionFetcher that requests and receives provisioning data. | 310 // The ProvisionFetcher that requests and receives provisioning data. |
304 // Non-null iff when a provision request is pending. | 311 // Non-null iff when a provision request is pending. |
305 std::unique_ptr<ProvisionFetcher> provision_fetcher_; | 312 std::unique_ptr<ProvisionFetcher> provision_fetcher_; |
306 | 313 |
307 // Callbacks for firing session events. | 314 // Callbacks for firing session events. |
308 SessionMessageCB session_message_cb_; | 315 SessionMessageCB session_message_cb_; |
309 SessionClosedCB session_closed_cb_; | 316 SessionClosedCB session_closed_cb_; |
310 SessionKeysChangeCB session_keys_change_cb_; | 317 SessionKeysChangeCB session_keys_change_cb_; |
311 SessionExpirationUpdateCB session_expiration_update_cb_; | 318 SessionExpirationUpdateCB session_expiration_update_cb_; |
312 | 319 |
(...skipping 12 matching lines...) Expand all Loading... |
325 | 332 |
326 // NOTE: Weak pointers must be invalidated before all other member variables. | 333 // NOTE: Weak pointers must be invalidated before all other member variables. |
327 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; | 334 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; |
328 | 335 |
329 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 336 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
330 }; | 337 }; |
331 | 338 |
332 } // namespace media | 339 } // namespace media |
333 | 340 |
334 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 341 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
OLD | NEW |