OLD | NEW |
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/proxy_decryptor.h" | 5 #include "media/cdm/proxy_decryptor.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "media/base/cdm_callback_promise.h" | 14 #include "media/base/cdm_callback_promise.h" |
14 #include "media/base/cdm_factory.h" | 15 #include "media/base/cdm_factory.h" |
15 #include "media/base/cdm_key_information.h" | 16 #include "media/base/cdm_key_information.h" |
16 #include "media/base/key_systems.h" | 17 #include "media/base/key_systems.h" |
17 #include "media/base/media_permission.h" | 18 #include "media/base/media_permission.h" |
18 #include "media/cdm/json_web_key.h" | 19 #include "media/cdm/json_web_key.h" |
19 #include "media/cdm/key_system_names.h" | 20 #include "media/cdm/key_system_names.h" |
20 | 21 |
21 namespace media { | 22 namespace media { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EmeInitDataType init_data_type, | 210 EmeInitDataType init_data_type, |
210 const std::vector<uint8>& init_data, | 211 const std::vector<uint8>& init_data, |
211 scoped_ptr<NewSessionCdmPromise> promise, | 212 scoped_ptr<NewSessionCdmPromise> promise, |
212 bool granted) { | 213 bool granted) { |
213 // ProxyDecryptor is only used by Prefixed EME, where RequestPermission() is | 214 // ProxyDecryptor is only used by Prefixed EME, where RequestPermission() is |
214 // only for triggering the permission UI. Later CheckPermission() will be | 215 // only for triggering the permission UI. Later CheckPermission() will be |
215 // called (e.g. in PlatformVerificationFlow on ChromeOS; in BrowserCdmManager | 216 // called (e.g. in PlatformVerificationFlow on ChromeOS; in BrowserCdmManager |
216 // on Android) and the permission status will be evaluated then. | 217 // on Android) and the permission status will be evaluated then. |
217 DVLOG_IF(1, !granted) << "Permission request rejected."; | 218 DVLOG_IF(1, !granted) << "Permission request rejected."; |
218 | 219 |
219 media_keys_->CreateSessionAndGenerateRequest( | 220 media_keys_->CreateSessionAndGenerateRequest(session_type, init_data_type, |
220 session_type, init_data_type, vector_as_array(&init_data), | 221 init_data, promise.Pass()); |
221 init_data.size(), promise.Pass()); | |
222 } | 222 } |
223 | 223 |
224 void ProxyDecryptor::AddKey(const uint8* key, | 224 void ProxyDecryptor::AddKey(const uint8* key, |
225 int key_length, | 225 int key_length, |
226 const uint8* init_data, | 226 const uint8* init_data, |
227 int init_data_length, | 227 int init_data_length, |
228 const std::string& session_id) { | 228 const std::string& session_id) { |
229 DVLOG(1) << "AddKey()"; | 229 DVLOG(1) << "AddKey()"; |
230 | 230 |
231 if (!media_keys_) { | 231 if (!media_keys_) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 if (!init_data) { | 264 if (!init_data) { |
265 static const uint8 kDummyInitData[1] = {0}; | 265 static const uint8 kDummyInitData[1] = {0}; |
266 init_data = kDummyInitData; | 266 init_data = kDummyInitData; |
267 init_data_length = arraysize(kDummyInitData); | 267 init_data_length = arraysize(kDummyInitData); |
268 } | 268 } |
269 | 269 |
270 std::string jwk = | 270 std::string jwk = |
271 GenerateJWKSet(key, key_length, init_data, init_data_length); | 271 GenerateJWKSet(key, key_length, init_data, init_data_length); |
272 DCHECK(!jwk.empty()); | 272 DCHECK(!jwk.empty()); |
273 media_keys_->UpdateSession(new_session_id, | 273 media_keys_->UpdateSession(new_session_id, |
274 reinterpret_cast<const uint8*>(jwk.data()), | 274 std::vector<uint8_t>(jwk.begin(), jwk.end()), |
275 jwk.size(), promise.Pass()); | 275 promise.Pass()); |
276 return; | 276 return; |
277 } | 277 } |
278 | 278 |
279 media_keys_->UpdateSession(new_session_id, key, key_length, promise.Pass()); | 279 media_keys_->UpdateSession(new_session_id, |
| 280 std::vector<uint8_t>(key, key + key_length), |
| 281 promise.Pass()); |
280 } | 282 } |
281 | 283 |
282 void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) { | 284 void ProxyDecryptor::CancelKeyRequest(const std::string& session_id) { |
283 DVLOG(1) << "CancelKeyRequest()"; | 285 DVLOG(1) << "CancelKeyRequest()"; |
284 | 286 |
285 if (!media_keys_) { | 287 if (!media_keys_) { |
286 OnLegacySessionError(std::string(), MediaKeys::INVALID_STATE_ERROR, 0, | 288 OnLegacySessionError(std::string(), MediaKeys::INVALID_STATE_ERROR, 0, |
287 "CDM is not available."); | 289 "CDM is not available."); |
288 return; | 290 return; |
289 } | 291 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 bool is_persistent = | 388 bool is_persistent = |
387 session_type == PersistentSession || session_type == LoadSession; | 389 session_type == PersistentSession || session_type == LoadSession; |
388 active_sessions_.insert(std::make_pair(session_id, is_persistent)); | 390 active_sessions_.insert(std::make_pair(session_id, is_persistent)); |
389 | 391 |
390 // For LoadSession(), generate the KeyAdded event. | 392 // For LoadSession(), generate the KeyAdded event. |
391 if (session_type == LoadSession) | 393 if (session_type == LoadSession) |
392 GenerateKeyAdded(session_id); | 394 GenerateKeyAdded(session_id); |
393 } | 395 } |
394 | 396 |
395 } // namespace media | 397 } // namespace media |
OLD | NEW |