Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: media/cdm/ppapi/ppapi_cdm_adapter.cc

Issue 2095963004: Revert of media: Add OutputProtectionProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cdm/ppapi/ppapi_cdm_adapter.h ('k') | media/test/data/eme_player_js/app_loader.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ppapi_cdm_adapter.h" 5 #include "media/cdm/ppapi/ppapi_cdm_adapter.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return PP_CDMKEYSTATUS_INVALID; 313 return PP_CDMKEYSTATUS_INVALID;
314 } 314 }
315 315
316 } // namespace 316 } // namespace
317 317
318 namespace media { 318 namespace media {
319 319
320 PpapiCdmAdapter::PpapiCdmAdapter(PP_Instance instance, pp::Module* module) 320 PpapiCdmAdapter::PpapiCdmAdapter(PP_Instance instance, pp::Module* module)
321 : pp::Instance(instance), 321 : pp::Instance(instance),
322 pp::ContentDecryptor_Private(this), 322 pp::ContentDecryptor_Private(this),
323 #if defined(OS_CHROMEOS)
323 output_protection_(this), 324 output_protection_(this),
325 platform_verification_(this),
324 output_link_mask_(0), 326 output_link_mask_(0),
325 output_protection_mask_(0), 327 output_protection_mask_(0),
326 query_output_protection_in_progress_(false), 328 query_output_protection_in_progress_(false),
327 uma_for_output_protection_query_reported_(false), 329 uma_for_output_protection_query_reported_(false),
328 uma_for_output_protection_positive_result_reported_(false), 330 uma_for_output_protection_positive_result_reported_(false),
329 #if defined(OS_CHROMEOS)
330 platform_verification_(this),
331 #endif 331 #endif
332 allocator_(this), 332 allocator_(this),
333 cdm_(NULL), 333 cdm_(NULL),
334 allow_distinctive_identifier_(false), 334 allow_distinctive_identifier_(false),
335 allow_persistent_state_(false), 335 allow_persistent_state_(false),
336 deferred_initialize_audio_decoder_(false), 336 deferred_initialize_audio_decoder_(false),
337 deferred_audio_decoder_config_id_(0), 337 deferred_audio_decoder_config_id_(0),
338 deferred_initialize_video_decoder_(false), 338 deferred_initialize_video_decoder_(false),
339 deferred_video_decoder_config_id_(0), 339 deferred_video_decoder_config_id_(0),
340 last_read_file_size_kb_(0), 340 last_read_file_size_kb_(0),
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // Fall through on error and issue an empty OnPlatformChallengeResponse(). 1062 // Fall through on error and issue an empty OnPlatformChallengeResponse().
1063 PP_DCHECK(result != PP_OK); 1063 PP_DCHECK(result != PP_OK);
1064 } 1064 }
1065 #endif 1065 #endif
1066 1066
1067 cdm::PlatformChallengeResponse platform_challenge_response = {}; 1067 cdm::PlatformChallengeResponse platform_challenge_response = {};
1068 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1068 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1069 } 1069 }
1070 1070
1071 void PpapiCdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { 1071 void PpapiCdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) {
1072 #if defined(OS_CHROMEOS)
1072 int32_t result = output_protection_.EnableProtection( 1073 int32_t result = output_protection_.EnableProtection(
1073 desired_protection_mask, 1074 desired_protection_mask,
1074 callback_factory_.NewCallback(&PpapiCdmAdapter::EnableProtectionDone)); 1075 callback_factory_.NewCallback(&PpapiCdmAdapter::EnableProtectionDone));
1075 1076
1076 // Errors are ignored since clients must call QueryOutputProtectionStatus() to 1077 // Errors are ignored since clients must call QueryOutputProtectionStatus() to
1077 // inspect the protection status on a regular basis. 1078 // inspect the protection status on a regular basis.
1078 1079
1079 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING) 1080 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING)
1080 CDM_DLOG() << __FUNCTION__ << " failed!"; 1081 CDM_DLOG() << __FUNCTION__ << " failed!";
1082 #endif
1081 } 1083 }
1082 1084
1083 void PpapiCdmAdapter::QueryOutputProtectionStatus() { 1085 void PpapiCdmAdapter::QueryOutputProtectionStatus() {
1086 #if defined(OS_CHROMEOS)
1084 PP_DCHECK(!query_output_protection_in_progress_); 1087 PP_DCHECK(!query_output_protection_in_progress_);
1085 1088
1086 output_link_mask_ = output_protection_mask_ = 0; 1089 output_link_mask_ = output_protection_mask_ = 0;
1087 const int32_t result = output_protection_.QueryStatus( 1090 const int32_t result = output_protection_.QueryStatus(
1088 &output_link_mask_, &output_protection_mask_, 1091 &output_link_mask_, &output_protection_mask_,
1089 callback_factory_.NewCallback( 1092 callback_factory_.NewCallback(
1090 &PpapiCdmAdapter::QueryOutputProtectionStatusDone)); 1093 &PpapiCdmAdapter::QueryOutputProtectionStatusDone));
1091 if (result == PP_OK_COMPLETIONPENDING) { 1094 if (result == PP_OK_COMPLETIONPENDING) {
1092 query_output_protection_in_progress_ = true; 1095 query_output_protection_in_progress_ = true;
1093 ReportOutputProtectionQuery(); 1096 ReportOutputProtectionQuery();
1094 return; 1097 return;
1095 } 1098 }
1096 1099
1097 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). 1100 // Fall through on error and issue an empty OnQueryOutputProtectionStatus().
1098 PP_DCHECK(result != PP_OK); 1101 PP_DCHECK(result != PP_OK);
1099 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result; 1102 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result;
1103 #endif
1104 cdm_->OnQueryOutputProtectionStatus(cdm::kQueryFailed, 0, 0);
1100 } 1105 }
1101 1106
1102 void PpapiCdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, 1107 void PpapiCdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type,
1103 cdm::Status decoder_status) { 1108 cdm::Status decoder_status) {
1104 switch (stream_type) { 1109 switch (stream_type) {
1105 case cdm::kStreamTypeAudio: 1110 case cdm::kStreamTypeAudio:
1106 PP_DCHECK(deferred_initialize_audio_decoder_); 1111 PP_DCHECK(deferred_initialize_audio_decoder_);
1107 CallOnMain(callback_factory_.NewCallback( 1112 CallOnMain(callback_factory_.NewCallback(
1108 &PpapiCdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO, 1113 &PpapiCdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO,
1109 deferred_audio_decoder_config_id_, decoder_status == cdm::kSuccess)); 1114 deferred_audio_decoder_config_id_, decoder_status == cdm::kSuccess));
(...skipping 17 matching lines...) Expand all
1127 CDM_DLOG() 1132 CDM_DLOG()
1128 << "Cannot create FileIO because persistent state is not allowed."; 1133 << "Cannot create FileIO because persistent state is not allowed.";
1129 return nullptr; 1134 return nullptr;
1130 } 1135 }
1131 1136
1132 return new CdmFileIOImpl( 1137 return new CdmFileIOImpl(
1133 client, pp_instance(), 1138 client, pp_instance(),
1134 callback_factory_.NewCallback(&PpapiCdmAdapter::OnFirstFileRead)); 1139 callback_factory_.NewCallback(&PpapiCdmAdapter::OnFirstFileRead));
1135 } 1140 }
1136 1141
1142 #if defined(OS_CHROMEOS)
1137 void PpapiCdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) { 1143 void PpapiCdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) {
1138 pp::UMAPrivate uma_interface(this); 1144 pp::UMAPrivate uma_interface(this);
1139 uma_interface.HistogramEnumeration("Media.EME.OutputProtection", status, 1145 uma_interface.HistogramEnumeration("Media.EME.OutputProtection", status,
1140 OUTPUT_PROTECTION_MAX); 1146 OUTPUT_PROTECTION_MAX);
1141 } 1147 }
1142 1148
1143 void PpapiCdmAdapter::ReportOutputProtectionQuery() { 1149 void PpapiCdmAdapter::ReportOutputProtectionQuery() {
1144 if (uma_for_output_protection_query_reported_) 1150 if (uma_for_output_protection_query_reported_)
1145 return; 1151 return;
1146 1152
1147 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED); 1153 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED);
1148 uma_for_output_protection_query_reported_ = true; 1154 uma_for_output_protection_query_reported_ = true;
1149 } 1155 }
1150 1156
1151 void PpapiCdmAdapter::ReportOutputProtectionQueryResult() { 1157 void PpapiCdmAdapter::ReportOutputProtectionQueryResult() {
1152 if (uma_for_output_protection_positive_result_reported_) 1158 if (uma_for_output_protection_positive_result_reported_)
1153 return; 1159 return;
1154 1160
1155 // Report UMAs for output protection query result. 1161 // Report UMAs for output protection query result.
1156 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal); 1162 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal);
1157 1163
1158 if (!external_links) { 1164 if (!external_links) {
1159 ReportOutputProtectionUMA(OUTPUT_PROTECTION_NO_EXTERNAL_LINK); 1165 ReportOutputProtectionUMA(OUTPUT_PROTECTION_NO_EXTERNAL_LINK);
1160 uma_for_output_protection_positive_result_reported_ = true; 1166 uma_for_output_protection_positive_result_reported_ = true;
1161 return; 1167 return;
1162 } 1168 }
1163 1169
1164 const uint32_t kProtectableLinks = 1170 const uint32_t kProtectableLinks =
1165 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort; 1171 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort;
1166 bool is_unprotectable_link_connected = 1172 bool is_unprotectable_link_connected = external_links & ~kProtectableLinks;
1167 (external_links & ~kProtectableLinks) != 0;
1168 bool is_hdcp_enabled_on_all_protectable_links = 1173 bool is_hdcp_enabled_on_all_protectable_links =
1169 (output_protection_mask_ & cdm::kProtectionHDCP) != 0; 1174 output_protection_mask_ & cdm::kProtectionHDCP;
1170 1175
1171 if (!is_unprotectable_link_connected && 1176 if (!is_unprotectable_link_connected &&
1172 is_hdcp_enabled_on_all_protectable_links) { 1177 is_hdcp_enabled_on_all_protectable_links) {
1173 ReportOutputProtectionUMA(OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); 1178 ReportOutputProtectionUMA(OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED);
1174 uma_for_output_protection_positive_result_reported_ = true; 1179 uma_for_output_protection_positive_result_reported_ = true;
1175 return; 1180 return;
1176 } 1181 }
1177 1182
1178 // Do not report a negative result because it could be a false negative. 1183 // Do not report a negative result because it could be a false negative.
1179 // Instead, we will calculate number of negatives using the total number of 1184 // Instead, we will calculate number of negatives using the total number of
1180 // queries and success results. 1185 // queries and success results.
1181 } 1186 }
1182 1187
1183 #if defined(OS_CHROMEOS)
1184 void PpapiCdmAdapter::SendPlatformChallengeDone( 1188 void PpapiCdmAdapter::SendPlatformChallengeDone(
1185 int32_t result, 1189 int32_t result,
1186 const linked_ptr<PepperPlatformChallengeResponse>& response) { 1190 const linked_ptr<PepperPlatformChallengeResponse>& response) {
1187 if (result != PP_OK) { 1191 if (result != PP_OK) {
1188 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; 1192 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!";
1189 cdm::PlatformChallengeResponse platform_challenge_response = {}; 1193 cdm::PlatformChallengeResponse platform_challenge_response = {};
1190 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1194 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1191 return; 1195 return;
1192 } 1196 }
1193 1197
1194 pp::VarArrayBuffer signed_data_var(response->signed_data); 1198 pp::VarArrayBuffer signed_data_var(response->signed_data);
1195 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature); 1199 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature);
1196 std::string platform_key_certificate_string = 1200 std::string platform_key_certificate_string =
1197 response->platform_key_certificate.AsString(); 1201 response->platform_key_certificate.AsString();
1198 1202
1199 cdm::PlatformChallengeResponse platform_challenge_response = { 1203 cdm::PlatformChallengeResponse platform_challenge_response = {
1200 static_cast<uint8_t*>(signed_data_var.Map()), 1204 static_cast<uint8_t*>(signed_data_var.Map()),
1201 signed_data_var.ByteLength(), 1205 signed_data_var.ByteLength(),
1202 static_cast<uint8_t*>(signed_data_signature_var.Map()), 1206 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1203 signed_data_signature_var.ByteLength(), 1207 signed_data_signature_var.ByteLength(),
1204 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), 1208 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()),
1205 static_cast<uint32_t>(platform_key_certificate_string.length())}; 1209 static_cast<uint32_t>(platform_key_certificate_string.length())};
1206 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1210 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1207 1211
1208 signed_data_var.Unmap(); 1212 signed_data_var.Unmap();
1209 signed_data_signature_var.Unmap(); 1213 signed_data_signature_var.Unmap();
1210 } 1214 }
1211 #endif
1212 1215
1213 void PpapiCdmAdapter::EnableProtectionDone(int32_t result) { 1216 void PpapiCdmAdapter::EnableProtectionDone(int32_t result) {
1214 // Does nothing since clients must call QueryOutputProtectionStatus() to 1217 // Does nothing since clients must call QueryOutputProtectionStatus() to
1215 // inspect the protection status on a regular basis. 1218 // inspect the protection status on a regular basis.
1216 CDM_DLOG() << __FUNCTION__ << " : " << result; 1219 CDM_DLOG() << __FUNCTION__ << " : " << result;
1217 } 1220 }
1218 1221
1219 void PpapiCdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { 1222 void PpapiCdmAdapter::QueryOutputProtectionStatusDone(int32_t result) {
1220 PP_DCHECK(query_output_protection_in_progress_); 1223 PP_DCHECK(query_output_protection_in_progress_);
1221 query_output_protection_in_progress_ = false; 1224 query_output_protection_in_progress_ = false;
1222 1225
1223 // Return a query status of failed on error. 1226 // Return a query status of failed on error.
1224 cdm::QueryResult query_result; 1227 cdm::QueryResult query_result;
1225 if (result != PP_OK) { 1228 if (result != PP_OK) {
1226 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result; 1229 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result;
1227 output_link_mask_ = output_protection_mask_ = 0; 1230 output_link_mask_ = output_protection_mask_ = 0;
1228 query_result = cdm::kQueryFailed; 1231 query_result = cdm::kQueryFailed;
1229 } else { 1232 } else {
1230 query_result = cdm::kQuerySucceeded; 1233 query_result = cdm::kQuerySucceeded;
1231 ReportOutputProtectionQueryResult(); 1234 ReportOutputProtectionQueryResult();
1232 } 1235 }
1233 1236
1234 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_, 1237 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_,
1235 output_protection_mask_); 1238 output_protection_mask_);
1236 } 1239 }
1240 #endif
1237 1241
1238 PpapiCdmAdapter::SessionError::SessionError( 1242 PpapiCdmAdapter::SessionError::SessionError(
1239 cdm::Error error, 1243 cdm::Error error,
1240 uint32_t system_code, 1244 uint32_t system_code,
1241 const std::string& error_description) 1245 const std::string& error_description)
1242 : error(error), 1246 : error(error),
1243 system_code(system_code), 1247 system_code(system_code),
1244 error_description(error_description) {} 1248 error_description(error_description) {}
1245 1249
1246 PpapiCdmAdapter::SessionMessage::SessionMessage( 1250 PpapiCdmAdapter::SessionMessage::SessionMessage(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 } // namespace media 1317 } // namespace media
1314 1318
1315 namespace pp { 1319 namespace pp {
1316 1320
1317 // Factory function for your specialization of the Module object. 1321 // Factory function for your specialization of the Module object.
1318 Module* CreateModule() { 1322 Module* CreateModule() {
1319 return new media::PpapiCdmAdapterModule(); 1323 return new media::PpapiCdmAdapterModule();
1320 } 1324 }
1321 1325
1322 } // namespace pp 1326 } // namespace pp
OLDNEW
« no previous file with comments | « media/cdm/ppapi/ppapi_cdm_adapter.h ('k') | media/test/data/eme_player_js/app_loader.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698