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" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 } // namespace | 248 } // namespace |
249 | 249 |
250 namespace media { | 250 namespace media { |
251 | 251 |
252 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) | 252 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
253 : pp::Instance(instance), | 253 : pp::Instance(instance), |
254 pp::ContentDecryptor_Private(this), | 254 pp::ContentDecryptor_Private(this), |
255 #if defined(OS_CHROMEOS) | 255 #if defined(OS_CHROMEOS) |
256 output_protection_(this), | 256 output_protection_(this), |
257 platform_verification_(this), | 257 platform_verification_(this), |
258 challenge_in_progress_(false), | |
259 output_link_mask_(0), | 258 output_link_mask_(0), |
260 output_protection_mask_(0), | 259 output_protection_mask_(0), |
261 query_output_protection_in_progress_(false), | 260 query_output_protection_in_progress_(false), |
262 uma_for_output_protection_query_reported_(false), | 261 uma_for_output_protection_query_reported_(false), |
263 uma_for_output_protection_positive_result_reported_(false), | 262 uma_for_output_protection_positive_result_reported_(false), |
264 #endif | 263 #endif |
265 allocator_(this), | 264 allocator_(this), |
266 cdm_(NULL), | 265 cdm_(NULL), |
267 deferred_initialize_audio_decoder_(false), | 266 deferred_initialize_audio_decoder_(false), |
268 deferred_audio_decoder_config_id_(0), | 267 deferred_audio_decoder_config_id_(0), |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( | 997 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( |
999 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 998 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
1000 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); | 999 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); |
1001 } | 1000 } |
1002 #endif // !defined(NDEBUG) | 1001 #endif // !defined(NDEBUG) |
1003 | 1002 |
1004 void CdmAdapter::SendPlatformChallenge( | 1003 void CdmAdapter::SendPlatformChallenge( |
1005 const char* service_id, uint32_t service_id_length, | 1004 const char* service_id, uint32_t service_id_length, |
1006 const char* challenge, uint32_t challenge_length) { | 1005 const char* challenge, uint32_t challenge_length) { |
1007 #if defined(OS_CHROMEOS) | 1006 #if defined(OS_CHROMEOS) |
1008 PP_DCHECK(!challenge_in_progress_); | |
1009 | |
1010 // Ensure member variables set by the callback are in a clean state. | |
1011 signed_data_output_ = pp::Var(); | |
1012 signed_data_signature_output_ = pp::Var(); | |
1013 platform_key_certificate_output_ = pp::Var(); | |
1014 | |
1015 pp::VarArrayBuffer challenge_var(challenge_length); | 1007 pp::VarArrayBuffer challenge_var(challenge_length); |
1016 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); | 1008 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); |
1017 memcpy(var_data, challenge, challenge_length); | 1009 memcpy(var_data, challenge, challenge_length); |
1018 | 1010 |
1019 std::string service_id_str(service_id, service_id_length); | 1011 std::string service_id_str(service_id, service_id_length); |
1012 | |
1013 linked_ptr<PepperPlatformChallengeResponse> response( | |
1014 new PepperPlatformChallengeResponse()); | |
1015 | |
1020 int32_t result = platform_verification_.ChallengePlatform( | 1016 int32_t result = platform_verification_.ChallengePlatform( |
1021 pp::Var(service_id_str), challenge_var, &signed_data_output_, | 1017 pp::Var(service_id_str), |
1022 &signed_data_signature_output_, &platform_key_certificate_output_, | 1018 challenge_var, |
1023 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone)); | 1019 &response->signed_data, |
1020 &response->signed_data_signature, | |
1021 &response->platform_key_certificate, | |
1022 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone, | |
1023 response)); | |
1024 challenge_var.Unmap(); | 1024 challenge_var.Unmap(); |
1025 if (result == PP_OK_COMPLETIONPENDING) { | 1025 if (result == PP_OK_COMPLETIONPENDING) |
1026 challenge_in_progress_ = true; | |
1027 return; | 1026 return; |
1028 } | |
1029 | 1027 |
1030 // Fall through on error and issue an empty OnPlatformChallengeResponse(). | 1028 // Fall through on error and issue an empty OnPlatformChallengeResponse(). |
1031 PP_DCHECK(result != PP_OK); | 1029 PP_DCHECK(result != PP_OK); |
1032 #endif | 1030 #endif |
1033 | 1031 |
1034 cdm::PlatformChallengeResponse response = {}; | 1032 cdm::PlatformChallengeResponse platform_challenge_response = {}; |
xhwang
2014/07/16 00:13:18
rename because we have a different "response" on l
| |
1035 cdm_->OnPlatformChallengeResponse(response); | 1033 cdm_->OnPlatformChallengeResponse(platform_challenge_response); |
1036 } | 1034 } |
1037 | 1035 |
1038 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { | 1036 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { |
1039 #if defined(OS_CHROMEOS) | 1037 #if defined(OS_CHROMEOS) |
1040 int32_t result = output_protection_.EnableProtection( | 1038 int32_t result = output_protection_.EnableProtection( |
1041 desired_protection_mask, callback_factory_.NewCallback( | 1039 desired_protection_mask, callback_factory_.NewCallback( |
1042 &CdmAdapter::EnableProtectionDone)); | 1040 &CdmAdapter::EnableProtectionDone)); |
1043 | 1041 |
1044 // Errors are ignored since clients must call QueryOutputProtectionStatus() to | 1042 // Errors are ignored since clients must call QueryOutputProtectionStatus() to |
1045 // inspect the protection status on a regular basis. | 1043 // inspect the protection status on a regular basis. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); | 1141 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); |
1144 uma_for_output_protection_positive_result_reported_ = true; | 1142 uma_for_output_protection_positive_result_reported_ = true; |
1145 return; | 1143 return; |
1146 } | 1144 } |
1147 | 1145 |
1148 // Do not report a negative result because it could be a false negative. | 1146 // Do not report a negative result because it could be a false negative. |
1149 // Instead, we will calculate number of negatives using the total number of | 1147 // Instead, we will calculate number of negatives using the total number of |
1150 // queries and success results. | 1148 // queries and success results. |
1151 } | 1149 } |
1152 | 1150 |
1153 void CdmAdapter::SendPlatformChallengeDone(int32_t result) { | 1151 void CdmAdapter::SendPlatformChallengeDone( |
1154 challenge_in_progress_ = false; | 1152 int32_t result, |
1155 | 1153 const linked_ptr<PepperPlatformChallengeResponse>& response) { |
1156 if (result != PP_OK) { | 1154 if (result != PP_OK) { |
1157 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; | 1155 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; |
1158 cdm::PlatformChallengeResponse response = {}; | 1156 cdm::PlatformChallengeResponse platform_challenge_response = {}; |
1159 cdm_->OnPlatformChallengeResponse(response); | 1157 cdm_->OnPlatformChallengeResponse(platform_challenge_response); |
1160 return; | 1158 return; |
1161 } | 1159 } |
1162 | 1160 |
1163 pp::VarArrayBuffer signed_data_var(signed_data_output_); | 1161 pp::VarArrayBuffer signed_data_var(response->signed_data); |
1164 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); | 1162 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature); |
1165 std::string platform_key_certificate_string = | 1163 std::string platform_key_certificate_string = |
1166 platform_key_certificate_output_.AsString(); | 1164 response->platform_key_certificate.AsString(); |
1167 | 1165 |
1168 cdm::PlatformChallengeResponse response = { | 1166 cdm::PlatformChallengeResponse platform_challenge_response = { |
1169 static_cast<uint8_t*>(signed_data_var.Map()), | 1167 static_cast<uint8_t*>(signed_data_var.Map()), |
1170 signed_data_var.ByteLength(), | 1168 signed_data_var.ByteLength(), |
1171 static_cast<uint8_t*>(signed_data_signature_var.Map()), | 1169 static_cast<uint8_t*>(signed_data_signature_var.Map()), |
1172 signed_data_signature_var.ByteLength(), | 1170 signed_data_signature_var.ByteLength(), |
1173 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), | 1171 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), |
1174 static_cast<uint32_t>(platform_key_certificate_string.length())}; | 1172 static_cast<uint32_t>(platform_key_certificate_string.length())}; |
1175 cdm_->OnPlatformChallengeResponse(response); | 1173 cdm_->OnPlatformChallengeResponse(platform_challenge_response); |
dmichael (off chromium)
2014/07/16 15:21:32
One thing I just noticed... OnPlatformChallengeRe
xhwang
2014/07/16 16:14:31
Thanks for pointing this out. In all CDM interface
| |
1176 | 1174 |
1177 signed_data_var.Unmap(); | 1175 signed_data_var.Unmap(); |
1178 signed_data_signature_var.Unmap(); | 1176 signed_data_signature_var.Unmap(); |
1179 } | 1177 } |
1180 | 1178 |
1181 void CdmAdapter::EnableProtectionDone(int32_t result) { | 1179 void CdmAdapter::EnableProtectionDone(int32_t result) { |
1182 // Does nothing since clients must call QueryOutputProtectionStatus() to | 1180 // Does nothing since clients must call QueryOutputProtectionStatus() to |
1183 // inspect the protection status on a regular basis. | 1181 // inspect the protection status on a regular basis. |
1184 CDM_DLOG() << __FUNCTION__ << " : " << result; | 1182 CDM_DLOG() << __FUNCTION__ << " : " << result; |
1185 } | 1183 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 } // namespace media | 1266 } // namespace media |
1269 | 1267 |
1270 namespace pp { | 1268 namespace pp { |
1271 | 1269 |
1272 // Factory function for your specialization of the Module object. | 1270 // Factory function for your specialization of the Module object. |
1273 Module* CreateModule() { | 1271 Module* CreateModule() { |
1274 return new media::CdmAdapterModule(); | 1272 return new media::CdmAdapterModule(); |
1275 } | 1273 } |
1276 | 1274 |
1277 } // namespace pp | 1275 } // namespace pp |
OLD | NEW |