OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are | 81 // Returns a MediaDrmBridge instance if |key_system| and |security_level| are |
82 // supported, and nullptr otherwise. The default security level will be used | 82 // supported, and nullptr otherwise. The default security level will be used |
83 // if |security_level| is SECURITY_LEVEL_DEFAULT. | 83 // if |security_level| is SECURITY_LEVEL_DEFAULT. |
84 static scoped_refptr<MediaDrmBridge> Create( | 84 static scoped_refptr<MediaDrmBridge> Create( |
85 const std::string& key_system, | 85 const std::string& key_system, |
86 SecurityLevel security_level, | 86 SecurityLevel security_level, |
87 const CreateFetcherCB& create_fetcher_cb, | 87 const CreateFetcherCB& create_fetcher_cb, |
88 const SessionMessageCB& session_message_cb, | 88 const SessionMessageCB& session_message_cb, |
89 const SessionClosedCB& session_closed_cb, | 89 const SessionClosedCB& session_closed_cb, |
90 const LegacySessionErrorCB& legacy_session_error_cb, | |
91 const SessionKeysChangeCB& session_keys_change_cb, | 90 const SessionKeysChangeCB& session_keys_change_cb, |
92 const SessionExpirationUpdateCB& session_expiration_update_cb); | 91 const SessionExpirationUpdateCB& session_expiration_update_cb); |
93 | 92 |
94 // Same as Create() except that no session callbacks are provided. This is | 93 // Same as Create() except that no session callbacks are provided. This is |
95 // used when we need to use MediaDrmBridge without creating any sessions. | 94 // used when we need to use MediaDrmBridge without creating any sessions. |
96 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( | 95 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( |
97 const std::string& key_system, | 96 const std::string& key_system, |
98 SecurityLevel security_level, | 97 SecurityLevel security_level, |
99 const CreateFetcherCB& create_fetcher_cb); | 98 const CreateFetcherCB& create_fetcher_cb); |
100 | 99 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Note: No |system_error| is available from MediaDrm. | 187 // Note: No |system_error| is available from MediaDrm. |
189 // TODO(xhwang): Implement Exception code. | 188 // TODO(xhwang): Implement Exception code. |
190 void OnPromiseRejected( | 189 void OnPromiseRejected( |
191 JNIEnv* env, | 190 JNIEnv* env, |
192 const base::android::JavaParamRef<jobject>& j_media_drm, | 191 const base::android::JavaParamRef<jobject>& j_media_drm, |
193 jint j_promise_id, | 192 jint j_promise_id, |
194 const base::android::JavaParamRef<jstring>& j_error_message); | 193 const base::android::JavaParamRef<jstring>& j_error_message); |
195 | 194 |
196 // Session event callbacks. | 195 // Session event callbacks. |
197 | 196 |
198 // TODO(xhwang): Remove |j_legacy_destination_url| now that prefixed EME | |
199 // support is removed. http://crbug.com/249976 | |
200 void OnSessionMessage( | 197 void OnSessionMessage( |
201 JNIEnv* env, | 198 JNIEnv* env, |
202 const base::android::JavaParamRef<jobject>& j_media_drm, | 199 const base::android::JavaParamRef<jobject>& j_media_drm, |
203 const base::android::JavaParamRef<jbyteArray>& j_session_id, | 200 const base::android::JavaParamRef<jbyteArray>& j_session_id, |
204 jint j_message_type, | 201 jint j_message_type, |
205 const base::android::JavaParamRef<jbyteArray>& j_message, | 202 const base::android::JavaParamRef<jbyteArray>& j_message); |
206 const base::android::JavaParamRef<jstring>& j_legacy_destination_url); | |
207 void OnSessionClosed( | 203 void OnSessionClosed( |
208 JNIEnv* env, | 204 JNIEnv* env, |
209 const base::android::JavaParamRef<jobject>& j_media_drm, | 205 const base::android::JavaParamRef<jobject>& j_media_drm, |
210 const base::android::JavaParamRef<jbyteArray>& j_session_id); | 206 const base::android::JavaParamRef<jbyteArray>& j_session_id); |
211 | 207 |
212 void OnSessionKeysChange( | 208 void OnSessionKeysChange( |
213 JNIEnv* env, | 209 JNIEnv* env, |
214 const base::android::JavaParamRef<jobject>& j_media_drm, | 210 const base::android::JavaParamRef<jobject>& j_media_drm, |
215 const base::android::JavaParamRef<jbyteArray>& j_session_id, | 211 const base::android::JavaParamRef<jbyteArray>& j_session_id, |
216 const base::android::JavaParamRef<jobjectArray>& j_keys_info, | 212 const base::android::JavaParamRef<jobjectArray>& j_keys_info, |
217 bool has_additional_usable_key); | 213 bool has_additional_usable_key); |
218 | 214 |
219 // |expiry_time_ms| is the new expiration time for the keys in the session. | 215 // |expiry_time_ms| is the new expiration time for the keys in the session. |
220 // The time is in milliseconds, relative to the Unix epoch. A time of 0 | 216 // The time is in milliseconds, relative to the Unix epoch. A time of 0 |
221 // indicates that the keys never expire. | 217 // indicates that the keys never expire. |
222 void OnSessionExpirationUpdate( | 218 void OnSessionExpirationUpdate( |
223 JNIEnv* env, | 219 JNIEnv* env, |
224 const base::android::JavaParamRef<jobject>& j_media_drm, | 220 const base::android::JavaParamRef<jobject>& j_media_drm, |
225 const base::android::JavaParamRef<jbyteArray>& j_session_id, | 221 const base::android::JavaParamRef<jbyteArray>& j_session_id, |
226 jlong expiry_time_ms); | 222 jlong expiry_time_ms); |
227 | 223 |
228 // Called by the CDM when an error occurred in session |j_session_id| | |
229 // unrelated to one of the MediaKeys calls that accept a |promise|. | |
230 // Note: | |
231 // - This method is only for supporting prefixed EME API. | |
232 // TODO(ddorwin): Remove it now. https://crbug.com/249976 | |
233 // - This method will be ignored by unprefixed EME. All errors reported | |
234 // in this method should probably also be reported by one of other methods. | |
235 void OnLegacySessionError( | |
236 JNIEnv* env, | |
237 const base::android::JavaParamRef<jobject>& j_media_drm, | |
238 const base::android::JavaParamRef<jbyteArray>& j_session_id, | |
239 const base::android::JavaParamRef<jstring>& j_error_message); | |
240 | |
241 // Called by the java object when credential reset is completed. | 224 // Called by the java object when credential reset is completed. |
242 void OnResetDeviceCredentialsCompleted( | 225 void OnResetDeviceCredentialsCompleted( |
243 JNIEnv* env, | 226 JNIEnv* env, |
244 const base::android::JavaParamRef<jobject>&, | 227 const base::android::JavaParamRef<jobject>&, |
245 bool success); | 228 bool success); |
246 | 229 |
247 private: | 230 private: |
248 // For DeleteSoon() in DeleteOnCorrectThread(). | 231 // For DeleteSoon() in DeleteOnCorrectThread(). |
249 friend class base::DeleteHelper<MediaDrmBridge>; | 232 friend class base::DeleteHelper<MediaDrmBridge>; |
250 | 233 |
251 static scoped_refptr<MediaDrmBridge> CreateInternal( | 234 static scoped_refptr<MediaDrmBridge> CreateInternal( |
252 const std::string& key_system, | 235 const std::string& key_system, |
253 SecurityLevel security_level, | 236 SecurityLevel security_level, |
254 const CreateFetcherCB& create_fetcher_cb, | 237 const CreateFetcherCB& create_fetcher_cb, |
255 const SessionMessageCB& session_message_cb, | 238 const SessionMessageCB& session_message_cb, |
256 const SessionClosedCB& session_closed_cb, | 239 const SessionClosedCB& session_closed_cb, |
257 const LegacySessionErrorCB& legacy_session_error_cb, | |
258 const SessionKeysChangeCB& session_keys_change_cb, | 240 const SessionKeysChangeCB& session_keys_change_cb, |
259 const SessionExpirationUpdateCB& session_expiration_update_cb); | 241 const SessionExpirationUpdateCB& session_expiration_update_cb); |
260 | 242 |
261 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The | 243 // Constructs a MediaDrmBridge for |scheme_uuid| and |security_level|. The |
262 // default security level will be used if |security_level| is | 244 // default security level will be used if |security_level| is |
263 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks | 245 // SECURITY_LEVEL_DEFAULT. Sessions should not be created if session callbacks |
264 // are null. | 246 // are null. |
265 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, | 247 MediaDrmBridge(const std::vector<uint8_t>& scheme_uuid, |
266 SecurityLevel security_level, | 248 SecurityLevel security_level, |
267 const CreateFetcherCB& create_fetcher_cb, | 249 const CreateFetcherCB& create_fetcher_cb, |
268 const SessionMessageCB& session_message_cb, | 250 const SessionMessageCB& session_message_cb, |
269 const SessionClosedCB& session_closed_cb, | 251 const SessionClosedCB& session_closed_cb, |
270 const LegacySessionErrorCB& legacy_session_error_cb, | |
271 const SessionKeysChangeCB& session_keys_change_cb, | 252 const SessionKeysChangeCB& session_keys_change_cb, |
272 const SessionExpirationUpdateCB& session_expiration_update_cb); | 253 const SessionExpirationUpdateCB& session_expiration_update_cb); |
273 | 254 |
274 ~MediaDrmBridge() override; | 255 ~MediaDrmBridge() override; |
275 | 256 |
276 static bool IsSecureDecoderRequired(SecurityLevel security_level); | 257 static bool IsSecureDecoderRequired(SecurityLevel security_level); |
277 | 258 |
278 // Get the security level of the media. | 259 // Get the security level of the media. |
279 SecurityLevel GetSecurityLevel(); | 260 SecurityLevel GetSecurityLevel(); |
280 | 261 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // The callback to create a ProvisionFetcher. | 293 // The callback to create a ProvisionFetcher. |
313 CreateFetcherCB create_fetcher_cb_; | 294 CreateFetcherCB create_fetcher_cb_; |
314 | 295 |
315 // The ProvisionFetcher that requests and receives provisioning data. | 296 // The ProvisionFetcher that requests and receives provisioning data. |
316 // Non-null iff when a provision request is pending. | 297 // Non-null iff when a provision request is pending. |
317 std::unique_ptr<ProvisionFetcher> provision_fetcher_; | 298 std::unique_ptr<ProvisionFetcher> provision_fetcher_; |
318 | 299 |
319 // Callbacks for firing session events. | 300 // Callbacks for firing session events. |
320 SessionMessageCB session_message_cb_; | 301 SessionMessageCB session_message_cb_; |
321 SessionClosedCB session_closed_cb_; | 302 SessionClosedCB session_closed_cb_; |
322 LegacySessionErrorCB legacy_session_error_cb_; | |
323 SessionKeysChangeCB session_keys_change_cb_; | 303 SessionKeysChangeCB session_keys_change_cb_; |
324 SessionExpirationUpdateCB session_expiration_update_cb_; | 304 SessionExpirationUpdateCB session_expiration_update_cb_; |
325 | 305 |
326 MediaCryptoReadyCB media_crypto_ready_cb_; | 306 MediaCryptoReadyCB media_crypto_ready_cb_; |
327 | 307 |
328 ResetCredentialsCB reset_credentials_cb_; | 308 ResetCredentialsCB reset_credentials_cb_; |
329 | 309 |
330 PlayerTrackerImpl player_tracker_; | 310 PlayerTrackerImpl player_tracker_; |
331 | 311 |
332 CdmPromiseAdapter cdm_promise_adapter_; | 312 CdmPromiseAdapter cdm_promise_adapter_; |
333 | 313 |
334 // Default task runner. | 314 // Default task runner. |
335 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 315 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
336 | 316 |
337 MediaDrmBridgeCdmContext media_drm_bridge_cdm_context_; | 317 MediaDrmBridgeCdmContext media_drm_bridge_cdm_context_; |
338 | 318 |
339 // NOTE: Weak pointers must be invalidated before all other member variables. | 319 // NOTE: Weak pointers must be invalidated before all other member variables. |
340 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; | 320 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; |
341 | 321 |
342 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 322 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
343 }; | 323 }; |
344 | 324 |
345 } // namespace media | 325 } // namespace media |
346 | 326 |
347 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 327 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
OLD | NEW |