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

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

Issue 2765343003: media: Add MediaDrmStorage (Closed)
Patch Set: Created 3 years, 9 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
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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // are not handled by Chrome explicitly. 87 // are not handled by Chrome explicitly.
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 SecurityLevel security_level, 95 SecurityLevel security_level,
95 const CreateFetcherCB& create_fetcher_cb, 96 const CreateFetcherCB& create_fetcher_cb,
97 const CreateStorageCB& create_storage_cb,
96 const SessionMessageCB& session_message_cb, 98 const SessionMessageCB& session_message_cb,
97 const SessionClosedCB& session_closed_cb, 99 const SessionClosedCB& session_closed_cb,
98 const SessionKeysChangeCB& session_keys_change_cb, 100 const SessionKeysChangeCB& session_keys_change_cb,
99 const SessionExpirationUpdateCB& session_expiration_update_cb); 101 const SessionExpirationUpdateCB& session_expiration_update_cb);
100 102
101 // Same as Create() except that no session callbacks are provided. This is 103 // Same as Create() except that no session callbacks are provided. This is
102 // used when we need to use MediaDrmBridge without creating any sessions. 104 // used when we need to use MediaDrmBridge without creating any sessions.
103 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( 105 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport(
104 const std::string& key_system, 106 const std::string& key_system,
105 SecurityLevel security_level, 107 SecurityLevel security_level,
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 bool success); 232 bool success);
231 233
232 private: 234 private:
233 // For DeleteSoon() in DeleteOnCorrectThread(). 235 // For DeleteSoon() in DeleteOnCorrectThread().
234 friend class base::DeleteHelper<MediaDrmBridge>; 236 friend class base::DeleteHelper<MediaDrmBridge>;
235 237
236 static scoped_refptr<MediaDrmBridge> CreateInternal( 238 static scoped_refptr<MediaDrmBridge> CreateInternal(
237 const std::string& key_system, 239 const std::string& key_system,
238 SecurityLevel security_level, 240 SecurityLevel security_level,
239 const CreateFetcherCB& create_fetcher_cb, 241 const CreateFetcherCB& create_fetcher_cb,
242 const CreateStorageCB& create_storage_cb,
240 const SessionMessageCB& session_message_cb, 243 const SessionMessageCB& session_message_cb,
241 const SessionClosedCB& session_closed_cb, 244 const SessionClosedCB& session_closed_cb,
242 const SessionKeysChangeCB& session_keys_change_cb, 245 const SessionKeysChangeCB& session_keys_change_cb,
243 const SessionExpirationUpdateCB& session_expiration_update_cb); 246 const SessionExpirationUpdateCB& session_expiration_update_cb);
244 247
245 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The 248 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The
246 // default security level will be used if |security_level| is 249 // default security level will be used if |security_level| is
247 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks 250 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks
248 // are null. 251 // are null.
249 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, 252 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid,
250 SecurityLevel security_level, 253 SecurityLevel security_level,
251 const CreateFetcherCB& create_fetcher_cb, 254 const CreateFetcherCB& create_fetcher_cb,
255 const CreateStorageCB& create_storage_cb,
252 const SessionMessageCB& session_message_cb, 256 const SessionMessageCB& session_message_cb,
253 const SessionClosedCB& session_closed_cb, 257 const SessionClosedCB& session_closed_cb,
254 const SessionKeysChangeCB& session_keys_change_cb, 258 const SessionKeysChangeCB& session_keys_change_cb,
255 const SessionExpirationUpdateCB& session_expiration_update_cb); 259 const SessionExpirationUpdateCB& session_expiration_update_cb);
256 260
257 ~MediaDrmBridge() override; 261 ~MediaDrmBridge() override;
258 262
259 static bool IsSecureDecoderRequired(SecurityLevel security_level); 263 static bool IsSecureDecoderRequired(SecurityLevel security_level);
260 264
261 // Get the security level of the media. 265 // Get the security level of the media.
262 SecurityLevel GetSecurityLevel(); 266 SecurityLevel GetSecurityLevel();
263 267
264 // A helper method to create a JavaObjectPtr. 268 // A helper method to create a JavaObjectPtr.
265 JavaObjectPtr CreateJavaObjectPtr(jobject object); 269 JavaObjectPtr CreateJavaObjectPtr(jobject object);
266 270
267 // A helper method that is called when MediaCrypto is ready. 271 // A helper method that is called when MediaCrypto is ready.
268 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto); 272 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto);
269 273
270 // Sends HTTP provisioning request to a provisioning server. 274 // Sends HTTP provisioning request to a provisioning server.
271 void SendProvisioningRequest(const std::string& default_url, 275 void SendProvisioningRequest(const std::string& default_url,
272 const std::string& request_data); 276 const std::string& request_data);
273 277
274 // Process the data received by provisioning server. 278 // Process the data received by provisioning server.
275 void ProcessProvisionResponse(bool success, const std::string& response); 279 void ProcessProvisionResponse(bool success, const std::string& response);
276 280
277 // Called on the |task_runner_| when there is additional usable key. 281 // Called on the |task_runner_| when there is additional usable key.
278 void OnHasAdditionalUsableKey(); 282 void OnHasAdditionalUsableKey();
279 283
284 void OnStorageResult(bool);
285
280 // UUID of the key system. 286 // UUID of the key system.
281 std::vector<uint8_t> scheme_uuid_; 287 std::vector<uint8_t> scheme_uuid_;
282 288
283 // Java MediaDrm instance. 289 // Java MediaDrm instance.
284 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 290 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
285 291
286 // Java MediaCrypto instance. Possible values are: 292 // Java MediaCrypto instance. Possible values are:
287 // !j_media_crypto_: 293 // !j_media_crypto_:
288 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). 294 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady().
289 // !j_media_crypto_->is_null(): 295 // !j_media_crypto_->is_null():
290 // MediaCrypto creation succeeded and it has been notified. 296 // MediaCrypto creation succeeded and it has been notified.
291 // j_media_crypto_->is_null(): 297 // j_media_crypto_->is_null():
292 // MediaCrypto creation failed and it has been notified. 298 // MediaCrypto creation failed and it has been notified.
293 JavaObjectPtr j_media_crypto_; 299 JavaObjectPtr j_media_crypto_;
294 300
295 // The callback to create a ProvisionFetcher. 301 // The callback to create a ProvisionFetcher.
296 CreateFetcherCB create_fetcher_cb_; 302 CreateFetcherCB create_fetcher_cb_;
297 303
304 // The callback to create a MediaDrmStorage.
305 CreateStorageCB create_storage_cb_;
306
298 // The ProvisionFetcher that requests and receives provisioning data. 307 // The ProvisionFetcher that requests and receives provisioning data.
299 // Non-null iff when a provision request is pending. 308 // Non-null iff when a provision request is pending.
300 std::unique_ptr<ProvisionFetcher> provision_fetcher_; 309 std::unique_ptr<ProvisionFetcher> provision_fetcher_;
301 310
311 std::unique_ptr<MediaDrmStorage> media_drm_storage_;
312
302 // Callbacks for firing session events. 313 // Callbacks for firing session events.
303 SessionMessageCB session_message_cb_; 314 SessionMessageCB session_message_cb_;
304 SessionClosedCB session_closed_cb_; 315 SessionClosedCB session_closed_cb_;
305 SessionKeysChangeCB session_keys_change_cb_; 316 SessionKeysChangeCB session_keys_change_cb_;
306 SessionExpirationUpdateCB session_expiration_update_cb_; 317 SessionExpirationUpdateCB session_expiration_update_cb_;
307 318
308 MediaCryptoReadyCB media_crypto_ready_cb_; 319 MediaCryptoReadyCB media_crypto_ready_cb_;
309 320
310 ResetCredentialsCB reset_credentials_cb_; 321 ResetCredentialsCB reset_credentials_cb_;
311 322
312 PlayerTrackerImpl player_tracker_; 323 PlayerTrackerImpl player_tracker_;
313 324
314 CdmPromiseAdapter cdm_promise_adapter_; 325 CdmPromiseAdapter cdm_promise_adapter_;
315 326
316 // Default task runner. 327 // Default task runner.
317 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 328 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
318 329
319 MediaDrmBridgeCdmContext media_drm_bridge_cdm_context_; 330 MediaDrmBridgeCdmContext media_drm_bridge_cdm_context_;
320 331
321 // NOTE: Weak pointers must be invalidated before all other member variables. 332 // NOTE: Weak pointers must be invalidated before all other member variables.
322 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; 333 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
323 334
324 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 335 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
325 }; 336 };
326 337
327 } // namespace media 338 } // namespace media
328 339
329 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 340 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698