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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 202 |
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) | 203 if (!cdm_factory) |
ddorwin
2014/12/19 18:16:56
ditto
xhwang
2014/12/19 19:18:30
Done.
| |
212 return nullptr; | 204 return nullptr; |
213 | 205 |
214 return cdm_factory->Create( | 206 return cdm_factory->Create( |
215 key_system, | 207 key_system, |
216 security_origin, | 208 security_origin, |
217 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), | 209 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), |
218 base::Bind(&ProxyDecryptor::OnSessionReady, weak_this), | 210 base::Bind(&ProxyDecryptor::OnSessionReady, weak_this), |
219 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), | 211 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), |
220 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), | 212 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), |
221 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), | 213 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 bool is_persistent = | 301 bool is_persistent = |
310 session_type == PersistentSession || session_type == LoadSession; | 302 session_type == PersistentSession || session_type == LoadSession; |
311 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); | 303 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); |
312 | 304 |
313 // For LoadSession(), generate the SessionReady event. | 305 // For LoadSession(), generate the SessionReady event. |
314 if (session_type == LoadSession) | 306 if (session_type == LoadSession) |
315 OnSessionReady(web_session_id); | 307 OnSessionReady(web_session_id); |
316 } | 308 } |
317 | 309 |
318 } // namespace media | 310 } // namespace media |
OLD | NEW |