| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mojo/services/mojo_cdm_service.h" | 5 #include "media/mojo/services/mojo_cdm_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "media/base/cdm_key_information.h" |
| 8 #include "media/base/key_systems.h" | 9 #include "media/base/key_systems.h" |
| 9 #include "media/cdm/aes_decryptor.h" | 10 #include "media/cdm/aes_decryptor.h" |
| 11 #include "media/mojo/services/media_type_converters.h" |
| 10 #include "media/mojo/services/mojo_cdm_promise.h" | 12 #include "media/mojo/services/mojo_cdm_promise.h" |
| 11 #include "mojo/common/common_type_converters.h" | 13 #include "mojo/common/common_type_converters.h" |
| 12 | 14 |
| 13 namespace media { | 15 namespace media { |
| 14 | 16 |
| 15 typedef MojoCdmPromise<> SimpleMojoCdmPromise; | 17 typedef MojoCdmPromise<> SimpleMojoCdmPromise; |
| 16 typedef MojoCdmPromise<std::string> NewSessionMojoCdmPromise; | 18 typedef MojoCdmPromise<std::string> NewSessionMojoCdmPromise; |
| 17 typedef MojoCdmPromise<std::vector<std::vector<uint8_t>>> KeyIdsMojoCdmPromise; | |
| 18 | 19 |
| 19 MojoCdmService::MojoCdmService(const mojo::String& key_system) | 20 MojoCdmService::MojoCdmService(const mojo::String& key_system) |
| 20 : weak_factory_(this) { | 21 : weak_factory_(this) { |
| 21 base::WeakPtr<MojoCdmService> weak_this = weak_factory_.GetWeakPtr(); | 22 base::WeakPtr<MojoCdmService> weak_this = weak_factory_.GetWeakPtr(); |
| 22 if (CanUseAesDecryptor(key_system)) { | 23 if (CanUseAesDecryptor(key_system)) { |
| 23 cdm_.reset(new AesDecryptor( | 24 cdm_.reset(new AesDecryptor( |
| 24 base::Bind(&MojoCdmService::OnSessionMessage, weak_this), | 25 base::Bind(&MojoCdmService::OnSessionMessage, weak_this), |
| 25 base::Bind(&MojoCdmService::OnSessionClosed, weak_this), | 26 base::Bind(&MojoCdmService::OnSessionClosed, weak_this), |
| 26 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this))); | 27 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this))); |
| 27 } | 28 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 NOTIMPLEMENTED(); | 104 NOTIMPLEMENTED(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void MojoCdmService::OnSessionMessage(const std::string& session_id, | 107 void MojoCdmService::OnSessionMessage(const std::string& session_id, |
| 107 const std::vector<uint8_t>& message, | 108 const std::vector<uint8_t>& message, |
| 108 const GURL& destination_url) { | 109 const GURL& destination_url) { |
| 109 client()->OnSessionMessage(session_id, mojo::Array<uint8_t>::From(message), | 110 client()->OnSessionMessage(session_id, mojo::Array<uint8_t>::From(message), |
| 110 mojo::String::From(destination_url)); | 111 mojo::String::From(destination_url)); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, | 114 void MojoCdmService::OnSessionKeysChange( |
| 114 bool has_additional_usable_key) { | 115 const std::string& session_id, |
| 115 client()->OnSessionKeysChange(session_id, has_additional_usable_key); | 116 bool has_additional_usable_key, |
| 117 const CdmKeyInformationVector& key_information) { |
| 118 client()->OnSessionKeysChange( |
| 119 session_id, has_additional_usable_key, |
| 120 mojo::Array<mojo::CdmKeyInformationPtr>::From(key_information)); |
| 116 } | 121 } |
| 117 | 122 |
| 118 void MojoCdmService::OnSessionExpirationUpdate( | 123 void MojoCdmService::OnSessionExpirationUpdate( |
| 119 const std::string& session_id, | 124 const std::string& session_id, |
| 120 const base::Time& new_expiry_time) { | 125 const base::Time& new_expiry_time) { |
| 121 client()->OnSessionExpirationUpdate(session_id, | 126 client()->OnSessionExpirationUpdate(session_id, |
| 122 new_expiry_time.ToInternalValue()); | 127 new_expiry_time.ToInternalValue()); |
| 123 } | 128 } |
| 124 | 129 |
| 125 void MojoCdmService::OnSessionClosed(const std::string& session_id) { | 130 void MojoCdmService::OnSessionClosed(const std::string& session_id) { |
| 126 client()->OnSessionClosed(session_id); | 131 client()->OnSessionClosed(session_id); |
| 127 } | 132 } |
| 128 | 133 |
| 129 void MojoCdmService::OnSessionError(const std::string& session_id, | 134 void MojoCdmService::OnSessionError(const std::string& session_id, |
| 130 MediaKeys::Exception exception, | 135 MediaKeys::Exception exception, |
| 131 uint32_t system_code, | 136 uint32_t system_code, |
| 132 const std::string& error_message) { | 137 const std::string& error_message) { |
| 133 client()->OnSessionError(session_id, | 138 client()->OnSessionError(session_id, |
| 134 static_cast<mojo::CdmException>(exception), | 139 static_cast<mojo::CdmException>(exception), |
| 135 system_code, error_message); | 140 system_code, error_message); |
| 136 } | 141 } |
| 137 | 142 |
| 138 } // namespace media | 143 } // namespace media |
| OLD | NEW |