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 <string.h> | 7 #include <string.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "ppapi/shared_impl/scoped_pp_resource.h" | 31 #include "ppapi/shared_impl/scoped_pp_resource.h" |
32 #include "ppapi/shared_impl/time_conversion.h" | 32 #include "ppapi/shared_impl/time_conversion.h" |
33 #include "ppapi/shared_impl/var.h" | 33 #include "ppapi/shared_impl/var.h" |
34 #include "ppapi/shared_impl/var_tracker.h" | 34 #include "ppapi/shared_impl/var_tracker.h" |
35 #include "ppapi/thunk/enter.h" | 35 #include "ppapi/thunk/enter.h" |
36 #include "ppapi/thunk/ppb_buffer_api.h" | 36 #include "ppapi/thunk/ppb_buffer_api.h" |
37 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
38 | 38 |
39 using media::CdmPromise; | 39 using media::CdmPromise; |
40 using media::Decryptor; | 40 using media::Decryptor; |
41 using media::MediaKeys; | 41 using media::ContentDecryptionModule; |
42 using media::NewSessionCdmPromise; | 42 using media::NewSessionCdmPromise; |
43 using media::SimpleCdmPromise; | 43 using media::SimpleCdmPromise; |
44 using ppapi::ArrayBufferVar; | 44 using ppapi::ArrayBufferVar; |
45 using ppapi::ArrayVar; | 45 using ppapi::ArrayVar; |
46 using ppapi::PpapiGlobals; | 46 using ppapi::PpapiGlobals; |
47 using ppapi::ScopedPPResource; | 47 using ppapi::ScopedPPResource; |
48 using ppapi::StringVar; | 48 using ppapi::StringVar; |
49 using ppapi::thunk::EnterResourceNoLock; | 49 using ppapi::thunk::EnterResourceNoLock; |
50 using ppapi::thunk::PPB_Buffer_API; | 50 using ppapi::thunk::PPB_Buffer_API; |
51 | 51 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 return media::kSampleFormatPlanarS16; | 266 return media::kSampleFormatPlanarS16; |
267 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32: | 267 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32: |
268 return media::kSampleFormatPlanarF32; | 268 return media::kSampleFormatPlanarF32; |
269 default: | 269 default: |
270 NOTREACHED(); | 270 NOTREACHED(); |
271 return media::kUnknownSampleFormat; | 271 return media::kUnknownSampleFormat; |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 PP_SessionType MediaSessionTypeToPpSessionType( | 275 PP_SessionType MediaSessionTypeToPpSessionType( |
276 MediaKeys::SessionType session_type) { | 276 ContentDecryptionModule::SessionType session_type) { |
277 switch (session_type) { | 277 switch (session_type) { |
278 case MediaKeys::TEMPORARY_SESSION: | 278 case ContentDecryptionModule::TEMPORARY_SESSION: |
279 return PP_SESSIONTYPE_TEMPORARY; | 279 return PP_SESSIONTYPE_TEMPORARY; |
280 case MediaKeys::PERSISTENT_LICENSE_SESSION: | 280 case ContentDecryptionModule::PERSISTENT_LICENSE_SESSION: |
281 return PP_SESSIONTYPE_PERSISTENT_LICENSE; | 281 return PP_SESSIONTYPE_PERSISTENT_LICENSE; |
282 case MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION: | 282 case ContentDecryptionModule::PERSISTENT_RELEASE_MESSAGE_SESSION: |
283 return PP_SESSIONTYPE_PERSISTENT_RELEASE; | 283 return PP_SESSIONTYPE_PERSISTENT_RELEASE; |
284 default: | 284 default: |
285 NOTREACHED(); | 285 NOTREACHED(); |
286 return PP_SESSIONTYPE_TEMPORARY; | 286 return PP_SESSIONTYPE_TEMPORARY; |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
290 PP_InitDataType MediaInitDataTypeToPpInitDataType( | 290 PP_InitDataType MediaInitDataTypeToPpInitDataType( |
291 media::EmeInitDataType init_data_type) { | 291 media::EmeInitDataType init_data_type) { |
292 switch (init_data_type) { | 292 switch (init_data_type) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 case PP_CDMKEYSTATUS_STATUSPENDING: | 342 case PP_CDMKEYSTATUS_STATUSPENDING: |
343 return media::CdmKeyInformation::KEY_STATUS_PENDING; | 343 return media::CdmKeyInformation::KEY_STATUS_PENDING; |
344 case PP_CDMKEYSTATUS_RELEASED: | 344 case PP_CDMKEYSTATUS_RELEASED: |
345 return media::CdmKeyInformation::RELEASED; | 345 return media::CdmKeyInformation::RELEASED; |
346 default: | 346 default: |
347 NOTREACHED(); | 347 NOTREACHED(); |
348 return media::CdmKeyInformation::INTERNAL_ERROR; | 348 return media::CdmKeyInformation::INTERNAL_ERROR; |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 MediaKeys::MessageType PpCdmMessageTypeToMediaMessageType( | 352 ContentDecryptionModule::MessageType PpCdmMessageTypeToMediaMessageType( |
353 PP_CdmMessageType message_type) { | 353 PP_CdmMessageType message_type) { |
354 switch (message_type) { | 354 switch (message_type) { |
355 case PP_CDMMESSAGETYPE_LICENSE_REQUEST: | 355 case PP_CDMMESSAGETYPE_LICENSE_REQUEST: |
356 return MediaKeys::LICENSE_REQUEST; | 356 return ContentDecryptionModule::LICENSE_REQUEST; |
357 case PP_CDMMESSAGETYPE_LICENSE_RENEWAL: | 357 case PP_CDMMESSAGETYPE_LICENSE_RENEWAL: |
358 return MediaKeys::LICENSE_RENEWAL; | 358 return ContentDecryptionModule::LICENSE_RENEWAL; |
359 case PP_CDMMESSAGETYPE_LICENSE_RELEASE: | 359 case PP_CDMMESSAGETYPE_LICENSE_RELEASE: |
360 return MediaKeys::LICENSE_RELEASE; | 360 return ContentDecryptionModule::LICENSE_RELEASE; |
361 default: | 361 default: |
362 NOTREACHED(); | 362 NOTREACHED(); |
363 return MediaKeys::LICENSE_REQUEST; | 363 return ContentDecryptionModule::LICENSE_REQUEST; |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. | 367 // TODO(xhwang): Unify EME UMA reporting code when prefixed EME is deprecated. |
368 // See http://crbug.com/412987 for details. | 368 // See http://crbug.com/412987 for details. |
369 void ReportSystemCodeUMA(const std::string& key_system, uint32_t system_code) { | 369 void ReportSystemCodeUMA(const std::string& key_system, uint32_t system_code) { |
370 // Sparse histogram macro does not cache the histogram, so it's safe to use | 370 // Sparse histogram macro does not cache the histogram, so it's safe to use |
371 // macro with non-static histogram name here. | 371 // macro with non-static histogram name here. |
372 UMA_HISTOGRAM_SPARSE_SLOWLY( | 372 UMA_HISTOGRAM_SPARSE_SLOWLY( |
373 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode", | 373 "Media.EME." + media::GetKeySystemNameForUMA(key_system) + ".SystemCode", |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 437 |
438 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 438 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
439 PP_Var certificate_array = | 439 PP_Var certificate_array = |
440 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 440 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
441 base::checked_cast<uint32_t>(certificate.size()), certificate.data()); | 441 base::checked_cast<uint32_t>(certificate.size()), certificate.data()); |
442 plugin_decryption_interface_->SetServerCertificate( | 442 plugin_decryption_interface_->SetServerCertificate( |
443 pp_instance_, promise_id, certificate_array); | 443 pp_instance_, promise_id, certificate_array); |
444 } | 444 } |
445 | 445 |
446 void ContentDecryptorDelegate::CreateSessionAndGenerateRequest( | 446 void ContentDecryptorDelegate::CreateSessionAndGenerateRequest( |
447 MediaKeys::SessionType session_type, | 447 ContentDecryptionModule::SessionType session_type, |
448 media::EmeInitDataType init_data_type, | 448 media::EmeInitDataType init_data_type, |
449 const std::vector<uint8_t>& init_data, | 449 const std::vector<uint8_t>& init_data, |
450 std::unique_ptr<NewSessionCdmPromise> promise) { | 450 std::unique_ptr<NewSessionCdmPromise> promise) { |
451 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 451 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
452 PP_Var init_data_array = | 452 PP_Var init_data_array = |
453 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 453 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
454 base::checked_cast<uint32_t>(init_data.size()), init_data.data()); | 454 base::checked_cast<uint32_t>(init_data.size()), init_data.data()); |
455 plugin_decryption_interface_->CreateSessionAndGenerateRequest( | 455 plugin_decryption_interface_->CreateSessionAndGenerateRequest( |
456 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), | 456 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), |
457 MediaInitDataTypeToPpInitDataType(init_data_type), init_data_array); | 457 MediaInitDataTypeToPpInitDataType(init_data_type), init_data_array); |
458 } | 458 } |
459 | 459 |
460 void ContentDecryptorDelegate::LoadSession( | 460 void ContentDecryptorDelegate::LoadSession( |
461 media::MediaKeys::SessionType session_type, | 461 ContentDecryptionModule::SessionType session_type, |
462 const std::string& session_id, | 462 const std::string& session_id, |
463 std::unique_ptr<NewSessionCdmPromise> promise) { | 463 std::unique_ptr<NewSessionCdmPromise> promise) { |
464 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); | 464 uint32_t promise_id = cdm_promise_adapter_.SavePromise(std::move(promise)); |
465 plugin_decryption_interface_->LoadSession( | 465 plugin_decryption_interface_->LoadSession( |
466 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), | 466 pp_instance_, promise_id, MediaSessionTypeToPpSessionType(session_type), |
467 StringVar::StringToPPVar(session_id)); | 467 StringVar::StringToPPVar(session_id)); |
468 } | 468 } |
469 | 469 |
470 void ContentDecryptorDelegate::UpdateSession( | 470 void ContentDecryptorDelegate::UpdateSession( |
471 const std::string& session_id, | 471 const std::string& session_id, |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 | 1275 |
1276 if (!video_decode_cb_.is_null()) | 1276 if (!video_decode_cb_.is_null()) |
1277 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1277 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1278 | 1278 |
1279 cdm_promise_adapter_.Clear(); | 1279 cdm_promise_adapter_.Clear(); |
1280 | 1280 |
1281 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); | 1281 cdm_session_tracker_.CloseRemainingSessions(session_closed_cb_); |
1282 } | 1282 } |
1283 | 1283 |
1284 } // namespace content | 1284 } // namespace content |
OLD | NEW |