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

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

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more trybot issue Created 6 years, 6 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/cdm_adapter.h ('k') | media/cdm/ppapi/cdm_wrapper.h » ('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/cdm_adapter.h"
6 6
7 #include "media/cdm/ppapi/cdm_file_io_impl.h" 7 #include "media/cdm/ppapi/cdm_file_io_impl.h"
8 #include "media/cdm/ppapi/cdm_helpers.h" 8 #include "media/cdm/ppapi/cdm_helpers.h"
9 #include "media/cdm/ppapi/cdm_logging.h" 9 #include "media/cdm/ppapi/cdm_logging.h"
10 #include "media/cdm/ppapi/supported_cdm_versions.h" 10 #include "media/cdm/ppapi/supported_cdm_versions.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 case PP_DECRYPTORSTREAMTYPE_AUDIO: 204 case PP_DECRYPTORSTREAMTYPE_AUDIO:
205 return cdm::kStreamTypeAudio; 205 return cdm::kStreamTypeAudio;
206 case PP_DECRYPTORSTREAMTYPE_VIDEO: 206 case PP_DECRYPTORSTREAMTYPE_VIDEO:
207 return cdm::kStreamTypeVideo; 207 return cdm::kStreamTypeVideo;
208 } 208 }
209 209
210 PP_NOTREACHED(); 210 PP_NOTREACHED();
211 return cdm::kStreamTypeVideo; 211 return cdm::kStreamTypeVideo;
212 } 212 }
213 213
214 cdm::SessionType PpSessionTypeToCdmSessionType(PP_SessionType session_type) {
215 switch (session_type) {
216 case PP_SESSIONTYPE_TEMPORARY:
217 return cdm::kTemporary;
218 case PP_SESSIONTYPE_PERSISTENT:
219 return cdm::kPersistent;
220 default:
221 PP_NOTREACHED();
222 return cdm::kTemporary;
223 }
224 }
225
226 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) {
227 switch (error) {
228 case cdm::kNotSupportedError:
229 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR;
230 case cdm::kInvalidStateError:
231 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR;
232 case cdm::kInvalidAccessError:
233 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR;
234 case cdm::kQuotaExceededError:
235 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR;
236 case cdm::kUnknownError:
237 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR;
238 case cdm::kClientError:
239 return PP_CDMEXCEPTIONCODE_CLIENTERROR;
240 case cdm::kOutputError:
241 return PP_CDMEXCEPTIONCODE_OUTPUTERROR;
242 default:
243 PP_NOTREACHED();
244 return PP_CDMEXCEPTIONCODE_UNKNOWNERROR;
245 }
246 }
247
214 } // namespace 248 } // namespace
215 249
216 namespace media { 250 namespace media {
217 251
218 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) 252 CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module)
219 : pp::Instance(instance), 253 : pp::Instance(instance),
220 pp::ContentDecryptor_Private(this), 254 pp::ContentDecryptor_Private(this),
221 #if defined(OS_CHROMEOS) 255 #if defined(OS_CHROMEOS)
222 output_protection_(this), 256 output_protection_(this),
223 platform_verification_(this), 257 platform_verification_(this),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 317 }
284 #endif // defined(CHECK_DOCUMENT_URL) 318 #endif // defined(CHECK_DOCUMENT_URL)
285 319
286 if (!cdm_ && !CreateCdmInstance(key_system)) 320 if (!cdm_ && !CreateCdmInstance(key_system))
287 return; 321 return;
288 322
289 PP_DCHECK(cdm_); 323 PP_DCHECK(cdm_);
290 key_system_ = key_system; 324 key_system_ = key_system;
291 } 325 }
292 326
293 void CdmAdapter::CreateSession(uint32_t session_id, 327 void CdmAdapter::CreateSession(uint32_t promise_id,
294 const std::string& content_type, 328 const std::string& init_data_type,
295 pp::VarArrayBuffer init_data) { 329 pp::VarArrayBuffer init_data,
330 PP_SessionType session_type) {
296 // Initialize() doesn't report an error, so CreateSession() can be called 331 // Initialize() doesn't report an error, so CreateSession() can be called
297 // even if Initialize() failed. 332 // even if Initialize() failed.
333 // TODO(jrummell): Remove this code when prefixed EME gets removed.
334 // TODO(jrummell): Verify that Initialize() failing does not resolve the
335 // MediaKeys.create() promise.
298 if (!cdm_) { 336 if (!cdm_) {
299 OnSessionError(session_id, cdm::kUnknownError, 0); 337 RejectPromise(promise_id,
338 cdm::kInvalidStateError,
339 0,
340 "CDM has not been initialized.");
300 return; 341 return;
301 } 342 }
302 343
303 cdm_->CreateSession(session_id, 344 cdm_->CreateSession(promise_id,
304 content_type.data(), 345 init_data_type.data(),
305 content_type.size(), 346 init_data_type.size(),
306 static_cast<const uint8_t*>(init_data.Map()), 347 static_cast<const uint8_t*>(init_data.Map()),
307 init_data.ByteLength()); 348 init_data.ByteLength(),
349 PpSessionTypeToCdmSessionType(session_type));
308 } 350 }
309 351
310 void CdmAdapter::LoadSession(uint32_t session_id, 352 void CdmAdapter::LoadSession(uint32_t promise_id,
311 const std::string& web_session_id) { 353 const std::string& web_session_id) {
312 // Initialize() doesn't report an error, so LoadSession() can be called 354 // Initialize() doesn't report an error, so LoadSession() can be called
313 // even if Initialize() failed. 355 // even if Initialize() failed.
356 // TODO(jrummell): Remove this code when prefixed EME gets removed.
357 // TODO(jrummell): Verify that Initialize() failing does not resolve the
358 // MediaKeys.create() promise.
314 if (!cdm_) { 359 if (!cdm_) {
315 OnSessionError(session_id, cdm::kUnknownError, 0); 360 RejectPromise(promise_id,
361 cdm::kInvalidStateError,
362 0,
363 "CDM has not been initialized.");
316 return; 364 return;
317 } 365 }
318 366
319 cdm_->LoadSession(session_id, web_session_id.data(), web_session_id.size()); 367 cdm_->LoadSession(promise_id, web_session_id.data(), web_session_id.size());
320 } 368 }
321 369
322 void CdmAdapter::UpdateSession(uint32_t session_id, 370 void CdmAdapter::UpdateSession(uint32_t promise_id,
371 const std::string& web_session_id,
323 pp::VarArrayBuffer response) { 372 pp::VarArrayBuffer response) {
324 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); 373 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map());
325 const uint32_t response_size = response.ByteLength(); 374 const uint32_t response_size = response.ByteLength();
326 375
327 if (!response_ptr || response_size <= 0) { 376 PP_DCHECK(!web_session_id.empty());
328 OnSessionError(session_id, cdm::kUnknownError, 0); 377 PP_DCHECK(response_ptr);
329 return; 378 PP_DCHECK(response_size > 0);
330 } 379
331 cdm_->UpdateSession(session_id, response_ptr, response_size); 380 cdm_->UpdateSession(promise_id,
381 web_session_id.data(),
382 web_session_id.length(),
383 response_ptr,
384 response_size);
332 } 385 }
333 386
334 void CdmAdapter::ReleaseSession(uint32_t session_id) { 387 void CdmAdapter::ReleaseSession(uint32_t promise_id,
335 cdm_->ReleaseSession(session_id); 388 const std::string& web_session_id) {
389 cdm_->ReleaseSession(
390 promise_id, web_session_id.data(), web_session_id.length());
336 } 391 }
337 392
338 // Note: In the following decryption/decoding related functions, errors are NOT 393 // Note: In the following decryption/decoding related functions, errors are NOT
339 // reported via KeyError, but are reported via corresponding PPB calls. 394 // reported via KeyError, but are reported via corresponding PPB calls.
340 395
341 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer, 396 void CdmAdapter::Decrypt(pp::Buffer_Dev encrypted_buffer,
342 const PP_EncryptedBlockInfo& encrypted_block_info) { 397 const PP_EncryptedBlockInfo& encrypted_block_info) {
343 PP_DCHECK(!encrypted_buffer.is_null()); 398 PP_DCHECK(!encrypted_buffer.is_null());
344 399
345 // Release a buffer that the caller indicated it is finished with. 400 // Release a buffer that the caller indicated it is finished with.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 delay_ms, 577 delay_ms,
523 callback_factory_.NewCallback(&CdmAdapter::TimerExpired, context), 578 callback_factory_.NewCallback(&CdmAdapter::TimerExpired, context),
524 PP_OK); 579 PP_OK);
525 } 580 }
526 581
527 void CdmAdapter::TimerExpired(int32_t result, void* context) { 582 void CdmAdapter::TimerExpired(int32_t result, void* context) {
528 PP_DCHECK(result == PP_OK); 583 PP_DCHECK(result == PP_OK);
529 cdm_->TimerExpired(context); 584 cdm_->TimerExpired(context);
530 } 585 }
531 586
587 // cdm::Host_4 methods
588
532 double CdmAdapter::GetCurrentWallTimeInSeconds() { 589 double CdmAdapter::GetCurrentWallTimeInSeconds() {
533 return pp::Module::Get()->core()->GetTime(); 590 return GetCurrentTime();
534 } 591 }
535 592
536 void CdmAdapter::OnSessionCreated(uint32_t session_id, 593 void CdmAdapter::OnSessionCreated(uint32_t session_id,
537 const char* web_session_id, 594 const char* web_session_id,
538 uint32_t web_session_id_length) { 595 uint32_t web_session_id_length) {
539 PostOnMain(callback_factory_.NewCallback( 596 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
540 &CdmAdapter::SendSessionCreatedInternal, 597 cdm_->AssignWebSessionId(session_id, web_session_id, web_session_id_length);
541 session_id, 598 OnResolveNewSessionPromise(promise_id, web_session_id, web_session_id_length);
542 std::string(web_session_id, web_session_id_length)));
543 } 599 }
544 600
545 void CdmAdapter::OnSessionMessage(uint32_t session_id, 601 void CdmAdapter::OnSessionMessage(uint32_t session_id,
546 const char* message, 602 const char* message,
547 uint32_t message_length, 603 uint32_t message_length,
548 const char* destination_url, 604 const char* destination_url,
549 uint32_t destination_url_length) { 605 uint32_t destination_url_length) {
550 PostOnMain(callback_factory_.NewCallback( 606 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
551 &CdmAdapter::SendSessionMessageInternal, 607 OnSessionMessage(web_session_id.data(),
552 session_id, 608 web_session_id.length(),
553 std::vector<uint8>(message, message + message_length), 609 message,
554 std::string(destination_url, destination_url_length))); 610 message_length,
611 destination_url,
612 destination_url_length);
555 } 613 }
556 614
557 void CdmAdapter::OnSessionReady(uint32_t session_id) { 615 void CdmAdapter::OnSessionReady(uint32_t session_id) {
558 PostOnMain(callback_factory_.NewCallback( 616 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
559 &CdmAdapter::SendSessionReadyInternal, session_id)); 617 if (promise_id) {
618 OnResolvePromise(promise_id);
619 } else {
620 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
621 OnSessionReady(web_session_id.data(), web_session_id.length());
622 }
560 } 623 }
561 624
562 void CdmAdapter::OnSessionClosed(uint32_t session_id) { 625 void CdmAdapter::OnSessionClosed(uint32_t session_id) {
563 PostOnMain(callback_factory_.NewCallback( 626 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
564 &CdmAdapter::SendSessionClosedInternal, session_id)); 627 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
628 cdm_->DropWebSessionId(web_session_id);
629 if (promise_id) {
630 OnResolvePromise(promise_id);
631 } else {
632 OnSessionClosed(web_session_id.data(), web_session_id.length());
633 }
565 } 634 }
566 635
567 void CdmAdapter::OnSessionError(uint32_t session_id, 636 void CdmAdapter::OnSessionError(uint32_t session_id,
568 cdm::MediaKeyError error_code, 637 cdm::MediaKeyError error_code,
569 uint32_t system_code) { 638 uint32_t system_code) {
639 uint32_t promise_id = cdm_->LookupPromiseId(session_id);
640
641 // Existing cdm::MediaKeyError don't map to DOM error names. Convert them
642 // into non-standard names so that the prefixed API can extract them.
643 // TODO(jrummell): Remove this conversion and the inverse when CDM4 is gone.
644 cdm::Error error;
645 switch (error_code) {
646 case cdm::kPrefixedClientError:
647 error = cdm::kClientError;
648 break;
649 case cdm::kPrefixedOutputError:
650 error = cdm::kOutputError;
651 break;
652 case cdm::kPrefixedUnknownError:
653 default:
654 error = cdm::kUnknownError;
655 break;
656 }
657
658 if (promise_id) {
659 RejectPromise(promise_id, error, system_code, std::string());
660 } else {
661 std::string web_session_id = cdm_->LookupWebSessionId(session_id);
662 OnSessionError(web_session_id.data(),
663 web_session_id.length(),
664 error,
665 system_code,
666 NULL,
667 0);
668 }
669 }
670
671 // cdm::Host_5 methods
672
673 cdm::Time CdmAdapter::GetCurrentTime() {
674 return pp::Module::Get()->core()->GetTime();
675 }
676
677 void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
678 PostOnMain(callback_factory_.NewCallback(
679 &CdmAdapter::SendPromiseResolvedInternal, promise_id));
680 }
681
682 void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
683 const char* web_session_id,
684 uint32_t web_session_id_length) {
685 PostOnMain(callback_factory_.NewCallback(
686 &CdmAdapter::SendPromiseResolvedWithSessionInternal,
687 promise_id,
688 std::string(web_session_id, web_session_id_length)));
689 }
690
691 void CdmAdapter::OnRejectPromise(uint32_t promise_id,
692 cdm::Error error,
693 uint32_t system_code,
694 const char* error_message,
695 uint32_t error_message_length) {
696 RejectPromise(promise_id,
697 error,
698 system_code,
699 std::string(error_message, error_message_length));
700 }
701
702 void CdmAdapter::RejectPromise(uint32_t promise_id,
703 cdm::Error error,
704 uint32_t system_code,
705 const std::string& error_message) {
706 PostOnMain(callback_factory_.NewCallback(
707 &CdmAdapter::SendPromiseRejectedInternal,
708 promise_id,
709 SessionError(error, system_code, error_message)));
710 }
711
712 void CdmAdapter::OnSessionMessage(const char* web_session_id,
713 uint32_t web_session_id_length,
714 const char* message,
715 uint32_t message_length,
716 const char* destination_url,
717 uint32_t destination_url_length) {
718 PostOnMain(callback_factory_.NewCallback(
719 &CdmAdapter::SendSessionMessageInternal,
720 std::string(web_session_id, web_session_id_length),
721 std::vector<uint8>(message, message + message_length),
722 std::string(destination_url, destination_url_length)));
723 }
724
725 void CdmAdapter::OnSessionKeysChange(const char* web_session_id,
726 uint32_t web_session_id_length,
727 bool has_additional_usable_key) {
728 // TODO(jrummell): Implement this event in subsequent CL
729 // (http://crbug.com/370251).
730 PP_NOTREACHED();
731 }
732
733 void CdmAdapter::OnExpirationChange(const char* web_session_id,
734 uint32_t web_session_id_length,
735 cdm::Time new_expiry_time) {
736 // TODO(jrummell): Implement this event in subsequent CL
737 // (http://crbug.com/370251).
738 PP_NOTREACHED();
739 }
740
741 void CdmAdapter::OnSessionReady(const char* web_session_id,
742 uint32_t web_session_id_length) {
743 PostOnMain(callback_factory_.NewCallback(
744 &CdmAdapter::SendSessionReadyInternal,
745 std::string(web_session_id, web_session_id_length)));
746 }
747
748 void CdmAdapter::OnSessionClosed(const char* web_session_id,
749 uint32_t web_session_id_length) {
750 PostOnMain(callback_factory_.NewCallback(
751 &CdmAdapter::SendSessionClosedInternal,
752 std::string(web_session_id, web_session_id_length)));
753 }
754
755 void CdmAdapter::OnSessionError(const char* web_session_id,
756 uint32_t web_session_id_length,
757 cdm::Error error,
758 uint32_t system_code,
759 const char* error_message,
760 uint32_t error_message_length) {
570 PostOnMain(callback_factory_.NewCallback( 761 PostOnMain(callback_factory_.NewCallback(
571 &CdmAdapter::SendSessionErrorInternal, 762 &CdmAdapter::SendSessionErrorInternal,
572 session_id, 763 std::string(web_session_id, web_session_id_length),
573 error_code, 764 SessionError(error,
574 system_code)); 765 system_code,
575 } 766 std::string(error_message, error_message_length))));
576 767 }
577 void CdmAdapter::SendSessionCreatedInternal(int32_t result, 768
578 uint32_t session_id, 769 // Helpers to pass the event to Pepper.
579 const std::string& web_session_id) { 770
580 PP_DCHECK(result == PP_OK); 771 void CdmAdapter::SendPromiseResolvedInternal(int32_t result,
581 pp::ContentDecryptor_Private::SessionCreated(session_id, web_session_id); 772 uint32_t promise_id) {
773 PP_DCHECK(result == PP_OK);
774 pp::ContentDecryptor_Private::PromiseResolved(promise_id);
775 }
776
777 void CdmAdapter::SendPromiseResolvedWithSessionInternal(
778 int32_t result,
779 uint32_t promise_id,
780 const std::string& web_session_id) {
781 PP_DCHECK(result == PP_OK);
782 pp::ContentDecryptor_Private::PromiseResolvedWithSession(promise_id,
783 web_session_id);
784 }
785
786 void CdmAdapter::SendPromiseRejectedInternal(int32_t result,
787 uint32_t promise_id,
788 const SessionError& error) {
789 PP_DCHECK(result == PP_OK);
790 pp::ContentDecryptor_Private::PromiseRejected(
791 promise_id,
792 CdmExceptionTypeToPpCdmExceptionType(error.error),
793 error.system_code,
794 error.error_description);
582 } 795 }
583 796
584 void CdmAdapter::SendSessionMessageInternal( 797 void CdmAdapter::SendSessionMessageInternal(
585 int32_t result, 798 int32_t result,
586 uint32_t session_id, 799 const std::string& web_session_id,
587 const std::vector<uint8>& message, 800 const std::vector<uint8>& message,
588 const std::string& destination_url) { 801 const std::string& destination_url) {
589 PP_DCHECK(result == PP_OK); 802 PP_DCHECK(result == PP_OK);
590 803
591 pp::VarArrayBuffer message_array_buffer(message.size()); 804 pp::VarArrayBuffer message_array_buffer(message.size());
592 if (message.size() > 0) { 805 if (message.size() > 0) {
593 memcpy(message_array_buffer.Map(), message.data(), message.size()); 806 memcpy(message_array_buffer.Map(), message.data(), message.size());
594 } 807 }
595 808
596 pp::ContentDecryptor_Private::SessionMessage( 809 pp::ContentDecryptor_Private::SessionMessage(
597 session_id, message_array_buffer, destination_url); 810 web_session_id, message_array_buffer, destination_url);
598 } 811 }
599 812
600 void CdmAdapter::SendSessionReadyInternal(int32_t result, uint32_t session_id) { 813 void CdmAdapter::SendSessionReadyInternal(int32_t result,
814 const std::string& web_session_id) {
601 PP_DCHECK(result == PP_OK); 815 PP_DCHECK(result == PP_OK);
602 pp::ContentDecryptor_Private::SessionReady(session_id); 816 pp::ContentDecryptor_Private::SessionReady(web_session_id);
603 } 817 }
604 818
605 void CdmAdapter::SendSessionClosedInternal(int32_t result, 819 void CdmAdapter::SendSessionClosedInternal(int32_t result,
606 uint32_t session_id) { 820 const std::string& web_session_id) {
607 PP_DCHECK(result == PP_OK); 821 PP_DCHECK(result == PP_OK);
608 pp::ContentDecryptor_Private::SessionClosed(session_id); 822 pp::ContentDecryptor_Private::SessionClosed(web_session_id);
609 } 823 }
610 824
611 void CdmAdapter::SendSessionErrorInternal(int32_t result, 825 void CdmAdapter::SendSessionErrorInternal(int32_t result,
612 uint32_t session_id, 826 const std::string& web_session_id,
613 cdm::MediaKeyError error_code, 827 const SessionError& error) {
614 uint32_t system_code) {
615 PP_DCHECK(result == PP_OK); 828 PP_DCHECK(result == PP_OK);
616 pp::ContentDecryptor_Private::SessionError( 829 pp::ContentDecryptor_Private::SessionError(
617 session_id, error_code, system_code); 830 web_session_id,
831 CdmExceptionTypeToPpCdmExceptionType(error.error),
832 error.system_code,
833 error.error_description);
618 } 834 }
619 835
620 void CdmAdapter::DeliverBlock(int32_t result, 836 void CdmAdapter::DeliverBlock(int32_t result,
621 const cdm::Status& status, 837 const cdm::Status& status,
622 const LinkedDecryptedBlock& decrypted_block, 838 const LinkedDecryptedBlock& decrypted_block,
623 const PP_DecryptTrackingInfo& tracking_info) { 839 const PP_DecryptTrackingInfo& tracking_info) {
624 PP_DCHECK(result == PP_OK); 840 PP_DCHECK(result == PP_OK);
625 PP_DecryptedBlockInfo decrypted_block_info; 841 PP_DecryptedBlockInfo decrypted_block_info;
626 decrypted_block_info.tracking_info = tracking_info; 842 decrypted_block_info.tracking_info = tracking_info;
627 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp(); 843 decrypted_block_info.tracking_info.timestamp = decrypted_block->Timestamp();
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 cdm_->OnPlatformChallengeResponse(response); 1152 cdm_->OnPlatformChallengeResponse(response);
937 return; 1153 return;
938 } 1154 }
939 1155
940 pp::VarArrayBuffer signed_data_var(signed_data_output_); 1156 pp::VarArrayBuffer signed_data_var(signed_data_output_);
941 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_); 1157 pp::VarArrayBuffer signed_data_signature_var(signed_data_signature_output_);
942 std::string platform_key_certificate_string = 1158 std::string platform_key_certificate_string =
943 platform_key_certificate_output_.AsString(); 1159 platform_key_certificate_output_.AsString();
944 1160
945 cdm::PlatformChallengeResponse response = { 1161 cdm::PlatformChallengeResponse response = {
946 static_cast<uint8_t*>(signed_data_var.Map()), 1162 static_cast<uint8_t*>(signed_data_var.Map()),
947 signed_data_var.ByteLength(), 1163 signed_data_var.ByteLength(),
948 1164 static_cast<uint8_t*>(signed_data_signature_var.Map()),
949 static_cast<uint8_t*>(signed_data_signature_var.Map()), 1165 signed_data_signature_var.ByteLength(),
950 signed_data_signature_var.ByteLength(), 1166 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.data()),
951 1167 static_cast<uint32_t>(platform_key_certificate_string.length())};
952 reinterpret_cast<const uint8_t*>(platform_key_certificate_string.c_str()),
953 static_cast<uint32_t>(platform_key_certificate_string.length())
954 };
955 cdm_->OnPlatformChallengeResponse(response); 1168 cdm_->OnPlatformChallengeResponse(response);
956 1169
957 signed_data_var.Unmap(); 1170 signed_data_var.Unmap();
958 signed_data_signature_var.Unmap(); 1171 signed_data_signature_var.Unmap();
959 } 1172 }
960 1173
961 void CdmAdapter::EnableProtectionDone(int32_t result) { 1174 void CdmAdapter::EnableProtectionDone(int32_t result) {
962 // Does nothing since clients must call QueryOutputProtectionStatus() to 1175 // Does nothing since clients must call QueryOutputProtectionStatus() to
963 // inspect the protection status on a regular basis. 1176 // inspect the protection status on a regular basis.
964 CDM_DLOG() << __FUNCTION__ << " : " << result; 1177 CDM_DLOG() << __FUNCTION__ << " : " << result;
965 } 1178 }
966 1179
967 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) { 1180 void CdmAdapter::QueryOutputProtectionStatusDone(int32_t result) {
968 PP_DCHECK(query_output_protection_in_progress_); 1181 PP_DCHECK(query_output_protection_in_progress_);
969 query_output_protection_in_progress_ = false; 1182 query_output_protection_in_progress_ = false;
970 1183
971 // Return a protection status of none on error. 1184 // Return a protection status of none on error.
972 if (result != PP_OK) 1185 if (result != PP_OK)
973 output_link_mask_ = output_protection_mask_ = 0; 1186 output_link_mask_ = output_protection_mask_ = 0;
974 else 1187 else
975 ReportOutputProtectionQueryResult(); 1188 ReportOutputProtectionQueryResult();
976 1189
977 cdm_->OnQueryOutputProtectionStatus(output_link_mask_, 1190 cdm_->OnQueryOutputProtectionStatus(output_link_mask_,
978 output_protection_mask_); 1191 output_protection_mask_);
979 } 1192 }
980 #endif 1193 #endif
981 1194
1195 CdmAdapter::SessionError::SessionError(cdm::Error error,
1196 uint32_t system_code,
1197 std::string error_description)
1198 : error(error),
1199 system_code(system_code),
1200 error_description(error_description) {
1201 }
1202
982 void* GetCdmHost(int host_interface_version, void* user_data) { 1203 void* GetCdmHost(int host_interface_version, void* user_data) {
983 if (!host_interface_version || !user_data) 1204 if (!host_interface_version || !user_data)
984 return NULL; 1205 return NULL;
985 1206
986 COMPILE_ASSERT( 1207 COMPILE_ASSERT(
987 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_4::kVersion, 1208 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_5::kVersion,
988 update_code_below); 1209 update_code_below);
989 1210
990 // Ensure IsSupportedCdmHostVersion matches implementation of this function. 1211 // Ensure IsSupportedCdmHostVersion matches implementation of this function.
991 // Always update this DCHECK when updating this function. 1212 // Always update this DCHECK when updating this function.
992 // If this check fails, update this function and DCHECK or update 1213 // If this check fails, update this function and DCHECK or update
993 // IsSupportedCdmHostVersion. 1214 // IsSupportedCdmHostVersion.
994 1215
995 PP_DCHECK( 1216 PP_DCHECK(
996 // Future version is not supported. 1217 // Future version is not supported.
997 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion + 1) && 1218 !IsSupportedCdmHostVersion(cdm::Host_5::kVersion + 1) &&
998 // Current version is supported. 1219 // Current version is supported.
1220 IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
1221 // Include all previous supported versions (if any) here.
999 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) && 1222 IsSupportedCdmHostVersion(cdm::Host_4::kVersion) &&
1000 // Include all previous supported versions (if any) here.
1001 // No supported previous versions.
1002 // One older than the oldest supported version is not supported. 1223 // One older than the oldest supported version is not supported.
1003 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1)); 1224 !IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1));
1004 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); 1225 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version));
1005 1226
1006 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); 1227 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
1007 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; 1228 CDM_DLOG() << "Create CDM Host with version " << host_interface_version;
1008 switch (host_interface_version) { 1229 switch (host_interface_version) {
1009 case cdm::Host_4::kVersion: 1230 case cdm::Host_4::kVersion:
1010 return static_cast<cdm::Host_4*>(cdm_adapter); 1231 return static_cast<cdm::Host_4*>(cdm_adapter);
1232 case cdm::Host_5::kVersion:
1233 return static_cast<cdm::Host_5*>(cdm_adapter);
1011 default: 1234 default:
1012 PP_NOTREACHED(); 1235 PP_NOTREACHED();
1013 return NULL; 1236 return NULL;
1014 } 1237 }
1015 } 1238 }
1016 1239
1017 // This object is the global object representing this plugin library as long 1240 // This object is the global object representing this plugin library as long
1018 // as it is loaded. 1241 // as it is loaded.
1019 class CdmAdapterModule : public pp::Module { 1242 class CdmAdapterModule : public pp::Module {
1020 public: 1243 public:
(...skipping 17 matching lines...) Expand all
1038 } // namespace media 1261 } // namespace media
1039 1262
1040 namespace pp { 1263 namespace pp {
1041 1264
1042 // Factory function for your specialization of the Module object. 1265 // Factory function for your specialization of the Module object.
1043 Module* CreateModule() { 1266 Module* CreateModule() {
1044 return new media::CdmAdapterModule(); 1267 return new media::CdmAdapterModule();
1045 } 1268 }
1046 1269
1047 } // namespace pp 1270 } // namespace pp
OLDNEW
« no previous file with comments | « media/cdm/ppapi/cdm_adapter.h ('k') | media/cdm/ppapi/cdm_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698