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

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

Issue 1427183002: Move MediaDrmBridge provision communication to native side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For on-demand provisioning the fetcher is created in content/ and depends on the renderer. Created 5 years, 1 month 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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "media/base/browser_cdm.h" 16 #include "media/base/browser_cdm.h"
17 #include "media/base/cdm_promise_adapter.h" 17 #include "media/base/cdm_promise_adapter.h"
18 #include "media/base/media_export.h" 18 #include "media/base/media_export.h"
19 #include "media/cdm/player_tracker_impl.h" 19 #include "media/cdm/player_tracker_impl.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 class GURL; 22 class GURL;
23 23
24 namespace media { 24 namespace media {
25 25
26 class MediaDrmBridge; 26 class MediaDrmBridge;
27 class ProvisionFetcher;
27 28
28 using ScopedMediaDrmBridgePtr = scoped_ptr<MediaDrmBridge, BrowserCdmDeleter>; 29 using ScopedMediaDrmBridgePtr = scoped_ptr<MediaDrmBridge, BrowserCdmDeleter>;
29 30
30 // This class provides DRM services for android EME implementation. 31 // This class provides DRM services for android EME implementation.
31 class MEDIA_EXPORT MediaDrmBridge : public BrowserCdm { 32 class MEDIA_EXPORT MediaDrmBridge : public BrowserCdm {
32 public: 33 public:
33 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 34 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400
34 enum SecurityLevel { 35 enum SecurityLevel {
35 SECURITY_LEVEL_NONE = 0, 36 SECURITY_LEVEL_NONE = 0,
36 SECURITY_LEVEL_1 = 1, 37 SECURITY_LEVEL_1 = 1,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 // Returns the list of the platform-supported key system names that 72 // Returns the list of the platform-supported key system names that
72 // are not handled by Chrome explicitly. 73 // are not handled by Chrome explicitly.
73 static std::vector<std::string> GetPlatformKeySystemNames(); 74 static std::vector<std::string> GetPlatformKeySystemNames();
74 75
75 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL 76 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL
76 // pointer otherwise. 77 // pointer otherwise.
77 // TODO(xhwang): Is it okay not to update session expiration info? 78 // TODO(xhwang): Is it okay not to update session expiration info?
78 static ScopedMediaDrmBridgePtr Create( 79 static ScopedMediaDrmBridgePtr Create(
79 const std::string& key_system, 80 const std::string& key_system,
81 scoped_ptr<ProvisionFetcher> provision_fetcher,
80 const SessionMessageCB& session_message_cb, 82 const SessionMessageCB& session_message_cb,
81 const SessionClosedCB& session_closed_cb, 83 const SessionClosedCB& session_closed_cb,
82 const LegacySessionErrorCB& legacy_session_error_cb, 84 const LegacySessionErrorCB& legacy_session_error_cb,
83 const SessionKeysChangeCB& session_keys_change_cb, 85 const SessionKeysChangeCB& session_keys_change_cb,
84 const SessionExpirationUpdateCB& session_expiration_update_cb); 86 const SessionExpirationUpdateCB& session_expiration_update_cb);
85 87
86 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL 88 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL
87 // otherwise. No session callbacks are provided. This is used when we need to 89 // otherwise. No session callbacks are provided. This is used when we need to
88 // use MediaDrmBridge without creating any sessions. 90 // use MediaDrmBridge without creating any sessions.
89 static ScopedMediaDrmBridgePtr CreateWithoutSessionSupport( 91 static ScopedMediaDrmBridgePtr CreateWithoutSessionSupport(
xhwang 2015/11/06 23:08:19 tip: You'll need to do a rebase. Please keep the r
Tima Vaisburd 2015/11/11 03:03:34 Done.
90 const std::string& key_system); 92 const std::string& key_system);
91 93
92 // Returns a WeakPtr to be used on the |task_runner_|. 94 // Returns a WeakPtr to be used on the |task_runner_|.
93 base::WeakPtr<MediaDrmBridge> WeakPtr(); 95 base::WeakPtr<MediaDrmBridge> WeakPtr();
94 96
95 // MediaKeys (via BrowserCdm) implementation. 97 // MediaKeys (via BrowserCdm) implementation.
96 void SetServerCertificate( 98 void SetServerCertificate(
97 const std::vector<uint8_t>& certificate, 99 const std::vector<uint8_t>& certificate,
98 scoped_ptr<media::SimpleCdmPromise> promise) override; 100 scoped_ptr<media::SimpleCdmPromise> promise) override;
99 void CreateSessionAndGenerateRequest( 101 void CreateSessionAndGenerateRequest(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Sets callback which will be called when MediaCrypto is ready. If 149 // Sets callback which will be called when MediaCrypto is ready. If
148 // |media_crypto_ready_cb| is null, previously set callback will be cleared. 150 // |media_crypto_ready_cb| is null, previously set callback will be cleared.
149 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb); 151 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb);
150 152
151 // All the OnXxx functions below are called from Java. The implementation must 153 // All the OnXxx functions below are called from Java. The implementation must
152 // only do minimal work and then post tasks to avoid reentrancy issues. 154 // only do minimal work and then post tasks to avoid reentrancy issues.
153 155
154 // Called by Java after a MediaCrypto object is created. 156 // Called by Java after a MediaCrypto object is created.
155 void OnMediaCryptoReady(JNIEnv* env, jobject j_media_drm); 157 void OnMediaCryptoReady(JNIEnv* env, jobject j_media_drm);
156 158
159 // Called by Java when we need to send a provisioning request,
160 void OnStartProvisioning(JNIEnv* env,
161 jobject j_media_drm,
162 jstring j_default_url,
163 jbyteArray j_request_data);
164
157 // Callbacks to resolve the promise for |promise_id|. 165 // Callbacks to resolve the promise for |promise_id|.
158 void OnPromiseResolved(JNIEnv* env, jobject j_media_drm, jint j_promise_id); 166 void OnPromiseResolved(JNIEnv* env, jobject j_media_drm, jint j_promise_id);
159 void OnPromiseResolvedWithSession(JNIEnv* env, 167 void OnPromiseResolvedWithSession(JNIEnv* env,
160 jobject j_media_drm, 168 jobject j_media_drm,
161 jint j_promise_id, 169 jint j_promise_id,
162 jbyteArray j_session_id); 170 jbyteArray j_session_id);
163 171
164 // Callback to reject the promise for |promise_id| with |error_message|. 172 // Callback to reject the promise for |promise_id| with |error_message|.
165 // Note: No |system_error| is available from MediaDrm. 173 // Note: No |system_error| is available from MediaDrm.
166 // TODO(xhwang): Implement Exception code. 174 // TODO(xhwang): Implement Exception code.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void OnLegacySessionError(JNIEnv* env, 214 void OnLegacySessionError(JNIEnv* env,
207 jobject j_media_drm, 215 jobject j_media_drm,
208 jbyteArray j_session_id, 216 jbyteArray j_session_id,
209 jstring j_error_message); 217 jstring j_error_message);
210 218
211 // Called by the java object when credential reset is completed. 219 // Called by the java object when credential reset is completed.
212 void OnResetDeviceCredentialsCompleted(JNIEnv* env, jobject, bool success); 220 void OnResetDeviceCredentialsCompleted(JNIEnv* env, jobject, bool success);
213 221
214 private: 222 private:
215 MediaDrmBridge(const std::vector<uint8>& scheme_uuid, 223 MediaDrmBridge(const std::vector<uint8>& scheme_uuid,
224 scoped_ptr<ProvisionFetcher> provision_fetcher,
216 const SessionMessageCB& session_message_cb, 225 const SessionMessageCB& session_message_cb,
217 const SessionClosedCB& session_closed_cb, 226 const SessionClosedCB& session_closed_cb,
218 const LegacySessionErrorCB& legacy_session_error_cb, 227 const LegacySessionErrorCB& legacy_session_error_cb,
219 const SessionKeysChangeCB& session_keys_change_cb, 228 const SessionKeysChangeCB& session_keys_change_cb,
220 const SessionExpirationUpdateCB& session_expiration_update_cb); 229 const SessionExpirationUpdateCB& session_expiration_update_cb);
221 230
222 static bool IsSecureDecoderRequired(SecurityLevel security_level); 231 static bool IsSecureDecoderRequired(SecurityLevel security_level);
223 232
224 // Get the security level of the media. 233 // Get the security level of the media.
225 SecurityLevel GetSecurityLevel(); 234 SecurityLevel GetSecurityLevel();
226 235
227 // A helper method that calls a |player_tracker_| method on correct thread. 236 // A helper method that calls a |player_tracker_| method on correct thread.
228 void NotifyNewKeyOnCorrectThread(); 237 void NotifyNewKeyOnCorrectThread();
229 238
230 // A helper method that calculates the |media_crypto_ready_cb_| arguments and 239 // A helper method that calculates the |media_crypto_ready_cb_| arguments and
231 // run this callback. 240 // run this callback.
232 void NotifyMediaCryptoReady(const MediaCryptoReadyCB& cb); 241 void NotifyMediaCryptoReady(const MediaCryptoReadyCB& cb);
233 242
243 // Sends HTTP provisioning request to a provisioning server.
244 void SendProvisioningRequest(const std::string& default_url,
245 const std::string& request_data);
246
247 // Process the data received by provisioning server.
248 void ProcessProvisionResponse(bool success, const std::string& response);
249
234 // UUID of the key system. 250 // UUID of the key system.
235 std::vector<uint8> scheme_uuid_; 251 std::vector<uint8> scheme_uuid_;
236 252
237 // Java MediaDrm instance. 253 // Java MediaDrm instance.
238 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 254 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
239 255
256 // The object that requests and receives provisioning data.
257 scoped_ptr<ProvisionFetcher> provision_fetcher_;
258
240 // Callbacks for firing session events. 259 // Callbacks for firing session events.
241 SessionMessageCB session_message_cb_; 260 SessionMessageCB session_message_cb_;
242 SessionClosedCB session_closed_cb_; 261 SessionClosedCB session_closed_cb_;
243 LegacySessionErrorCB legacy_session_error_cb_; 262 LegacySessionErrorCB legacy_session_error_cb_;
244 SessionKeysChangeCB session_keys_change_cb_; 263 SessionKeysChangeCB session_keys_change_cb_;
245 SessionExpirationUpdateCB session_expiration_update_cb_; 264 SessionExpirationUpdateCB session_expiration_update_cb_;
246 265
247 MediaCryptoReadyCB media_crypto_ready_cb_; 266 MediaCryptoReadyCB media_crypto_ready_cb_;
248 267
249 ResetCredentialsCB reset_credentials_cb_; 268 ResetCredentialsCB reset_credentials_cb_;
(...skipping 17 matching lines...) Expand all
267 286
268 // Default WeakPtrFactory. 287 // Default WeakPtrFactory.
269 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; 288 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
270 289
271 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 290 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
272 }; 291 };
273 292
274 } // namespace media 293 } // namespace media
275 294
276 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 295 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698