| 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 "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "content/renderer/pepper/ppb_buffer_impl.h" | 11 #include "content/renderer/pepper/ppb_buffer_impl.h" |
| 12 #include "media/base/audio_buffer.h" | 12 #include "media/base/audio_buffer.h" |
| 13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
| 14 #include "media/base/bind_to_current_loop.h" | 14 #include "media/base/bind_to_current_loop.h" |
| 15 #include "media/base/cdm_promise.h" | 15 #include "media/base/cdm_promise.h" |
| 16 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" |
| 17 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
| 18 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
| 19 #include "media/base/decrypt_config.h" | 19 #include "media/base/decrypt_config.h" |
| 20 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
| 21 #include "media/base/video_decoder_config.h" | 21 #include "media/base/video_decoder_config.h" |
| 22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 23 #include "media/base/video_util.h" | 23 #include "media/base/video_util.h" |
| 24 #include "ppapi/shared_impl/array_var.h" | 24 #include "ppapi/shared_impl/array_var.h" |
| 25 #include "ppapi/shared_impl/scoped_pp_resource.h" | 25 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 26 #include "ppapi/shared_impl/time_conversion.h" |
| 26 #include "ppapi/shared_impl/var.h" | 27 #include "ppapi/shared_impl/var.h" |
| 27 #include "ppapi/shared_impl/var_tracker.h" | 28 #include "ppapi/shared_impl/var_tracker.h" |
| 28 #include "ppapi/thunk/enter.h" | 29 #include "ppapi/thunk/enter.h" |
| 29 #include "ppapi/thunk/ppb_buffer_api.h" | 30 #include "ppapi/thunk/ppb_buffer_api.h" |
| 30 #include "ui/gfx/rect.h" | 31 #include "ui/gfx/rect.h" |
| 31 | 32 |
| 32 using media::CdmPromise; | 33 using media::CdmPromise; |
| 33 using media::Decryptor; | 34 using media::Decryptor; |
| 34 using media::KeyIdsPromise; | 35 using media::KeyIdsPromise; |
| 35 using media::MediaKeys; | 36 using media::MediaKeys; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 weak_this_ = weak_ptr_factory_.GetWeakPtr(); | 305 weak_this_ = weak_ptr_factory_.GetWeakPtr(); |
| 305 } | 306 } |
| 306 | 307 |
| 307 ContentDecryptorDelegate::~ContentDecryptorDelegate() { | 308 ContentDecryptorDelegate::~ContentDecryptorDelegate() { |
| 308 SatisfyAllPendingCallbacksOnError(); | 309 SatisfyAllPendingCallbacksOnError(); |
| 309 } | 310 } |
| 310 | 311 |
| 311 void ContentDecryptorDelegate::Initialize( | 312 void ContentDecryptorDelegate::Initialize( |
| 312 const std::string& key_system, | 313 const std::string& key_system, |
| 313 const media::SessionMessageCB& session_message_cb, | 314 const media::SessionMessageCB& session_message_cb, |
| 315 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 316 const media::SessionExpirationChangeCB& session_expiration_change_cb, |
| 314 const media::SessionReadyCB& session_ready_cb, | 317 const media::SessionReadyCB& session_ready_cb, |
| 315 const media::SessionClosedCB& session_closed_cb, | 318 const media::SessionClosedCB& session_closed_cb, |
| 316 const media::SessionErrorCB& session_error_cb, | 319 const media::SessionErrorCB& session_error_cb, |
| 317 const base::Closure& fatal_plugin_error_cb) { | 320 const base::Closure& fatal_plugin_error_cb) { |
| 318 DCHECK(!key_system.empty()); | 321 DCHECK(!key_system.empty()); |
| 319 DCHECK(key_system_.empty()); | 322 DCHECK(key_system_.empty()); |
| 320 key_system_ = key_system; | 323 key_system_ = key_system; |
| 321 | 324 |
| 322 session_message_cb_ = session_message_cb; | 325 session_message_cb_ = session_message_cb; |
| 326 session_keys_change_cb_ = session_keys_change_cb; |
| 327 session_expiration_change_cb_ = session_expiration_change_cb; |
| 323 session_ready_cb_ = session_ready_cb; | 328 session_ready_cb_ = session_ready_cb; |
| 324 session_closed_cb_ = session_closed_cb; | 329 session_closed_cb_ = session_closed_cb; |
| 325 session_error_cb_ = session_error_cb; | 330 session_error_cb_ = session_error_cb; |
| 326 fatal_plugin_error_cb_ = fatal_plugin_error_cb; | 331 fatal_plugin_error_cb_ = fatal_plugin_error_cb; |
| 327 | 332 |
| 328 plugin_decryption_interface_->Initialize( | 333 plugin_decryption_interface_->Initialize( |
| 329 pp_instance_, StringVar::StringToPPVar(key_system_)); | 334 pp_instance_, StringVar::StringToPPVar(key_system_)); |
| 330 } | 335 } |
| 331 | 336 |
| 332 void ContentDecryptorDelegate::InstanceCrashed() { | 337 void ContentDecryptorDelegate::InstanceCrashed() { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. | 810 verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. |
| 806 } | 811 } |
| 807 | 812 |
| 808 session_message_cb_.Run( | 813 session_message_cb_.Run( |
| 809 web_session_id_string->value(), message_vector, verified_gurl); | 814 web_session_id_string->value(), message_vector, verified_gurl); |
| 810 } | 815 } |
| 811 | 816 |
| 812 void ContentDecryptorDelegate::OnSessionKeysChange( | 817 void ContentDecryptorDelegate::OnSessionKeysChange( |
| 813 PP_Var web_session_id, | 818 PP_Var web_session_id, |
| 814 PP_Bool has_additional_usable_key) { | 819 PP_Bool has_additional_usable_key) { |
| 815 // TODO(jrummell): Pass this event on. | 820 if (session_keys_change_cb_.is_null()) |
| 821 return; |
| 822 |
| 823 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
| 824 DCHECK(web_session_id_string); |
| 825 |
| 826 session_keys_change_cb_.Run(web_session_id_string->value(), |
| 827 PP_ToBool(has_additional_usable_key)); |
| 816 } | 828 } |
| 817 | 829 |
| 818 void ContentDecryptorDelegate::OnSessionExpirationChange( | 830 void ContentDecryptorDelegate::OnSessionExpirationChange( |
| 819 PP_Var web_session_id, | 831 PP_Var web_session_id, |
| 820 PP_Time new_expiry_time) { | 832 PP_Time new_expiry_time) { |
| 821 // TODO(jrummell): Pass this event on. | 833 if (session_expiration_change_cb_.is_null()) |
| 834 return; |
| 835 |
| 836 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
| 837 DCHECK(web_session_id_string); |
| 838 |
| 839 session_expiration_change_cb_.Run( |
| 840 web_session_id_string->value(), |
| 841 ppapi::PPTimeToTime(new_expiry_time).ToDoubleT()); |
| 822 } | 842 } |
| 823 | 843 |
| 824 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id) { | 844 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id) { |
| 825 if (session_ready_cb_.is_null()) | 845 if (session_ready_cb_.is_null()) |
| 826 return; | 846 return; |
| 827 | 847 |
| 828 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 848 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
| 829 DCHECK(web_session_id_string); | 849 DCHECK(web_session_id_string); |
| 830 | 850 |
| 831 session_ready_cb_.Run(web_session_id_string->value()); | 851 session_ready_cb_.Run(web_session_id_string->value()); |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 | 1322 |
| 1303 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1323 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
| 1304 uint32_t promise_id) { | 1324 uint32_t promise_id) { |
| 1305 PromiseMap::iterator it = promises_.find(promise_id); | 1325 PromiseMap::iterator it = promises_.find(promise_id); |
| 1306 if (it == promises_.end()) | 1326 if (it == promises_.end()) |
| 1307 return scoped_ptr<CdmPromise>(); | 1327 return scoped_ptr<CdmPromise>(); |
| 1308 return promises_.take_and_erase(it); | 1328 return promises_.take_and_erase(it); |
| 1309 } | 1329 } |
| 1310 | 1330 |
| 1311 } // namespace content | 1331 } // namespace content |
| OLD | NEW |