| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 case media::EmeInitDataType::CENC: | 85 case media::EmeInitDataType::CENC: |
| 86 return "video/mp4"; | 86 return "video/mp4"; |
| 87 case media::EmeInitDataType::KEYIDS: | 87 case media::EmeInitDataType::KEYIDS: |
| 88 return "keyids"; | 88 return "keyids"; |
| 89 default: | 89 default: |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 return "unknown"; | 91 return "unknown"; |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 MediaKeys::MessageType GetMessageType(RequestType request_type) { | 95 ContentDecryptionModule::MessageType GetMessageType(RequestType request_type) { |
| 96 switch (request_type) { | 96 switch (request_type) { |
| 97 case RequestType::REQUEST_TYPE_INITIAL: | 97 case RequestType::REQUEST_TYPE_INITIAL: |
| 98 return MediaKeys::LICENSE_REQUEST; | 98 return ContentDecryptionModule::LICENSE_REQUEST; |
| 99 case RequestType::REQUEST_TYPE_RENEWAL: | 99 case RequestType::REQUEST_TYPE_RENEWAL: |
| 100 return MediaKeys::LICENSE_RENEWAL; | 100 return ContentDecryptionModule::LICENSE_RENEWAL; |
| 101 case RequestType::REQUEST_TYPE_RELEASE: | 101 case RequestType::REQUEST_TYPE_RELEASE: |
| 102 return MediaKeys::LICENSE_RELEASE; | 102 return ContentDecryptionModule::LICENSE_RELEASE; |
| 103 } | 103 } |
| 104 | 104 |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 return MediaKeys::LICENSE_REQUEST; | 106 return ContentDecryptionModule::LICENSE_REQUEST; |
| 107 } | 107 } |
| 108 | 108 |
| 109 CdmKeyInformation::KeyStatus ConvertKeyStatus(KeyStatus key_status) { | 109 CdmKeyInformation::KeyStatus ConvertKeyStatus(KeyStatus key_status) { |
| 110 switch (key_status) { | 110 switch (key_status) { |
| 111 case KeyStatus::KEY_STATUS_USABLE: | 111 case KeyStatus::KEY_STATUS_USABLE: |
| 112 return CdmKeyInformation::USABLE; | 112 return CdmKeyInformation::USABLE; |
| 113 case KeyStatus::KEY_STATUS_EXPIRED: | 113 case KeyStatus::KEY_STATUS_EXPIRED: |
| 114 return CdmKeyInformation::EXPIRED; | 114 return CdmKeyInformation::EXPIRED; |
| 115 case KeyStatus::KEY_STATUS_OUTPUT_NOT_ALLOWED: | 115 case KeyStatus::KEY_STATUS_OUTPUT_NOT_ALLOWED: |
| 116 return CdmKeyInformation::OUTPUT_RESTRICTED; | 116 return CdmKeyInformation::OUTPUT_RESTRICTED; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 360 } |
| 361 | 361 |
| 362 void MediaDrmBridge::CreateSessionAndGenerateRequest( | 362 void MediaDrmBridge::CreateSessionAndGenerateRequest( |
| 363 SessionType session_type, | 363 SessionType session_type, |
| 364 media::EmeInitDataType init_data_type, | 364 media::EmeInitDataType init_data_type, |
| 365 const std::vector<uint8_t>& init_data, | 365 const std::vector<uint8_t>& init_data, |
| 366 std::unique_ptr<media::NewSessionCdmPromise> promise) { | 366 std::unique_ptr<media::NewSessionCdmPromise> promise) { |
| 367 DCHECK(task_runner_->BelongsToCurrentThread()); | 367 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 368 DVLOG(2) << __func__; | 368 DVLOG(2) << __func__; |
| 369 | 369 |
| 370 if (session_type != media::MediaKeys::TEMPORARY_SESSION) { | 370 if (session_type != ContentDecryptionModule::TEMPORARY_SESSION) { |
| 371 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; | 371 NOTIMPLEMENTED() << "EME persistent sessions not yet supported on Android."; |
| 372 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, | 372 promise->reject(CdmPromise::NOT_SUPPORTED_ERROR, 0, |
| 373 "Only the temporary session type is supported."); | 373 "Only the temporary session type is supported."); |
| 374 return; | 374 return; |
| 375 } | 375 } |
| 376 | 376 |
| 377 JNIEnv* env = AttachCurrentThread(); | 377 JNIEnv* env = AttachCurrentThread(); |
| 378 ScopedJavaLocalRef<jbyteArray> j_init_data; | 378 ScopedJavaLocalRef<jbyteArray> j_init_data; |
| 379 ScopedJavaLocalRef<jobjectArray> j_optional_parameters; | 379 ScopedJavaLocalRef<jobjectArray> j_optional_parameters; |
| 380 | 380 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 void MediaDrmBridge::OnSessionMessage( | 630 void MediaDrmBridge::OnSessionMessage( |
| 631 JNIEnv* env, | 631 JNIEnv* env, |
| 632 const JavaParamRef<jobject>& j_media_drm, | 632 const JavaParamRef<jobject>& j_media_drm, |
| 633 const JavaParamRef<jbyteArray>& j_session_id, | 633 const JavaParamRef<jbyteArray>& j_session_id, |
| 634 jint j_message_type, | 634 jint j_message_type, |
| 635 const JavaParamRef<jbyteArray>& j_message) { | 635 const JavaParamRef<jbyteArray>& j_message) { |
| 636 DVLOG(2) << __func__; | 636 DVLOG(2) << __func__; |
| 637 | 637 |
| 638 std::vector<uint8_t> message; | 638 std::vector<uint8_t> message; |
| 639 JavaByteArrayToByteVector(env, j_message, &message); | 639 JavaByteArrayToByteVector(env, j_message, &message); |
| 640 MediaKeys::MessageType message_type = | 640 ContentDecryptionModule::MessageType message_type = |
| 641 GetMessageType(static_cast<RequestType>(j_message_type)); | 641 GetMessageType(static_cast<RequestType>(j_message_type)); |
| 642 | 642 |
| 643 task_runner_->PostTask( | 643 task_runner_->PostTask( |
| 644 FROM_HERE, base::Bind(session_message_cb_, AsString(env, j_session_id), | 644 FROM_HERE, base::Bind(session_message_cb_, AsString(env, j_session_id), |
| 645 message_type, message)); | 645 message_type, message)); |
| 646 } | 646 } |
| 647 | 647 |
| 648 void MediaDrmBridge::OnSessionClosed( | 648 void MediaDrmBridge::OnSessionClosed( |
| 649 JNIEnv* env, | 649 JNIEnv* env, |
| 650 const JavaParamRef<jobject>& j_media_drm, | 650 const JavaParamRef<jobject>& j_media_drm, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 871 } |
| 872 | 872 |
| 873 void MediaDrmBridge::OnHasAdditionalUsableKey() { | 873 void MediaDrmBridge::OnHasAdditionalUsableKey() { |
| 874 DCHECK(task_runner_->BelongsToCurrentThread()); | 874 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 875 DVLOG(1) << __func__; | 875 DVLOG(1) << __func__; |
| 876 | 876 |
| 877 player_tracker_.NotifyNewKey(); | 877 player_tracker_.NotifyNewKey(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 } // namespace media | 880 } // namespace media |
| OLD | NEW |