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 "media/cdm/ppapi/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
6 | 6 |
7 #include "media/cdm/ppapi/cdm_file_io_impl.h" | 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
8 #include "media/cdm/ppapi/cdm_helpers.h" | 8 #include "media/cdm/ppapi/cdm_helpers.h" |
9 #include "media/cdm/ppapi/cdm_logging.h" | 9 #include "media/cdm/ppapi/cdm_logging.h" |
10 #include "media/cdm/ppapi/supported_cdm_versions.h" | 10 #include "media/cdm/ppapi/supported_cdm_versions.h" |
11 #include "ppapi/c/ppb_console.h" | 11 #include "ppapi/c/ppb_console.h" |
| 12 #include "ppapi/cpp/private/uma_private.h" |
12 | 13 |
13 #if defined(CHECK_DOCUMENT_URL) | 14 #if defined(CHECK_DOCUMENT_URL) |
14 #include "ppapi/cpp/dev/url_util_dev.h" | 15 #include "ppapi/cpp/dev/url_util_dev.h" |
15 #include "ppapi/cpp/instance_handle.h" | 16 #include "ppapi/cpp/instance_handle.h" |
16 #endif // defined(CHECK_DOCUMENT_URL) | 17 #endif // defined(CHECK_DOCUMENT_URL) |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 #if !defined(NDEBUG) | 21 #if !defined(NDEBUG) |
21 #define DLOG_TO_CONSOLE(message) LogToConsole(message); | 22 #define DLOG_TO_CONSOLE(message) LogToConsole(message); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 218 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
218 : pp::Instance(instance), | 219 : pp::Instance(instance), |
219 pp::ContentDecryptor_Private(this), | 220 pp::ContentDecryptor_Private(this), |
220 #if defined(OS_CHROMEOS) | 221 #if defined(OS_CHROMEOS) |
221 output_protection_(this), | 222 output_protection_(this), |
222 platform_verification_(this), | 223 platform_verification_(this), |
223 challenge_in_progress_(false), | 224 challenge_in_progress_(false), |
224 output_link_mask_(0), | 225 output_link_mask_(0), |
225 output_protection_mask_(0), | 226 output_protection_mask_(0), |
226 query_output_protection_in_progress_(false), | 227 query_output_protection_in_progress_(false), |
| 228 uma_for_output_protection_query_reported_(false), |
| 229 uma_for_output_protection_result_reported_(false), |
227 #endif | 230 #endif |
228 allocator_(this), | 231 allocator_(this), |
229 cdm_(NULL), | 232 cdm_(NULL), |
230 deferred_initialize_audio_decoder_(false), | 233 deferred_initialize_audio_decoder_(false), |
231 deferred_audio_decoder_config_id_(0), | 234 deferred_audio_decoder_config_id_(0), |
232 deferred_initialize_video_decoder_(false), | 235 deferred_initialize_video_decoder_(false), |
233 deferred_video_decoder_config_id_(0) { | 236 deferred_video_decoder_config_id_(0) { |
234 callback_factory_.Initialize(this); | 237 callback_factory_.Initialize(this); |
235 } | 238 } |
236 | 239 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 PP_DCHECK(!query_output_protection_in_progress_); | 837 PP_DCHECK(!query_output_protection_in_progress_); |
835 | 838 |
836 output_link_mask_ = output_protection_mask_ = 0; | 839 output_link_mask_ = output_protection_mask_ = 0; |
837 const int32_t result = output_protection_.QueryStatus( | 840 const int32_t result = output_protection_.QueryStatus( |
838 &output_link_mask_, | 841 &output_link_mask_, |
839 &output_protection_mask_, | 842 &output_protection_mask_, |
840 callback_factory_.NewCallback( | 843 callback_factory_.NewCallback( |
841 &CdmAdapter::QueryOutputProtectionStatusDone)); | 844 &CdmAdapter::QueryOutputProtectionStatusDone)); |
842 if (result == PP_OK_COMPLETIONPENDING) { | 845 if (result == PP_OK_COMPLETIONPENDING) { |
843 query_output_protection_in_progress_ = true; | 846 query_output_protection_in_progress_ = true; |
| 847 if (!uma_for_output_protection_query_reported_) { |
| 848 ReportOutputProtectionStatus(OUTPUT_PROTECTION_QUERIED); |
| 849 uma_for_output_protection_query_reported_ = true; |
| 850 } |
| 851 |
844 return; | 852 return; |
845 } | 853 } |
846 | 854 |
847 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). | 855 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). |
848 PP_DCHECK(result != PP_OK); | 856 PP_DCHECK(result != PP_OK); |
849 #endif | 857 #endif |
850 | 858 |
851 cdm_->OnQueryOutputProtectionStatus(0, 0); | 859 cdm_->OnQueryOutputProtectionStatus(0, 0); |
852 } | 860 } |
853 | 861 |
(...skipping 22 matching lines...) Expand all Loading... |
876 break; | 884 break; |
877 } | 885 } |
878 } | 886 } |
879 | 887 |
880 // The CDM owns the returned object and must call FileIO::Close() to release it. | 888 // The CDM owns the returned object and must call FileIO::Close() to release it. |
881 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { | 889 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { |
882 return new CdmFileIOImpl(client, pp_instance()); | 890 return new CdmFileIOImpl(client, pp_instance()); |
883 } | 891 } |
884 | 892 |
885 #if defined(OS_CHROMEOS) | 893 #if defined(OS_CHROMEOS) |
| 894 void CdmAdapter::ReportOutputProtectionStatus(OutputProtectionStatus status) { |
| 895 pp::UMAPrivate uma_interface_(this); |
| 896 std::string uma_name = "Media.EME.OutputProtection"; |
| 897 uma_interface_.HistogramEnumeration(uma_name, status, OUTPUT_PROTECTION_MAX); |
| 898 } |
| 899 |
| 900 void CdmAdapter::ReportOutputProtectionQueryResult(int32_t result) { |
| 901 // Report UMAs for output protection query result. |
| 902 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal); |
| 903 if (result != PP_OK) |
| 904 ReportOutputProtectionStatus(OUTPUT_PROTECTION_QUERY_ERROR); |
| 905 else if (!external_links) |
| 906 ReportOutputProtectionStatus(OUTPUT_PROTECTION_NO_EXTERNAL_LINK); |
| 907 else if ((output_protection_mask_ & external_links) == external_links) |
| 908 ReportOutputProtectionStatus(OUTPUT_PROTECTION_EXTERNAL_LINK_PROTECTED); |
| 909 else |
| 910 ReportOutputProtectionStatus(OUTPUT_PROTECTION_EXTERNAL_LINK_NOT_PROTECTED); |
| 911 } |
| 912 |
886 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { | 913 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { |
887 challenge_in_progress_ = false; | 914 challenge_in_progress_ = false; |
888 | 915 |
889 if (result != PP_OK) { | 916 if (result != PP_OK) { |
890 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; | 917 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; |
891 cdm::PlatformChallengeResponse response = {}; | 918 cdm::PlatformChallengeResponse response = {}; |
892 cdm_->OnPlatformChallengeResponse(response); | 919 cdm_->OnPlatformChallengeResponse(response); |
893 return; | 920 return; |
894 } | 921 } |
895 | 922 |
(...skipping 25 matching lines...) Expand all Loading... |
921 } | 948 } |
922 | 949 |
923 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { | 950 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { |
924 PP_DCHECK(query_output_protection_in_progress_); | 951 PP_DCHECK(query_output_protection_in_progress_); |
925 query_output_protection_in_progress_ = false; | 952 query_output_protection_in_progress_ = false; |
926 | 953 |
927 // Return a protection status of none on error. | 954 // Return a protection status of none on error. |
928 if (result != PP_OK) | 955 if (result != PP_OK) |
929 output_link_mask_ = output_protection_mask_ = 0; | 956 output_link_mask_ = output_protection_mask_ = 0; |
930 | 957 |
| 958 if (!uma_for_output_protection_result_reported_) { |
| 959 ReportOutputProtectionQueryResult(result); |
| 960 uma_for_output_protection_result_reported_ = true; |
| 961 } |
| 962 |
931 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, | 963 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, |
932 output_protection_mask_); | 964 output_protection_mask_); |
933 } | 965 } |
934 #endif | 966 #endif |
935 | 967 |
936 void* GetCdmHost(int host_interface_version, void* user_data) { | 968 void* GetCdmHost(int host_interface_version, void* user_data) { |
937 if (!host_interface_version || !user_data) | 969 if (!host_interface_version || !user_data) |
938 return NULL; | 970 return NULL; |
939 | 971 |
940 COMPILE_ASSERT( | 972 COMPILE_ASSERT( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } // namespace media | 1024 } // namespace media |
993 | 1025 |
994 namespace pp { | 1026 namespace pp { |
995 | 1027 |
996 // Factory function for your specialization of the Module object. | 1028 // Factory function for your specialization of the Module object. |
997 Module* CreateModule() { | 1029 Module* CreateModule() { |
998 return new media::CdmAdapterModule(); | 1030 return new media::CdmAdapterModule(); |
999 } | 1031 } |
1000 | 1032 |
1001 } // namespace pp | 1033 } // namespace pp |
OLD | NEW |