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

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

Issue 1512173003: media: Refactor MediaCrypto creation and notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 // Reset the device credentials. 139 // Reset the device credentials.
140 void ResetDeviceCredentials(const ResetCredentialsCB& callback); 140 void ResetDeviceCredentials(const ResetCredentialsCB& callback);
141 141
142 // Helper functions to resolve promises. 142 // Helper functions to resolve promises.
143 void ResolvePromise(uint32_t promise_id); 143 void ResolvePromise(uint32_t promise_id);
144 void ResolvePromiseWithSession(uint32_t promise_id, 144 void ResolvePromiseWithSession(uint32_t promise_id,
145 const std::string& session_id); 145 const std::string& session_id);
146 void RejectPromise(uint32_t promise_id, const std::string& error_message); 146 void RejectPromise(uint32_t promise_id, const std::string& error_message);
147 147
148 // Returns a MediaCrypto object if it's already created. Returns a null object 148 // Returns a MediaCrypto object. Can only be called after |j_media_crypto_|
149 // otherwise. 149 // is set.
150 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); 150 // TODO(xhwang): This is only used by MediaSourcePlayer et al. Remove this
151 // method when MediaSourcePlayer is deprecated.
152 jobject GetMediaCrypto();
151 153
152 // Registers a callback which will be called when MediaCrypto is ready. 154 // Registers a callback which will be called when MediaCrypto is ready.
153 // Can be called on any thread. Only one callback should be registered. 155 // Can be called on any thread. Only one callback should be registered.
154 // The registered callbacks will be fired on |task_runner_|. The caller 156 // The registered callbacks will be fired on |task_runner_|. The caller
155 // should make sure that the callbacks are posted to the correct thread. 157 // should make sure that the callbacks are posted to the correct thread.
156 // TODO(xhwang): Move this up to be close to RegisterPlayer(). 158 // TODO(xhwang): Move this up to be close to RegisterPlayer().
157 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb); 159 void SetMediaCryptoReadyCB(const MediaCryptoReadyCB& media_crypto_ready_cb);
158 160
159 // All the OnXxx functions below are called from Java. The implementation must 161 // All the OnXxx functions below are called from Java. The implementation must
160 // only do minimal work and then post tasks to avoid reentrancy issues. 162 // only do minimal work and then post tasks to avoid reentrancy issues.
161 163
162 // Called by Java after a MediaCrypto object is created. 164 // Called by Java after a MediaCrypto object is created.
163 void OnMediaCryptoReady( 165 void OnMediaCryptoReady(
164 JNIEnv* env, 166 JNIEnv* env,
165 const base::android::JavaParamRef<jobject>& j_media_drm); 167 const base::android::JavaParamRef<jobject>& j_media_drm,
168 const base::android::JavaParamRef<jobject>& j_media_crypto);
166 169
167 // Called by Java when we need to send a provisioning request, 170 // Called by Java when we need to send a provisioning request,
168 void OnStartProvisioning( 171 void OnStartProvisioning(
169 JNIEnv* env, 172 JNIEnv* env,
170 const base::android::JavaParamRef<jobject>& j_media_drm, 173 const base::android::JavaParamRef<jobject>& j_media_drm,
171 const base::android::JavaParamRef<jstring>& j_default_url, 174 const base::android::JavaParamRef<jstring>& j_default_url,
172 const base::android::JavaParamRef<jbyteArray>& j_request_data); 175 const base::android::JavaParamRef<jbyteArray>& j_request_data);
173 176
174 // Callbacks to resolve the promise for |promise_id|. 177 // Callbacks to resolve the promise for |promise_id|.
175 void OnPromiseResolved( 178 void OnPromiseResolved(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 const SessionKeysChangeCB& session_keys_change_cb, 256 const SessionKeysChangeCB& session_keys_change_cb,
254 const SessionExpirationUpdateCB& session_expiration_update_cb); 257 const SessionExpirationUpdateCB& session_expiration_update_cb);
255 258
256 ~MediaDrmBridge() override; 259 ~MediaDrmBridge() override;
257 260
258 static bool IsSecureDecoderRequired(SecurityLevel security_level); 261 static bool IsSecureDecoderRequired(SecurityLevel security_level);
259 262
260 // Get the security level of the media. 263 // Get the security level of the media.
261 SecurityLevel GetSecurityLevel(); 264 SecurityLevel GetSecurityLevel();
262 265
263 // A helper method that calculates the |media_crypto_ready_cb_| arguments and 266 // A helper method to create a JavaObjectPtr.
264 // run this callback. 267 JavaObjectPtr CreateJavaObjectPtr(jobject object);
265 void NotifyMediaCryptoReady(const MediaCryptoReadyCB& cb); 268
269 // A helper method that is called when MediaCrypto is ready.
270 void NotifyMediaCryptoReady(JavaObjectPtr j_media_crypto);
266 271
267 // Sends HTTP provisioning request to a provisioning server. 272 // Sends HTTP provisioning request to a provisioning server.
268 void SendProvisioningRequest(const std::string& default_url, 273 void SendProvisioningRequest(const std::string& default_url,
269 const std::string& request_data); 274 const std::string& request_data);
270 275
271 // Process the data received by provisioning server. 276 // Process the data received by provisioning server.
272 void ProcessProvisionResponse(bool success, const std::string& response); 277 void ProcessProvisionResponse(bool success, const std::string& response);
273 278
274 // UUID of the key system. 279 // UUID of the key system.
275 std::vector<uint8> scheme_uuid_; 280 std::vector<uint8> scheme_uuid_;
276 281
277 // Java MediaDrm instance. 282 // Java MediaDrm instance.
278 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 283 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
279 284
285 // Java MediaCrypto instance. Possible values are:
286 // !j_media_crypto_: MediaCrypto creation has not been notified (through
287 // NotifyMediaCryptoReady()).
288 // !j_media_crypto_->is_null(): MediaCrypto successfully created and notified.
289 // j_media_crypto_->is_null(): MediaCrypto notified but creation failed.
Tima Vaisburd 2015/12/11 02:15:21 nit: I'd change the order: "MediaCrypto creation f
xhwang 2015/12/11 05:50:19 Done.
290 JavaObjectPtr j_media_crypto_;
291
280 // The callback to create a ProvisionFetcher. 292 // The callback to create a ProvisionFetcher.
281 CreateFetcherCB create_fetcher_cb_; 293 CreateFetcherCB create_fetcher_cb_;
282 294
283 // The ProvisionFetcher that requests and receives provisioning data. 295 // The ProvisionFetcher that requests and receives provisioning data.
284 // Non-null iff when a provision request is pending. 296 // Non-null iff when a provision request is pending.
285 scoped_ptr<ProvisionFetcher> provision_fetcher_; 297 scoped_ptr<ProvisionFetcher> provision_fetcher_;
286 298
287 // Callbacks for firing session events. 299 // Callbacks for firing session events.
288 SessionMessageCB session_message_cb_; 300 SessionMessageCB session_message_cb_;
289 SessionClosedCB session_closed_cb_; 301 SessionClosedCB session_closed_cb_;
(...skipping 14 matching lines...) Expand all
304 316
305 // NOTE: Weak pointers must be invalidated before all other member variables. 317 // NOTE: Weak pointers must be invalidated before all other member variables.
306 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; 318 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
307 319
308 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 320 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
309 }; 321 };
310 322
311 } // namespace media 323 } // namespace media
312 324
313 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 325 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698