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/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "content/renderer/media/crypto/key_systems.h" |
11 #include "content/renderer/pepper/ppb_buffer_impl.h" | 13 #include "content/renderer/pepper/ppb_buffer_impl.h" |
12 #include "media/base/audio_buffer.h" | 14 #include "media/base/audio_buffer.h" |
13 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/bind_to_current_loop.h" | 16 #include "media/base/bind_to_current_loop.h" |
15 #include "media/base/cdm_promise.h" | 17 #include "media/base/cdm_promise.h" |
16 #include "media/base/channel_layout.h" | 18 #include "media/base/channel_layout.h" |
17 #include "media/base/data_buffer.h" | 19 #include "media/base/data_buffer.h" |
18 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
19 #include "media/base/decrypt_config.h" | 21 #include "media/base/decrypt_config.h" |
20 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return false; | 89 return false; |
88 | 90 |
89 memcpy(array, str.data(), str.size()); | 91 memcpy(array, str.data(), str.size()); |
90 return true; | 92 return true; |
91 } | 93 } |
92 | 94 |
93 // Fills the |block_info| with information from |encrypted_buffer|. | 95 // Fills the |block_info| with information from |encrypted_buffer|. |
94 // | 96 // |
95 // Returns true if |block_info| is successfully filled. Returns false | 97 // Returns true if |block_info| is successfully filled. Returns false |
96 // otherwise. | 98 // otherwise. |
97 static bool MakeEncryptedBlockInfo( | 99 bool MakeEncryptedBlockInfo( |
98 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 100 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
99 uint32_t request_id, | 101 uint32_t request_id, |
100 PP_EncryptedBlockInfo* block_info) { | 102 PP_EncryptedBlockInfo* block_info) { |
101 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and | 103 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and |
102 // anywhere else. | 104 // anywhere else. |
103 memset(block_info, 0, sizeof(*block_info)); | 105 memset(block_info, 0, sizeof(*block_info)); |
104 block_info->tracking_info.request_id = request_id; | 106 block_info->tracking_info.request_id = request_id; |
105 | 107 |
106 // EOS buffers need a request ID and nothing more. | 108 // EOS buffers need a request ID and nothing more. |
107 if (encrypted_buffer->end_of_stream()) | 109 if (encrypted_buffer->end_of_stream()) |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 case PP_CDMEXCEPTIONCODE_CLIENTERROR: | 283 case PP_CDMEXCEPTIONCODE_CLIENTERROR: |
282 return MediaKeys::CLIENT_ERROR; | 284 return MediaKeys::CLIENT_ERROR; |
283 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: | 285 case PP_CDMEXCEPTIONCODE_OUTPUTERROR: |
284 return MediaKeys::OUTPUT_ERROR; | 286 return MediaKeys::OUTPUT_ERROR; |
285 default: | 287 default: |
286 NOTREACHED(); | 288 NOTREACHED(); |
287 return MediaKeys::UNKNOWN_ERROR; | 289 return MediaKeys::UNKNOWN_ERROR; |
288 } | 290 } |
289 } | 291 } |
290 | 292 |
| 293 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. |
| 294 // See http://crbug.com/412987 for details. |
| 295 void ReportSystemCodeUMA(const std::string& key_system, uint32 system_code) { |
| 296 // Sparse histogram macro does not cache the histogram, so it's safe to use |
| 297 // macro with non-static histogram name here. |
| 298 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 299 "Media.EME." + KeySystemNameForUMA(key_system) + ".SystemCode", |
| 300 system_code); |
| 301 } |
| 302 |
291 } // namespace | 303 } // namespace |
292 | 304 |
293 ContentDecryptorDelegate::ContentDecryptorDelegate( | 305 ContentDecryptorDelegate::ContentDecryptorDelegate( |
294 PP_Instance pp_instance, | 306 PP_Instance pp_instance, |
295 const PPP_ContentDecryptor_Private* plugin_decryption_interface) | 307 const PPP_ContentDecryptor_Private* plugin_decryption_interface) |
296 : pp_instance_(pp_instance), | 308 : pp_instance_(pp_instance), |
297 plugin_decryption_interface_(plugin_decryption_interface), | 309 plugin_decryption_interface_(plugin_decryption_interface), |
298 next_decryption_request_id_(1), | 310 next_decryption_request_id_(1), |
299 audio_samples_per_second_(0), | 311 audio_samples_per_second_(0), |
300 audio_channel_count_(0), | 312 audio_channel_count_(0), |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 | 772 |
761 KeyIdsPromise* key_ids_promise(static_cast<KeyIdsPromise*>(promise.get())); | 773 KeyIdsPromise* key_ids_promise(static_cast<KeyIdsPromise*>(promise.get())); |
762 key_ids_promise->resolve(key_ids_vector); | 774 key_ids_promise->resolve(key_ids_vector); |
763 } | 775 } |
764 | 776 |
765 void ContentDecryptorDelegate::OnPromiseRejected( | 777 void ContentDecryptorDelegate::OnPromiseRejected( |
766 uint32 promise_id, | 778 uint32 promise_id, |
767 PP_CdmExceptionCode exception_code, | 779 PP_CdmExceptionCode exception_code, |
768 uint32 system_code, | 780 uint32 system_code, |
769 PP_Var error_description) { | 781 PP_Var error_description) { |
| 782 ReportSystemCodeUMA(key_system_, system_code); |
| 783 |
770 StringVar* error_description_string = StringVar::FromPPVar(error_description); | 784 StringVar* error_description_string = StringVar::FromPPVar(error_description); |
771 DCHECK(error_description_string); | 785 DCHECK(error_description_string); |
772 | 786 |
773 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); | 787 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
774 DCHECK(promise); | 788 DCHECK(promise); |
775 if (promise) { | 789 if (promise) { |
776 promise->reject(PpExceptionTypeToMediaException(exception_code), | 790 promise->reject(PpExceptionTypeToMediaException(exception_code), |
777 system_code, | 791 system_code, |
778 error_description_string->value()); | 792 error_description_string->value()); |
779 } | 793 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 DCHECK(web_session_id_string); | 853 DCHECK(web_session_id_string); |
840 | 854 |
841 session_closed_cb_.Run(web_session_id_string->value()); | 855 session_closed_cb_.Run(web_session_id_string->value()); |
842 } | 856 } |
843 | 857 |
844 void ContentDecryptorDelegate::OnSessionError( | 858 void ContentDecryptorDelegate::OnSessionError( |
845 PP_Var web_session_id, | 859 PP_Var web_session_id, |
846 PP_CdmExceptionCode exception_code, | 860 PP_CdmExceptionCode exception_code, |
847 uint32 system_code, | 861 uint32 system_code, |
848 PP_Var error_description) { | 862 PP_Var error_description) { |
| 863 ReportSystemCodeUMA(key_system_, system_code); |
| 864 |
849 if (session_error_cb_.is_null()) | 865 if (session_error_cb_.is_null()) |
850 return; | 866 return; |
851 | 867 |
852 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 868 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
853 DCHECK(web_session_id_string); | 869 DCHECK(web_session_id_string); |
854 | 870 |
855 StringVar* error_description_string = StringVar::FromPPVar(error_description); | 871 StringVar* error_description_string = StringVar::FromPPVar(error_description); |
856 DCHECK(error_description_string); | 872 DCHECK(error_description_string); |
857 | 873 |
858 session_error_cb_.Run(web_session_id_string->value(), | 874 session_error_cb_.Run(web_session_id_string->value(), |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 | 1318 |
1303 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1319 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
1304 uint32_t promise_id) { | 1320 uint32_t promise_id) { |
1305 PromiseMap::iterator it = promises_.find(promise_id); | 1321 PromiseMap::iterator it = promises_.find(promise_id); |
1306 if (it == promises_.end()) | 1322 if (it == promises_.end()) |
1307 return scoped_ptr<CdmPromise>(); | 1323 return scoped_ptr<CdmPromise>(); |
1308 return promises_.take_and_erase(it); | 1324 return promises_.take_and_erase(it); |
1309 } | 1325 } |
1310 | 1326 |
1311 } // namespace content | 1327 } // namespace content |
OLD | NEW |