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

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

Issue 1023003002: Add support for cdm::ContentDecryptionModule_8, remove CDM_6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/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_helpers.h" 9 #include "media/cdm/ppapi/cdm_helpers.h"
10 #include "media/cdm/ppapi/cdm_logging.h" 10 #include "media/cdm/ppapi/cdm_logging.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 case PP_SESSIONTYPE_PERSISTENT_LICENSE: 225 case PP_SESSIONTYPE_PERSISTENT_LICENSE:
226 return cdm::kPersistentLicense; 226 return cdm::kPersistentLicense;
227 case PP_SESSIONTYPE_PERSISTENT_RELEASE: 227 case PP_SESSIONTYPE_PERSISTENT_RELEASE:
228 return cdm::kPersistentKeyRelease; 228 return cdm::kPersistentKeyRelease;
229 } 229 }
230 230
231 PP_NOTREACHED(); 231 PP_NOTREACHED();
232 return cdm::kTemporary; 232 return cdm::kTemporary;
233 } 233 }
234 234
235 cdm::InitDataType InitDataTypeToCdmInitDataType(
236 const std::string& init_data_type) {
237 if (init_data_type == "cenc")
238 return cdm::kCenc;
239 if (init_data_type == "webm")
240 return cdm::kWebM;
241 if (init_data_type == "keyids")
242 return cdm::kKeyIds;
243
244 PP_NOTREACHED();
245 return cdm::kWebM;
ddorwin 2015/03/20 00:05:22 perhaps kKeyIds since it's not supported in existi
jrummell 2015/03/20 18:05:09 Done.
246 }
247
235 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) { 248 PP_CdmExceptionCode CdmExceptionTypeToPpCdmExceptionType(cdm::Error error) {
236 switch (error) { 249 switch (error) {
237 case cdm::kNotSupportedError: 250 case cdm::kNotSupportedError:
238 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR; 251 return PP_CDMEXCEPTIONCODE_NOTSUPPORTEDERROR;
239 case cdm::kInvalidStateError: 252 case cdm::kInvalidStateError:
240 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR; 253 return PP_CDMEXCEPTIONCODE_INVALIDSTATEERROR;
241 case cdm::kInvalidAccessError: 254 case cdm::kInvalidAccessError:
242 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR; 255 return PP_CDMEXCEPTIONCODE_INVALIDACCESSERROR;
243 case cdm::kQuotaExceededError: 256 case cdm::kQuotaExceededError:
244 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR; 257 return PP_CDMEXCEPTIONCODE_QUOTAEXCEEDEDERROR;
(...skipping 26 matching lines...) Expand all
271 PP_CdmKeyStatus CdmKeyStatusToPpKeyStatus(cdm::KeyStatus status) { 284 PP_CdmKeyStatus CdmKeyStatusToPpKeyStatus(cdm::KeyStatus status) {
272 switch (status) { 285 switch (status) {
273 case cdm::kUsable: 286 case cdm::kUsable:
274 return PP_CDMKEYSTATUS_USABLE; 287 return PP_CDMKEYSTATUS_USABLE;
275 case cdm::kInternalError: 288 case cdm::kInternalError:
276 return PP_CDMKEYSTATUS_INVALID; 289 return PP_CDMKEYSTATUS_INVALID;
277 case cdm::kExpired: 290 case cdm::kExpired:
278 return PP_CDMKEYSTATUS_EXPIRED; 291 return PP_CDMKEYSTATUS_EXPIRED;
279 case cdm::kOutputNotAllowed: 292 case cdm::kOutputNotAllowed:
280 return PP_CDMKEYSTATUS_OUTPUTNOTALLOWED; 293 return PP_CDMKEYSTATUS_OUTPUTNOTALLOWED;
294 case cdm::kOutputDownscaled:
295 return PP_CDMKEYSTATUS_OUTPUTDOWNSCALED;
296 case cdm::kStatusPending:
297 return PP_CDMKEYSTATUS_STATUSPENDING;
281 } 298 }
282 299
283 PP_NOTREACHED(); 300 PP_NOTREACHED();
284 return PP_CDMKEYSTATUS_INVALID; 301 return PP_CDMKEYSTATUS_INVALID;
285 } 302 }
286 303
287 } // namespace 304 } // namespace
288 305
289 namespace media { 306 namespace media {
290 307
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // "Store this new error object internally with the MediaKeys instance being 350 // "Store this new error object internally with the MediaKeys instance being
334 // created. This will be used to fire an error against any session created for 351 // created. This will be used to fire an error against any session created for
335 // this instance." These errors will be reported during session creation 352 // this instance." These errors will be reported during session creation
336 // (CreateSession()) or session loading (LoadSession()). 353 // (CreateSession()) or session loading (LoadSession()).
337 // TODO(xhwang): If necessary, we need to store the error here if we want to 354 // TODO(xhwang): If necessary, we need to store the error here if we want to
338 // support more specific error reporting (other than "Unknown"). 355 // support more specific error reporting (other than "Unknown").
339 void CdmAdapter::Initialize(const std::string& key_system, 356 void CdmAdapter::Initialize(const std::string& key_system,
340 bool allow_distinctive_identifier, 357 bool allow_distinctive_identifier,
341 bool allow_persistent_state) { 358 bool allow_persistent_state) {
342 PP_DCHECK(!key_system.empty()); 359 PP_DCHECK(!key_system.empty());
343 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); 360 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_));
ddorwin 2015/03/20 00:05:22 xhwang: Is this and line 381 because of prefixed?
xhwang 2015/03/20 00:53:23 Hmm, actually I am not sure. It's added here: htt
ddorwin 2015/03/20 01:10:14 As discussed offline, this will be addressed by 46
jrummell 2015/03/20 18:05:09 Done.
344 361
345 #if defined(CHECK_DOCUMENT_URL) 362 #if defined(CHECK_DOCUMENT_URL)
346 PP_URLComponents_Dev url_components = {}; 363 PP_URLComponents_Dev url_components = {};
347 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); 364 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get();
348 if (!url_util) 365 if (!url_util)
349 return; 366 return;
350 pp::Var href = url_util->GetDocumentURL(pp::InstanceHandle(pp_instance()), 367 pp::Var href = url_util->GetDocumentURL(pp::InstanceHandle(pp_instance()),
351 &url_components); 368 &url_components);
352 PP_DCHECK(href.is_string()); 369 PP_DCHECK(href.is_string());
353 std::string url = href.AsString(); 370 std::string url = href.AsString();
354 PP_DCHECK(!url.empty()); 371 PP_DCHECK(!url.empty());
355 std::string url_scheme = 372 std::string url_scheme =
356 url.substr(url_components.scheme.begin, url_components.scheme.len); 373 url.substr(url_components.scheme.begin, url_components.scheme.len);
357 if (url_scheme != "file") { 374 if (url_scheme != "file") {
358 // Skip this check for file:// URLs as they don't have a host component. 375 // Skip this check for file:// URLs as they don't have a host component.
359 PP_DCHECK(url_components.host.begin); 376 PP_DCHECK(url_components.host.begin);
360 PP_DCHECK(0 < url_components.host.len); 377 PP_DCHECK(0 < url_components.host.len);
361 } 378 }
362 #endif // defined(CHECK_DOCUMENT_URL) 379 #endif // defined(CHECK_DOCUMENT_URL)
363 380
364 if (!cdm_ && !CreateCdmInstance(key_system)) 381 if (!cdm_ && !CreateCdmInstance(key_system))
365 return; 382 return;
366 383
367 PP_DCHECK(cdm_); 384 PP_DCHECK(cdm_);
368 key_system_ = key_system; 385 key_system_ = key_system;
369 allow_distinctive_identifier_ = allow_distinctive_identifier; 386 allow_distinctive_identifier_ = allow_distinctive_identifier;
370 allow_persistent_state_ = allow_persistent_state; 387 allow_persistent_state_ = allow_persistent_state;
388 cdm_->Initialize(allow_distinctive_identifier, allow_persistent_state);
371 } 389 }
372 390
373 void CdmAdapter::SetServerCertificate(uint32_t promise_id, 391 void CdmAdapter::SetServerCertificate(uint32_t promise_id,
374 pp::VarArrayBuffer server_certificate) { 392 pp::VarArrayBuffer server_certificate) {
375 const uint8_t* server_certificate_ptr = 393 const uint8_t* server_certificate_ptr =
376 static_cast<const uint8_t*>(server_certificate.Map()); 394 static_cast<const uint8_t*>(server_certificate.Map());
377 const uint32_t server_certificate_size = server_certificate.ByteLength(); 395 const uint32_t server_certificate_size = server_certificate.ByteLength();
378 396
379 if (!server_certificate_ptr || 397 if (!server_certificate_ptr ||
380 server_certificate_size < media::limits::kMinCertificateLength || 398 server_certificate_size < media::limits::kMinCertificateLength ||
(...skipping 11 matching lines...) Expand all
392 cdm::kInvalidStateError, 410 cdm::kInvalidStateError,
393 0, 411 0,
394 "CDM has not been initialized."); 412 "CDM has not been initialized.");
395 return; 413 return;
396 } 414 }
397 415
398 cdm_->SetServerCertificate( 416 cdm_->SetServerCertificate(
399 promise_id, server_certificate_ptr, server_certificate_size); 417 promise_id, server_certificate_ptr, server_certificate_size);
400 } 418 }
401 419
420 // TODO(jrummell): |init_data_type| should be an enum all the way through
421 // Chromium. http://crbug.com/417440
ddorwin 2015/03/20 00:05:22 Not sure that's the right bug. We probably need a
jrummell 2015/03/20 18:05:09 417440 is the bug referenced in webmediaplayer_imp
ddorwin 2015/03/20 18:26:29 Okay, but please do file a separate bug for the Pe
jrummell 2015/03/20 18:49:34 Opened bug 469228.
402 void CdmAdapter::CreateSessionAndGenerateRequest( 422 void CdmAdapter::CreateSessionAndGenerateRequest(
403 uint32_t promise_id, 423 uint32_t promise_id,
404 PP_SessionType session_type, 424 PP_SessionType session_type,
405 const std::string& init_data_type, 425 const std::string& init_data_type,
406 pp::VarArrayBuffer init_data) { 426 pp::VarArrayBuffer init_data) {
407 // Initialize() doesn't report an error, so CreateSession() can be called 427 // Initialize() doesn't report an error, so CreateSession() can be called
408 // even if Initialize() failed. 428 // even if Initialize() failed.
409 // TODO(jrummell): Remove this code when prefixed EME gets removed. 429 // TODO(jrummell): Remove this code when prefixed EME gets removed.
410 // TODO(jrummell): Verify that Initialize() failing does not resolve the 430 // TODO(jrummell): Verify that Initialize() failing does not resolve the
411 // MediaKeys.create() promise. 431 // MediaKeys.create() promise.
412 if (!cdm_) { 432 if (!cdm_) {
413 RejectPromise(promise_id, 433 RejectPromise(promise_id,
414 cdm::kInvalidStateError, 434 cdm::kInvalidStateError,
415 0, 435 0,
416 "CDM has not been initialized."); 436 "CDM has not been initialized.");
417 return; 437 return;
418 } 438 }
419 439
420 cdm_->CreateSessionAndGenerateRequest( 440 cdm_->CreateSessionAndGenerateRequest(
421 promise_id, PpSessionTypeToCdmSessionType(session_type), 441 promise_id, PpSessionTypeToCdmSessionType(session_type),
422 init_data_type.data(), init_data_type.size(), 442 InitDataTypeToCdmInitDataType(init_data_type),
423 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength()); 443 static_cast<const uint8_t*>(init_data.Map()), init_data.ByteLength());
424 } 444 }
425 445
426 void CdmAdapter::LoadSession(uint32_t promise_id, 446 void CdmAdapter::LoadSession(uint32_t promise_id,
427 PP_SessionType session_type, 447 PP_SessionType session_type,
428 const std::string& session_id) { 448 const std::string& session_id) {
429 // Initialize() doesn't report an error, so LoadSession() can be called 449 // Initialize() doesn't report an error, so LoadSession() can be called
430 // even if Initialize() failed. 450 // even if Initialize() failed.
431 // TODO(jrummell): Remove this code when prefixed EME gets removed. 451 // TODO(jrummell): Remove this code when prefixed EME gets removed.
432 // TODO(jrummell): Verify that Initialize() failing does not resolve the 452 // TODO(jrummell): Verify that Initialize() failing does not resolve the
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 PostOnMain(callback_factory_.NewCallback( 691 PostOnMain(callback_factory_.NewCallback(
672 &CdmAdapter::SendPromiseResolvedWithSessionInternal, promise_id, 692 &CdmAdapter::SendPromiseResolvedWithSessionInternal, promise_id,
673 std::string(session_id, session_id_size))); 693 std::string(session_id, session_id_size)));
674 } 694 }
675 695
676 void CdmAdapter::OnResolvePromise(uint32_t promise_id) { 696 void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
677 PostOnMain(callback_factory_.NewCallback( 697 PostOnMain(callback_factory_.NewCallback(
678 &CdmAdapter::SendPromiseResolvedInternal, promise_id)); 698 &CdmAdapter::SendPromiseResolvedInternal, promise_id));
679 } 699 }
680 700
681 // cdm::Host_6 only
682 void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id,
683 const cdm::BinaryData* usable_key_ids,
684 uint32_t usable_key_ids_size) {
685 // This should never be called as GetUsableKeyIds() has been removed.
686 PP_NOTREACHED();
687 }
688
689 void CdmAdapter::OnRejectPromise(uint32_t promise_id, 701 void CdmAdapter::OnRejectPromise(uint32_t promise_id,
690 cdm::Error error, 702 cdm::Error error,
691 uint32_t system_code, 703 uint32_t system_code,
692 const char* error_message, 704 const char* error_message,
693 uint32_t error_message_size) { 705 uint32_t error_message_size) {
694 // UMA to investigate http://crbug.com/410630 706 // UMA to investigate http://crbug.com/410630
695 // TODO(xhwang): Remove after bug is fixed. 707 // TODO(xhwang): Remove after bug is fixed.
696 if (system_code == 0x27) { 708 if (system_code == 0x27) {
697 pp::UMAPrivate uma_interface(this); 709 pp::UMAPrivate uma_interface(this);
698 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError", 710 uma_interface.HistogramCustomCounts("Media.EME.CdmFileIO.FileSizeKBOnError",
(...skipping 10 matching lines...) Expand all
709 void CdmAdapter::RejectPromise(uint32_t promise_id, 721 void CdmAdapter::RejectPromise(uint32_t promise_id,
710 cdm::Error error, 722 cdm::Error error,
711 uint32_t system_code, 723 uint32_t system_code,
712 const std::string& error_message) { 724 const std::string& error_message) {
713 PostOnMain(callback_factory_.NewCallback( 725 PostOnMain(callback_factory_.NewCallback(
714 &CdmAdapter::SendPromiseRejectedInternal, 726 &CdmAdapter::SendPromiseRejectedInternal,
715 promise_id, 727 promise_id,
716 SessionError(error, system_code, error_message))); 728 SessionError(error, system_code, error_message)));
717 } 729 }
718 730
719 // cdm::Host_7 only.
720 void CdmAdapter::OnSessionMessage(const char* session_id, 731 void CdmAdapter::OnSessionMessage(const char* session_id,
721 uint32_t session_id_size, 732 uint32_t session_id_size,
722 cdm::MessageType message_type, 733 cdm::MessageType message_type,
723 const char* message, 734 const char* message,
724 uint32_t message_size, 735 uint32_t message_size,
725 const char* legacy_destination_url, 736 const char* legacy_destination_url,
726 uint32_t legacy_destination_url_size) { 737 uint32_t legacy_destination_url_size) {
727 // License requests should not specify |legacy_destination_url|. 738 // License requests should not specify |legacy_destination_url|.
728 // |legacy_destination_url| is not passed to unprefixed EME applications, 739 // |legacy_destination_url| is not passed to unprefixed EME applications,
729 // so it can be removed when the prefixed API is removed. 740 // so it can be removed when the prefixed API is removed.
730 PP_DCHECK(legacy_destination_url_size == 0 || 741 PP_DCHECK(legacy_destination_url_size == 0 ||
731 message_type != cdm::MessageType::kLicenseRequest); 742 message_type != cdm::MessageType::kLicenseRequest);
732 743
733 PostOnMain(callback_factory_.NewCallback( 744 PostOnMain(callback_factory_.NewCallback(
734 &CdmAdapter::SendSessionMessageInternal, 745 &CdmAdapter::SendSessionMessageInternal,
735 SessionMessage( 746 SessionMessage(
736 std::string(session_id, session_id_size), message_type, message, 747 std::string(session_id, session_id_size), message_type, message,
737 message_size, 748 message_size,
738 std::string(legacy_destination_url, legacy_destination_url_size)))); 749 std::string(legacy_destination_url, legacy_destination_url_size))));
739 } 750 }
740 751
741 // cdm::Host_6 only.
742 void CdmAdapter::OnSessionMessage(const char* session_id,
743 uint32_t session_id_size,
744 const char* message,
745 uint32_t message_size,
746 const char* destination_url,
747 uint32_t destination_url_size) {
748 // |destination_url| is no longer passed to unprefixed EME applications,
749 // so it will be dropped. All messages will appear as license renewals
750 // if |destination_url| is provided, license request if not.
751 cdm::MessageType message_type = (destination_url_size > 0)
752 ? cdm::MessageType::kLicenseRenewal
753 : cdm::MessageType::kLicenseRequest;
754 PostOnMain(callback_factory_.NewCallback(
755 &CdmAdapter::SendSessionMessageInternal,
756 SessionMessage(std::string(session_id, session_id_size), message_type,
757 message, message_size,
758 std::string(destination_url, destination_url_size))));
759 }
760
761 // cdm::Host_7 only.
762 void CdmAdapter::OnSessionKeysChange(const char* session_id, 752 void CdmAdapter::OnSessionKeysChange(const char* session_id,
763 uint32_t session_id_size, 753 uint32_t session_id_size,
764 bool has_additional_usable_key, 754 bool has_additional_usable_key,
765 const cdm::KeyInformation* keys_info, 755 const cdm::KeyInformation* keys_info,
766 uint32_t keys_info_count) { 756 uint32_t keys_info_count) {
767 std::vector<PP_KeyInformation> key_information; 757 std::vector<PP_KeyInformation> key_information;
768 for (uint32_t i = 0; i < keys_info_count; ++i) { 758 for (uint32_t i = 0; i < keys_info_count; ++i) {
769 const auto& key_info = keys_info[i]; 759 const auto& key_info = keys_info[i];
770 PP_KeyInformation next_key = {}; 760 PP_KeyInformation next_key = {};
771 761
(...skipping 11 matching lines...) Expand all
783 next_key.system_code = key_info.system_code; 773 next_key.system_code = key_info.system_code;
784 key_information.push_back(next_key); 774 key_information.push_back(next_key);
785 } 775 }
786 776
787 PostOnMain(callback_factory_.NewCallback( 777 PostOnMain(callback_factory_.NewCallback(
788 &CdmAdapter::SendSessionKeysChangeInternal, 778 &CdmAdapter::SendSessionKeysChangeInternal,
789 std::string(session_id, session_id_size), has_additional_usable_key, 779 std::string(session_id, session_id_size), has_additional_usable_key,
790 key_information)); 780 key_information));
791 } 781 }
792 782
793 // cdm::Host_6 only.
794 void CdmAdapter::OnSessionUsableKeysChange(const char* session_id,
795 uint32_t session_id_size,
796 bool has_additional_usable_key) {
797 PostOnMain(callback_factory_.NewCallback(
798 &CdmAdapter::SendSessionKeysChangeInternal,
799 std::string(session_id, session_id_size), has_additional_usable_key,
800 std::vector<PP_KeyInformation>()));
801 }
802
803 void CdmAdapter::OnExpirationChange(const char* session_id, 783 void CdmAdapter::OnExpirationChange(const char* session_id,
804 uint32_t session_id_size, 784 uint32_t session_id_size,
805 cdm::Time new_expiry_time) { 785 cdm::Time new_expiry_time) {
806 PostOnMain(callback_factory_.NewCallback( 786 PostOnMain(callback_factory_.NewCallback(
807 &CdmAdapter::SendExpirationChangeInternal, 787 &CdmAdapter::SendExpirationChangeInternal,
808 std::string(session_id, session_id_size), new_expiry_time)); 788 std::string(session_id, session_id_size), new_expiry_time));
809 } 789 }
810 790
811 void CdmAdapter::OnSessionClosed(const char* session_id, 791 void CdmAdapter::OnSessionClosed(const char* session_id,
812 uint32_t session_id_size) { 792 uint32_t session_id_size) {
813 PostOnMain( 793 PostOnMain(
814 callback_factory_.NewCallback(&CdmAdapter::SendSessionClosedInternal, 794 callback_factory_.NewCallback(&CdmAdapter::SendSessionClosedInternal,
815 std::string(session_id, session_id_size))); 795 std::string(session_id, session_id_size)));
816 } 796 }
817 797
818 // cdm::Host_6 only. 798 void CdmAdapter::OnLegacySessionError(const char* session_id,
819 void CdmAdapter::OnSessionError(const char* session_id, 799 uint32_t session_id_size,
820 uint32_t session_id_size, 800 cdm::Error error,
821 cdm::Error error, 801 uint32_t system_code,
822 uint32_t system_code, 802 const char* error_message,
823 const char* error_message, 803 uint32_t error_message_size) {
824 uint32_t error_message_size) {
825 PostOnMain(callback_factory_.NewCallback( 804 PostOnMain(callback_factory_.NewCallback(
826 &CdmAdapter::SendSessionErrorInternal, 805 &CdmAdapter::SendSessionErrorInternal,
827 std::string(session_id, session_id_size), 806 std::string(session_id, session_id_size),
828 SessionError(error, system_code, 807 SessionError(error, system_code,
829 std::string(error_message, error_message_size)))); 808 std::string(error_message, error_message_size))));
830 } 809 }
831 810
832 // cdm::Host_7 only.
833 void CdmAdapter::OnLegacySessionError(const char* session_id,
834 uint32_t session_id_size,
835 cdm::Error error,
836 uint32_t system_code,
837 const char* error_message,
838 uint32_t error_message_size) {
839 OnSessionError(session_id, session_id_size, error, system_code, error_message,
840 error_message_size);
841 }
842
843 // Helpers to pass the event to Pepper. 811 // Helpers to pass the event to Pepper.
844 812
845 void CdmAdapter::SendPromiseResolvedInternal(int32_t result, 813 void CdmAdapter::SendPromiseResolvedInternal(int32_t result,
846 uint32_t promise_id) { 814 uint32_t promise_id) {
847 PP_DCHECK(result == PP_OK); 815 PP_DCHECK(result == PP_OK);
848 pp::ContentDecryptor_Private::PromiseResolved(promise_id); 816 pp::ContentDecryptor_Private::PromiseResolved(promise_id);
849 } 817 }
850 818
851 void CdmAdapter::SendPromiseResolvedWithSessionInternal( 819 void CdmAdapter::SendPromiseResolvedWithSessionInternal(
852 int32_t result, 820 int32_t result,
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 message_type(message_type), 1307 message_type(message_type),
1340 message(message, message + message_size), 1308 message(message, message + message_size),
1341 legacy_destination_url(legacy_destination_url) { 1309 legacy_destination_url(legacy_destination_url) {
1342 } 1310 }
1343 1311
1344 void* GetCdmHost(int host_interface_version, void* user_data) { 1312 void* GetCdmHost(int host_interface_version, void* user_data) {
1345 if (!host_interface_version || !user_data) 1313 if (!host_interface_version || !user_data)
1346 return NULL; 1314 return NULL;
1347 1315
1348 static_assert( 1316 static_assert(
1349 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_7::kVersion, 1317 cdm::ContentDecryptionModule::Host::kVersion == cdm::Host_8::kVersion,
1350 "update the code below"); 1318 "update the code below");
1351 1319
1352 // Ensure IsSupportedCdmHostVersion matches implementation of this function. 1320 // Ensure IsSupportedCdmHostVersion matches implementation of this function.
1353 // Always update this DCHECK when updating this function. 1321 // Always update this DCHECK when updating this function.
1354 // If this check fails, update this function and DCHECK or update 1322 // If this check fails, update this function and DCHECK or update
1355 // IsSupportedCdmHostVersion. 1323 // IsSupportedCdmHostVersion.
1356 1324
1357 PP_DCHECK( 1325 PP_DCHECK(
1358 // Future version is not supported. 1326 // Future version is not supported.
1359 !IsSupportedCdmHostVersion(cdm::Host_7::kVersion + 1) && 1327 !IsSupportedCdmHostVersion(cdm::Host_8::kVersion + 1) &&
1360 // Current version is supported. 1328 // Current version is supported.
1329 IsSupportedCdmHostVersion(cdm::Host_8::kVersion) &&
1330 // Include all previous supported versions (if any) here.
1361 IsSupportedCdmHostVersion(cdm::Host_7::kVersion) && 1331 IsSupportedCdmHostVersion(cdm::Host_7::kVersion) &&
1362 // Include all previous supported versions (if any) here.
1363 IsSupportedCdmHostVersion(cdm::Host_6::kVersion) &&
1364 // One older than the oldest supported version is not supported. 1332 // One older than the oldest supported version is not supported.
1365 !IsSupportedCdmHostVersion(cdm::Host_6::kVersion - 1)); 1333 !IsSupportedCdmHostVersion(cdm::Host_7::kVersion - 1));
1366 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version)); 1334 PP_DCHECK(IsSupportedCdmHostVersion(host_interface_version));
1367 1335
1368 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data); 1336 CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
1369 CDM_DLOG() << "Create CDM Host with version " << host_interface_version; 1337 CDM_DLOG() << "Create CDM Host with version " << host_interface_version;
1370 switch (host_interface_version) { 1338 switch (host_interface_version) {
1339 case cdm::Host_8::kVersion:
1340 return static_cast<cdm::Host_8*>(cdm_adapter);
1371 case cdm::Host_7::kVersion: 1341 case cdm::Host_7::kVersion:
1372 return static_cast<cdm::Host_7*>(cdm_adapter); 1342 return static_cast<cdm::Host_7*>(cdm_adapter);
1373 case cdm::Host_6::kVersion:
1374 return static_cast<cdm::Host_6*>(cdm_adapter);
1375 default: 1343 default:
1376 PP_NOTREACHED(); 1344 PP_NOTREACHED();
1377 return NULL; 1345 return NULL;
1378 } 1346 }
1379 } 1347 }
1380 1348
1381 // This object is the global object representing this plugin library as long 1349 // This object is the global object representing this plugin library as long
1382 // as it is loaded. 1350 // as it is loaded.
1383 class CdmAdapterModule : public pp::Module { 1351 class CdmAdapterModule : public pp::Module {
1384 public: 1352 public:
(...skipping 17 matching lines...) Expand all
1402 } // namespace media 1370 } // namespace media
1403 1371
1404 namespace pp { 1372 namespace pp {
1405 1373
1406 // Factory function for your specialization of the Module object. 1374 // Factory function for your specialization of the Module object.
1407 Module* CreateModule() { 1375 Module* CreateModule() {
1408 return new media::CdmAdapterModule(); 1376 return new media::CdmAdapterModule();
1409 } 1377 }
1410 1378
1411 } // namespace pp 1379 } // 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