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

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

Issue 1837143002: media: Pass MediaPermission to MediaDrmBridge Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More plumbing Created 4 years, 7 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 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 #include "media/base/media_export.h" 21 #include "media/base/media_export.h"
22 #include "media/base/media_keys.h" 22 #include "media/base/media_keys.h"
23 #include "media/base/player_tracker.h" 23 #include "media/base/player_tracker.h"
24 #include "media/cdm/player_tracker_impl.h" 24 #include "media/cdm/player_tracker_impl.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 class GURL; 27 class GURL;
28 28
29 namespace media { 29 namespace media {
30 30
31 class MediaPermission;
32
31 // Implements a CDM using Android MediaDrm API. 33 // Implements a CDM using Android MediaDrm API.
32 // 34 //
33 // Thread Safety: 35 // Thread Safety:
34 // 36 //
35 // This class lives on the thread where it is created. All methods must be 37 // This class lives on the thread where it is created. All methods must be
36 // called on the |task_runner_| except for the PlayerTracker methods and 38 // called on the |task_runner_| except for the PlayerTracker methods and
37 // SetMediaCryptoReadyCB(), which can be called on any thread. 39 // SetMediaCryptoReadyCB(), which can be called on any thread.
38 40
39 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys, public PlayerTracker { 41 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys, public PlayerTracker {
40 public: 42 public:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 76
75 // Returns the list of the platform-supported key system names that 77 // Returns the list of the platform-supported key system names that
76 // are not handled by Chrome explicitly. 78 // are not handled by Chrome explicitly.
77 static std::vector<std::string> GetPlatformKeySystemNames(); 79 static std::vector<std::string> GetPlatformKeySystemNames();
78 80
79 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are 81 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are
80 // supported, and nullptr otherwise. The default security level will be used 82 // supported, and nullptr otherwise. The default security level will be used
81 // if |security_level| is SECURITY_LEVEL_DEFAULT. 83 // if |security_level| is SECURITY_LEVEL_DEFAULT.
82 static scoped_refptr<MediaDrmBridge> Create( 84 static scoped_refptr<MediaDrmBridge> Create(
83 const std::string& key_system, 85 const std::string& key_system,
86 const GURL& security_origin,
84 SecurityLevel security_level, 87 SecurityLevel security_level,
88 MediaPermission* media_permission,
85 const CreateFetcherCB& create_fetcher_cb, 89 const CreateFetcherCB& create_fetcher_cb,
86 const SessionMessageCB& session_message_cb, 90 const SessionMessageCB& session_message_cb,
87 const SessionClosedCB& session_closed_cb, 91 const SessionClosedCB& session_closed_cb,
88 const LegacySessionErrorCB& legacy_session_error_cb, 92 const LegacySessionErrorCB& legacy_session_error_cb,
89 const SessionKeysChangeCB& session_keys_change_cb, 93 const SessionKeysChangeCB& session_keys_change_cb,
90 const SessionExpirationUpdateCB& session_expiration_update_cb); 94 const SessionExpirationUpdateCB& session_expiration_update_cb);
91 95
92 // Same as Create() except that no session callbacks are provided. This is 96 // Same as Create() except that no session callbacks are provided. This is
93 // used when we need to use MediaDrmBridge without creating any sessions. 97 // used when we need to use MediaDrmBridge without creating any sessions.
94 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( 98 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 JNIEnv* env, 244 JNIEnv* env,
241 const base::android::JavaParamRef<jobject>&, 245 const base::android::JavaParamRef<jobject>&,
242 bool success); 246 bool success);
243 247
244 private: 248 private:
245 // For DeleteSoon() in DeleteOnCorrectThread(). 249 // For DeleteSoon() in DeleteOnCorrectThread().
246 friend class base::DeleteHelper<MediaDrmBridge>; 250 friend class base::DeleteHelper<MediaDrmBridge>;
247 251
248 static scoped_refptr<MediaDrmBridge> CreateInternal( 252 static scoped_refptr<MediaDrmBridge> CreateInternal(
249 const std::string& key_system, 253 const std::string& key_system,
254 const GURL& security_origin,
250 SecurityLevel security_level, 255 SecurityLevel security_level,
256 MediaPermission* media_permission,
251 const CreateFetcherCB& create_fetcher_cb, 257 const CreateFetcherCB& create_fetcher_cb,
252 const SessionMessageCB& session_message_cb, 258 const SessionMessageCB& session_message_cb,
253 const SessionClosedCB& session_closed_cb, 259 const SessionClosedCB& session_closed_cb,
254 const LegacySessionErrorCB& legacy_session_error_cb, 260 const LegacySessionErrorCB& legacy_session_error_cb,
255 const SessionKeysChangeCB& session_keys_change_cb, 261 const SessionKeysChangeCB& session_keys_change_cb,
256 const SessionExpirationUpdateCB& session_expiration_update_cb); 262 const SessionExpirationUpdateCB& session_expiration_update_cb);
257 263
258 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The 264 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The
259 // default security level will be used if |security_level| is 265 // default security level will be used if |security_level| is
260 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks 266 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks
261 // are null. 267 // are null.
262 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, 268 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid,
269 const GURL& security_origin,
263 SecurityLevel security_level, 270 SecurityLevel security_level,
271 MediaPermission* media_permission,
264 const CreateFetcherCB& create_fetcher_cb, 272 const CreateFetcherCB& create_fetcher_cb,
265 const SessionMessageCB& session_message_cb, 273 const SessionMessageCB& session_message_cb,
266 const SessionClosedCB& session_closed_cb, 274 const SessionClosedCB& session_closed_cb,
267 const LegacySessionErrorCB& legacy_session_error_cb, 275 const LegacySessionErrorCB& legacy_session_error_cb,
268 const SessionKeysChangeCB& session_keys_change_cb, 276 const SessionKeysChangeCB& session_keys_change_cb,
269 const SessionExpirationUpdateCB& session_expiration_update_cb); 277 const SessionExpirationUpdateCB& session_expiration_update_cb);
270 278
271 ~MediaDrmBridge() override; 279 ~MediaDrmBridge() override;
272 280
273 static bool IsSecureDecoderRequired(SecurityLevel security_level); 281 static bool IsSecureDecoderRequired(SecurityLevel security_level);
274 282
275 // Get the security level of the media. 283 // Get the security level of the media.
276 SecurityLevel GetSecurityLevel(); 284 SecurityLevel GetSecurityLevel();
277 285
278 // A helper method to create a JavaObjectPtr. 286 // A helper method to create a JavaObjectPtr.
279 JavaObjectPtr CreateJavaObjectPtr(jobject object); 287 JavaObjectPtr CreateJavaObjectPtr(jobject object);
280 288
281 // A helper method that is called when MediaCrypto is ready. 289 // A helper method that is called when MediaCrypto is ready.
282 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto); 290 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto);
283 291
292 void CreateSessionAndGenerateRequestIfPermitted(
293 EmeInitDataType init_data_type,
294 const std::vector<uint8_t>& init_data,
295 scoped_ptr<NewSessionCdmPromise> promise,
296 bool permitted);
297
284 // Sends HTTP provisioning request to a provisioning server. 298 // Sends HTTP provisioning request to a provisioning server.
285 void SendProvisioningRequest(const std::string& default_url, 299 void SendProvisioningRequest(const std::string& default_url,
286 const std::string& request_data); 300 const std::string& request_data);
287 301
288 // Process the data received by provisioning server. 302 // Process the data received by provisioning server.
289 void ProcessProvisionResponse(bool success, const std::string& response); 303 void ProcessProvisionResponse(bool success, const std::string& response);
290 304
291 // Called on the |task_runner_| when there is additional usable key. 305 // Called on the |task_runner_| when there is additional usable key.
292 void OnHasAdditionalUsableKey(); 306 void OnHasAdditionalUsableKey();
293 307
294 // UUID of the key system. 308 // UUID of the key system.
295 std::vector<uint8_t> scheme_uuid_; 309 std::vector<uint8_t> scheme_uuid_;
296 310
311 GURL security_origin_;
312
297 // Java MediaDrm instance. 313 // Java MediaDrm instance.
298 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 314 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
299 315
300 // Java MediaCrypto instance. Possible values are: 316 // Java MediaCrypto instance. Possible values are:
301 // !j_media_crypto_: 317 // !j_media_crypto_:
302 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady(). 318 // MediaCrypto creation has not been notified via NotifyMediaCryptoReady().
303 // !j_media_crypto_->is_null(): 319 // !j_media_crypto_->is_null():
304 // MediaCrypto creation succeeded and it has been notified. 320 // MediaCrypto creation succeeded and it has been notified.
305 // j_media_crypto_->is_null(): 321 // j_media_crypto_->is_null():
306 // MediaCrypto creation failed and it has been notified. 322 // MediaCrypto creation failed and it has been notified.
307 JavaObjectPtr j_media_crypto_; 323 JavaObjectPtr j_media_crypto_;
308 324
325 MediaPermission* media_permission_;
326
309 // The callback to create a ProvisionFetcher. 327 // The callback to create a ProvisionFetcher.
310 CreateFetcherCB create_fetcher_cb_; 328 CreateFetcherCB create_fetcher_cb_;
311 329
312 // The ProvisionFetcher that requests and receives provisioning data. 330 // The ProvisionFetcher that requests and receives provisioning data.
313 // Non-null iff when a provision request is pending. 331 // Non-null iff when a provision request is pending.
314 scoped_ptr<ProvisionFetcher> provision_fetcher_; 332 scoped_ptr<ProvisionFetcher> provision_fetcher_;
315 333
316 // Callbacks for firing session events. 334 // Callbacks for firing session events.
317 SessionMessageCB session_message_cb_; 335 SessionMessageCB session_message_cb_;
318 SessionClosedCB session_closed_cb_; 336 SessionClosedCB session_closed_cb_;
(...skipping 16 matching lines...) Expand all
335 353
336 // NOTE: Weak pointers must be invalidated before all other member variables. 354 // NOTE: Weak pointers must be invalidated before all other member variables.
337 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; 355 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
338 356
339 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 357 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
340 }; 358 };
341 359
342 } // namespace media 360 } // namespace media
343 361
344 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 362 #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