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.h" | 5 #include "media/mojo/services/mojo_cdm.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "media/base/cdm_key_information.h" |
9 #include "media/base/cdm_promise.h" | 10 #include "media/base/cdm_promise.h" |
| 11 #include "media/mojo/services/media_type_converters.h" |
10 #include "mojo/public/cpp/application/connect.h" | 12 #include "mojo/public/cpp/application/connect.h" |
11 #include "mojo/public/cpp/bindings/interface_impl.h" | 13 #include "mojo/public/cpp/bindings/interface_impl.h" |
12 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
14 | 16 |
15 namespace media { | 17 namespace media { |
16 | 18 |
17 static mojo::Array<uint8_t> CreateMojoArray(const uint8_t* data, int length) { | 19 static mojo::Array<uint8_t> CreateMojoArray(const uint8_t* data, int length) { |
18 DCHECK(data); | 20 DCHECK(data); |
19 DCHECK_GT(length, 0); | 21 DCHECK_GT(length, 0); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 136 |
135 void MojoCdm::OnSessionError(const mojo::String& session_id, | 137 void MojoCdm::OnSessionError(const mojo::String& session_id, |
136 mojo::CdmException exception, | 138 mojo::CdmException exception, |
137 uint32_t system_code, | 139 uint32_t system_code, |
138 const mojo::String& error_message) { | 140 const mojo::String& error_message) { |
139 session_error_cb_.Run(session_id, | 141 session_error_cb_.Run(session_id, |
140 static_cast<MediaKeys::Exception>(exception), | 142 static_cast<MediaKeys::Exception>(exception), |
141 system_code, error_message); | 143 system_code, error_message); |
142 } | 144 } |
143 | 145 |
144 void MojoCdm::OnSessionKeysChange(const mojo::String& session_id, | 146 void MojoCdm::OnSessionKeysChange( |
145 bool has_additional_usable_key) { | 147 const mojo::String& session_id, |
146 session_keys_change_cb_.Run(session_id, has_additional_usable_key); | 148 bool has_additional_usable_key, |
| 149 mojo::Array<mojo::CdmKeyInformationPtr> keys_info) { |
| 150 media::CdmKeysInfo key_data; |
| 151 key_data.reserve(keys_info.size()); |
| 152 for (size_t i = 0; i < keys_info.size(); ++i) { |
| 153 key_data.push_back( |
| 154 keys_info[i].To<scoped_ptr<media::CdmKeyInformation>>().release()); |
| 155 } |
| 156 session_keys_change_cb_.Run(session_id, has_additional_usable_key, |
| 157 key_data.Pass()); |
147 } | 158 } |
148 | 159 |
149 void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id, | 160 void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id, |
150 int64_t new_expiry_time_usec) { | 161 int64_t new_expiry_time_usec) { |
151 session_expiration_update_cb_.Run( | 162 session_expiration_update_cb_.Run( |
152 session_id, base::Time::FromInternalValue(new_expiry_time_usec)); | 163 session_id, base::Time::FromInternalValue(new_expiry_time_usec)); |
153 } | 164 } |
154 | 165 |
155 template <typename... T> | 166 template <typename... T> |
156 void MojoCdm::OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise, | 167 void MojoCdm::OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise, |
157 mojo::CdmPromiseResultPtr result, | 168 mojo::CdmPromiseResultPtr result, |
158 typename MojoTypeTrait<T>::MojoType... args) { | 169 typename MojoTypeTrait<T>::MojoType... args) { |
159 if (result->success) | 170 if (result->success) |
160 promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. | 171 promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. |
161 else | 172 else |
162 RejectPromise(promise.Pass(), result.Pass()); | 173 RejectPromise(promise.Pass(), result.Pass()); |
163 } | 174 } |
164 | 175 |
165 } // namespace media | 176 } // namespace media |
OLD | NEW |