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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 SessionCreationType session_creation_type = TemporarySession; | 105 SessionCreationType session_creation_type = TemporarySession; |
106 if (HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader)) { | 106 if (HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader)) { |
107 session_creation_type = LoadSession; | 107 session_creation_type = LoadSession; |
108 } else if (HasHeader(init_data, | 108 } else if (HasHeader(init_data, |
109 init_data_length, | 109 init_data_length, |
110 kPrefixedApiPersistentSessionHeader)) { | 110 kPrefixedApiPersistentSessionHeader)) { |
111 session_creation_type = PersistentSession; | 111 session_creation_type = PersistentSession; |
112 } | 112 } |
113 | 113 |
114 scoped_ptr<media::NewSessionCdmPromise> promise( | 114 scoped_ptr<media::NewSessionCdmPromise> promise( |
115 new media::NewSessionCdmPromise( | 115 new media::CdmCallbackPromise<std::string>( |
116 base::Bind(&ProxyDecryptor::SetSessionId, | 116 base::Bind(&ProxyDecryptor::SetSessionId, |
117 weak_ptr_factory_.GetWeakPtr(), | 117 weak_ptr_factory_.GetWeakPtr(), |
118 session_creation_type), | 118 session_creation_type), |
119 base::Bind(&ProxyDecryptor::OnSessionError, | 119 base::Bind(&ProxyDecryptor::OnSessionError, |
120 weak_ptr_factory_.GetWeakPtr(), | 120 weak_ptr_factory_.GetWeakPtr(), |
121 std::string()))); // No session id until created. | 121 std::string()))); // No session id until created. |
122 | 122 |
123 if (session_creation_type == LoadSession) { | 123 if (session_creation_type == LoadSession) { |
124 media_keys_->LoadSession( | 124 media_keys_->LoadSession( |
125 std::string(reinterpret_cast<const char*>( | 125 std::string(reinterpret_cast<const char*>( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } else { | 168 } else { |
169 OnSessionError(std::string(), | 169 OnSessionError(std::string(), |
170 media::MediaKeys::NOT_SUPPORTED_ERROR, | 170 media::MediaKeys::NOT_SUPPORTED_ERROR, |
171 0, | 171 0, |
172 "SessionId not specified."); | 172 "SessionId not specified."); |
173 return; | 173 return; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 scoped_ptr<media::SimpleCdmPromise> promise( | 177 scoped_ptr<media::SimpleCdmPromise> promise( |
178 new media::SimpleCdmPromise(base::Bind(&ProxyDecryptor::OnSessionReady, | 178 new media::CdmCallbackPromise<void>( |
179 weak_ptr_factory_.GetWeakPtr(), | 179 base::Bind(&ProxyDecryptor::OnSessionReady, |
180 web_session_id), | 180 weak_ptr_factory_.GetWeakPtr(), |
181 base::Bind(&ProxyDecryptor::OnSessionError, | 181 web_session_id), |
182 weak_ptr_factory_.GetWeakPtr(), | 182 base::Bind(&ProxyDecryptor::OnSessionError, |
183 web_session_id))); | 183 weak_ptr_factory_.GetWeakPtr(), |
| 184 web_session_id))); |
184 | 185 |
185 // EME WD spec only supports a single array passed to the CDM. For | 186 // EME WD spec only supports a single array passed to the CDM. For |
186 // Clear Key using v0.1b, both arrays are used (|init_data| is key_id). | 187 // Clear Key using v0.1b, both arrays are used (|init_data| is key_id). |
187 // Since the EME WD spec supports the key as a JSON Web Key, | 188 // Since the EME WD spec supports the key as a JSON Web Key, |
188 // convert the 2 arrays to a JWK and pass it as the single array. | 189 // convert the 2 arrays to a JWK and pass it as the single array. |
189 if (is_clear_key_) { | 190 if (is_clear_key_) { |
190 // Decryptor doesn't support empty key ID (see http://crbug.com/123265). | 191 // Decryptor doesn't support empty key ID (see http://crbug.com/123265). |
191 // So ensure a non-empty value is passed. | 192 // So ensure a non-empty value is passed. |
192 if (!init_data) { | 193 if (!init_data) { |
193 static const uint8 kDummyInitData[1] = {0}; | 194 static const uint8 kDummyInitData[1] = {0}; |
(...skipping 11 matching lines...) Expand all Loading... |
205 return; | 206 return; |
206 } | 207 } |
207 | 208 |
208 media_keys_->UpdateSession(session_id, key, key_length, promise.Pass()); | 209 media_keys_->UpdateSession(session_id, key, key_length, promise.Pass()); |
209 } | 210 } |
210 | 211 |
211 void ProxyDecryptor::CancelKeyRequest(const std::string& web_session_id) { | 212 void ProxyDecryptor::CancelKeyRequest(const std::string& web_session_id) { |
212 DVLOG(1) << "CancelKeyRequest()"; | 213 DVLOG(1) << "CancelKeyRequest()"; |
213 | 214 |
214 scoped_ptr<media::SimpleCdmPromise> promise( | 215 scoped_ptr<media::SimpleCdmPromise> promise( |
215 new media::SimpleCdmPromise(base::Bind(&ProxyDecryptor::OnSessionClosed, | 216 new media::CdmCallbackPromise<void>( |
216 weak_ptr_factory_.GetWeakPtr(), | 217 base::Bind(&ProxyDecryptor::OnSessionClosed, |
217 web_session_id), | 218 weak_ptr_factory_.GetWeakPtr(), |
218 base::Bind(&ProxyDecryptor::OnSessionError, | 219 web_session_id), |
219 weak_ptr_factory_.GetWeakPtr(), | 220 base::Bind(&ProxyDecryptor::OnSessionError, |
220 web_session_id))); | 221 weak_ptr_factory_.GetWeakPtr(), |
| 222 web_session_id))); |
221 media_keys_->RemoveSession(web_session_id, promise.Pass()); | 223 media_keys_->RemoveSession(web_session_id, promise.Pass()); |
222 } | 224 } |
223 | 225 |
224 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( | 226 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( |
225 const std::string& key_system, | 227 const std::string& key_system, |
226 const GURL& security_origin) { | 228 const GURL& security_origin) { |
227 return ContentDecryptionModuleFactory::Create( | 229 return ContentDecryptionModuleFactory::Create( |
228 key_system, | 230 key_system, |
229 security_origin, | 231 security_origin, |
230 #if defined(ENABLE_PEPPER_CDMS) | 232 #if defined(ENABLE_PEPPER_CDMS) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 bool is_persistent = | 337 bool is_persistent = |
336 session_type == PersistentSession || session_type == LoadSession; | 338 session_type == PersistentSession || session_type == LoadSession; |
337 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); | 339 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); |
338 | 340 |
339 // For LoadSession(), generate the SessionReady event. | 341 // For LoadSession(), generate the SessionReady event. |
340 if (session_type == LoadSession) | 342 if (session_type == LoadSession) |
341 OnSessionReady(web_session_id); | 343 OnSessionReady(web_session_id); |
342 } | 344 } |
343 | 345 |
344 } // namespace content | 346 } // namespace content |
OLD | NEW |