| 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/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "media/base/cdm_callback_promise.h" | 13 #include "media/base/cdm_callback_promise.h" |
| 14 #include "media/base/cdm_factory.h" | 14 #include "media/base/cdm_factory.h" |
| 15 #include "media/base/key_systems.h" | 15 #include "media/base/key_systems.h" |
| 16 #include "media/cdm/aes_decryptor.h" | |
| 17 #include "media/cdm/json_web_key.h" | 16 #include "media/cdm/json_web_key.h" |
| 18 #include "media/cdm/key_system_names.h" | 17 #include "media/cdm/key_system_names.h" |
| 19 | 18 |
| 20 namespace media { | 19 namespace media { |
| 21 | 20 |
| 22 // Special system code to signal a closed persistent session in a SessionError() | 21 // Special system code to signal a closed persistent session in a SessionError() |
| 23 // call. This is needed because there is no SessionClosed() call in the prefixed | 22 // call. This is needed because there is no SessionClosed() call in the prefixed |
| 24 // EME API. | 23 // EME API. |
| 25 const int kSessionClosedSystemCode = 29127; | 24 const int kSessionClosedSystemCode = 29127; |
| 26 | 25 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 weak_ptr_factory_.GetWeakPtr(), | 192 weak_ptr_factory_.GetWeakPtr(), |
| 194 web_session_id))); | 193 web_session_id))); |
| 195 media_keys_->RemoveSession(web_session_id, promise.Pass()); | 194 media_keys_->RemoveSession(web_session_id, promise.Pass()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 scoped_ptr<MediaKeys> ProxyDecryptor::CreateMediaKeys( | 197 scoped_ptr<MediaKeys> ProxyDecryptor::CreateMediaKeys( |
| 199 CdmFactory* cdm_factory, | 198 CdmFactory* cdm_factory, |
| 200 const std::string& key_system, | 199 const std::string& key_system, |
| 201 const GURL& security_origin) { | 200 const GURL& security_origin) { |
| 202 base::WeakPtr<ProxyDecryptor> weak_this = weak_ptr_factory_.GetWeakPtr(); | 201 base::WeakPtr<ProxyDecryptor> weak_this = weak_ptr_factory_.GetWeakPtr(); |
| 203 | |
| 204 if (CanUseAesDecryptor(key_system)) { | |
| 205 return scoped_ptr<media::MediaKeys>(new AesDecryptor( | |
| 206 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), | |
| 207 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), | |
| 208 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this))); | |
| 209 } | |
| 210 | |
| 211 if (!cdm_factory) | |
| 212 return nullptr; | |
| 213 | |
| 214 return cdm_factory->Create( | 202 return cdm_factory->Create( |
| 215 key_system, | 203 key_system, |
| 216 security_origin, | 204 security_origin, |
| 217 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), | 205 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), |
| 218 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), | 206 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), |
| 219 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), | 207 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), |
| 220 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), | 208 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), |
| 221 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this)); | 209 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this)); |
| 222 } | 210 } |
| 223 | 211 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 bool is_persistent = | 297 bool is_persistent = |
| 310 session_type == PersistentSession || session_type == LoadSession; | 298 session_type == PersistentSession || session_type == LoadSession; |
| 311 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); | 299 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); |
| 312 | 300 |
| 313 // For LoadSession(), generate the KeyAdded event. | 301 // For LoadSession(), generate the KeyAdded event. |
| 314 if (session_type == LoadSession) | 302 if (session_type == LoadSession) |
| 315 GenerateKeyAdded(web_session_id); | 303 GenerateKeyAdded(web_session_id); |
| 316 } | 304 } |
| 317 | 305 |
| 318 } // namespace media | 306 } // namespace media |
| OLD | NEW |