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