Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(788)

Side by Side Diff: media/base/android/media_drm_bridge.h

Issue 2823513002: [Clank] Load origin id before create MediaDrmBridge (Closed)
Patch Set: Rebase + Nit Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/android/android_cdm_factory.cc ('k') | media/base/android/media_drm_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // |requires_secure_video_codec| - true if secure video decoder is required 66 // |requires_secure_video_codec| - true if secure video decoder is required
67 using MediaCryptoReadyCB = 67 using MediaCryptoReadyCB =
68 base::Callback<void(JavaObjectPtr media_crypto, 68 base::Callback<void(JavaObjectPtr media_crypto,
69 bool requires_secure_video_codec)>; 69 bool requires_secure_video_codec)>;
70 70
71 using CreatedCB = base::OnceCallback<void(scoped_refptr<MediaDrmBridge>)>;
72
71 // Checks whether MediaDRM is available and usable, including for decoding. 73 // Checks whether MediaDRM is available and usable, including for decoding.
72 // All other static methods check IsAvailable() or equivalent internally. 74 // All other static methods check IsAvailable() or equivalent internally.
73 // There is no need to check IsAvailable() explicitly before calling them. 75 // There is no need to check IsAvailable() explicitly before calling them.
74 static bool IsAvailable(); 76 static bool IsAvailable();
75 77
76 static bool RegisterMediaDrmBridge(JNIEnv* env); 78 static bool RegisterMediaDrmBridge(JNIEnv* env);
77 79
78 // Checks whether |key_system| is supported. 80 // Checks whether |key_system| is supported.
79 static bool IsKeySystemSupported(const std::string& key_system); 81 static bool IsKeySystemSupported(const std::string& key_system);
80 82
81 // Checks whether |key_system| is supported with |container_mime_type|. 83 // Checks whether |key_system| is supported with |container_mime_type|.
82 // |container_mime_type| must not be empty. 84 // |container_mime_type| must not be empty.
83 static bool IsKeySystemSupportedWithType( 85 static bool IsKeySystemSupportedWithType(
84 const std::string& key_system, 86 const std::string& key_system,
85 const std::string& container_mime_type); 87 const std::string& container_mime_type);
86 88
87 static bool IsPersistentLicenseTypeSupported(const std::string& key_system); 89 static bool IsPersistentLicenseTypeSupported(const std::string& key_system);
88 90
89 // Returns the list of the platform-supported key system names that 91 // Returns the list of the platform-supported key system names that
90 // are not handled by Chrome explicitly. 92 // are not handled by Chrome explicitly.
91 static std::vector<std::string> GetPlatformKeySystemNames(); 93 static std::vector<std::string> GetPlatformKeySystemNames();
92 94
93 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are 95 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are
94 // supported, and nullptr otherwise. The default security level will be used 96 // supported, and nullptr otherwise. The default security level will be used
95 // if |security_level| is SECURITY_LEVEL_DEFAULT. 97 // if |security_level| is SECURITY_LEVEL_DEFAULT.
96 static scoped_refptr<MediaDrmBridge> Create( 98 static void Create(
97 const std::string& key_system, 99 const std::string& key_system,
98 const GURL& security_origin, 100 const GURL& security_origin,
99 SecurityLevel security_level, 101 SecurityLevel security_level,
100 const CreateFetcherCB& create_fetcher_cb, 102 const CreateFetcherCB& create_fetcher_cb,
101 const CreateStorageCB& create_storage_cb, 103 const CreateStorageCB& create_storage_cb,
102 const SessionMessageCB& session_message_cb, 104 const SessionMessageCB& session_message_cb,
103 const SessionClosedCB& session_closed_cb, 105 const SessionClosedCB& session_closed_cb,
104 const SessionKeysChangeCB& session_keys_change_cb, 106 const SessionKeysChangeCB& session_keys_change_cb,
105 const SessionExpirationUpdateCB& session_expiration_update_cb); 107 const SessionExpirationUpdateCB& session_expiration_update_cb,
108 CreatedCB created_cb);
106 109
107 // 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
108 // used when we need to use MediaDrmBridge without creating any sessions. 111 // used when we need to use MediaDrmBridge without creating any sessions.
109 // 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
110 // licenses. 113 // licenses.
111 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( 114 static void CreateWithoutSessionSupport(
112 const std::string& key_system, 115 const std::string& key_system,
113 SecurityLevel security_level, 116 SecurityLevel security_level,
114 const CreateFetcherCB& create_fetcher_cb); 117 const CreateFetcherCB& create_fetcher_cb,
118 CreatedCB created_cb);
115 119
116 // ContentDecryptionModule implementation. 120 // ContentDecryptionModule implementation.
117 void SetServerCertificate( 121 void SetServerCertificate(
118 const std::vector<uint8_t>& certificate, 122 const std::vector<uint8_t>& certificate,
119 std::unique_ptr<media::SimpleCdmPromise> promise) override; 123 std::unique_ptr<media::SimpleCdmPromise> promise) override;
120 void CreateSessionAndGenerateRequest( 124 void CreateSessionAndGenerateRequest(
121 CdmSessionType session_type, 125 CdmSessionType session_type,
122 media::EmeInitDataType init_data_type, 126 media::EmeInitDataType init_data_type,
123 const std::vector<uint8_t>& init_data, 127 const std::vector<uint8_t>& init_data,
124 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
239 // Called by the java object when credential reset is completed. 243 // Called by the java object when credential reset is completed.
240 void OnResetDeviceCredentialsCompleted( 244 void OnResetDeviceCredentialsCompleted(
241 JNIEnv* env, 245 JNIEnv* env,
242 const base::android::JavaParamRef<jobject>&, 246 const base::android::JavaParamRef<jobject>&,
243 bool success); 247 bool success);
244 248
245 private: 249 private:
246 // For DeleteSoon() in DeleteOnCorrectThread(). 250 // For DeleteSoon() in DeleteOnCorrectThread().
247 friend class base::DeleteHelper<MediaDrmBridge>; 251 friend class base::DeleteHelper<MediaDrmBridge>;
248 252
249 static scoped_refptr<MediaDrmBridge> CreateInternal( 253 static void CreateInternal(
250 const std::string& key_system, 254 const std::vector<uint8_t>& scheme_uuid,
251 const GURL& security_origin,
252 SecurityLevel security_level, 255 SecurityLevel security_level,
256 std::unique_ptr<MediaDrmStorageBridge> storage,
253 const CreateFetcherCB& create_fetcher_cb, 257 const CreateFetcherCB& create_fetcher_cb,
254 const CreateStorageCB& create_storage_cb,
255 const SessionMessageCB& session_message_cb, 258 const SessionMessageCB& session_message_cb,
256 const SessionClosedCB& session_closed_cb, 259 const SessionClosedCB& session_closed_cb,
257 const SessionKeysChangeCB& session_keys_change_cb, 260 const SessionKeysChangeCB& session_keys_change_cb,
258 const SessionExpirationUpdateCB& session_expiration_update_cb); 261 const SessionExpirationUpdateCB& session_expiration_update_cb,
262 CreatedCB bound_cdm_created_cb);
259 263
260 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The 264 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The
261 // default security level will be used if |security_level| is 265 // default security level will be used if |security_level| is
262 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks 266 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks
263 // are null. 267 // are null.
264 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, 268 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid,
265 const GURL& security_origin,
266 SecurityLevel security_level, 269 SecurityLevel security_level,
270 std::unique_ptr<MediaDrmStorageBridge> storage,
267 const CreateFetcherCB& create_fetcher_cb, 271 const CreateFetcherCB& create_fetcher_cb,
268 const CreateStorageCB& create_storage_cb,
269 const SessionMessageCB& session_message_cb, 272 const SessionMessageCB& session_message_cb,
270 const SessionClosedCB& session_closed_cb, 273 const SessionClosedCB& session_closed_cb,
271 const SessionKeysChangeCB& session_keys_change_cb, 274 const SessionKeysChangeCB& session_keys_change_cb,
272 const SessionExpirationUpdateCB& session_expiration_update_cb); 275 const SessionExpirationUpdateCB& session_expiration_update_cb);
273 276
274 ~MediaDrmBridge() override; 277 ~MediaDrmBridge() override;
275 278
276 // Get the security level of the media. 279 // Get the security level of the media.
277 SecurityLevel GetSecurityLevel(); 280 SecurityLevel GetSecurityLevel();
278 281
279 // A helper method that is called when MediaCrypto is ready. 282 // A helper method that is called when MediaCrypto is ready.
280 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto); 283 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto);
281 284
282 // Sends HTTP provisioning request to a provisioning server. 285 // Sends HTTP provisioning request to a provisioning server.
283 void SendProvisioningRequest(const std::string& default_url, 286 void SendProvisioningRequest(const std::string& default_url,
284 const std::string& request_data); 287 const std::string& request_data);
285 288
286 // Process the data received by provisioning server. 289 // Process the data received by provisioning server.
287 void ProcessProvisionResponse(bool success, const std::string& response); 290 void ProcessProvisionResponse(bool success, const std::string& response);
288 291
289 // Called on the |task_runner_| when there is additional usable key. 292 // Called on the |task_runner_| when there is additional usable key.
290 void OnHasAdditionalUsableKey(); 293 void OnHasAdditionalUsableKey();
291 294
292 // UUID of the key system. 295 // UUID of the key system.
293 std::vector<uint8_t> scheme_uuid_; 296 std::vector<uint8_t> scheme_uuid_;
294 297
295 // Persistent storage for session ID map. 298 // Persistent storage for session ID map.
296 MediaDrmStorageBridge storage_; 299 std::unique_ptr<MediaDrmStorageBridge> storage_;
297 300
298 // Java MediaDrm instance. 301 // Java MediaDrm instance.
299 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 302 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
300 303
301 // Java MediaCrypto instance. Possible values are: 304 // Java MediaCrypto instance. Possible values are:
302 // !j_media_crypto_: 305 // !j_media_crypto_:
303 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). 306 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady().
304 // !j_media_crypto_->is_null(): 307 // !j_media_crypto_->is_null():
305 // MediaCrypto creation succeeded and it has been notified. 308 // MediaCrypto creation succeeded and it has been notified.
306 // j_media_crypto_->is_null(): 309 // j_media_crypto_->is_null():
(...skipping 28 matching lines...) Expand all
335 338
336 // NOTE: Weak pointers must be invalidated before all other member variables. 339 // NOTE: Weak pointers must be invalidated before all other member variables.
337 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; 340 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
338 341
339 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 342 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
340 }; 343 };
341 344
342 } // namespace media 345 } // namespace media
343 346
344 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 347 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW
« no previous file with comments | « media/base/android/android_cdm_factory.cc ('k') | media/base/android/media_drm_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698