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/ppapi/cdm_adapter.h" | 5 #include "media/cdm/ppapi/cdm_adapter.h" |
6 | 6 |
7 #include "media/cdm/ppapi/cdm_file_io_impl.h" | 7 #include "media/cdm/ppapi/cdm_file_io_impl.h" |
8 #include "media/cdm/ppapi/cdm_helpers.h" | 8 #include "media/cdm/ppapi/cdm_helpers.h" |
9 #include "media/cdm/ppapi/cdm_logging.h" | 9 #include "media/cdm/ppapi/cdm_logging.h" |
10 #include "media/cdm/ppapi/supported_cdm_versions.h" | 10 #include "media/cdm/ppapi/supported_cdm_versions.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 bool success = cdm_ != NULL; | 241 bool success = cdm_ != NULL; |
242 | 242 |
243 const std::string message = "CDM instance for " + key_system + | 243 const std::string message = "CDM instance for " + key_system + |
244 (success ? "" : " could not be") + " created."; | 244 (success ? "" : " could not be") + " created."; |
245 DLOG_TO_CONSOLE(message); | 245 DLOG_TO_CONSOLE(message); |
246 CDM_DLOG() << message; | 246 CDM_DLOG() << message; |
247 | 247 |
248 return success; | 248 return success; |
249 } | 249 } |
250 | 250 |
251 // No KeyErrors should be reported in this function because they cannot be | 251 // No errors should be reported in this function because the spec says: |
252 // bubbled up in the WD EME API. Those errors will be reported during session | 252 // "Store this new error object internally with the MediaKeys instance being |
253 // creation (CreateSession). | 253 // created. This will be used to fire an error against any session created for |
254 // this instance." These errors will be reported during session creation | |
255 // (CreateSession()) or session loading (LoadSession()). | |
256 // TODO(xhwang): If necessary, we need to store the error here if we want to | |
257 // support more delicate error reporting (other than "Unknown"). | |
ddorwin
2014/02/10 23:26:24
delicate? Maybe specific?
xhwang
2014/02/10 23:42:34
Done.
xhwang
2014/02/10 23:42:34
Done.
| |
254 void CdmAdapter::Initialize(const std::string& key_system) { | 258 void CdmAdapter::Initialize(const std::string& key_system) { |
255 PP_DCHECK(!key_system.empty()); | 259 PP_DCHECK(!key_system.empty()); |
256 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); | 260 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
257 | 261 |
258 if (!cdm_ && !CreateCdmInstance(key_system)) | 262 if (!cdm_ && !CreateCdmInstance(key_system)) |
259 return; | 263 return; |
260 | 264 |
261 PP_DCHECK(cdm_); | 265 PP_DCHECK(cdm_); |
262 key_system_ = key_system; | 266 key_system_ = key_system; |
263 } | 267 } |
264 | 268 |
265 void CdmAdapter::CreateSession(uint32_t session_id, | 269 void CdmAdapter::CreateSession(uint32_t session_id, |
266 const std::string& type, | 270 const std::string& content_type, |
267 pp::VarArrayBuffer init_data) { | 271 pp::VarArrayBuffer init_data) { |
268 // Initialize() doesn't report an error, so CreateSession() can be called | 272 // Initialize() doesn't report an error, so CreateSession() can be called |
269 // even if Initialize() failed. | 273 // even if Initialize() failed. |
270 if (!cdm_) { | 274 if (!cdm_) { |
271 OnSessionError(session_id, cdm::kUnknownError, 0); | 275 OnSessionError(session_id, cdm::kUnknownError, 0); |
272 return; | 276 return; |
273 } | 277 } |
274 | 278 |
275 #if defined(CHECK_DOCUMENT_URL) | 279 #if defined(CHECK_DOCUMENT_URL) |
276 PP_URLComponents_Dev url_components = {}; | 280 PP_URLComponents_Dev url_components = {}; |
277 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); | 281 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); |
278 if (!url_util) { | 282 if (!url_util) { |
279 OnSessionError(session_id, cdm::kUnknownError, 0); | 283 OnSessionError(session_id, cdm::kUnknownError, 0); |
280 return; | 284 return; |
281 } | 285 } |
282 pp::Var href = url_util->GetDocumentURL( | 286 pp::Var href = url_util->GetDocumentURL( |
283 pp::InstanceHandle(pp_instance()), &url_components); | 287 pp::InstanceHandle(pp_instance()), &url_components); |
284 PP_DCHECK(href.is_string()); | 288 PP_DCHECK(href.is_string()); |
285 PP_DCHECK(!href.AsString().empty()); | 289 PP_DCHECK(!href.AsString().empty()); |
286 PP_DCHECK(url_components.host.begin); | 290 PP_DCHECK(url_components.host.begin); |
287 PP_DCHECK(0 < url_components.host.len); | 291 PP_DCHECK(0 < url_components.host.len); |
288 #endif // defined(CHECK_DOCUMENT_URL) | 292 #endif // defined(CHECK_DOCUMENT_URL) |
289 | 293 |
290 cdm_->CreateSession(session_id, | 294 cdm_->CreateSession(session_id, |
291 type.data(), | 295 content_type.data(), |
292 type.size(), | 296 content_type.size(), |
293 static_cast<const uint8_t*>(init_data.Map()), | 297 static_cast<const uint8_t*>(init_data.Map()), |
294 init_data.ByteLength()); | 298 init_data.ByteLength()); |
295 } | 299 } |
296 | 300 |
301 void CdmAdapter::LoadSession(uint32_t session_id, | |
302 const std::string& web_session_id) { | |
303 // Initialize() doesn't report an error, so LoadSession() can be called | |
304 // even if Initialize() failed. | |
305 if (!cdm_) { | |
306 OnSessionError(session_id, cdm::kUnknownError, 0); | |
307 return; | |
308 } | |
309 | |
310 if (!cdm_->LoadSession( | |
311 session_id, web_session_id.data(), web_session_id.size())) | |
312 OnSessionError(session_id, cdm::kUnknownError, 0); | |
313 } | |
314 | |
297 void CdmAdapter::UpdateSession(uint32_t session_id, | 315 void CdmAdapter::UpdateSession(uint32_t session_id, |
298 pp::VarArrayBuffer response) { | 316 pp::VarArrayBuffer response) { |
299 // TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions. | 317 // TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions. |
300 // We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976. | 318 // We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976. |
301 if (!cdm_) { | 319 if (!cdm_) { |
302 OnSessionError(session_id, cdm::kUnknownError, 0); | 320 OnSessionError(session_id, cdm::kUnknownError, 0); |
303 return; | 321 return; |
304 } | 322 } |
305 | 323 |
306 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); | 324 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 } // namespace media | 1058 } // namespace media |
1041 | 1059 |
1042 namespace pp { | 1060 namespace pp { |
1043 | 1061 |
1044 // Factory function for your specialization of the Module object. | 1062 // Factory function for your specialization of the Module object. |
1045 Module* CreateModule() { | 1063 Module* CreateModule() { |
1046 return new media::CdmAdapterModule(); | 1064 return new media::CdmAdapterModule(); |
1047 } | 1065 } |
1048 | 1066 |
1049 } // namespace pp | 1067 } // namespace pp |
OLD | NEW |