OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cstring> | 5 #include <cstring> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 LinkedKeyMessage key_request(new KeyMessageImpl()); | 550 LinkedKeyMessage key_request(new KeyMessageImpl()); |
551 cdm::Status status = cdm_->GenerateKeyRequest( | 551 cdm::Status status = cdm_->GenerateKeyRequest( |
552 type.data(), type.size(), | 552 type.data(), type.size(), |
553 static_cast<const uint8_t*>(init_data.Map()), | 553 static_cast<const uint8_t*>(init_data.Map()), |
554 init_data.ByteLength(), | 554 init_data.ByteLength(), |
555 key_request.get()); | 555 key_request.get()); |
556 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); | 556 PP_DCHECK(status == cdm::kSuccess || status == cdm::kSessionError); |
557 if (status != cdm::kSuccess || | 557 if (status != cdm::kSuccess) { |
558 !key_request->message() || | |
559 key_request->message()->size() == 0) { | |
560 FireKeyError(""); | 558 FireKeyError(""); |
561 return; | 559 return; |
562 } | 560 } |
563 | 561 |
564 // TODO(xhwang): Remove unnecessary CallOnMain calls here and below once we | 562 // TODO(xhwang): Remove unnecessary CallOnMain calls here and below once we |
565 // only support out-of-process. | 563 // only support out-of-process. |
566 // If running out-of-process, PPB calls will always behave asynchronously | 564 // If running out-of-process, PPB calls will always behave asynchronously |
567 // since IPC is involved. In that case, if we are already on main thread, | 565 // since IPC is involved. In that case, if we are already on main thread, |
568 // we don't need to use CallOnMain to help us call PPB call on main thread, | 566 // we don't need to use CallOnMain to help us call PPB call on main thread, |
569 // or to help call PPB asynchronously. | 567 // or to help call PPB asynchronously. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 807 } |
810 | 808 |
811 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { | 809 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { |
812 PP_DCHECK(result == PP_OK); | 810 PP_DCHECK(result == PP_OK); |
813 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); | 811 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); |
814 } | 812 } |
815 | 813 |
816 void CdmWrapper::KeyMessage(int32_t result, | 814 void CdmWrapper::KeyMessage(int32_t result, |
817 const LinkedKeyMessage& key_message) { | 815 const LinkedKeyMessage& key_message) { |
818 PP_DCHECK(result == PP_OK); | 816 PP_DCHECK(result == PP_OK); |
819 pp::Buffer_Dev message_buffer = | 817 |
820 static_cast<const PpbBuffer*>(key_message->message())->buffer_dev(); | 818 pp::Buffer_Dev message_buffer; |
| 819 if (key_message->message()) { |
| 820 message_buffer = static_cast<const PpbBuffer*>( |
| 821 key_message->message())->buffer_dev(); |
| 822 } |
| 823 |
821 pp::ContentDecryptor_Private::KeyMessage( | 824 pp::ContentDecryptor_Private::KeyMessage( |
822 key_system_, | 825 key_system_, |
823 key_message->session_id_string(), | 826 key_message->session_id_string(), |
824 message_buffer, | 827 message_buffer, |
825 key_message->default_url_string()); | 828 key_message->default_url_string()); |
826 } | 829 } |
827 | 830 |
828 // TODO(xhwang): Support MediaKeyError (see spec: http://goo.gl/rbdnR) in CDM | 831 // TODO(xhwang): Support MediaKeyError (see spec: http://goo.gl/rbdnR) in CDM |
829 // interface and in this function. | 832 // interface and in this function. |
830 void CdmWrapper::KeyError(int32_t result, const std::string& session_id) { | 833 void CdmWrapper::KeyError(int32_t result, const std::string& session_id) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 } // namespace webkit_media | 983 } // namespace webkit_media |
981 | 984 |
982 namespace pp { | 985 namespace pp { |
983 | 986 |
984 // Factory function for your specialization of the Module object. | 987 // Factory function for your specialization of the Module object. |
985 Module* CreateModule() { | 988 Module* CreateModule() { |
986 return new webkit_media::CdmWrapperModule(); | 989 return new webkit_media::CdmWrapperModule(); |
987 } | 990 } |
988 | 991 |
989 } // namespace pp | 992 } // namespace pp |
OLD | NEW |