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/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
12 #include "content/renderer/media/crypto/key_systems.h" | 12 #include "content/renderer/media/crypto/key_systems.h" |
13 #include "content/renderer/pepper/ppb_buffer_impl.h" | 13 #include "content/renderer/pepper/ppb_buffer_impl.h" |
14 #include "media/base/audio_buffer.h" | 14 #include "media/base/audio_buffer.h" |
15 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
16 #include "media/base/bind_to_current_loop.h" | 16 #include "media/base/bind_to_current_loop.h" |
17 #include "media/base/cdm_promise.h" | 17 #include "media/base/cdm_promise.h" |
18 #include "media/base/channel_layout.h" | 18 #include "media/base/channel_layout.h" |
19 #include "media/base/data_buffer.h" | 19 #include "media/base/data_buffer.h" |
20 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
21 #include "media/base/decrypt_config.h" | 21 #include "media/base/decrypt_config.h" |
22 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
23 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
24 #include "media/base/video_frame.h" | 24 #include "media/base/video_frame.h" |
25 #include "media/base/video_util.h" | 25 #include "media/base/video_util.h" |
26 #include "ppapi/shared_impl/array_var.h" | 26 #include "ppapi/shared_impl/array_var.h" |
27 #include "ppapi/shared_impl/scoped_pp_resource.h" | 27 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 28 #include "ppapi/shared_impl/time_conversion.h" |
28 #include "ppapi/shared_impl/var.h" | 29 #include "ppapi/shared_impl/var.h" |
29 #include "ppapi/shared_impl/var_tracker.h" | 30 #include "ppapi/shared_impl/var_tracker.h" |
30 #include "ppapi/thunk/enter.h" | 31 #include "ppapi/thunk/enter.h" |
31 #include "ppapi/thunk/ppb_buffer_api.h" | 32 #include "ppapi/thunk/ppb_buffer_api.h" |
32 #include "ui/gfx/rect.h" | 33 #include "ui/gfx/rect.h" |
33 | 34 |
34 using media::CdmPromise; | 35 using media::CdmPromise; |
35 using media::Decryptor; | 36 using media::Decryptor; |
36 using media::KeyIdsPromise; | 37 using media::KeyIdsPromise; |
37 using media::MediaKeys; | 38 using media::MediaKeys; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 ContentDecryptorDelegate::~ContentDecryptorDelegate() { | 320 ContentDecryptorDelegate::~ContentDecryptorDelegate() { |
320 SatisfyAllPendingCallbacksOnError(); | 321 SatisfyAllPendingCallbacksOnError(); |
321 } | 322 } |
322 | 323 |
323 void ContentDecryptorDelegate::Initialize( | 324 void ContentDecryptorDelegate::Initialize( |
324 const std::string& key_system, | 325 const std::string& key_system, |
325 const media::SessionMessageCB& session_message_cb, | 326 const media::SessionMessageCB& session_message_cb, |
326 const media::SessionReadyCB& session_ready_cb, | 327 const media::SessionReadyCB& session_ready_cb, |
327 const media::SessionClosedCB& session_closed_cb, | 328 const media::SessionClosedCB& session_closed_cb, |
328 const media::SessionErrorCB& session_error_cb, | 329 const media::SessionErrorCB& session_error_cb, |
| 330 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 331 const media::SessionExpirationUpdateCB& session_expiration_update_cb, |
329 const base::Closure& fatal_plugin_error_cb) { | 332 const base::Closure& fatal_plugin_error_cb) { |
330 DCHECK(!key_system.empty()); | 333 DCHECK(!key_system.empty()); |
331 DCHECK(key_system_.empty()); | 334 DCHECK(key_system_.empty()); |
332 key_system_ = key_system; | 335 key_system_ = key_system; |
333 | 336 |
334 session_message_cb_ = session_message_cb; | 337 session_message_cb_ = session_message_cb; |
335 session_ready_cb_ = session_ready_cb; | 338 session_ready_cb_ = session_ready_cb; |
336 session_closed_cb_ = session_closed_cb; | 339 session_closed_cb_ = session_closed_cb; |
337 session_error_cb_ = session_error_cb; | 340 session_error_cb_ = session_error_cb; |
| 341 session_keys_change_cb_ = session_keys_change_cb; |
| 342 session_expiration_update_cb_ = session_expiration_update_cb; |
338 fatal_plugin_error_cb_ = fatal_plugin_error_cb; | 343 fatal_plugin_error_cb_ = fatal_plugin_error_cb; |
339 | 344 |
340 plugin_decryption_interface_->Initialize( | 345 plugin_decryption_interface_->Initialize( |
341 pp_instance_, StringVar::StringToPPVar(key_system_)); | 346 pp_instance_, StringVar::StringToPPVar(key_system_)); |
342 } | 347 } |
343 | 348 |
344 void ContentDecryptorDelegate::InstanceCrashed() { | 349 void ContentDecryptorDelegate::InstanceCrashed() { |
345 fatal_plugin_error_cb_.Run(); | 350 fatal_plugin_error_cb_.Run(); |
346 SatisfyAllPendingCallbacksOnError(); | 351 SatisfyAllPendingCallbacksOnError(); |
347 } | 352 } |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. | 824 verified_gurl = GURL::EmptyGURL(); // Replace invalid destination_url. |
820 } | 825 } |
821 | 826 |
822 session_message_cb_.Run( | 827 session_message_cb_.Run( |
823 web_session_id_string->value(), message_vector, verified_gurl); | 828 web_session_id_string->value(), message_vector, verified_gurl); |
824 } | 829 } |
825 | 830 |
826 void ContentDecryptorDelegate::OnSessionKeysChange( | 831 void ContentDecryptorDelegate::OnSessionKeysChange( |
827 PP_Var web_session_id, | 832 PP_Var web_session_id, |
828 PP_Bool has_additional_usable_key) { | 833 PP_Bool has_additional_usable_key) { |
829 // TODO(jrummell): Pass this event on. | 834 if (session_keys_change_cb_.is_null()) |
| 835 return; |
| 836 |
| 837 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
| 838 DCHECK(web_session_id_string); |
| 839 |
| 840 session_keys_change_cb_.Run(web_session_id_string->value(), |
| 841 PP_ToBool(has_additional_usable_key)); |
830 } | 842 } |
831 | 843 |
832 void ContentDecryptorDelegate::OnSessionExpirationChange( | 844 void ContentDecryptorDelegate::OnSessionExpirationChange( |
833 PP_Var web_session_id, | 845 PP_Var web_session_id, |
834 PP_Time new_expiry_time) { | 846 PP_Time new_expiry_time) { |
835 // TODO(jrummell): Pass this event on. | 847 if (session_expiration_update_cb_.is_null()) |
| 848 return; |
| 849 |
| 850 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
| 851 DCHECK(web_session_id_string); |
| 852 |
| 853 session_expiration_update_cb_.Run(web_session_id_string->value(), |
| 854 ppapi::PPTimeToTime(new_expiry_time)); |
836 } | 855 } |
837 | 856 |
838 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id) { | 857 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id) { |
839 if (session_ready_cb_.is_null()) | 858 if (session_ready_cb_.is_null()) |
840 return; | 859 return; |
841 | 860 |
842 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 861 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
843 DCHECK(web_session_id_string); | 862 DCHECK(web_session_id_string); |
844 | 863 |
845 session_ready_cb_.Run(web_session_id_string->value()); | 864 session_ready_cb_.Run(web_session_id_string->value()); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 | 1337 |
1319 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1338 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
1320 uint32_t promise_id) { | 1339 uint32_t promise_id) { |
1321 PromiseMap::iterator it = promises_.find(promise_id); | 1340 PromiseMap::iterator it = promises_.find(promise_id); |
1322 if (it == promises_.end()) | 1341 if (it == promises_.end()) |
1323 return scoped_ptr<CdmPromise>(); | 1342 return scoped_ptr<CdmPromise>(); |
1324 return promises_.take_and_erase(it); | 1343 return promises_.take_and_erase(it); |
1325 } | 1344 } |
1326 | 1345 |
1327 } // namespace content | 1346 } // namespace content |
OLD | NEW |