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 "content/renderer/media/crypto/proxy_decryptor.h" | 5 #include "content/renderer/media/crypto/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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 void ProxyDecryptor::CancelKeyRequest(const std::string& web_session_id) { | 211 void ProxyDecryptor::CancelKeyRequest(const std::string& web_session_id) { |
212 DVLOG(1) << "CancelKeyRequest()"; | 212 DVLOG(1) << "CancelKeyRequest()"; |
213 | 213 |
214 scoped_ptr<media::SimpleCdmPromise> promise( | 214 scoped_ptr<media::SimpleCdmPromise> promise( |
215 new media::SimpleCdmPromise(base::Bind(&ProxyDecryptor::OnSessionClosed, | 215 new media::SimpleCdmPromise(base::Bind(&ProxyDecryptor::OnSessionClosed, |
216 weak_ptr_factory_.GetWeakPtr(), | 216 weak_ptr_factory_.GetWeakPtr(), |
217 web_session_id), | 217 web_session_id), |
218 base::Bind(&ProxyDecryptor::OnSessionError, | 218 base::Bind(&ProxyDecryptor::OnSessionError, |
219 weak_ptr_factory_.GetWeakPtr(), | 219 weak_ptr_factory_.GetWeakPtr(), |
220 web_session_id))); | 220 web_session_id))); |
221 media_keys_->ReleaseSession(web_session_id, promise.Pass()); | 221 media_keys_->RemoveSession(web_session_id, promise.Pass()); |
222 } | 222 } |
223 | 223 |
224 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( | 224 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( |
225 const std::string& key_system, | 225 const std::string& key_system, |
226 const GURL& security_origin) { | 226 const GURL& security_origin) { |
227 return ContentDecryptionModuleFactory::Create( | 227 return ContentDecryptionModuleFactory::Create( |
228 key_system, | 228 key_system, |
229 security_origin, | 229 security_origin, |
230 #if defined(ENABLE_PEPPER_CDMS) | 230 #if defined(ENABLE_PEPPER_CDMS) |
231 create_pepper_cdm_cb_, | 231 create_pepper_cdm_cb_, |
232 #elif defined(ENABLE_BROWSER_CDMS) | 232 #elif defined(ENABLE_BROWSER_CDMS) |
233 manager_, | 233 manager_, |
234 &cdm_id_, | 234 &cdm_id_, |
235 #endif // defined(ENABLE_PEPPER_CDMS) | 235 #endif // defined(ENABLE_PEPPER_CDMS) |
236 base::Bind(&ProxyDecryptor::OnSessionMessage, | 236 base::Bind(&ProxyDecryptor::OnSessionMessage, |
237 weak_ptr_factory_.GetWeakPtr()), | 237 weak_ptr_factory_.GetWeakPtr()), |
238 base::Bind(&ProxyDecryptor::OnSessionReady, | 238 base::Bind(&ProxyDecryptor::OnSessionReady, |
239 weak_ptr_factory_.GetWeakPtr()), | 239 weak_ptr_factory_.GetWeakPtr()), |
240 base::Bind(&ProxyDecryptor::OnSessionClosed, | 240 base::Bind(&ProxyDecryptor::OnSessionClosed, |
241 weak_ptr_factory_.GetWeakPtr()), | 241 weak_ptr_factory_.GetWeakPtr()), |
242 base::Bind(&ProxyDecryptor::OnSessionError, | 242 base::Bind(&ProxyDecryptor::OnSessionError, |
| 243 weak_ptr_factory_.GetWeakPtr()), |
| 244 base::Bind(&ProxyDecryptor::OnSessionKeysChange, |
| 245 weak_ptr_factory_.GetWeakPtr()), |
| 246 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, |
243 weak_ptr_factory_.GetWeakPtr())); | 247 weak_ptr_factory_.GetWeakPtr())); |
244 } | 248 } |
245 | 249 |
246 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, | 250 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, |
247 const std::vector<uint8>& message, | 251 const std::vector<uint8>& message, |
248 const GURL& destination_url) { | 252 const GURL& destination_url) { |
249 // Assumes that OnSessionCreated() has been called before this. | 253 // Assumes that OnSessionCreated() has been called before this. |
250 | 254 |
251 // For ClearKey, convert the message from JSON into just passing the key | 255 // For ClearKey, convert the message from JSON into just passing the key |
252 // as the message. If unable to extract the key, return the message unchanged. | 256 // as the message. If unable to extract the key, return the message unchanged. |
253 if (is_clear_key_) { | 257 if (is_clear_key_) { |
254 std::vector<uint8> key; | 258 std::vector<uint8> key; |
255 if (media::ExtractFirstKeyIdFromLicenseRequest(message, &key)) { | 259 if (media::ExtractFirstKeyIdFromLicenseRequest(message, &key)) { |
256 key_message_cb_.Run(web_session_id, key, destination_url); | 260 key_message_cb_.Run(web_session_id, key, destination_url); |
257 return; | 261 return; |
258 } | 262 } |
259 } | 263 } |
260 | 264 |
261 key_message_cb_.Run(web_session_id, message, destination_url); | 265 key_message_cb_.Run(web_session_id, message, destination_url); |
262 } | 266 } |
263 | 267 |
| 268 void ProxyDecryptor::OnSessionKeysChange(const std::string& web_session_id, |
| 269 bool has_additional_usable_key) { |
| 270 // EME v0.1b doesn't support this event. |
| 271 } |
| 272 |
| 273 void ProxyDecryptor::OnSessionExpirationUpdate( |
| 274 const std::string& web_session_id, |
| 275 const base::Time& new_expiry_time) { |
| 276 // EME v0.1b doesn't support this event. |
| 277 } |
| 278 |
264 void ProxyDecryptor::OnSessionReady(const std::string& web_session_id) { | 279 void ProxyDecryptor::OnSessionReady(const std::string& web_session_id) { |
265 key_added_cb_.Run(web_session_id); | 280 key_added_cb_.Run(web_session_id); |
266 } | 281 } |
267 | 282 |
268 void ProxyDecryptor::OnSessionClosed(const std::string& web_session_id) { | 283 void ProxyDecryptor::OnSessionClosed(const std::string& web_session_id) { |
269 base::hash_map<std::string, bool>::iterator it = | 284 base::hash_map<std::string, bool>::iterator it = |
270 active_sessions_.find(web_session_id); | 285 active_sessions_.find(web_session_id); |
271 | 286 |
272 // Latest EME spec separates closing a session ("allows an application to | 287 // Latest EME spec separates closing a session ("allows an application to |
273 // indicate that it no longer needs the session") and actually closing the | 288 // indicate that it no longer needs the session") and actually closing the |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 bool is_persistent = | 335 bool is_persistent = |
321 session_type == PersistentSession || session_type == LoadSession; | 336 session_type == PersistentSession || session_type == LoadSession; |
322 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); | 337 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); |
323 | 338 |
324 // For LoadSession(), generate the SessionReady event. | 339 // For LoadSession(), generate the SessionReady event. |
325 if (session_type == LoadSession) | 340 if (session_type == LoadSession) |
326 OnSessionReady(web_session_id); | 341 OnSessionReady(web_session_id); |
327 } | 342 } |
328 | 343 |
329 } // namespace content | 344 } // namespace content |
OLD | NEW |