| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/renderer/media/crypto/ppapi_decryptor.h" | 5 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::Bind(&PpapiDecryptor::OnSessionKeysChange, weak_this), | 83 base::Bind(&PpapiDecryptor::OnSessionKeysChange, weak_this), |
| 84 base::Bind(&PpapiDecryptor::OnSessionExpirationUpdate, weak_this), | 84 base::Bind(&PpapiDecryptor::OnSessionExpirationUpdate, weak_this), |
| 85 base::Bind(&PpapiDecryptor::OnFatalPluginError, weak_this)); | 85 base::Bind(&PpapiDecryptor::OnFatalPluginError, weak_this)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 PpapiDecryptor::~PpapiDecryptor() { | 88 PpapiDecryptor::~PpapiDecryptor() { |
| 89 pepper_cdm_wrapper_.reset(); | 89 pepper_cdm_wrapper_.reset(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void PpapiDecryptor::SetServerCertificate( | 92 void PpapiDecryptor::SetServerCertificate( |
| 93 const uint8* certificate_data, | 93 const std::vector<uint8_t>& certificate, |
| 94 int certificate_data_length, | |
| 95 scoped_ptr<media::SimpleCdmPromise> promise) { | 94 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 96 DVLOG(2) << __FUNCTION__; | 95 DVLOG(2) << __FUNCTION__; |
| 97 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 96 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 98 | 97 |
| 99 if (!CdmDelegate()) { | 98 if (!CdmDelegate()) { |
| 100 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 99 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 101 return; | 100 return; |
| 102 } | 101 } |
| 103 | 102 |
| 104 CdmDelegate()->SetServerCertificate( | 103 CdmDelegate()->SetServerCertificate(certificate, promise.Pass()); |
| 105 certificate_data, certificate_data_length, promise.Pass()); | |
| 106 } | 104 } |
| 107 | 105 |
| 108 void PpapiDecryptor::CreateSessionAndGenerateRequest( | 106 void PpapiDecryptor::CreateSessionAndGenerateRequest( |
| 109 SessionType session_type, | 107 SessionType session_type, |
| 110 media::EmeInitDataType init_data_type, | 108 media::EmeInitDataType init_data_type, |
| 111 const uint8* init_data, | 109 const std::vector<uint8_t>& init_data, |
| 112 int init_data_length, | |
| 113 scoped_ptr<media::NewSessionCdmPromise> promise) { | 110 scoped_ptr<media::NewSessionCdmPromise> promise) { |
| 114 DVLOG(2) << __FUNCTION__; | 111 DVLOG(2) << __FUNCTION__; |
| 115 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 112 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 116 | 113 |
| 117 if (!CdmDelegate()) { | 114 if (!CdmDelegate()) { |
| 118 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 115 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 119 return; | 116 return; |
| 120 } | 117 } |
| 121 | 118 |
| 122 CdmDelegate()->CreateSessionAndGenerateRequest(session_type, init_data_type, | 119 CdmDelegate()->CreateSessionAndGenerateRequest(session_type, init_data_type, |
| 123 init_data, init_data_length, | 120 init_data, promise.Pass()); |
| 124 promise.Pass()); | |
| 125 } | 121 } |
| 126 | 122 |
| 127 void PpapiDecryptor::LoadSession( | 123 void PpapiDecryptor::LoadSession( |
| 128 SessionType session_type, | 124 SessionType session_type, |
| 129 const std::string& session_id, | 125 const std::string& session_id, |
| 130 scoped_ptr<media::NewSessionCdmPromise> promise) { | 126 scoped_ptr<media::NewSessionCdmPromise> promise) { |
| 131 DVLOG(2) << __FUNCTION__; | 127 DVLOG(2) << __FUNCTION__; |
| 132 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 128 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 133 | 129 |
| 134 if (!CdmDelegate()) { | 130 if (!CdmDelegate()) { |
| 135 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 131 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 136 return; | 132 return; |
| 137 } | 133 } |
| 138 CdmDelegate()->LoadSession(session_type, session_id, promise.Pass()); | 134 CdmDelegate()->LoadSession(session_type, session_id, promise.Pass()); |
| 139 } | 135 } |
| 140 | 136 |
| 141 void PpapiDecryptor::UpdateSession( | 137 void PpapiDecryptor::UpdateSession( |
| 142 const std::string& session_id, | 138 const std::string& session_id, |
| 143 const uint8* response, | 139 const std::vector<uint8_t>& response, |
| 144 int response_length, | |
| 145 scoped_ptr<media::SimpleCdmPromise> promise) { | 140 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 146 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 141 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 147 | 142 |
| 148 if (!CdmDelegate()) { | 143 if (!CdmDelegate()) { |
| 149 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 144 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 150 return; | 145 return; |
| 151 } | 146 } |
| 152 CdmDelegate()->UpdateSession(session_id, response, response_length, | 147 CdmDelegate()->UpdateSession(session_id, response, promise.Pass()); |
| 153 promise.Pass()); | |
| 154 } | 148 } |
| 155 | 149 |
| 156 void PpapiDecryptor::CloseSession(const std::string& session_id, | 150 void PpapiDecryptor::CloseSession(const std::string& session_id, |
| 157 scoped_ptr<media::SimpleCdmPromise> promise) { | 151 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 158 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 152 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 159 | 153 |
| 160 if (!CdmDelegate()) { | 154 if (!CdmDelegate()) { |
| 161 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 155 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 162 return; | 156 return; |
| 163 } | 157 } |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 DCHECK(!video_decoder_init_cb_.is_null()); | 380 DCHECK(!video_decoder_init_cb_.is_null()); |
| 387 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); | 381 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); |
| 388 break; | 382 break; |
| 389 default: | 383 default: |
| 390 NOTREACHED(); | 384 NOTREACHED(); |
| 391 } | 385 } |
| 392 } | 386 } |
| 393 | 387 |
| 394 void PpapiDecryptor::OnSessionMessage(const std::string& session_id, | 388 void PpapiDecryptor::OnSessionMessage(const std::string& session_id, |
| 395 MessageType message_type, | 389 MessageType message_type, |
| 396 const std::vector<uint8>& message, | 390 const std::vector<uint8_t>& message, |
| 397 const GURL& legacy_destination_url) { | 391 const GURL& legacy_destination_url) { |
| 398 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 392 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 399 session_message_cb_.Run(session_id, message_type, message, | 393 session_message_cb_.Run(session_id, message_type, message, |
| 400 legacy_destination_url); | 394 legacy_destination_url); |
| 401 } | 395 } |
| 402 | 396 |
| 403 void PpapiDecryptor::OnSessionKeysChange(const std::string& session_id, | 397 void PpapiDecryptor::OnSessionKeysChange(const std::string& session_id, |
| 404 bool has_additional_usable_key, | 398 bool has_additional_usable_key, |
| 405 media::CdmKeysInfo keys_info) { | 399 media::CdmKeysInfo keys_info) { |
| 406 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 400 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 422 } | 416 } |
| 423 | 417 |
| 424 void PpapiDecryptor::OnSessionClosed(const std::string& session_id) { | 418 void PpapiDecryptor::OnSessionClosed(const std::string& session_id) { |
| 425 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 419 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 426 session_closed_cb_.Run(session_id); | 420 session_closed_cb_.Run(session_id); |
| 427 } | 421 } |
| 428 | 422 |
| 429 void PpapiDecryptor::OnLegacySessionError( | 423 void PpapiDecryptor::OnLegacySessionError( |
| 430 const std::string& session_id, | 424 const std::string& session_id, |
| 431 MediaKeys::Exception exception_code, | 425 MediaKeys::Exception exception_code, |
| 432 uint32 system_code, | 426 uint32_t system_code, |
| 433 const std::string& error_description) { | 427 const std::string& error_description) { |
| 434 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 428 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 435 legacy_session_error_cb_.Run(session_id, exception_code, system_code, | 429 legacy_session_error_cb_.Run(session_id, exception_code, system_code, |
| 436 error_description); | 430 error_description); |
| 437 } | 431 } |
| 438 | 432 |
| 439 void PpapiDecryptor::AttemptToResumePlayback() { | 433 void PpapiDecryptor::AttemptToResumePlayback() { |
| 440 if (!new_audio_key_cb_.is_null()) | 434 if (!new_audio_key_cb_.is_null()) |
| 441 new_audio_key_cb_.Run(); | 435 new_audio_key_cb_.Run(); |
| 442 | 436 |
| 443 if (!new_video_key_cb_.is_null()) | 437 if (!new_video_key_cb_.is_null()) |
| 444 new_video_key_cb_.Run(); | 438 new_video_key_cb_.Run(); |
| 445 } | 439 } |
| 446 | 440 |
| 447 void PpapiDecryptor::OnFatalPluginError() { | 441 void PpapiDecryptor::OnFatalPluginError() { |
| 448 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 442 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 449 pepper_cdm_wrapper_.reset(); | 443 pepper_cdm_wrapper_.reset(); |
| 450 } | 444 } |
| 451 | 445 |
| 452 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 446 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
| 453 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 447 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 454 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 448 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
| 455 } | 449 } |
| 456 | 450 |
| 457 } // namespace content | 451 } // namespace content |
| OLD | NEW |