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

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

Issue 1402413005: Rename cdm_adapter to ppapi_cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename flag Created 5 years, 2 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/cdm/ppapi/ppapi_cdm_adapter.gni » ('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/cdm_adapter.h" 5 #include "media/cdm/ppapi/ppapi_cdm_adapter.h"
6 6
7 #include "media/base/limits.h" 7 #include "media/base/limits.h"
8 #include "media/cdm/ppapi/cdm_file_io_impl.h" 8 #include "media/cdm/ppapi/cdm_file_io_impl.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/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 #include "ppapi/cpp/private/uma_private.h"
13 13
14 #if defined(CHECK_DOCUMENT_URL) 14 #if defined(CHECK_DOCUMENT_URL)
15 #include "ppapi/cpp/dev/url_util_dev.h" 15 #include "ppapi/cpp/dev/url_util_dev.h"
16 #include "ppapi/cpp/instance_handle.h" 16 #include "ppapi/cpp/instance_handle.h"
17 #endif // defined(CHECK_DOCUMENT_URL) 17 #endif // defined(CHECK_DOCUMENT_URL)
18 18
19 namespace { 19 namespace {
20 20
21 // Constants for UMA reporting of file size (in KB) via HistogramCustomCounts(). 21 // Constants for UMA reporting of file size (in KB) via HistogramCustomCounts().
22 // Note that the histogram is log-scaled (rather than linear). 22 // Note that the histogram is log-scaled (rather than linear).
23 const uint32_t kSizeKBMin = 1; 23 const uint32_t kSizeKBMin = 1;
24 const uint32_t kSizeKBMax = 512 * 1024; // 512MB 24 const uint32_t kSizeKBMax = 512 * 1024; // 512MB
25 const uint32_t kSizeKBBuckets = 100; 25 const uint32_t kSizeKBBuckets = 100;
26 26
27 #if !defined(NDEBUG) 27 #if !defined(NDEBUG)
28 #define DLOG_TO_CONSOLE(message) LogToConsole(message); 28 #define DLOG_TO_CONSOLE(message) LogToConsole(message);
29 #else 29 #else
30 #define DLOG_TO_CONSOLE(message) (void)(message); 30 #define DLOG_TO_CONSOLE(message) (void)(message);
31 #endif 31 #endif
32 32
33 bool IsMainThread() { 33 bool IsMainThread() {
34 return pp::Module::Get()->core()->IsMainThread(); 34 return pp::Module::Get()->core()->IsMainThread();
35 } 35 }
36 36
37 // Posts a task to run |cb| on the main thread. The task is posted even if the 37 // Posts a task to run |cb| on the main thread. The task is posted even if the
38 // current thread is the main thread. 38 // current thread is the main thread.
39 void PostOnMain(pp::CompletionCallback cb) { 39 void PostOnMain(pp::CompletionCallback cb) {
40 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK); 40 pp::Module::Get()->core()->CallOnMainThread(0, cb, PP_OK);
41 } 41 }
42 42
43 // Ensures |cb| is called on the main thread, either because the current thread 43 // Ensures |cb| is called on the main thread, either because the current thread
44 // is the main thread or by posting it to the main thread. 44 // is the main thread or by posting it to the main thread.
45 void CallOnMain(pp::CompletionCallback cb) { 45 void CallOnMain(pp::CompletionCallback cb) {
46 // TODO(tomfinegan): This is only necessary because PPAPI doesn't allow calls 46 // TODO(tomfinegan): This is only necessary because PPAPI doesn't allow calls
47 // off the main thread yet. Remove this once the change lands. 47 // off the main thread yet. Remove this once the change lands.
48 if (IsMainThread()) 48 if (IsMainThread())
49 cb.Run(PP_OK); 49 cb.Run(PP_OK);
50 else 50 else
51 PostOnMain(cb); 51 PostOnMain(cb);
52 } 52 }
53 53
54 // Configures a cdm::InputBuffer. |subsamples| must exist as long as 54 // Configures a cdm::InputBuffer. |subsamples| must exist as long as
55 // |input_buffer| is in use. 55 // |input_buffer| is in use.
56 void ConfigureInputBuffer( 56 void ConfigureInputBuffer(const pp::Buffer_Dev& encrypted_buffer,
57 const pp::Buffer_Dev& encrypted_buffer, 57 const PP_EncryptedBlockInfo& encrypted_block_info,
58 const PP_EncryptedBlockInfo& encrypted_block_info, 58 std::vector<cdm::SubsampleEntry>* subsamples,
59 std::vector<cdm::SubsampleEntry>* subsamples, 59 cdm::InputBuffer* input_buffer) {
60 cdm::InputBuffer* input_buffer) {
61 PP_DCHECK(subsamples); 60 PP_DCHECK(subsamples);
62 PP_DCHECK(!encrypted_buffer.is_null()); 61 PP_DCHECK(!encrypted_buffer.is_null());
63 62
64 input_buffer->data = static_cast<uint8_t*>(encrypted_buffer.data()); 63 input_buffer->data = static_cast<uint8_t*>(encrypted_buffer.data());
65 input_buffer->data_size = encrypted_block_info.data_size; 64 input_buffer->data_size = encrypted_block_info.data_size;
66 PP_DCHECK(encrypted_buffer.size() >= input_buffer->data_size); 65 PP_DCHECK(encrypted_buffer.size() >= input_buffer->data_size);
67 66
68 PP_DCHECK(encrypted_block_info.key_id_size <= 67 PP_DCHECK(encrypted_block_info.key_id_size <=
69 arraysize(encrypted_block_info.key_id)); 68 arraysize(encrypted_block_info.key_id));
70 input_buffer->key_id_size = encrypted_block_info.key_id_size; 69 input_buffer->key_id_size = encrypted_block_info.key_id_size;
71 input_buffer->key_id = input_buffer->key_id_size > 0 ? 70 input_buffer->key_id =
72 encrypted_block_info.key_id : NULL; 71 input_buffer->key_id_size > 0 ? encrypted_block_info.key_id : NULL;
73 72
74 PP_DCHECK(encrypted_block_info.iv_size <= arraysize(encrypted_block_info.iv)); 73 PP_DCHECK(encrypted_block_info.iv_size <= arraysize(encrypted_block_info.iv));
75 input_buffer->iv_size = encrypted_block_info.iv_size; 74 input_buffer->iv_size = encrypted_block_info.iv_size;
76 input_buffer->iv = encrypted_block_info.iv_size > 0 ? 75 input_buffer->iv =
77 encrypted_block_info.iv : NULL; 76 encrypted_block_info.iv_size > 0 ? encrypted_block_info.iv : NULL;
78 77
79 input_buffer->num_subsamples = encrypted_block_info.num_subsamples; 78 input_buffer->num_subsamples = encrypted_block_info.num_subsamples;
80 if (encrypted_block_info.num_subsamples > 0) { 79 if (encrypted_block_info.num_subsamples > 0) {
81 subsamples->reserve(encrypted_block_info.num_subsamples); 80 subsamples->reserve(encrypted_block_info.num_subsamples);
82 81
83 for (uint32_t i = 0; i < encrypted_block_info.num_subsamples; ++i) { 82 for (uint32_t i = 0; i < encrypted_block_info.num_subsamples; ++i) {
84 subsamples->push_back(cdm::SubsampleEntry( 83 subsamples->push_back(
85 encrypted_block_info.subsamples[i].clear_bytes, 84 cdm::SubsampleEntry(encrypted_block_info.subsamples[i].clear_bytes,
86 encrypted_block_info.subsamples[i].cipher_bytes)); 85 encrypted_block_info.subsamples[i].cipher_bytes));
87 } 86 }
88 87
89 input_buffer->subsamples = &(*subsamples)[0]; 88 input_buffer->subsamples = &(*subsamples)[0];
90 } 89 }
91 90
92 input_buffer->timestamp = encrypted_block_info.tracking_info.timestamp; 91 input_buffer->timestamp = encrypted_block_info.tracking_info.timestamp;
93 } 92 }
94 93
95 PP_DecryptResult CdmStatusToPpDecryptResult(cdm::Status status) { 94 PP_DecryptResult CdmStatusToPpDecryptResult(cdm::Status status) {
96 switch (status) { 95 switch (status) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 398
400 void CdmAdapter::SetServerCertificate(uint32_t promise_id, 399 void CdmAdapter::SetServerCertificate(uint32_t promise_id,
401 pp::VarArrayBuffer server_certificate) { 400 pp::VarArrayBuffer server_certificate) {
402 const uint8_t* server_certificate_ptr = 401 const uint8_t* server_certificate_ptr =
403 static_cast<const uint8_t*>(server_certificate.Map()); 402 static_cast<const uint8_t*>(server_certificate.Map());
404 const uint32_t server_certificate_size = server_certificate.ByteLength(); 403 const uint32_t server_certificate_size = server_certificate.ByteLength();
405 404
406 if (!server_certificate_ptr || 405 if (!server_certificate_ptr ||
407 server_certificate_size < media::limits::kMinCertificateLength || 406 server_certificate_size < media::limits::kMinCertificateLength ||
408 server_certificate_size > media::limits::kMaxCertificateLength) { 407 server_certificate_size > media::limits::kMaxCertificateLength) {
409 RejectPromise( 408 RejectPromise(promise_id, cdm::kInvalidAccessError, 0,
410 promise_id, cdm::kInvalidAccessError, 0, "Incorrect certificate."); 409 "Incorrect certificate.");
411 return; 410 return;
412 } 411 }
413 412
414 cdm_->SetServerCertificate( 413 cdm_->SetServerCertificate(promise_id, server_certificate_ptr,
415 promise_id, server_certificate_ptr, server_certificate_size); 414 server_certificate_size);
416 } 415 }
417 416
418 void CdmAdapter::CreateSessionAndGenerateRequest(uint32_t promise_id, 417 void CdmAdapter::CreateSessionAndGenerateRequest(uint32_t promise_id,
419 PP_SessionType session_type, 418 PP_SessionType session_type,
420 PP_InitDataType init_data_type, 419 PP_InitDataType init_data_type,
421 pp::VarArrayBuffer init_data) { 420 pp::VarArrayBuffer init_data) {
422 cdm_->CreateSessionAndGenerateRequest( 421 cdm_->CreateSessionAndGenerateRequest(
423 promise_id, PpSessionTypeToCdmSessionType(session_type), 422 promise_id, PpSessionTypeToCdmSessionType(session_type),
424 PpInitDataTypeToCdmInitDataType(init_data_type), 423 PpInitDataTypeToCdmInitDataType(init_data_type),
425 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); 424 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 cdm::InputBuffer input_buffer; 472 cdm::InputBuffer input_buffer;
474 std::vector<cdm::SubsampleEntry> subsamples; 473 std::vector<cdm::SubsampleEntry> subsamples;
475 ConfigureInputBuffer(encrypted_buffer, encrypted_block_info, &subsamples, 474 ConfigureInputBuffer(encrypted_buffer, encrypted_block_info, &subsamples,
476 &input_buffer); 475 &input_buffer);
477 status = cdm_->Decrypt(input_buffer, decrypted_block.get()); 476 status = cdm_->Decrypt(input_buffer, decrypted_block.get());
478 PP_DCHECK(status != cdm::kSuccess || 477 PP_DCHECK(status != cdm::kSuccess ||
479 (decrypted_block->DecryptedBuffer() && 478 (decrypted_block->DecryptedBuffer() &&
480 decrypted_block->DecryptedBuffer()->Size())); 479 decrypted_block->DecryptedBuffer()->Size()));
481 } 480 }
482 481
483 CallOnMain(callback_factory_.NewCallback( 482 CallOnMain(callback_factory_.NewCallback(&CdmAdapter::DeliverBlock, status,
484 &CdmAdapter::DeliverBlock, 483 decrypted_block,
485 status, 484 encrypted_block_info.tracking_info));
486 decrypted_block,
487 encrypted_block_info.tracking_info));
488 } 485 }
489 486
490 void CdmAdapter::InitializeAudioDecoder( 487 void CdmAdapter::InitializeAudioDecoder(
491 const PP_AudioDecoderConfig& decoder_config, 488 const PP_AudioDecoderConfig& decoder_config,
492 pp::Buffer_Dev extra_data_buffer) { 489 pp::Buffer_Dev extra_data_buffer) {
493 PP_DCHECK(!deferred_initialize_audio_decoder_); 490 PP_DCHECK(!deferred_initialize_audio_decoder_);
494 PP_DCHECK(deferred_audio_decoder_config_id_ == 0); 491 PP_DCHECK(deferred_audio_decoder_config_id_ == 0);
495 cdm::Status status = cdm::kSessionError; 492 cdm::Status status = cdm::kSessionError;
496 if (cdm_) { 493 if (cdm_) {
497 cdm::AudioDecoderConfig cdm_decoder_config; 494 cdm::AudioDecoderConfig cdm_decoder_config;
498 cdm_decoder_config.codec = 495 cdm_decoder_config.codec =
499 PpAudioCodecToCdmAudioCodec(decoder_config.codec); 496 PpAudioCodecToCdmAudioCodec(decoder_config.codec);
500 cdm_decoder_config.channel_count = decoder_config.channel_count; 497 cdm_decoder_config.channel_count = decoder_config.channel_count;
501 cdm_decoder_config.bits_per_channel = decoder_config.bits_per_channel; 498 cdm_decoder_config.bits_per_channel = decoder_config.bits_per_channel;
502 cdm_decoder_config.samples_per_second = decoder_config.samples_per_second; 499 cdm_decoder_config.samples_per_second = decoder_config.samples_per_second;
503 cdm_decoder_config.extra_data = 500 cdm_decoder_config.extra_data =
504 static_cast<uint8_t*>(extra_data_buffer.data()); 501 static_cast<uint8_t*>(extra_data_buffer.data());
505 cdm_decoder_config.extra_data_size = extra_data_buffer.size(); 502 cdm_decoder_config.extra_data_size = extra_data_buffer.size();
506 status = cdm_->InitializeAudioDecoder(cdm_decoder_config); 503 status = cdm_->InitializeAudioDecoder(cdm_decoder_config);
507 } 504 }
508 505
509 if (status == cdm::kDeferredInitialization) { 506 if (status == cdm::kDeferredInitialization) {
510 deferred_initialize_audio_decoder_ = true; 507 deferred_initialize_audio_decoder_ = true;
511 deferred_audio_decoder_config_id_ = decoder_config.request_id; 508 deferred_audio_decoder_config_id_ = decoder_config.request_id;
512 return; 509 return;
513 } 510 }
514 511
515 CallOnMain(callback_factory_.NewCallback( 512 CallOnMain(callback_factory_.NewCallback(
516 &CdmAdapter::DecoderInitializeDone, 513 &CdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO,
517 PP_DECRYPTORSTREAMTYPE_AUDIO, 514 decoder_config.request_id, status == cdm::kSuccess));
518 decoder_config.request_id,
519 status == cdm::kSuccess));
520 } 515 }
521 516
522 void CdmAdapter::InitializeVideoDecoder( 517 void CdmAdapter::InitializeVideoDecoder(
523 const PP_VideoDecoderConfig& decoder_config, 518 const PP_VideoDecoderConfig& decoder_config,
524 pp::Buffer_Dev extra_data_buffer) { 519 pp::Buffer_Dev extra_data_buffer) {
525 PP_DCHECK(!deferred_initialize_video_decoder_); 520 PP_DCHECK(!deferred_initialize_video_decoder_);
526 PP_DCHECK(deferred_video_decoder_config_id_ == 0); 521 PP_DCHECK(deferred_video_decoder_config_id_ == 0);
527 cdm::Status status = cdm::kSessionError; 522 cdm::Status status = cdm::kSessionError;
528 if (cdm_) { 523 if (cdm_) {
529 cdm::VideoDecoderConfig cdm_decoder_config; 524 cdm::VideoDecoderConfig cdm_decoder_config;
(...skipping 11 matching lines...) Expand all
541 status = cdm_->InitializeVideoDecoder(cdm_decoder_config); 536 status = cdm_->InitializeVideoDecoder(cdm_decoder_config);
542 } 537 }
543 538
544 if (status == cdm::kDeferredInitialization) { 539 if (status == cdm::kDeferredInitialization) {
545 deferred_initialize_video_decoder_ = true; 540 deferred_initialize_video_decoder_ = true;
546 deferred_video_decoder_config_id_ = decoder_config.request_id; 541 deferred_video_decoder_config_id_ = decoder_config.request_id;
547 return; 542 return;
548 } 543 }
549 544
550 CallOnMain(callback_factory_.NewCallback( 545 CallOnMain(callback_factory_.NewCallback(
551 &CdmAdapter::DecoderInitializeDone, 546 &CdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_VIDEO,
552 PP_DECRYPTORSTREAMTYPE_VIDEO, 547 decoder_config.request_id, status == cdm::kSuccess));
553 decoder_config.request_id,
554 status == cdm::kSuccess));
555 } 548 }
556 549
557 void CdmAdapter::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, 550 void CdmAdapter::DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
558 uint32_t request_id) { 551 uint32_t request_id) {
559 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded. 552 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded.
560 if (cdm_) { 553 if (cdm_) {
561 cdm_->DeinitializeDecoder( 554 cdm_->DeinitializeDecoder(
562 PpDecryptorStreamTypeToCdmStreamType(decoder_type)); 555 PpDecryptorStreamTypeToCdmStreamType(decoder_type));
563 } 556 }
564 557
565 CallOnMain(callback_factory_.NewCallback( 558 CallOnMain(callback_factory_.NewCallback(&CdmAdapter::DecoderDeinitializeDone,
566 &CdmAdapter::DecoderDeinitializeDone, 559 decoder_type, request_id));
567 decoder_type,
568 request_id));
569 } 560 }
570 561
571 void CdmAdapter::ResetDecoder(PP_DecryptorStreamType decoder_type, 562 void CdmAdapter::ResetDecoder(PP_DecryptorStreamType decoder_type,
572 uint32_t request_id) { 563 uint32_t request_id) {
573 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded. 564 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded.
574 if (cdm_) 565 if (cdm_)
575 cdm_->ResetDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type)); 566 cdm_->ResetDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type));
576 567
577 CallOnMain(callback_factory_.NewCallback(&CdmAdapter::DecoderResetDone, 568 CallOnMain(callback_factory_.NewCallback(&CdmAdapter::DecoderResetDone,
578 decoder_type, 569 decoder_type, request_id));
579 request_id));
580 } 570 }
581 571
582 void CdmAdapter::DecryptAndDecode( 572 void CdmAdapter::DecryptAndDecode(
583 PP_DecryptorStreamType decoder_type, 573 PP_DecryptorStreamType decoder_type,
584 pp::Buffer_Dev encrypted_buffer, 574 pp::Buffer_Dev encrypted_buffer,
585 const PP_EncryptedBlockInfo& encrypted_block_info) { 575 const PP_EncryptedBlockInfo& encrypted_block_info) {
586 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded. 576 PP_DCHECK(cdm_); // InitializeXxxxxDecoder should have succeeded.
587 // Release a buffer that the caller indicated it is finished with. 577 // Release a buffer that the caller indicated it is finished with.
588 allocator_.Release(encrypted_block_info.tracking_info.buffer_id); 578 allocator_.Release(encrypted_block_info.tracking_info.buffer_id);
589 579
590 cdm::InputBuffer input_buffer; 580 cdm::InputBuffer input_buffer;
591 std::vector<cdm::SubsampleEntry> subsamples; 581 std::vector<cdm::SubsampleEntry> subsamples;
592 if (cdm_ && !encrypted_buffer.is_null()) { 582 if (cdm_ && !encrypted_buffer.is_null()) {
593 ConfigureInputBuffer(encrypted_buffer, 583 ConfigureInputBuffer(encrypted_buffer, encrypted_block_info, &subsamples,
594 encrypted_block_info,
595 &subsamples,
596 &input_buffer); 584 &input_buffer);
597 } 585 }
598 586
599 cdm::Status status = cdm::kDecodeError; 587 cdm::Status status = cdm::kDecodeError;
600 588
601 switch (decoder_type) { 589 switch (decoder_type) {
602 case PP_DECRYPTORSTREAMTYPE_VIDEO: { 590 case PP_DECRYPTORSTREAMTYPE_VIDEO: {
603 LinkedVideoFrame video_frame(new VideoFrameImpl()); 591 LinkedVideoFrame video_frame(new VideoFrameImpl());
604 if (cdm_) 592 if (cdm_)
605 status = cdm_->DecryptAndDecodeFrame(input_buffer, video_frame.get()); 593 status = cdm_->DecryptAndDecodeFrame(input_buffer, video_frame.get());
606 CallOnMain(callback_factory_.NewCallback( 594 CallOnMain(callback_factory_.NewCallback(
607 &CdmAdapter::DeliverFrame, 595 &CdmAdapter::DeliverFrame, status, video_frame,
608 status,
609 video_frame,
610 encrypted_block_info.tracking_info)); 596 encrypted_block_info.tracking_info));
611 return; 597 return;
612 } 598 }
613 599
614 case PP_DECRYPTORSTREAMTYPE_AUDIO: { 600 case PP_DECRYPTORSTREAMTYPE_AUDIO: {
615 LinkedAudioFrames audio_frames(new AudioFramesImpl()); 601 LinkedAudioFrames audio_frames(new AudioFramesImpl());
616 if (cdm_) { 602 if (cdm_) {
617 status = cdm_->DecryptAndDecodeSamples(input_buffer, 603 status =
618 audio_frames.get()); 604 cdm_->DecryptAndDecodeSamples(input_buffer, audio_frames.get());
619 } 605 }
620 CallOnMain(callback_factory_.NewCallback( 606 CallOnMain(callback_factory_.NewCallback(
621 &CdmAdapter::DeliverSamples, 607 &CdmAdapter::DeliverSamples, status, audio_frames,
622 status,
623 audio_frames,
624 encrypted_block_info.tracking_info)); 608 encrypted_block_info.tracking_info));
625 return; 609 return;
626 } 610 }
627 611
628 default: 612 default:
629 PP_NOTREACHED(); 613 PP_NOTREACHED();
630 return; 614 return;
631 } 615 }
632 } 616 }
633 617
634 cdm::Buffer* CdmAdapter::Allocate(uint32_t capacity) { 618 cdm::Buffer* CdmAdapter::Allocate(uint32_t capacity) {
635 return allocator_.Allocate(capacity); 619 return allocator_.Allocate(capacity);
636 } 620 }
637 621
638 void CdmAdapter::SetTimer(int64_t delay_ms, void* context) { 622 void CdmAdapter::SetTimer(int64_t delay_ms, void* context) {
639 // NOTE: doesn't really need to run on the main thread; could just as well run 623 // NOTE: doesn't really need to run on the main thread; could just as well run
640 // on a helper thread if |cdm_| were thread-friendly and care was taken. We 624 // on a helper thread if |cdm_| were thread-friendly and care was taken. We
641 // only use CallOnMainThread() here to get delayed-execution behavior. 625 // only use CallOnMainThread() here to get delayed-execution behavior.
642 pp::Module::Get()->core()->CallOnMainThread( 626 pp::Module::Get()->core()->CallOnMainThread(
643 delay_ms, 627 delay_ms,
644 callback_factory_.NewCallback(&CdmAdapter::TimerExpired, context), 628 callback_factory_.NewCallback(&CdmAdapter::TimerExpired, context), PP_OK);
645 PP_OK);
646 } 629 }
647 630
648 void CdmAdapter::TimerExpired(int32_t result, void* context) { 631 void CdmAdapter::TimerExpired(int32_t result, void* context) {
649 PP_DCHECK(result == PP_OK); 632 PP_DCHECK(result == PP_OK);
650 cdm_->TimerExpired(context); 633 cdm_->TimerExpired(context);
651 } 634 }
652 635
653 cdm::Time CdmAdapter::GetCurrentWallTime() { 636 cdm::Time CdmAdapter::GetCurrentWallTime() {
654 return pp::Module::Get()->core()->GetTime(); 637 return pp::Module::Get()->core()->GetTime();
655 } 638 }
(...skipping 14 matching lines...) Expand all
670 void CdmAdapter::OnRejectPromise(uint32_t promise_id, 653 void CdmAdapter::OnRejectPromise(uint32_t promise_id,
671 cdm::Error error, 654 cdm::Error error,
672 uint32_t system_code, 655 uint32_t system_code,
673 const char* error_message, 656 const char* error_message,
674 uint32_t error_message_size) { 657 uint32_t error_message_size) {
675 // UMA to investigate http://crbug.com/410630 658 // UMA to investigate http://crbug.com/410630
676 // TODO(xhwang): Remove after bug is fixed. 659 // TODO(xhwang): Remove after bug is fixed.
677 if (system_code == 0x27) { 660 if (system_code == 0x27) {
678 pp::UMAPrivate uma_interface(this); 661 pp::UMAPrivate uma_interface(this);
679 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", 662 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError",
680 last_read_file_size_kb_, 663 last_read_file_size_kb_, kSizeKBMin,
681 kSizeKBMin, 664 kSizeKBMax, kSizeKBBuckets);
682 kSizeKBMax,
683 kSizeKBBuckets);
684 } 665 }
685 666
686 RejectPromise(promise_id, error, system_code, 667 RejectPromise(promise_id, error, system_code,
687 std::string(error_message, error_message_size)); 668 std::string(error_message, error_message_size));
688 } 669 }
689 670
690 void CdmAdapter::RejectPromise(uint32_t promise_id, 671 void CdmAdapter::RejectPromise(uint32_t promise_id,
691 cdm::Error error, 672 cdm::Error error,
692 uint32_t system_code, 673 uint32_t system_code,
693 const std::string& error_message) { 674 const std::string& error_message) {
694 PostOnMain(callback_factory_.NewCallback( 675 PostOnMain(callback_factory_.NewCallback(
695 &CdmAdapter::SendPromiseRejectedInternal, 676 &CdmAdapter::SendPromiseRejectedInternal, promise_id,
696 promise_id,
697 SessionError(error, system_code, error_message))); 677 SessionError(error, system_code, error_message)));
698 } 678 }
699 679
700 void CdmAdapter::OnSessionMessage(const char* session_id, 680 void CdmAdapter::OnSessionMessage(const char* session_id,
701 uint32_t session_id_size, 681 uint32_t session_id_size,
702 cdm::MessageType message_type, 682 cdm::MessageType message_type,
703 const char* message, 683 const char* message,
704 uint32_t message_size, 684 uint32_t message_size,
705 const char* legacy_destination_url, 685 const char* legacy_destination_url,
706 uint32_t legacy_destination_url_size) { 686 uint32_t legacy_destination_url_size) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 PP_DCHECK(result == PP_OK); 772 PP_DCHECK(result == PP_OK);
793 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id, 773 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id,
794 session_id); 774 session_id);
795 } 775 }
796 776
797 void CdmAdapter::SendPromiseRejectedInternal(int32_t result, 777 void CdmAdapter::SendPromiseRejectedInternal(int32_t result,
798 uint32_t promise_id, 778 uint32_t promise_id,
799 const SessionError& error) { 779 const SessionError& error) {
800 PP_DCHECK(result == PP_OK); 780 PP_DCHECK(result == PP_OK);
801 pp::ContentDecryptor_Private::PromiseRejected( 781 pp::ContentDecryptor_Private::PromiseRejected(
802 promise_id, 782 promise_id, CdmExceptionTypeToPpCdmExceptionType(error.error),
803 CdmExceptionTypeToPpCdmExceptionType(error.error), 783 error.system_code, error.error_description);
804 error.system_code,
805 error.error_description);
806 } 784 }
807 785
808 void CdmAdapter::SendSessionMessageInternal(int32_t result, 786 void CdmAdapter::SendSessionMessageInternal(int32_t result,
809 const SessionMessage& message) { 787 const SessionMessage& message) {
810 PP_DCHECK(result == PP_OK); 788 PP_DCHECK(result == PP_OK);
811 789
812 pp::VarArrayBuffer message_array_buffer(message.message.size()); 790 pp::VarArrayBuffer message_array_buffer(message.message.size());
813 if (message.message.size() > 0) { 791 if (message.message.size() > 0) {
814 memcpy(message_array_buffer.Map(), message.message.data(), 792 memcpy(message_array_buffer.Map(), message.message.data(),
815 message.message.size()); 793 message.message.size());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 861 }
884 862
885 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); 863 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info);
886 } 864 }
887 865
888 void CdmAdapter::DecoderInitializeDone(int32_t result, 866 void CdmAdapter::DecoderInitializeDone(int32_t result,
889 PP_DecryptorStreamType decoder_type, 867 PP_DecryptorStreamType decoder_type,
890 uint32_t request_id, 868 uint32_t request_id,
891 bool success) { 869 bool success) {
892 PP_DCHECK(result == PP_OK); 870 PP_DCHECK(result == PP_OK);
893 pp::ContentDecryptor_Private::DecoderInitializeDone(decoder_type, 871 pp::ContentDecryptor_Private::DecoderInitializeDone(decoder_type, request_id,
894 request_id,
895 success); 872 success);
896 } 873 }
897 874
898 void CdmAdapter::DecoderDeinitializeDone(int32_t result, 875 void CdmAdapter::DecoderDeinitializeDone(int32_t result,
899 PP_DecryptorStreamType decoder_type, 876 PP_DecryptorStreamType decoder_type,
900 uint32_t request_id) { 877 uint32_t request_id) {
901 pp::ContentDecryptor_Private::DecoderDeinitializeDone(decoder_type, 878 pp::ContentDecryptor_Private::DecoderDeinitializeDone(decoder_type,
902 request_id); 879 request_id);
903 } 880 }
904 881
905 void CdmAdapter::DecoderResetDone(int32_t result, 882 void CdmAdapter::DecoderResetDone(int32_t result,
906 PP_DecryptorStreamType decoder_type, 883 PP_DecryptorStreamType decoder_type,
907 uint32_t request_id) { 884 uint32_t request_id) {
908 pp::ContentDecryptor_Private::DecoderResetDone(decoder_type, request_id); 885 pp::ContentDecryptor_Private::DecoderResetDone(decoder_type, request_id);
909 } 886 }
910 887
911 void CdmAdapter::DeliverFrame( 888 void CdmAdapter::DeliverFrame(int32_t result,
912 int32_t result, 889 const cdm::Status& status,
913 const cdm::Status& status, 890 const LinkedVideoFrame& video_frame,
914 const LinkedVideoFrame& video_frame, 891 const PP_DecryptTrackingInfo& tracking_info) {
915 const PP_DecryptTrackingInfo& tracking_info) {
916 PP_DCHECK(result == PP_OK); 892 PP_DCHECK(result == PP_OK);
917 PP_DecryptedFrameInfo decrypted_frame_info = {}; 893 PP_DecryptedFrameInfo decrypted_frame_info = {};
918 decrypted_frame_info.tracking_info.request_id = tracking_info.request_id; 894 decrypted_frame_info.tracking_info.request_id = tracking_info.request_id;
919 decrypted_frame_info.tracking_info.buffer_id = 0; 895 decrypted_frame_info.tracking_info.buffer_id = 0;
920 decrypted_frame_info.result = CdmStatusToPpDecryptResult(status); 896 decrypted_frame_info.result = CdmStatusToPpDecryptResult(status);
921 897
922 pp::Buffer_Dev buffer; 898 pp::Buffer_Dev buffer;
923 899
924 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) { 900 if (decrypted_frame_info.result == PP_DECRYPTRESULT_SUCCESS) {
925 if (!IsValidVideoFrame(video_frame)) { 901 if (!IsValidVideoFrame(video_frame)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format()); 961 CdmAudioFormatToPpDecryptedSampleFormat(audio_frames->Format());
986 962
987 buffer = ppb_buffer->TakeBuffer(); 963 buffer = ppb_buffer->TakeBuffer();
988 } 964 }
989 } 965 }
990 966
991 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info); 967 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_sample_info);
992 } 968 }
993 969
994 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) { 970 bool CdmAdapter::IsValidVideoFrame(const LinkedVideoFrame& video_frame) {
995 if (!video_frame.get() || 971 if (!video_frame.get() || !video_frame->FrameBuffer() ||
996 !video_frame->FrameBuffer() ||
997 (video_frame->Format() != cdm::kI420 && 972 (video_frame->Format() != cdm::kI420 &&
998 video_frame->Format() != cdm::kYv12)) { 973 video_frame->Format() != cdm::kYv12)) {
999 CDM_DLOG() << "Invalid video frame!"; 974 CDM_DLOG() << "Invalid video frame!";
1000 return false; 975 return false;
1001 } 976 }
1002 977
1003 PpbBuffer* ppb_buffer = static_cast<PpbBuffer*>(video_frame->FrameBuffer()); 978 PpbBuffer* ppb_buffer = static_cast<PpbBuffer*>(video_frame->FrameBuffer());
1004 979
1005 for (uint32_t i = 0; i < cdm::VideoFrame::kMaxPlanes; ++i) { 980 for (uint32_t i = 0; i < cdm::VideoFrame::kMaxPlanes; ++i) {
1006 int plane_height = (i == cdm::VideoFrame::kYPlane) ? 981 int plane_height = (i == cdm::VideoFrame::kYPlane)
1007 video_frame->Size().height : (video_frame->Size().height + 1) / 2; 982 ? video_frame->Size().height
983 : (video_frame->Size().height + 1) / 2;
1008 cdm::VideoFrame::VideoPlane plane = 984 cdm::VideoFrame::VideoPlane plane =
1009 static_cast<cdm::VideoFrame::VideoPlane>(i); 985 static_cast<cdm::VideoFrame::VideoPlane>(i);
1010 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) + 986 if (ppb_buffer->Size() < video_frame->PlaneOffset(plane) +
1011 plane_height * video_frame->Stride(plane)) { 987 plane_height * video_frame->Stride(plane)) {
1012 return false; 988 return false;
1013 } 989 }
1014 } 990 }
1015 991
1016 return true; 992 return true;
1017 } 993 }
1018 994
1019 void CdmAdapter::OnFirstFileRead(int32_t file_size_bytes) { 995 void CdmAdapter::OnFirstFileRead(int32_t file_size_bytes) {
1020 PP_DCHECK(IsMainThread()); 996 PP_DCHECK(IsMainThread());
1021 PP_DCHECK(file_size_bytes >= 0); 997 PP_DCHECK(file_size_bytes >= 0);
1022 998
1023 last_read_file_size_kb_ = file_size_bytes / 1024; 999 last_read_file_size_kb_ = file_size_bytes / 1024;
1024 1000
1025 if (file_size_uma_reported_) 1001 if (file_size_uma_reported_)
1026 return; 1002 return;
1027 1003
1028 pp::UMAPrivate uma_interface(this); 1004 pp::UMAPrivate uma_interface(this);
1029 uma_interface.HistogramCustomCounts( 1005 uma_interface.HistogramCustomCounts(
1030 "Media.EME.CdmFileIO.FileSizeKBOnFirstRead", 1006 "Media.EME.CdmFileIO.FileSizeKBOnFirstRead", last_read_file_size_kb_,
1031 last_read_file_size_kb_, 1007 kSizeKBMin, kSizeKBMax, kSizeKBBuckets);
1032 kSizeKBMin,
1033 kSizeKBMax,
1034 kSizeKBBuckets);
1035 file_size_uma_reported_ = true; 1008 file_size_uma_reported_ = true;
1036 } 1009 }
1037 1010
1038 #if !defined(NDEBUG) 1011 #if !defined(NDEBUG)
1039 void CdmAdapter::LogToConsole(const pp::Var& value) { 1012 void CdmAdapter::LogToConsole(const pp::Var& value) {
1040 PP_DCHECK(IsMainThread()); 1013 PP_DCHECK(IsMainThread());
1041 const PPB_Console* console = reinterpret_cast<const PPB_Console*>( 1014 const PPB_Console* console = reinterpret_cast<const PPB_Console*>(
1042 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); 1015 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE));
1043 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var()); 1016 console->Log(pp_instance(), PP_LOGLEVEL_LOG, value.pp_var());
1044 } 1017 }
(...skipping 10 matching lines...) Expand all
1055 pp::VarArrayBuffer challenge_var(challenge_size); 1028 pp::VarArrayBuffer challenge_var(challenge_size);
1056 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); 1029 uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map());
1057 memcpy(var_data, challenge, challenge_size); 1030 memcpy(var_data, challenge, challenge_size);
1058 1031
1059 std::string service_id_str(service_id, service_id_size); 1032 std::string service_id_str(service_id, service_id_size);
1060 1033
1061 linked_ptr<PepperPlatformChallengeResponse> response( 1034 linked_ptr<PepperPlatformChallengeResponse> response(
1062 new PepperPlatformChallengeResponse()); 1035 new PepperPlatformChallengeResponse());
1063 1036
1064 int32_t result = platform_verification_.ChallengePlatform( 1037 int32_t result = platform_verification_.ChallengePlatform(
1065 pp::Var(service_id_str), 1038 pp::Var(service_id_str), challenge_var, &response->signed_data,
1066 challenge_var, 1039 &response->signed_data_signature, &response->platform_key_certificate,
1067 &response->signed_data,
1068 &response->signed_data_signature,
1069 &response->platform_key_certificate,
1070 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone, 1040 callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone,
1071 response)); 1041 response));
1072 challenge_var.Unmap(); 1042 challenge_var.Unmap();
1073 if (result == PP_OK_COMPLETIONPENDING) 1043 if (result == PP_OK_COMPLETIONPENDING)
1074 return; 1044 return;
1075 1045
1076 // Fall through on error and issue an empty OnPlatformChallengeResponse(). 1046 // Fall through on error and issue an empty OnPlatformChallengeResponse().
1077 PP_DCHECK(result != PP_OK); 1047 PP_DCHECK(result != PP_OK);
1078 } 1048 }
1079 #endif 1049 #endif
1080 1050
1081 cdm::PlatformChallengeResponse platform_challenge_response = {}; 1051 cdm::PlatformChallengeResponse platform_challenge_response = {};
1082 cdm_->OnPlatformChallengeResponse(platform_challenge_response); 1052 cdm_->OnPlatformChallengeResponse(platform_challenge_response);
1083 } 1053 }
1084 1054
1085 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) { 1055 void CdmAdapter::EnableOutputProtection(uint32_t desired_protection_mask) {
1086 #if defined(OS_CHROMEOS) 1056 #if defined(OS_CHROMEOS)
1087 int32_t result = output_protection_.EnableProtection( 1057 int32_t result = output_protection_.EnableProtection(
1088 desired_protection_mask, callback_factory_.NewCallback( 1058 desired_protection_mask,
1089 &CdmAdapter::EnableProtectionDone)); 1059 callback_factory_.NewCallback(&CdmAdapter::EnableProtectionDone));
1090 1060
1091 // Errors are ignored since clients must call QueryOutputProtectionStatus() to 1061 // Errors are ignored since clients must call QueryOutputProtectionStatus() to
1092 // inspect the protection status on a regular basis. 1062 // inspect the protection status on a regular basis.
1093 1063
1094 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING) 1064 if (result != PP_OK && result != PP_OK_COMPLETIONPENDING)
1095 CDM_DLOG() << __FUNCTION__ << " failed!"; 1065 CDM_DLOG() << __FUNCTION__ << " failed!";
1096 #endif 1066 #endif
1097 } 1067 }
1098 1068
1099 void CdmAdapter::QueryOutputProtectionStatus() { 1069 void CdmAdapter::QueryOutputProtectionStatus() {
1100 #if defined(OS_CHROMEOS) 1070 #if defined(OS_CHROMEOS)
1101 PP_DCHECK(!query_output_protection_in_progress_); 1071 PP_DCHECK(!query_output_protection_in_progress_);
1102 1072
1103 output_link_mask_ = output_protection_mask_ = 0; 1073 output_link_mask_ = output_protection_mask_ = 0;
1104 const int32_t result = output_protection_.QueryStatus( 1074 const int32_t result = output_protection_.QueryStatus(
1105 &output_link_mask_, 1075 &output_link_mask_, &output_protection_mask_,
1106 &output_protection_mask_,
1107 callback_factory_.NewCallback( 1076 callback_factory_.NewCallback(
1108 &CdmAdapter::QueryOutputProtectionStatusDone)); 1077 &CdmAdapter::QueryOutputProtectionStatusDone));
1109 if (result == PP_OK_COMPLETIONPENDING) { 1078 if (result == PP_OK_COMPLETIONPENDING) {
1110 query_output_protection_in_progress_ = true; 1079 query_output_protection_in_progress_ = true;
1111 ReportOutputProtectionQuery(); 1080 ReportOutputProtectionQuery();
1112 return; 1081 return;
1113 } 1082 }
1114 1083
1115 // Fall through on error and issue an empty OnQueryOutputProtectionStatus(). 1084 // Fall through on error and issue an empty OnQueryOutputProtectionStatus().
1116 PP_DCHECK(result != PP_OK); 1085 PP_DCHECK(result != PP_OK);
1117 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result; 1086 CDM_DLOG() << __FUNCTION__ << " failed, result = " << result;
1118 #endif 1087 #endif
1119 cdm_->OnQueryOutputProtectionStatus(cdm::kQueryFailed, 0, 0); 1088 cdm_->OnQueryOutputProtectionStatus(cdm::kQueryFailed, 0, 0);
1120 } 1089 }
1121 1090
1122 void CdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, 1091 void CdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type,
1123 cdm::Status decoder_status) { 1092 cdm::Status decoder_status) {
1124 switch (stream_type) { 1093 switch (stream_type) {
1125 case cdm::kStreamTypeAudio: 1094 case cdm::kStreamTypeAudio:
1126 PP_DCHECK(deferred_initialize_audio_decoder_); 1095 PP_DCHECK(deferred_initialize_audio_decoder_);
1127 CallOnMain( 1096 CallOnMain(callback_factory_.NewCallback(
1128 callback_factory_.NewCallback(&CdmAdapter::DecoderInitializeDone, 1097 &CdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_AUDIO,
1129 PP_DECRYPTORSTREAMTYPE_AUDIO, 1098 deferred_audio_decoder_config_id_, decoder_status == cdm::kSuccess));
1130 deferred_audio_decoder_config_id_,
1131 decoder_status == cdm::kSuccess));
1132 deferred_initialize_audio_decoder_ = false; 1099 deferred_initialize_audio_decoder_ = false;
1133 deferred_audio_decoder_config_id_ = 0; 1100 deferred_audio_decoder_config_id_ = 0;
1134 break; 1101 break;
1135 case cdm::kStreamTypeVideo: 1102 case cdm::kStreamTypeVideo:
1136 PP_DCHECK(deferred_initialize_video_decoder_); 1103 PP_DCHECK(deferred_initialize_video_decoder_);
1137 CallOnMain( 1104 CallOnMain(callback_factory_.NewCallback(
1138 callback_factory_.NewCallback(&CdmAdapter::DecoderInitializeDone, 1105 &CdmAdapter::DecoderInitializeDone, PP_DECRYPTORSTREAMTYPE_VIDEO,
1139 PP_DECRYPTORSTREAMTYPE_VIDEO, 1106 deferred_video_decoder_config_id_, decoder_status == cdm::kSuccess));
1140 deferred_video_decoder_config_id_,
1141 decoder_status == cdm::kSuccess));
1142 deferred_initialize_video_decoder_ = false; 1107 deferred_initialize_video_decoder_ = false;
1143 deferred_video_decoder_config_id_ = 0; 1108 deferred_video_decoder_config_id_ = 0;
1144 break; 1109 break;
1145 } 1110 }
1146 } 1111 }
1147 1112
1148 // The CDM owns the returned object and must call FileIO::Close() to release it. 1113 // The CDM owns the returned object and must call FileIO::Close() to release it.
1149 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { 1114 cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) {
1150 if (!allow_persistent_state_) { 1115 if (!allow_persistent_state_) {
1151 CDM_DLOG() 1116 CDM_DLOG()
1152 << "Cannot create FileIO because persistent state is not allowed."; 1117 << "Cannot create FileIO because persistent state is not allowed.";
1153 return nullptr; 1118 return nullptr;
1154 } 1119 }
1155 1120
1156 return new CdmFileIOImpl( 1121 return new CdmFileIOImpl(
1157 client, pp_instance(), 1122 client, pp_instance(),
1158 callback_factory_.NewCallback(&CdmAdapter::OnFirstFileRead)); 1123 callback_factory_.NewCallback(&CdmAdapter::OnFirstFileRead));
1159 } 1124 }
1160 1125
1161 #if defined(OS_CHROMEOS) 1126 #if defined(OS_CHROMEOS)
1162 void CdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) { 1127 void CdmAdapter::ReportOutputProtectionUMA(OutputProtectionStatus status) {
1163 pp::UMAPrivate uma_interface(this); 1128 pp::UMAPrivate uma_interface(this);
1164 uma_interface.HistogramEnumeration( 1129 uma_interface.HistogramEnumeration("Media.EME.OutputProtection", status,
1165 "Media.EME.OutputProtection", status, OUTPUT_PROTECTION_MAX); 1130 OUTPUT_PROTECTION_MAX);
1166 } 1131 }
1167 1132
1168 void CdmAdapter::ReportOutputProtectionQuery() { 1133 void CdmAdapter::ReportOutputProtectionQuery() {
1169 if (uma_for_output_protection_query_reported_) 1134 if (uma_for_output_protection_query_reported_)
1170 return; 1135 return;
1171 1136
1172 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED); 1137 ReportOutputProtectionUMA(OUTPUT_PROTECTION_QUERIED);
1173 uma_for_output_protection_query_reported_ = true; 1138 uma_for_output_protection_query_reported_ = true;
1174 } 1139 }
1175 1140
(...skipping 11 matching lines...) Expand all
1187 } 1152 }
1188 1153
1189 const uint32_t kProtectableLinks = 1154 const uint32_t kProtectableLinks =
1190 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort; 1155 cdm::kLinkTypeHDMI | cdm::kLinkTypeDVI | cdm::kLinkTypeDisplayPort;
1191 bool is_unprotectable_link_connected = external_links & ~kProtectableLinks; 1156 bool is_unprotectable_link_connected = external_links & ~kProtectableLinks;
1192 bool is_hdcp_enabled_on_all_protectable_links = 1157 bool is_hdcp_enabled_on_all_protectable_links =
1193 output_protection_mask_ & cdm::kProtectionHDCP; 1158 output_protection_mask_ & cdm::kProtectionHDCP;
1194 1159
1195 if (!is_unprotectable_link_connected && 1160 if (!is_unprotectable_link_connected &&
1196 is_hdcp_enabled_on_all_protectable_links) { 1161 is_hdcp_enabled_on_all_protectable_links) {
1197 ReportOutputProtectionUMA( 1162 ReportOutputProtectionUMA(OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED);
1198 OUTPUT_PROTECTION_ALL_EXTERNAL_LINKS_PROTECTED);
1199 uma_for_output_protection_positive_result_reported_ = true; 1163 uma_for_output_protection_positive_result_reported_ = true;
1200 return; 1164 return;
1201 } 1165 }
1202 1166
1203 // Do not report a negative result because it could be a false negative. 1167 // Do not report a negative result because it could be a false negative.
1204 // Instead, we will calculate number of negatives using the total number of 1168 // Instead, we will calculate number of negatives using the total number of
1205 // queries and success results. 1169 // queries and success results.
1206 } 1170 }
1207 1171
1208 void CdmAdapter::SendPlatformChallengeDone( 1172 void CdmAdapter::SendPlatformChallengeDone(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_, 1221 cdm_->OnQueryOutputProtectionStatus(query_result, output_link_mask_,
1258 output_protection_mask_); 1222 output_protection_mask_);
1259 } 1223 }
1260 #endif 1224 #endif
1261 1225
1262 CdmAdapter::SessionError::SessionError(cdm::Error error, 1226 CdmAdapter::SessionError::SessionError(cdm::Error error,
1263 uint32_t system_code, 1227 uint32_t system_code,
1264 const std::string& error_description) 1228 const std::string& error_description)
1265 : error(error), 1229 : error(error),
1266 system_code(system_code), 1230 system_code(system_code),
1267 error_description(error_description) { 1231 error_description(error_description) {}
1268 }
1269 1232
1270 CdmAdapter::SessionMessage::SessionMessage( 1233 CdmAdapter::SessionMessage::SessionMessage(
1271 const std::string& session_id, 1234 const std::string& session_id,
1272 cdm::MessageType message_type, 1235 cdm::MessageType message_type,
1273 const char* message, 1236 const char* message,
1274 uint32_t message_size, 1237 uint32_t message_size,
1275 const std::string& legacy_destination_url) 1238 const std::string& legacy_destination_url)
1276 : session_id(session_id), 1239 : session_id(session_id),
1277 message_type(message_type), 1240 message_type(message_type),
1278 message(message, message + message_size), 1241 message(message, message + message_size),
1279 legacy_destination_url(legacy_destination_url) { 1242 legacy_destination_url(legacy_destination_url) {}
1280 }
1281 1243
1282 void* GetCdmHost(int host_interface_version, void* user_data) { 1244 void* GetCdmHost(int host_interface_version, void* user_data) {
1283 if (!host_interface_version || !user_data) 1245 if (!host_interface_version || !user_data)
1284 return NULL; 1246 return NULL;
1285 1247
1286 static_assert( 1248 static_assert(
1287 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_8::kVersion, 1249 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_8::kVersion,
1288 "update the code below"); 1250 "update the code below");
1289 1251
1290 // Ensure IsSupportedCdmHostVersion matches implementation of this function. 1252 // Ensure IsSupportedCdmHostVersion matches implementation of this function.
(...skipping 27 matching lines...) Expand all
1318 1280
1319 // This object is the global object representing this plugin library as long 1281 // This object is the global object representing this plugin library as long
1320 // as it is loaded. 1282 // as it is loaded.
1321 class CdmAdapterModule : public pp::Module { 1283 class CdmAdapterModule : public pp::Module {
1322 public: 1284 public:
1323 CdmAdapterModule() : pp::Module() { 1285 CdmAdapterModule() : pp::Module() {
1324 // This function blocks the renderer thread (PluginInstance::Initialize()). 1286 // This function blocks the renderer thread (PluginInstance::Initialize()).
1325 // Move this call to other places if this may be a concern in the future. 1287 // Move this call to other places if this may be a concern in the future.
1326 INITIALIZE_CDM_MODULE(); 1288 INITIALIZE_CDM_MODULE();
1327 } 1289 }
1328 virtual ~CdmAdapterModule() { 1290 virtual ~CdmAdapterModule() { DeinitializeCdmModule(); }
1329 DeinitializeCdmModule();
1330 }
1331 1291
1332 virtual pp::Instance* CreateInstance(PP_Instance instance) { 1292 virtual pp::Instance* CreateInstance(PP_Instance instance) {
1333 return new CdmAdapter(instance, this); 1293 return new CdmAdapter(instance, this);
1334 } 1294 }
1335 1295
1336 private: 1296 private:
1337 CdmFileIOImpl::ResourceTracker cdm_file_io_impl_resource_tracker; 1297 CdmFileIOImpl::ResourceTracker cdm_file_io_impl_resource_tracker;
1338 }; 1298 };
1339 1299
1340 } // namespace media 1300 } // namespace media
1341 1301
1342 namespace pp { 1302 namespace pp {
1343 1303
1344 // Factory function for your specialization of the Module object. 1304 // Factory function for your specialization of the Module object.
1345 Module* CreateModule() { 1305 Module* CreateModule() {
1346 return new media::CdmAdapterModule(); 1306 return new media::CdmAdapterModule();
1347 } 1307 }
1348 1308
1349 } // namespace pp 1309 } // namespace pp
OLDNEW
« no previous file with comments | « media/cdm/ppapi/ppapi_cdm_adapter.h ('k') | media/cdm/ppapi/ppapi_cdm_adapter.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698