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 #include "media/base/android/media_drm_bridge.h" | 5 #include "media/base/android/media_drm_bridge.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/bind.h" | |
12 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
14 #include "base/command_line.h" | |
13 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
15 #include "base/location.h" | 17 #include "base/location.h" |
16 #include "base/logging.h" | 18 #include "base/logging.h" |
17 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
21 #include "base/sys_byteorder.h" | 23 #include "base/sys_byteorder.h" |
22 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
23 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
24 #include "jni/MediaDrmBridge_jni.h" | 26 #include "jni/MediaDrmBridge_jni.h" |
25 #include "media/base/android/media_client_android.h" | 27 #include "media/base/android/media_client_android.h" |
28 #include "media/base/android/media_codec_player.h" // for GetMediaTaskRunner() | |
26 #include "media/base/android/media_drm_bridge_delegate.h" | 29 #include "media/base/android/media_drm_bridge_delegate.h" |
27 #include "media/base/cdm_key_information.h" | 30 #include "media/base/cdm_key_information.h" |
31 #include "media/base/media_switches.h" | |
28 | 32 |
29 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 33 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
30 | 34 |
35 #define RUN_CB_ON_MEDIA_THREAD(cb, ...) \ | |
36 do { \ | |
37 if (use_media_thread_ && \ | |
38 !GetMediaTaskRunner()->BelongsToCurrentThread()) { \ | |
39 GetMediaTaskRunner()->PostTask(FROM_HERE, \ | |
40 base::Bind(cb, ##__VA_ARGS__)); \ | |
41 } else { \ | |
42 cb.Run(__VA_ARGS__); \ | |
43 } \ | |
44 } while (0) | |
45 | |
31 using base::android::AttachCurrentThread; | 46 using base::android::AttachCurrentThread; |
32 using base::android::ConvertUTF8ToJavaString; | 47 using base::android::ConvertUTF8ToJavaString; |
33 using base::android::ConvertJavaStringToUTF8; | 48 using base::android::ConvertJavaStringToUTF8; |
34 using base::android::JavaByteArrayToByteVector; | 49 using base::android::JavaByteArrayToByteVector; |
35 using base::android::ScopedJavaLocalRef; | 50 using base::android::ScopedJavaLocalRef; |
36 | 51 |
37 namespace media { | 52 namespace media { |
38 | 53 |
39 namespace { | 54 namespace { |
40 | 55 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 } | 262 } |
248 | 263 |
249 // static | 264 // static |
250 bool MediaDrmBridge::IsKeySystemSupportedWithType( | 265 bool MediaDrmBridge::IsKeySystemSupportedWithType( |
251 const std::string& key_system, | 266 const std::string& key_system, |
252 const std::string& container_mime_type) { | 267 const std::string& container_mime_type) { |
253 DCHECK(!key_system.empty() && !container_mime_type.empty()); | 268 DCHECK(!key_system.empty() && !container_mime_type.empty()); |
254 return IsKeySystemSupportedWithTypeImpl(key_system, container_mime_type); | 269 return IsKeySystemSupportedWithTypeImpl(key_system, container_mime_type); |
255 } | 270 } |
256 | 271 |
272 // static | |
257 bool MediaDrmBridge::RegisterMediaDrmBridge(JNIEnv* env) { | 273 bool MediaDrmBridge::RegisterMediaDrmBridge(JNIEnv* env) { |
258 return RegisterNativesImpl(env); | 274 return RegisterNativesImpl(env); |
259 } | 275 } |
260 | 276 |
261 MediaDrmBridge::MediaDrmBridge( | 277 MediaDrmBridge::MediaDrmBridge( |
262 const std::vector<uint8>& scheme_uuid, | 278 const std::vector<uint8>& scheme_uuid, |
263 const SessionMessageCB& session_message_cb, | 279 const SessionMessageCB& session_message_cb, |
264 const SessionClosedCB& session_closed_cb, | 280 const SessionClosedCB& session_closed_cb, |
265 const LegacySessionErrorCB& legacy_session_error_cb, | 281 const LegacySessionErrorCB& legacy_session_error_cb, |
266 const SessionKeysChangeCB& session_keys_change_cb, | 282 const SessionKeysChangeCB& session_keys_change_cb, |
267 const SessionExpirationUpdateCB& session_expiration_update_cb) | 283 const SessionExpirationUpdateCB& session_expiration_update_cb) |
268 : scheme_uuid_(scheme_uuid), | 284 : scheme_uuid_(scheme_uuid), |
269 session_message_cb_(session_message_cb), | 285 session_message_cb_(session_message_cb), |
270 session_closed_cb_(session_closed_cb), | 286 session_closed_cb_(session_closed_cb), |
271 legacy_session_error_cb_(legacy_session_error_cb), | 287 legacy_session_error_cb_(legacy_session_error_cb), |
272 session_keys_change_cb_(session_keys_change_cb), | 288 session_keys_change_cb_(session_keys_change_cb), |
273 session_expiration_update_cb_(session_expiration_update_cb) { | 289 session_expiration_update_cb_(session_expiration_update_cb), |
290 use_media_thread_(false), | |
291 destruction_started_(false), | |
292 weak_factory_(this) { | |
293 DVLOG(1) << "MediaDrmBridge::MediaDrmBridge"; | |
294 | |
295 use_media_thread_ = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
296 switches::kEnableMediaThreadForMediaPlayback); | |
297 | |
298 base::WeakPtr<MediaDrmBridge> weak_this = weak_factory_.GetWeakPtr(); | |
299 | |
300 internal_keys_added_cb_ = | |
301 base::Bind(&MediaDrmBridge::InternalKeysAdded, weak_this); | |
302 | |
274 JNIEnv* env = AttachCurrentThread(); | 303 JNIEnv* env = AttachCurrentThread(); |
275 CHECK(env); | 304 CHECK(env); |
276 | 305 |
277 ScopedJavaLocalRef<jbyteArray> j_scheme_uuid = | 306 ScopedJavaLocalRef<jbyteArray> j_scheme_uuid = |
278 base::android::ToJavaByteArray(env, &scheme_uuid[0], scheme_uuid.size()); | 307 base::android::ToJavaByteArray(env, &scheme_uuid[0], scheme_uuid.size()); |
279 j_media_drm_.Reset(Java_MediaDrmBridge_create( | 308 j_media_drm_.Reset(Java_MediaDrmBridge_create( |
280 env, j_scheme_uuid.obj(), reinterpret_cast<intptr_t>(this))); | 309 env, j_scheme_uuid.obj(), reinterpret_cast<intptr_t>(this))); |
281 } | 310 } |
282 | 311 |
283 MediaDrmBridge::~MediaDrmBridge() { | 312 void MediaDrmBridge::DeleteOnCorrectThread() { |
313 DVLOG(1) << "MediaDrmBridge::" << __FUNCTION__; | |
314 | |
315 // Prevent GetMediaCrypro() to be called from this point. | |
316 // TODO(timav): need a better way. | |
Tima Vaisburd
2015/09/18 00:41:38
I will try to eliminate this lock in the next patc
| |
317 { | |
318 base::AutoLock lock(destruction_started_lock_); | |
319 destruction_started_ = true; | |
320 } | |
321 | |
284 JNIEnv* env = AttachCurrentThread(); | 322 JNIEnv* env = AttachCurrentThread(); |
285 player_tracker_.NotifyCdmUnset(); | |
286 if (!j_media_drm_.is_null()) | 323 if (!j_media_drm_.is_null()) |
287 Java_MediaDrmBridge_destroy(env, j_media_drm_.obj()); | 324 Java_MediaDrmBridge_destroy(env, j_media_drm_.obj()); |
325 | |
326 // Post deletion onto Media thread if we use it. | |
327 if (use_media_thread_) | |
328 GetMediaTaskRunner()->DeleteSoon(FROM_HERE, this); | |
329 else | |
330 delete this; | |
331 } | |
332 | |
333 MediaDrmBridge::~MediaDrmBridge() { | |
334 DVLOG(1) << "MediaDrmBridge::" << __FUNCTION__; | |
335 | |
336 DCHECK(use_media_thread_ && GetMediaTaskRunner()->BelongsToCurrentThread()); | |
337 | |
338 player_tracker_.NotifyCdmUnset(); | |
288 } | 339 } |
289 | 340 |
290 // static | 341 // static |
291 scoped_ptr<MediaDrmBridge> MediaDrmBridge::Create( | 342 scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> MediaDrmBridge::Create( |
292 const std::string& key_system, | 343 const std::string& key_system, |
293 const SessionMessageCB& session_message_cb, | 344 const SessionMessageCB& session_message_cb, |
294 const SessionClosedCB& session_closed_cb, | 345 const SessionClosedCB& session_closed_cb, |
295 const LegacySessionErrorCB& legacy_session_error_cb, | 346 const LegacySessionErrorCB& legacy_session_error_cb, |
296 const SessionKeysChangeCB& session_keys_change_cb, | 347 const SessionKeysChangeCB& session_keys_change_cb, |
297 const SessionExpirationUpdateCB& session_expiration_update_cb) { | 348 const SessionExpirationUpdateCB& session_expiration_update_cb) { |
298 scoped_ptr<MediaDrmBridge> media_drm_bridge; | 349 scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> media_drm_bridge; |
299 if (!IsAvailable()) | 350 if (!IsAvailable()) |
300 return media_drm_bridge.Pass(); | 351 return media_drm_bridge.Pass(); |
301 | 352 |
302 UUID scheme_uuid = g_key_system_manager.Get().GetUUID(key_system); | 353 UUID scheme_uuid = g_key_system_manager.Get().GetUUID(key_system); |
303 if (scheme_uuid.empty()) | 354 if (scheme_uuid.empty()) |
304 return media_drm_bridge.Pass(); | 355 return media_drm_bridge.Pass(); |
305 | 356 |
306 media_drm_bridge.reset( | 357 media_drm_bridge.reset( |
307 new MediaDrmBridge(scheme_uuid, session_message_cb, session_closed_cb, | 358 new MediaDrmBridge(scheme_uuid, session_message_cb, session_closed_cb, |
308 legacy_session_error_cb, session_keys_change_cb, | 359 legacy_session_error_cb, session_keys_change_cb, |
309 session_expiration_update_cb)); | 360 session_expiration_update_cb)); |
310 | 361 |
311 if (media_drm_bridge->j_media_drm_.is_null()) | 362 if (media_drm_bridge->j_media_drm_.is_null()) |
312 media_drm_bridge.reset(); | 363 media_drm_bridge.reset(); |
313 | 364 |
314 return media_drm_bridge.Pass(); | 365 return media_drm_bridge.Pass(); |
315 } | 366 } |
316 | 367 |
317 // static | 368 // static |
318 scoped_ptr<MediaDrmBridge> MediaDrmBridge::CreateWithoutSessionSupport( | 369 scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> |
319 const std::string& key_system) { | 370 MediaDrmBridge::CreateWithoutSessionSupport(const std::string& key_system) { |
320 return MediaDrmBridge::Create( | 371 return MediaDrmBridge::Create( |
321 key_system, SessionMessageCB(), SessionClosedCB(), LegacySessionErrorCB(), | 372 key_system, SessionMessageCB(), SessionClosedCB(), LegacySessionErrorCB(), |
322 SessionKeysChangeCB(), SessionExpirationUpdateCB()); | 373 SessionKeysChangeCB(), SessionExpirationUpdateCB()); |
323 } | 374 } |
324 | 375 |
325 bool MediaDrmBridge::SetSecurityLevel(SecurityLevel security_level) { | 376 bool MediaDrmBridge::SetSecurityLevel(SecurityLevel security_level) { |
326 if (security_level != SECURITY_LEVEL_NONE && | 377 if (security_level != SECURITY_LEVEL_NONE && |
327 !std::equal(scheme_uuid_.begin(), scheme_uuid_.end(), kWidevineUuid)) { | 378 !std::equal(scheme_uuid_.begin(), scheme_uuid_.end(), kWidevineUuid)) { |
328 NOTREACHED() << "Widevine security level " << security_level | 379 NOTREACHED() << "Widevine security level " << security_level |
329 << "used with another key system"; | 380 << "used with another key system"; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 promise->reject(NOT_SUPPORTED_ERROR, 0, "RemoveSession() is not supported."); | 508 promise->reject(NOT_SUPPORTED_ERROR, 0, "RemoveSession() is not supported."); |
458 } | 509 } |
459 | 510 |
460 CdmContext* MediaDrmBridge::GetCdmContext() { | 511 CdmContext* MediaDrmBridge::GetCdmContext() { |
461 NOTREACHED(); | 512 NOTREACHED(); |
462 return nullptr; | 513 return nullptr; |
463 } | 514 } |
464 | 515 |
465 int MediaDrmBridge::RegisterPlayer(const base::Closure& new_key_cb, | 516 int MediaDrmBridge::RegisterPlayer(const base::Closure& new_key_cb, |
466 const base::Closure& cdm_unset_cb) { | 517 const base::Closure& cdm_unset_cb) { |
518 DCHECK(use_media_thread_ && GetMediaTaskRunner()->BelongsToCurrentThread()); | |
467 return player_tracker_.RegisterPlayer(new_key_cb, cdm_unset_cb); | 519 return player_tracker_.RegisterPlayer(new_key_cb, cdm_unset_cb); |
468 } | 520 } |
469 | 521 |
470 void MediaDrmBridge::UnregisterPlayer(int registration_id) { | 522 void MediaDrmBridge::UnregisterPlayer(int registration_id) { |
523 DCHECK(use_media_thread_ && GetMediaTaskRunner()->BelongsToCurrentThread()); | |
471 player_tracker_.UnregisterPlayer(registration_id); | 524 player_tracker_.UnregisterPlayer(registration_id); |
472 } | 525 } |
473 | 526 |
474 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { | 527 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { |
528 DCHECK(use_media_thread_ && GetMediaTaskRunner()->BelongsToCurrentThread()); | |
529 DVLOG(1) << "MediaDrmBridge::" << __FUNCTION__; | |
530 | |
475 if (closure.is_null()) { | 531 if (closure.is_null()) { |
476 media_crypto_ready_cb_.Reset(); | 532 media_crypto_ready_cb_.Reset(); |
477 return; | 533 return; |
478 } | 534 } |
479 | 535 |
480 DCHECK(media_crypto_ready_cb_.is_null()); | 536 DCHECK(media_crypto_ready_cb_.is_null()); |
481 | 537 |
482 if (!GetMediaCrypto().is_null()) { | 538 if (!GetMediaCrypto().is_null()) { |
483 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 539 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
484 return; | 540 return; |
485 } | 541 } |
486 | 542 |
487 media_crypto_ready_cb_ = closure; | 543 media_crypto_ready_cb_ = closure; |
488 } | 544 } |
489 | 545 |
490 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { | 546 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject j_media_drm) { |
547 DVLOG(1) << "MediaDrmBridge::" << __FUNCTION__; | |
548 | |
491 DCHECK(!GetMediaCrypto().is_null()); | 549 DCHECK(!GetMediaCrypto().is_null()); |
492 if (!media_crypto_ready_cb_.is_null()) | 550 |
493 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); | 551 if (media_crypto_ready_cb_.is_null()) |
552 return; | |
553 | |
554 // TODO(timav): shall we pass the MediaCrypto object with the callback? | |
555 RUN_CB_ON_MEDIA_THREAD(base::ResetAndReturn(&media_crypto_ready_cb_)); | |
494 } | 556 } |
495 | 557 |
496 void MediaDrmBridge::OnPromiseResolved(JNIEnv* env, | 558 void MediaDrmBridge::OnPromiseResolved(JNIEnv* env, |
497 jobject j_media_drm, | 559 jobject j_media_drm, |
498 jint j_promise_id) { | 560 jint j_promise_id) { |
499 cdm_promise_adapter_.ResolvePromise(j_promise_id); | 561 cdm_promise_adapter_.ResolvePromise(j_promise_id); |
500 } | 562 } |
501 | 563 |
502 void MediaDrmBridge::OnPromiseResolvedWithSession(JNIEnv* env, | 564 void MediaDrmBridge::OnPromiseResolvedWithSession(JNIEnv* env, |
503 jobject j_media_drm, | 565 jobject j_media_drm, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 jobject j_media_drm, | 599 jobject j_media_drm, |
538 jbyteArray j_session_id) { | 600 jbyteArray j_session_id) { |
539 session_closed_cb_.Run(GetSessionId(env, j_session_id)); | 601 session_closed_cb_.Run(GetSessionId(env, j_session_id)); |
540 } | 602 } |
541 | 603 |
542 void MediaDrmBridge::OnSessionKeysChange(JNIEnv* env, | 604 void MediaDrmBridge::OnSessionKeysChange(JNIEnv* env, |
543 jobject j_media_drm, | 605 jobject j_media_drm, |
544 jbyteArray j_session_id, | 606 jbyteArray j_session_id, |
545 jobjectArray j_keys_info, | 607 jobjectArray j_keys_info, |
546 bool has_additional_usable_key) { | 608 bool has_additional_usable_key) { |
547 if (has_additional_usable_key) | 609 DVLOG(1) << "MediaDrmBridge::" << __FUNCTION__; |
548 player_tracker_.NotifyNewKey(); | |
549 | 610 |
550 CdmKeysInfo cdm_keys_info; | 611 CdmKeysInfo cdm_keys_info; |
551 | 612 |
552 size_t size = env->GetArrayLength(j_keys_info); | 613 size_t size = env->GetArrayLength(j_keys_info); |
553 DCHECK_GT(size, 0u); | 614 DCHECK_GT(size, 0u); |
554 | 615 |
555 for (size_t i = 0; i < size; ++i) { | 616 for (size_t i = 0; i < size; ++i) { |
556 ScopedJavaLocalRef<jobject> j_key_status( | 617 ScopedJavaLocalRef<jobject> j_key_status( |
557 env, env->GetObjectArrayElement(j_keys_info, i)); | 618 env, env->GetObjectArrayElement(j_keys_info, i)); |
558 | 619 |
(...skipping 13 matching lines...) Expand all Loading... | |
572 << key_status; | 633 << key_status; |
573 | 634 |
574 // TODO(xhwang): Update CdmKeyInformation to take key_id and status in the | 635 // TODO(xhwang): Update CdmKeyInformation to take key_id and status in the |
575 // constructor. | 636 // constructor. |
576 scoped_ptr<CdmKeyInformation> cdm_key_information(new CdmKeyInformation()); | 637 scoped_ptr<CdmKeyInformation> cdm_key_information(new CdmKeyInformation()); |
577 cdm_key_information->key_id = key_id; | 638 cdm_key_information->key_id = key_id; |
578 cdm_key_information->status = key_status; | 639 cdm_key_information->status = key_status; |
579 cdm_keys_info.push_back(cdm_key_information.release()); | 640 cdm_keys_info.push_back(cdm_key_information.release()); |
580 } | 641 } |
581 | 642 |
582 session_keys_change_cb_.Run(GetSessionId(env, j_session_id), | 643 RUN_CB_ON_MEDIA_THREAD(internal_keys_added_cb_, has_additional_usable_key); |
583 has_additional_usable_key, cdm_keys_info.Pass()); | 644 |
645 std::string session_id = GetSessionId(env, j_session_id); | |
646 | |
647 session_keys_change_cb_.Run(session_id, has_additional_usable_key, | |
648 cdm_keys_info.Pass()); | |
649 } | |
650 | |
651 void MediaDrmBridge::InternalKeysAdded(bool has_additional_usable_key) { | |
652 DCHECK(use_media_thread_ && GetMediaTaskRunner()->BelongsToCurrentThread()); | |
653 if (has_additional_usable_key) | |
654 player_tracker_.NotifyNewKey(); | |
584 } | 655 } |
585 | 656 |
586 // According to MeidaDrm documentation [1], zero |expiry_time_ms| means the keys | 657 // According to MeidaDrm documentation [1], zero |expiry_time_ms| means the keys |
587 // will never expire. This will be translated into a NULL base::Time() [2], | 658 // will never expire. This will be translated into a NULL base::Time() [2], |
588 // which will then be mapped to a zero Java time [3]. The zero Java time is | 659 // which will then be mapped to a zero Java time [3]. The zero Java time is |
589 // passed to Blink which will then be translated to NaN [4], which is what the | 660 // passed to Blink which will then be translated to NaN [4], which is what the |
590 // spec uses to indicate that the license will never expire [5]. | 661 // spec uses to indicate that the license will never expire [5]. |
591 // [1] http://developer.android.com/reference/android/media/MediaDrm.OnExpiratio nUpdateListener.html | 662 // [1] http://developer.android.com/reference/android/media/MediaDrm.OnExpiratio nUpdateListener.html |
592 // [2] See base::Time::FromDoubleT() | 663 // [2] See base::Time::FromDoubleT() |
593 // [3] See base::Time::ToJavaTime() | 664 // [3] See base::Time::ToJavaTime() |
(...skipping 12 matching lines...) Expand all Loading... | |
606 void MediaDrmBridge::OnLegacySessionError(JNIEnv* env, | 677 void MediaDrmBridge::OnLegacySessionError(JNIEnv* env, |
607 jobject j_media_drm, | 678 jobject j_media_drm, |
608 jbyteArray j_session_id, | 679 jbyteArray j_session_id, |
609 jstring j_error_message) { | 680 jstring j_error_message) { |
610 std::string error_message = ConvertJavaStringToUTF8(env, j_error_message); | 681 std::string error_message = ConvertJavaStringToUTF8(env, j_error_message); |
611 legacy_session_error_cb_.Run(GetSessionId(env, j_session_id), | 682 legacy_session_error_cb_.Run(GetSessionId(env, j_session_id), |
612 MediaKeys::UNKNOWN_ERROR, 0, error_message); | 683 MediaKeys::UNKNOWN_ERROR, 0, error_message); |
613 } | 684 } |
614 | 685 |
615 ScopedJavaLocalRef<jobject> MediaDrmBridge::GetMediaCrypto() { | 686 ScopedJavaLocalRef<jobject> MediaDrmBridge::GetMediaCrypto() { |
687 base::AutoLock lock(destruction_started_lock_); | |
688 if (destruction_started_) | |
689 return ScopedJavaLocalRef<jobject>(); | |
690 | |
616 JNIEnv* env = AttachCurrentThread(); | 691 JNIEnv* env = AttachCurrentThread(); |
617 return Java_MediaDrmBridge_getMediaCrypto(env, j_media_drm_.obj()); | 692 return Java_MediaDrmBridge_getMediaCrypto(env, j_media_drm_.obj()); |
618 } | 693 } |
619 | 694 |
620 MediaDrmBridge::SecurityLevel MediaDrmBridge::GetSecurityLevel() { | 695 MediaDrmBridge::SecurityLevel MediaDrmBridge::GetSecurityLevel() { |
621 JNIEnv* env = AttachCurrentThread(); | 696 JNIEnv* env = AttachCurrentThread(); |
622 ScopedJavaLocalRef<jstring> j_security_level = | 697 ScopedJavaLocalRef<jstring> j_security_level = |
623 Java_MediaDrmBridge_getSecurityLevel(env, j_media_drm_.obj()); | 698 Java_MediaDrmBridge_getSecurityLevel(env, j_media_drm_.obj()); |
624 std::string security_level_str = | 699 std::string security_level_str = |
625 ConvertJavaStringToUTF8(env, j_security_level.obj()); | 700 ConvertJavaStringToUTF8(env, j_security_level.obj()); |
(...skipping 16 matching lines...) Expand all Loading... | |
642 JNIEnv* env = AttachCurrentThread(); | 717 JNIEnv* env = AttachCurrentThread(); |
643 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 718 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
644 } | 719 } |
645 | 720 |
646 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 721 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
647 JNIEnv* env, jobject, bool success) { | 722 JNIEnv* env, jobject, bool success) { |
648 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 723 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
649 } | 724 } |
650 | 725 |
651 } // namespace media | 726 } // namespace media |
OLD | NEW |