| 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/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const uint8* response, | 130 const uint8* response, |
| 131 int response_length) { | 131 int response_length) { |
| 132 DVLOG(2) << __FUNCTION__; | 132 DVLOG(2) << __FUNCTION__; |
| 133 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 133 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 134 | 134 |
| 135 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( | 135 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( |
| 136 session_id, response, response_length)) { | 136 session_id, response, response_length)) { |
| 137 ReportFailureToCallPlugin(session_id); | 137 ReportFailureToCallPlugin(session_id); |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 | |
| 141 if (!new_audio_key_cb_.is_null()) | |
| 142 new_audio_key_cb_.Run(); | |
| 143 | |
| 144 if (!new_video_key_cb_.is_null()) | |
| 145 new_video_key_cb_.Run(); | |
| 146 } | 140 } |
| 147 | 141 |
| 148 void PpapiDecryptor::ReleaseSession(uint32 session_id) { | 142 void PpapiDecryptor::ReleaseSession(uint32 session_id) { |
| 149 DVLOG(2) << __FUNCTION__; | 143 DVLOG(2) << __FUNCTION__; |
| 150 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 144 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 151 | 145 |
| 152 if (!plugin_cdm_delegate_ || | 146 if (!plugin_cdm_delegate_ || |
| 153 !plugin_cdm_delegate_->ReleaseSession(session_id)) { | 147 !plugin_cdm_delegate_->ReleaseSession(session_id)) { |
| 154 ReportFailureToCallPlugin(session_id); | 148 ReportFailureToCallPlugin(session_id); |
| 155 return; | 149 return; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 339 |
| 346 void PpapiDecryptor::OnSessionMessage(uint32 session_id, | 340 void PpapiDecryptor::OnSessionMessage(uint32 session_id, |
| 347 const std::vector<uint8>& message, | 341 const std::vector<uint8>& message, |
| 348 const std::string& destination_url) { | 342 const std::string& destination_url) { |
| 349 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 343 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 350 session_message_cb_.Run(session_id, message, destination_url); | 344 session_message_cb_.Run(session_id, message, destination_url); |
| 351 } | 345 } |
| 352 | 346 |
| 353 void PpapiDecryptor::OnSessionReady(uint32 session_id) { | 347 void PpapiDecryptor::OnSessionReady(uint32 session_id) { |
| 354 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 348 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 349 |
| 350 // Based on the spec, we need to resume playback when update() completes |
| 351 // successfully, or when a session is successfully loaded. In both cases, |
| 352 // the CDM fires OnSessionReady() event. So we choose to call the NewKeyCBs |
| 353 // here. |
| 354 // TODO(xhwang): Rename OnSessionReady to indicate that the playback may |
| 355 // resume successfully (e.g. a new key is available or available again). |
| 356 if (!new_audio_key_cb_.is_null()) |
| 357 new_audio_key_cb_.Run(); |
| 358 |
| 359 if (!new_video_key_cb_.is_null()) |
| 360 new_video_key_cb_.Run(); |
| 361 |
| 355 session_ready_cb_.Run(session_id); | 362 session_ready_cb_.Run(session_id); |
| 356 } | 363 } |
| 357 | 364 |
| 358 void PpapiDecryptor::OnSessionClosed(uint32 session_id) { | 365 void PpapiDecryptor::OnSessionClosed(uint32 session_id) { |
| 359 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 366 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 360 session_closed_cb_.Run(session_id); | 367 session_closed_cb_.Run(session_id); |
| 361 } | 368 } |
| 362 | 369 |
| 363 void PpapiDecryptor::OnSessionError(uint32 session_id, | 370 void PpapiDecryptor::OnSessionError(uint32 session_id, |
| 364 media::MediaKeys::KeyError error_code, | 371 media::MediaKeys::KeyError error_code, |
| 365 int system_code) { | 372 int system_code) { |
| 366 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 373 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 367 session_error_cb_.Run(session_id, error_code, system_code); | 374 session_error_cb_.Run(session_id, error_code, system_code); |
| 368 } | 375 } |
| 369 | 376 |
| 370 void PpapiDecryptor::OnFatalPluginError() { | 377 void PpapiDecryptor::OnFatalPluginError() { |
| 371 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 378 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 372 DCHECK(plugin_cdm_delegate_); | 379 DCHECK(plugin_cdm_delegate_); |
| 373 plugin_cdm_delegate_ = NULL; | 380 plugin_cdm_delegate_ = NULL; |
| 374 plugin_instance_ = NULL; | 381 plugin_instance_ = NULL; |
| 375 base::ResetAndReturn(&destroy_plugin_cb_).Run(); | 382 base::ResetAndReturn(&destroy_plugin_cb_).Run(); |
| 376 } | 383 } |
| 377 | 384 |
| 378 } // namespace content | 385 } // namespace content |
| OLD | NEW |