Chromium Code Reviews| 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 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 using ResetCredentialsCB = base::Callback<void(bool)>; | 61 using ResetCredentialsCB = base::Callback<void(bool)>; |
| 62 | 62 |
| 63 // Notification called when MediaCrypto object is ready. | 63 // Notification called when MediaCrypto object is ready. |
| 64 // Parameters: | 64 // Parameters: |
| 65 // |media_crypto| - global reference to MediaCrypto object | 65 // |media_crypto| - global reference to MediaCrypto object |
| 66 // |needs_protected_surface| - true if protected surface is required. | 66 // |needs_protected_surface| - true if protected surface is required. |
| 67 using MediaCryptoReadyCB = base::Callback<void(JavaObjectPtr media_crypto, | 67 using MediaCryptoReadyCB = base::Callback<void(JavaObjectPtr media_crypto, |
| 68 bool needs_protected_surface)>; | 68 bool needs_protected_surface)>; |
| 69 | 69 |
| 70 using MediaDrmCreatedCB = | |
|
xhwang
2017/05/03 06:00:55
nit: how about just CreationCB? Or it needs to be
yucliu1
2017/05/10 20:41:38
Done.
| |
| 71 base::OnceCallback<void(scoped_refptr<MediaDrmBridge>)>; | |
| 72 | |
| 70 // Checks whether MediaDRM is available and usable, including for decoding. | 73 // Checks whether MediaDRM is available and usable, including for decoding. |
| 71 // All other static methods check IsAvailable() or equivalent internally. | 74 // All other static methods check IsAvailable() or equivalent internally. |
| 72 // There is no need to check IsAvailable() explicitly before calling them. | 75 // There is no need to check IsAvailable() explicitly before calling them. |
| 73 static bool IsAvailable(); | 76 static bool IsAvailable(); |
| 74 | 77 |
| 75 static bool RegisterMediaDrmBridge(JNIEnv* env); | 78 static bool RegisterMediaDrmBridge(JNIEnv* env); |
| 76 | 79 |
| 77 // Checks whether |key_system| is supported. | 80 // Checks whether |key_system| is supported. |
| 78 static bool IsKeySystemSupported(const std::string& key_system); | 81 static bool IsKeySystemSupported(const std::string& key_system); |
| 79 | 82 |
| 80 // Checks whether |key_system| is supported with |container_mime_type|. | 83 // Checks whether |key_system| is supported with |container_mime_type|. |
| 81 // |container_mime_type| must not be empty. | 84 // |container_mime_type| must not be empty. |
| 82 static bool IsKeySystemSupportedWithType( | 85 static bool IsKeySystemSupportedWithType( |
| 83 const std::string& key_system, | 86 const std::string& key_system, |
| 84 const std::string& container_mime_type); | 87 const std::string& container_mime_type); |
| 85 | 88 |
| 86 static bool IsPersistentLicenseTypeSupported(const std::string& key_system); | 89 static bool IsPersistentLicenseTypeSupported(const std::string& key_system); |
| 87 | 90 |
| 88 // Returns the list of the platform-supported key system names that | 91 // Returns the list of the platform-supported key system names that |
| 89 // are not handled by Chrome explicitly. | 92 // are not handled by Chrome explicitly. |
| 90 static std::vector<std::string> GetPlatformKeySystemNames(); | 93 static std::vector<std::string> GetPlatformKeySystemNames(); |
| 91 | 94 |
| 92 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are | 95 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are |
| 93 // supported, and nullptr otherwise. The default security level will be used | 96 // supported, and nullptr otherwise. The default security level will be used |
| 94 // if |security_level| is SECURITY_LEVEL_DEFAULT. | 97 // if |security_level| is SECURITY_LEVEL_DEFAULT. |
| 95 static scoped_refptr<MediaDrmBridge> Create( | 98 static void Create( |
| 96 const std::string& key_system, | 99 const std::string& key_system, |
| 97 const GURL& security_origin, | 100 const GURL& security_origin, |
| 98 SecurityLevel security_level, | 101 SecurityLevel security_level, |
| 99 const CreateFetcherCB& create_fetcher_cb, | 102 const CreateFetcherCB& create_fetcher_cb, |
| 100 const CreateStorageCB& create_storage_cb, | 103 const CreateStorageCB& create_storage_cb, |
| 101 const SessionMessageCB& session_message_cb, | 104 const SessionMessageCB& session_message_cb, |
| 102 const SessionClosedCB& session_closed_cb, | 105 const SessionClosedCB& session_closed_cb, |
| 103 const SessionKeysChangeCB& session_keys_change_cb, | 106 const SessionKeysChangeCB& session_keys_change_cb, |
| 104 const SessionExpirationUpdateCB& session_expiration_update_cb); | 107 const SessionExpirationUpdateCB& session_expiration_update_cb, |
| 108 MediaDrmCreatedCB bound_cdm_created_cb); | |
|
xhwang
2017/05/03 06:00:56
ditto, just "CreationCB creation_cb"? "bound" is r
yucliu1
2017/05/10 20:41:38
Done.
| |
| 105 | 109 |
| 106 // Same as Create() except that no session callbacks are provided. This is | 110 // Same as Create() except that no session callbacks are provided. This is |
| 107 // used when we need to use MediaDrmBridge without creating any sessions. | 111 // used when we need to use MediaDrmBridge without creating any sessions. |
| 108 // TODO(yucliu): Pass |security_origin| here to clear per-origin certs and | 112 // TODO(yucliu): Pass |security_origin| here to clear per-origin certs and |
| 109 // licenses. | 113 // licenses. |
| 110 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( | 114 static void CreateWithoutSessionSupport( |
| 111 const std::string& key_system, | 115 const std::string& key_system, |
| 112 SecurityLevel security_level, | 116 SecurityLevel security_level, |
| 113 const CreateFetcherCB& create_fetcher_cb); | 117 const CreateFetcherCB& create_fetcher_cb, |
| 118 MediaDrmCreatedCB media_drm_created_cb); | |
| 114 | 119 |
| 115 // ContentDecryptionModule implementation. | 120 // ContentDecryptionModule implementation. |
| 116 void SetServerCertificate( | 121 void SetServerCertificate( |
| 117 const std::vector<uint8_t>& certificate, | 122 const std::vector<uint8_t>& certificate, |
| 118 std::unique_ptr<media::SimpleCdmPromise> promise) override; | 123 std::unique_ptr<media::SimpleCdmPromise> promise) override; |
| 119 void CreateSessionAndGenerateRequest( | 124 void CreateSessionAndGenerateRequest( |
| 120 CdmSessionType session_type, | 125 CdmSessionType session_type, |
| 121 media::EmeInitDataType init_data_type, | 126 media::EmeInitDataType init_data_type, |
| 122 const std::vector<uint8_t>& init_data, | 127 const std::vector<uint8_t>& init_data, |
| 123 std::unique_ptr<media::NewSessionCdmPromise> promise) override; | 128 std::unique_ptr<media::NewSessionCdmPromise> promise) override; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // Called by the java object when credential reset is completed. | 243 // Called by the java object when credential reset is completed. |
| 239 void OnResetDeviceCredentialsCompleted( | 244 void OnResetDeviceCredentialsCompleted( |
| 240 JNIEnv* env, | 245 JNIEnv* env, |
| 241 const base::android::JavaParamRef<jobject>&, | 246 const base::android::JavaParamRef<jobject>&, |
| 242 bool success); | 247 bool success); |
| 243 | 248 |
| 244 private: | 249 private: |
| 245 // For DeleteSoon() in DeleteOnCorrectThread(). | 250 // For DeleteSoon() in DeleteOnCorrectThread(). |
| 246 friend class base::DeleteHelper<MediaDrmBridge>; | 251 friend class base::DeleteHelper<MediaDrmBridge>; |
| 247 | 252 |
| 248 static scoped_refptr<MediaDrmBridge> CreateInternal( | 253 static void CreateInternal( |
| 249 const std::string& key_system, | 254 const std::vector<uint8_t>& scheme_uuid, |
| 250 const GURL& security_origin, | |
| 251 SecurityLevel security_level, | 255 SecurityLevel security_level, |
| 256 std::unique_ptr<MediaDrmStorageBridge> storage, | |
| 252 const CreateFetcherCB& create_fetcher_cb, | 257 const CreateFetcherCB& create_fetcher_cb, |
| 253 const CreateStorageCB& create_storage_cb, | |
| 254 const SessionMessageCB& session_message_cb, | 258 const SessionMessageCB& session_message_cb, |
| 255 const SessionClosedCB& session_closed_cb, | 259 const SessionClosedCB& session_closed_cb, |
| 256 const SessionKeysChangeCB& session_keys_change_cb, | 260 const SessionKeysChangeCB& session_keys_change_cb, |
| 257 const SessionExpirationUpdateCB& session_expiration_update_cb); | 261 const SessionExpirationUpdateCB& session_expiration_update_cb, |
| 262 MediaDrmCreatedCB bound_cdm_created_cb); | |
| 258 | 263 |
| 259 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The | 264 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The |
| 260 // default security level will be used if |security_level| is | 265 // default security level will be used if |security_level| is |
| 261 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks | 266 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks |
| 262 // are null. | 267 // are null. |
| 263 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, | 268 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, |
| 264 const GURL& security_origin, | |
| 265 SecurityLevel security_level, | 269 SecurityLevel security_level, |
| 270 std::unique_ptr<MediaDrmStorageBridge> storage, | |
| 266 const CreateFetcherCB& create_fetcher_cb, | 271 const CreateFetcherCB& create_fetcher_cb, |
| 267 const CreateStorageCB& create_storage_cb, | |
| 268 const SessionMessageCB& session_message_cb, | 272 const SessionMessageCB& session_message_cb, |
| 269 const SessionClosedCB& session_closed_cb, | 273 const SessionClosedCB& session_closed_cb, |
| 270 const SessionKeysChangeCB& session_keys_change_cb, | 274 const SessionKeysChangeCB& session_keys_change_cb, |
| 271 const SessionExpirationUpdateCB& session_expiration_update_cb); | 275 const SessionExpirationUpdateCB& session_expiration_update_cb); |
| 272 | 276 |
| 273 ~MediaDrmBridge() override; | 277 ~MediaDrmBridge() override; |
| 274 | 278 |
| 275 static bool IsSecureDecoderRequired(SecurityLevel security_level); | 279 static bool IsSecureDecoderRequired(SecurityLevel security_level); |
| 276 | 280 |
| 277 // Get the security level of the media. | 281 // Get the security level of the media. |
| 278 SecurityLevel GetSecurityLevel(); | 282 SecurityLevel GetSecurityLevel(); |
| 279 | 283 |
| 280 // A helper method that is called when MediaCrypto is ready. | 284 // A helper method that is called when MediaCrypto is ready. |
| 281 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto); | 285 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto); |
| 282 | 286 |
| 283 // Sends HTTP provisioning request to a provisioning server. | 287 // Sends HTTP provisioning request to a provisioning server. |
| 284 void SendProvisioningRequest(const std::string& default_url, | 288 void SendProvisioningRequest(const std::string& default_url, |
| 285 const std::string& request_data); | 289 const std::string& request_data); |
| 286 | 290 |
| 287 // Process the data received by provisioning server. | 291 // Process the data received by provisioning server. |
| 288 void ProcessProvisionResponse(bool success, const std::string& response); | 292 void ProcessProvisionResponse(bool success, const std::string& response); |
| 289 | 293 |
| 290 // Called on the |task_runner_| when there is additional usable key. | 294 // Called on the |task_runner_| when there is additional usable key. |
| 291 void OnHasAdditionalUsableKey(); | 295 void OnHasAdditionalUsableKey(); |
| 292 | 296 |
| 293 // UUID of the key system. | 297 // UUID of the key system. |
| 294 std::vector<uint8_t> scheme_uuid_; | 298 std::vector<uint8_t> scheme_uuid_; |
| 295 | 299 |
| 296 // Persistent storage for session ID map. | 300 // Persistent storage for session ID map. It may or may not be bound to an |
| 297 MediaDrmStorageBridge storage_; | 301 // origin. |
| 302 std::unique_ptr<MediaDrmStorageBridge> storage_; | |
| 298 | 303 |
| 299 // Java MediaDrm instance. | 304 // Java MediaDrm instance. |
| 300 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; | 305 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; |
| 301 | 306 |
| 302 // Java MediaCrypto instance. Possible values are: | 307 // Java MediaCrypto instance. Possible values are: |
| 303 // !j_media_crypto_: | 308 // !j_media_crypto_: |
| 304 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). | 309 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). |
| 305 // !j_media_crypto_->is_null(): | 310 // !j_media_crypto_->is_null(): |
| 306 // MediaCrypto creation succeeded and it has been notified. | 311 // MediaCrypto creation succeeded and it has been notified. |
| 307 // j_media_crypto_->is_null(): | 312 // j_media_crypto_->is_null(): |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 336 | 341 |
| 337 // NOTE: Weak pointers must be invalidated before all other member variables. | 342 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 338 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; | 343 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; |
| 339 | 344 |
| 340 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 345 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
| 341 }; | 346 }; |
| 342 | 347 |
| 343 } // namespace media | 348 } // namespace media |
| 344 | 349 |
| 345 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 350 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
| OLD | NEW |