Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 | 272 |
| 273 // static | 273 // static |
| 274 bool MediaDrmBridge::IsKeySystemSupported(const std::string& key_system) { | 274 bool MediaDrmBridge::IsKeySystemSupported(const std::string& key_system) { |
| 275 if (!MediaDrmBridge::IsAvailable()) | 275 if (!MediaDrmBridge::IsAvailable()) |
| 276 return false; | 276 return false; |
| 277 | 277 |
| 278 return IsKeySystemSupportedWithTypeImpl(key_system, ""); | 278 return IsKeySystemSupportedWithTypeImpl(key_system, ""); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // static | 281 // static |
| 282 bool MediaDrmBridge::IsPersistentLicenseTypeSupported( | 282 bool MediaDrmBridge::IsPersistentLicenseTypeSupported( |
|
xhwang
2017/04/05 18:31:50
Please also check the following in this function:
yucliu1
2017/04/05 23:04:07
Done.
| |
| 283 const std::string& key_system) { | 283 const std::string& key_system) { |
| 284 if (!MediaDrmBridge::IsAvailable()) | 284 if (!MediaDrmBridge::IsAvailable()) |
| 285 return false; | 285 return false; |
| 286 | 286 |
| 287 if (!base::FeatureList::IsEnabled(kMediaDrmPersistentLicense)) { | 287 if (!base::FeatureList::IsEnabled(kMediaDrmPersistentLicense)) { |
| 288 return false; | 288 return false; |
| 289 } | 289 } |
| 290 | 290 |
| 291 NOTIMPLEMENTED() << "In development. See http://crbug.com/493521"; | 291 NOTIMPLEMENTED() << "In development. See http://crbug.com/493521"; |
| 292 return false; | 292 return false; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 promise_id); | 453 promise_id); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void MediaDrmBridge::LoadSession( | 456 void MediaDrmBridge::LoadSession( |
| 457 CdmSessionType session_type, | 457 CdmSessionType session_type, |
| 458 const std::string& session_id, | 458 const std::string& session_id, |
| 459 std::unique_ptr<media::NewSessionCdmPromise> promise) { | 459 std::unique_ptr<media::NewSessionCdmPromise> promise) { |
| 460 DCHECK(task_runner_->BelongsToCurrentThread()); | 460 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 461 DVLOG(2) << __func__; | 461 DVLOG(2) << __func__; |
| 462 | 462 |
| 463 DCHECK(base::FeatureList::IsEnabled(kMediaDrmPersistentLicense)); | 463 DCHECK(base::FeatureList::IsEnabled(kMediaDrmPersistentLicense)); |
|
xhwang
2017/04/05 18:31:50
You can probably just DCHECK(IsPersistentLicenseTy
yucliu1
2017/04/05 23:04:07
Done.
| |
| 464 | 464 |
| 465 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; | 465 if (session_type != CdmSessionType::PERSISTENT_LICENSE_SESSION) { |
| 466 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 466 promise->reject( |
| 467 "LoadSession() is not supported."); | 467 CdmPromise::NOT_SUPPORTED_ERROR, 0, |
| 468 "LoadSession() is only supported for 'persistent-license'."); | |
| 469 return; | |
| 470 } | |
| 471 | |
| 472 JNIEnv* env = AttachCurrentThread(); | |
| 473 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray( | |
| 474 env, reinterpret_cast<const uint8_t*>(session_id.data()), | |
| 475 session_id.size()); | |
|
xhwang
2017/04/05 18:31:50
Might worth putting this in a helper function.
yucliu1
2017/04/05 23:04:07
Done.
| |
| 476 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | |
| 477 Java_MediaDrmBridge_loadSession(env, j_media_drm_, j_session_id, promise_id); | |
| 468 } | 478 } |
| 469 | 479 |
| 470 void MediaDrmBridge::UpdateSession( | 480 void MediaDrmBridge::UpdateSession( |
| 471 const std::string& session_id, | 481 const std::string& session_id, |
| 472 const std::vector<uint8_t>& response, | 482 const std::vector<uint8_t>& response, |
| 473 std::unique_ptr<media::SimpleCdmPromise> promise) { | 483 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 474 DCHECK(task_runner_->BelongsToCurrentThread()); | 484 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 475 DVLOG(2) << __func__; | 485 DVLOG(2) << __func__; |
| 476 | 486 |
| 477 JNIEnv* env = AttachCurrentThread(); | 487 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 498 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 508 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
| 499 Java_MediaDrmBridge_closeSession(env, j_media_drm_, j_session_id, promise_id); | 509 Java_MediaDrmBridge_closeSession(env, j_media_drm_, j_session_id, promise_id); |
| 500 } | 510 } |
| 501 | 511 |
| 502 void MediaDrmBridge::RemoveSession( | 512 void MediaDrmBridge::RemoveSession( |
| 503 const std::string& session_id, | 513 const std::string& session_id, |
| 504 std::unique_ptr<media::SimpleCdmPromise> promise) { | 514 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 505 DCHECK(task_runner_->BelongsToCurrentThread()); | 515 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 506 DVLOG(2) << __func__; | 516 DVLOG(2) << __func__; |
| 507 | 517 |
| 508 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; | 518 JNIEnv* env = AttachCurrentThread(); |
| 509 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 519 ScopedJavaLocalRef<jbyteArray> j_session_id = base::android::ToJavaByteArray( |
| 510 "RemoveSession() is not supported."); | 520 env, reinterpret_cast<const uint8_t*>(session_id.data()), |
| 521 session_id.size()); | |
| 522 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | |
| 523 Java_MediaDrmBridge_removeSession(env, j_media_drm_, j_session_id, | |
| 524 promise_id); | |
| 511 } | 525 } |
| 512 | 526 |
| 513 CdmContext* MediaDrmBridge::GetCdmContext() { | 527 CdmContext* MediaDrmBridge::GetCdmContext() { |
| 514 DVLOG(2) << __func__; | 528 DVLOG(2) << __func__; |
| 515 | 529 |
| 516 return &media_drm_bridge_cdm_context_; | 530 return &media_drm_bridge_cdm_context_; |
| 517 } | 531 } |
| 518 | 532 |
| 519 void MediaDrmBridge::DeleteOnCorrectThread() const { | 533 void MediaDrmBridge::DeleteOnCorrectThread() const { |
| 520 DVLOG(1) << __func__; | 534 DVLOG(1) << __func__; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 } | 938 } |
| 925 | 939 |
| 926 void MediaDrmBridge::OnHasAdditionalUsableKey() { | 940 void MediaDrmBridge::OnHasAdditionalUsableKey() { |
| 927 DCHECK(task_runner_->BelongsToCurrentThread()); | 941 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 928 DVLOG(1) << __func__; | 942 DVLOG(1) << __func__; |
| 929 | 943 |
| 930 player_tracker_.NotifyNewKey(); | 944 player_tracker_.NotifyNewKey(); |
| 931 } | 945 } |
| 932 | 946 |
| 933 } // namespace media | 947 } // namespace media |
| OLD | NEW |