Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "media/base/video_util.h" | 29 #include "media/base/video_util.h" |
| 30 #include "ppapi/shared_impl/array_var.h" | 30 #include "ppapi/shared_impl/array_var.h" |
| 31 #include "ppapi/shared_impl/scoped_pp_resource.h" | 31 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 32 #include "ppapi/shared_impl/time_conversion.h" | 32 #include "ppapi/shared_impl/time_conversion.h" |
| 33 #include "ppapi/shared_impl/var.h" | 33 #include "ppapi/shared_impl/var.h" |
| 34 #include "ppapi/shared_impl/var_tracker.h" | 34 #include "ppapi/shared_impl/var_tracker.h" |
| 35 #include "ppapi/thunk/enter.h" | 35 #include "ppapi/thunk/enter.h" |
| 36 #include "ppapi/thunk/ppb_buffer_api.h" | 36 #include "ppapi/thunk/ppb_buffer_api.h" |
| 37 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
| 38 | 38 |
| 39 using media::CdmPromise; | |
| 39 using media::Decryptor; | 40 using media::Decryptor; |
| 40 using media::MediaKeys; | 41 using media::MediaKeys; |
| 41 using media::NewSessionCdmPromise; | 42 using media::NewSessionCdmPromise; |
| 42 using media::SimpleCdmPromise; | 43 using media::SimpleCdmPromise; |
| 43 using ppapi::ArrayBufferVar; | 44 using ppapi::ArrayBufferVar; |
| 44 using ppapi::ArrayVar; | 45 using ppapi::ArrayVar; |
| 45 using ppapi::PpapiGlobals; | 46 using ppapi::PpapiGlobals; |
| 46 using ppapi::ScopedPPResource; | 47 using ppapi::ScopedPPResource; |
| 47 using ppapi::StringVar; | 48 using ppapi::StringVar; |
| 48 using ppapi::thunk::EnterResourceNoLock; | 49 using ppapi::thunk::EnterResourceNoLock; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 return PP_INITDATATYPE_KEYIDS; | 283 return PP_INITDATATYPE_KEYIDS; |
| 283 case media::EmeInitDataType::WEBM: | 284 case media::EmeInitDataType::WEBM: |
| 284 return PP_INITDATATYPE_WEBM; | 285 return PP_INITDATATYPE_WEBM; |
| 285 case media::EmeInitDataType::UNKNOWN: | 286 case media::EmeInitDataType::UNKNOWN: |
| 286 break; | 287 break; |
| 287 } | 288 } |
| 288 NOTREACHED(); | 289 NOTREACHED(); |
| 289 return PP_INITDATATYPE_KEYIDS; | 290 return PP_INITDATATYPE_KEYIDS; |
| 290 } | 291 } |
| 291 | 292 |
| 292 MediaKeys::Exception PpExceptionTypeToMediaException( | 293 CdmPromise::Exception PpExceptionTypeToMediaException( |
|
xhwang
2016/10/24 17:06:13
Please also update the function name.
| |
| 293 PP_CdmExceptionCode exception_code) { | 294 PP_CdmExceptionCode exception_code) { |
| 294 switch (exception_code) { | 295 switch (exception_code) { |
| 295 case PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR: | 296 case PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR: |
| 296 return MediaKeys::NOT_SUPPORTED_ERROR; | 297 return CdmPromise::NOT_SUPPORTED_ERROR; |
| 297 case PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR: | 298 case PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR: |
| 298 return MediaKeys::INVALID_STATE_ERROR; | 299 return CdmPromise::INVALID_STATE_ERROR; |
| 299 case PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR: | 300 case PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR: |
| 300 return MediaKeys::INVALID_ACCESS_ERROR; | 301 return CdmPromise::INVALID_ACCESS_ERROR; |
| 301 case PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR: | 302 case PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR: |
| 302 return MediaKeys::QUOTA_EXCEEDED_ERROR; | 303 return CdmPromise::QUOTA_EXCEEDED_ERROR; |
| 303 case PP_CDMEXCEPTIONCODE_UNKNOWNERROR: | 304 case PP_CDMEXCEPTIONCODE_UNKNOWNERROR: |
| 304 return MediaKeys::UNKNOWN_ERROR; | 305 return CdmPromise::UNKNOWN_ERROR; |
| 305 case PP_CDMEXCEPTIONCODE_CLIENTERROR: | 306 case PP_CDMEXCEPTIONCODE_CLIENTERROR: |
| 306 return MediaKeys::CLIENT_ERROR; | 307 return CdmPromise::CLIENT_ERROR; |
| 307 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: | 308 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: |
| 308 return MediaKeys::OUTPUT_ERROR; | 309 return CdmPromise::OUTPUT_ERROR; |
| 309 default: | 310 default: |
| 310 NOTREACHED(); | 311 NOTREACHED(); |
| 311 return MediaKeys::UNKNOWN_ERROR; | 312 return CdmPromise::UNKNOWN_ERROR; |
| 312 } | 313 } |
| 313 } | 314 } |
| 314 | 315 |
| 315 media::CdmKeyInformation::KeyStatus PpCdmKeyStatusToCdmKeyInformationKeyStatus( | 316 media::CdmKeyInformation::KeyStatus PpCdmKeyStatusToCdmKeyInformationKeyStatus( |
| 316 PP_CdmKeyStatus status) { | 317 PP_CdmKeyStatus status) { |
| 317 switch (status) { | 318 switch (status) { |
| 318 case PP_CDMKEYSTATUS_USABLE: | 319 case PP_CDMKEYSTATUS_USABLE: |
| 319 return media::CdmKeyInformation::USABLE; | 320 return media::CdmKeyInformation::USABLE; |
| 320 case PP_CDMKEYSTATUS_INVALID: | 321 case PP_CDMKEYSTATUS_INVALID: |
| 321 return media::CdmKeyInformation::INTERNAL_ERROR; | 322 return media::CdmKeyInformation::INTERNAL_ERROR; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 void ContentDecryptorDelegate::InstanceCrashed() { | 410 void ContentDecryptorDelegate::InstanceCrashed() { |
| 410 fatal_plugin_error_cb_.Run(); | 411 fatal_plugin_error_cb_.Run(); |
| 411 SatisfyAllPendingCallbacksOnError(); | 412 SatisfyAllPendingCallbacksOnError(); |
| 412 } | 413 } |
| 413 | 414 |
| 414 void ContentDecryptorDelegate::SetServerCertificate( | 415 void ContentDecryptorDelegate::SetServerCertificate( |
| 415 const std::vector<uint8_t>& certificate, | 416 const std::vector<uint8_t>& certificate, |
| 416 std::unique_ptr<media::SimpleCdmPromise> promise) { | 417 std::unique_ptr<media::SimpleCdmPromise> promise) { |
| 417 if (certificate.size() < media::limits::kMinCertificateLength || | 418 if (certificate.size() < media::limits::kMinCertificateLength || |
| 418 certificate.size() > media::limits::kMaxCertificateLength) { | 419 certificate.size() > media::limits::kMaxCertificateLength) { |
| 419 promise->reject( | 420 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0, |
| 420 media::MediaKeys::INVALID_ACCESS_ERROR, 0, "Incorrect certificate."); | 421 "Incorrect certificate."); |
| 421 return; | 422 return; |
| 422 } | 423 } |
| 423 | 424 |
| 424 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 425 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
| 425 PP_Var certificate_array = | 426 PP_Var certificate_array = |
| 426 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 427 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
| 427 base::checked_cast<uint32_t>(certificate.size()), certificate.data()); | 428 base::checked_cast<uint32_t>(certificate.size()), certificate.data()); |
| 428 plugin_decryption_interface_->SetServerCertificate( | 429 plugin_decryption_interface_->SetServerCertificate( |
| 429 pp_instance_, promise_id, certificate_array); | 430 pp_instance_, promise_id, certificate_array); |
| 430 } | 431 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 base::checked_cast<uint32_t>(response.size()), response.data()); | 464 base::checked_cast<uint32_t>(response.size()), response.data()); |
| 464 plugin_decryption_interface_->UpdateSession( | 465 plugin_decryption_interface_->UpdateSession( |
| 465 pp_instance_, promise_id, StringVar::StringToPPVar(session_id), | 466 pp_instance_, promise_id, StringVar::StringToPPVar(session_id), |
| 466 response_array); | 467 response_array); |
| 467 } | 468 } |
| 468 | 469 |
| 469 void ContentDecryptorDelegate::CloseSession( | 470 void ContentDecryptorDelegate::CloseSession( |
| 470 const std::string& session_id, | 471 const std::string& session_id, |
| 471 std::unique_ptr<SimpleCdmPromise> promise) { | 472 std::unique_ptr<SimpleCdmPromise> promise) { |
| 472 if (session_id.length() > media::limits::kMaxSessionIdLength) { | 473 if (session_id.length() > media::limits::kMaxSessionIdLength) { |
| 473 promise->reject( | 474 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0, |
| 474 media::MediaKeys::INVALID_ACCESS_ERROR, 0, "Incorrect session."); | 475 "Incorrect session."); |
| 475 return; | 476 return; |
| 476 } | 477 } |
| 477 | 478 |
| 478 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 479 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
| 479 plugin_decryption_interface_->CloseSession( | 480 plugin_decryption_interface_->CloseSession( |
| 480 pp_instance_, promise_id, StringVar::StringToPPVar(session_id)); | 481 pp_instance_, promise_id, StringVar::StringToPPVar(session_id)); |
| 481 } | 482 } |
| 482 | 483 |
| 483 void ContentDecryptorDelegate::RemoveSession( | 484 void ContentDecryptorDelegate::RemoveSession( |
| 484 const std::string& session_id, | 485 const std::string& session_id, |
| 485 std::unique_ptr<SimpleCdmPromise> promise) { | 486 std::unique_ptr<SimpleCdmPromise> promise) { |
| 486 if (session_id.length() > media::limits::kMaxSessionIdLength) { | 487 if (session_id.length() > media::limits::kMaxSessionIdLength) { |
| 487 promise->reject( | 488 promise->reject(CdmPromise::INVALID_ACCESS_ERROR, 0, |
| 488 media::MediaKeys::INVALID_ACCESS_ERROR, 0, "Incorrect session."); | 489 "Incorrect session."); |
| 489 return; | 490 return; |
| 490 } | 491 } |
| 491 | 492 |
| 492 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 493 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
| 493 plugin_decryption_interface_->RemoveSession( | 494 plugin_decryption_interface_->RemoveSession( |
| 494 pp_instance_, promise_id, StringVar::StringToPPVar(session_id)); | 495 pp_instance_, promise_id, StringVar::StringToPPVar(session_id)); |
| 495 } | 496 } |
| 496 | 497 |
| 497 // TODO(xhwang): Remove duplication of code in Decrypt(), | 498 // TODO(xhwang): Remove duplication of code in Decrypt(), |
| 498 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). | 499 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1254 empty_frames); | 1255 empty_frames); |
| 1255 } | 1256 } |
| 1256 | 1257 |
| 1257 if (!video_decode_cb_.is_null()) | 1258 if (!video_decode_cb_.is_null()) |
| 1258 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1259 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
| 1259 | 1260 |
| 1260 cdm_promise_adapter_.Clear(); | 1261 cdm_promise_adapter_.Clear(); |
| 1261 } | 1262 } |
| 1262 | 1263 |
| 1263 } // namespace content | 1264 } // namespace content |
| OLD | NEW |