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

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

Issue 2085063002: media: Add OutputProtectionProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 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)
324 output_protection_(this), 323 output_protection_(this),
325 platform_verification_(this),
326 output_link_mask_(0), 324 output_link_mask_(0),
327 output_protection_mask_(0), 325 output_protection_mask_(0),
328 query_output_protection_in_progress_(false), 326 query_output_protection_in_progress_(false),
329 uma_for_output_protection_query_reported_(false), 327 uma_for_output_protection_query_reported_(false),
330 uma_for_output_protection_positive_result_reported_(false), 328 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)
1073 int32_t result = output_protection_.EnableProtection( 1072 int32_t result = output_protection_.EnableProtection(
1074 desired_protection_mask, 1073 desired_protection_mask,
1075 callback_factory_.NewCallback(&PpapiCdmAdapter::EnableProtectionDone)); 1074 callback_factory_.NewCallback(&PpapiCdmAdapter::EnableProtectionDone));
1076 1075
1077 // Errors are ignored since clients must call QueryOutputProtectionStatus() to 1076 // Errors are ignored since clients must call QueryOutputProtectionStatus() to
1078 // inspect the protection status on a regular basis. 1077 // inspect the protection status on a regular basis.
1079 1078
1080 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING) 1079 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING)
1081 CDM_DLOG() << __FUNCTION__ << " failed!"; 1080 CDM_DLOG() << __FUNCTION__ << " failed!";
1082 #endif
1083 } 1081 }
1084 1082
1085 void PpapiCdmAdapter::QueryOutputProtectionStatus() { 1083 void PpapiCdmAdapter::QueryOutputProtectionStatus() {
1086 #if defined(OS_CHROMEOS)
1087 PP_DCHECK(!query_output_protection_in_progress_); 1084 PP_DCHECK(!query_output_protection_in_progress_);
1088 1085
1089 output_link_mask_ = output_protection_mask_ = 0; 1086 output_link_mask_ = output_protection_mask_ = 0;
1090 const int32_t result = output_protection_.QueryStatus( 1087 const int32_t result = output_protection_.QueryStatus(
1091 &output_link_mask_, &output_protection_mask_, 1088 &output_link_mask_, &output_protection_mask_,
1092 callback_factory_.NewCallback( 1089 callback_factory_.NewCallback(
1093 &PpapiCdmAdapter::QueryOutputProtectionStatusDone)); 1090 &PpapiCdmAdapter::QueryOutputProtectionStatusDone));
1094 if (result == PP_OK_COMPLETIONPENDING) { 1091 if (result == PP_OK_COMPLETIONPENDING) {
1095 query_output_protection_in_progress_ = true; 1092 query_output_protection_in_progress_ = true;
1096 ReportOutputProtectionQuery(); 1093 ReportOutputProtectionQuery();
1097 return; 1094 return;
1098 } 1095 }
1099 1096
1100 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). 1097 // Fall through on error and issue an empty OnQueryOutputProtectionStatus().
1101 PP_DCHECK(result != PP_OK); 1098 PP_DCHECK(result != PP_OK);
1102 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result; 1099 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result;
1103 #endif
1104 cdm_->OnQueryOutputProtectionStatus(cdm::kQueryFailed, 0, 0);
1105 } 1100 }
1106 1101
1107 void PpapiCdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, 1102 void PpapiCdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type,
1108 cdm::Status decoder_status) { 1103 cdm::Status decoder_status) {
1109 switch (stream_type) { 1104 switch (stream_type) {
1110 case cdm::kStreamTypeAudio: 1105 case cdm::kStreamTypeAudio:
1111 PP_DCHECK(deferred_initialize_audio_decoder_); 1106 PP_DCHECK(deferred_initialize_audio_decoder_);
1112 CallOnMain(callback_factory_.NewCallback( 1107 CallOnMain(callback_factory_.NewCallback(
1113 &PpapiCdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO, 1108 &PpapiCdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO,
1114 deferred_audio_decoder_config_id_, decoder_status == cdm::kSuccess)); 1109 deferred_audio_decoder_config_id_, decoder_status == cdm::kSuccess));
(...skipping 17 matching lines...) Expand all
1132 CDM_DLOG() 1127 CDM_DLOG()
1133 << "Cannot create FileIO because persistent state is not allowed."; 1128 << "Cannot create FileIO because persistent state is not allowed.";
1134 return nullptr; 1129 return nullptr;
1135 } 1130 }
1136 1131
1137 return new CdmFileIOImpl( 1132 return new CdmFileIOImpl(
1138 client, pp_instance(), 1133 client, pp_instance(),
1139 callback_factory_.NewCallback(&PpapiCdmAdapter::OnFirstFileRead)); 1134 callback_factory_.NewCallback(&PpapiCdmAdapter::OnFirstFileRead));
1140 } 1135 }
1141 1136
1142 #if defined(OS_CHROMEOS)
1143 void PpapiCdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) { 1137 void PpapiCdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) {
1144 pp::UMAPrivate uma_interface(this); 1138 pp::UMAPrivate uma_interface(this);
1145 uma_interface.HistogramEnumeration("Media.EME.OutputProtection", status, 1139 uma_interface.HistogramEnumeration("Media.EME.OutputProtection", status,
1146 OUTPUT_PROTECTION_MAX); 1140 OUTPUT_PROTECTION_MAX);
1147 } 1141 }
1148 1142
1149 void PpapiCdmAdapter::ReportOutputProtectionQuery() { 1143 void PpapiCdmAdapter::ReportOutputProtectionQuery() {
1150 if (uma_for_output_protection_query_reported_) 1144 if (uma_for_output_protection_query_reported_)
1151 return; 1145 return;
1152 1146
1153 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED); 1147 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED);
1154 uma_for_output_protection_query_reported_ = true; 1148 uma_for_output_protection_query_reported_ = true;
1155 } 1149 }
1156 1150
1157 void PpapiCdmAdapter::ReportOutputProtectionQueryResult() { 1151 void PpapiCdmAdapter::ReportOutputProtectionQueryResult() {
1158 if (uma_for_output_protection_positive_result_reported_) 1152 if (uma_for_output_protection_positive_result_reported_)
1159 return; 1153 return;
1160 1154
1161 // Report UMAs for output protection query result. 1155 // Report UMAs for output protection query result.
1162 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal); 1156 uint32_t external_links = (output_link_mask_ & ~cdm::kLinkTypeInternal);
1163 1157
1164 if (!external_links) { 1158 if (!external_links) {
1165 ReportOutputProtectionUMA(OUTPUT_PROTECTION_NO_EXTERNAL_LINK); 1159 ReportOutputProtectionUMA(OUTPUT_PROTECTION_NO_EXTERNAL_LINK);
1166 uma_for_output_protection_positive_result_reported_ = true; 1160 uma_for_output_protection_positive_result_reported_ = true;
1167 return; 1161 return;
1168 } 1162 }
1169 1163
1170 const uint32_t kProtectableLinks = 1164 const uint32_t kProtectableLinks =
1171 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort; 1165 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort;
1172 bool is_unprotectable_link_connected = external_links & ~kProtectableLinks; 1166 bool is_unprotectable_link_connected =
1167 (external_links & ~kProtectableLinks) != 0;
1173 bool is_hdcp_enabled_on_all_protectable_links = 1168 bool is_hdcp_enabled_on_all_protectable_links =
1174 output_protection_mask_ & cdm::kProtectionHDCP; 1169 (output_protection_mask_ & cdm::kProtectionHDCP) != 0;
1175 1170
1176 if (!is_unprotectable_link_connected && 1171 if (!is_unprotectable_link_connected &&
1177 is_hdcp_enabled_on_all_protectable_links) { 1172 is_hdcp_enabled_on_all_protectable_links) {
1178 ReportOutputProtectionUMA(OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED); 1173 ReportOutputProtectionUMA(OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED);
1179 uma_for_output_protection_positive_result_reported_ = true; 1174 uma_for_output_protection_positive_result_reported_ = true;
1180 return; 1175 return;
1181 } 1176 }
1182 1177
1183 // Do not report a negative result because it could be a false negative. 1178 // Do not report a negative result because it could be a false negative.
1184 // Instead, we will calculate number of negatives using the total number of 1179 // Instead, we will calculate number of negatives using the total number of
1185 // queries and success results. 1180 // queries and success results.
1186 } 1181 }
1187 1182
1183 #if defined(OS_CHROMEOS)
1188 void PpapiCdmAdapter::SendPlatformChallengeDone( 1184 void PpapiCdmAdapter::SendPlatformChallengeDone(
1189 int32_t result, 1185 int32_t result,
1190 const linked_ptr<PepperPlatformChallengeResponse>& response) { 1186 const linked_ptr<PepperPlatformChallengeResponse>& response) {
1191 if (result != PP_OK) { 1187 if (result != PP_OK) {
1192 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!"; 1188 CDM_DLOG() << __FUNCTION__ << ": Platform challenge failed!";
1193 cdm::PlatformChallengeResponse platform_challenge_response = {}; 1189 cdm::PlatformChallengeResponse platform_challenge_response = {};
1194 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1190 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1195 return; 1191 return;
1196 } 1192 }
1197 1193
1198 pp::VarArrayBuffer signed_data_var(response->signed_data); 1194 pp::VarArrayBuffer signed_data_var(response->signed_data);
1199 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature); 1195 pp::VarArrayBuffer signed_data_signature_var(response->signed_data_signature);
1200 std::string platform_key_certificate_string = 1196 std::string platform_key_certificate_string =
1201 response->platform_key_certificate.AsString(); 1197 response->platform_key_certificate.AsString();
1202 1198
1203 cdm::PlatformChallengeResponse platform_challenge_response = { 1199 cdm::PlatformChallengeResponse platform_challenge_response = {
1204 static_cast<uint8_t*>(signed_data_var.Map()), 1200 static_cast<uint8_t*>(signed_data_var.Map()),
1205 signed_data_var.ByteLength(), 1201 signed_data_var.ByteLength(),
1206 static_cast<uint8_t*>(signed_data_signature_var.Map()), 1202 static_cast<uint8_t*>(signed_data_signature_var.Map()),
1207 signed_data_signature_var.ByteLength(), 1203 signed_data_signature_var.ByteLength(),
1208 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()), 1204 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()),
1209 static_cast<uint32_t>(platform_key_certificate_string.length())}; 1205 static_cast<uint32_t>(platform_key_certificate_string.length())};
1210 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1206 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1211 1207
1212 signed_data_var.Unmap(); 1208 signed_data_var.Unmap();
1213 signed_data_signature_var.Unmap(); 1209 signed_data_signature_var.Unmap();
1214 } 1210 }
1211 #endif
1215 1212
1216 void PpapiCdmAdapter::EnableProtectionDone(int32_t result) { 1213 void PpapiCdmAdapter::EnableProtectionDone(int32_t result) {
1217 // Does nothing since clients must call QueryOutputProtectionStatus() to 1214 // Does nothing since clients must call QueryOutputProtectionStatus() to
1218 // inspect the protection status on a regular basis. 1215 // inspect the protection status on a regular basis.
1219 CDM_DLOG() << __FUNCTION__ << " : " << result; 1216 CDM_DLOG() << __FUNCTION__ << " : " << result;
1220 } 1217 }
1221 1218
1222 void PpapiCdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { 1219 void PpapiCdmAdapter::QueryOutputProtectionStatusDone(int32_t result) {
1223 PP_DCHECK(query_output_protection_in_progress_); 1220 PP_DCHECK(query_output_protection_in_progress_);
1224 query_output_protection_in_progress_ = false; 1221 query_output_protection_in_progress_ = false;
1225 1222
1226 // Return a query status of failed on error. 1223 // Return a query status of failed on error.
1227 cdm::QueryResult query_result; 1224 cdm::QueryResult query_result;
1228 if (result != PP_OK) { 1225 if (result != PP_OK) {
1229 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result; 1226 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result;
1230 output_link_mask_ = output_protection_mask_ = 0; 1227 output_link_mask_ = output_protection_mask_ = 0;
1231 query_result = cdm::kQueryFailed; 1228 query_result = cdm::kQueryFailed;
1232 } else { 1229 } else {
1233 query_result = cdm::kQuerySucceeded; 1230 query_result = cdm::kQuerySucceeded;
1234 ReportOutputProtectionQueryResult(); 1231 ReportOutputProtectionQueryResult();
1235 } 1232 }
1236 1233
1237 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_, 1234 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_,
1238 output_protection_mask_); 1235 output_protection_mask_);
1239 } 1236 }
1240 #endif
1241 1237
1242 PpapiCdmAdapter::SessionError::SessionError( 1238 PpapiCdmAdapter::SessionError::SessionError(
1243 cdm::Error error, 1239 cdm::Error error,
1244 uint32_t system_code, 1240 uint32_t system_code,
1245 const std::string& error_description) 1241 const std::string& error_description)
1246 : error(error), 1242 : error(error),
1247 system_code(system_code), 1243 system_code(system_code),
1248 error_description(error_description) {} 1244 error_description(error_description) {}
1249 1245
1250 PpapiCdmAdapter::SessionMessage::SessionMessage( 1246 PpapiCdmAdapter::SessionMessage::SessionMessage(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 } // namespace media 1313 } // namespace media
1318 1314
1319 namespace pp { 1315 namespace pp {
1320 1316
1321 // Factory function for your specialization of the Module object. 1317 // Factory function for your specialization of the Module object.
1322 Module* CreateModule() { 1318 Module* CreateModule() {
1323 return new media::PpapiCdmAdapterModule(); 1319 return new media::PpapiCdmAdapterModule();
1324 } 1320 }
1325 1321
1326 } // namespace pp 1322 } // 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