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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 KeyErrors should be reported in this function because they cannot be |
252 // bubbled up in the WD EME API. Those errors will be reported during session | 252 // bubbled up in the WD EME API. Those errors will be reported during session |
253 // creation (CreateSession). | 253 // creation (CreateSession()) or session loading (LoadSession()). |
ddorwin
2014/02/10 19:05:25
Technically, the spec says errors are to be saved
xhwang
2014/02/10 22:30:55
Done.
| |
254 void CdmAdapter::Initialize(const std::string& key_system) { | 254 void CdmAdapter::Initialize(const std::string& key_system) { |
255 PP_DCHECK(!key_system.empty()); | 255 PP_DCHECK(!key_system.empty()); |
256 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); | 256 PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
257 | 257 |
258 if (!cdm_ && !CreateCdmInstance(key_system)) | 258 if (!cdm_ && !CreateCdmInstance(key_system)) |
259 return; | 259 return; |
260 | 260 |
261 PP_DCHECK(cdm_); | 261 PP_DCHECK(cdm_); |
262 key_system_ = key_system; | 262 key_system_ = key_system; |
263 } | 263 } |
264 | 264 |
265 void CdmAdapter::CreateSession(uint32_t session_id, | 265 void CdmAdapter::CreateSession(uint32_t session_id, |
266 const std::string& type, | 266 const std::string& content_type, |
267 pp::VarArrayBuffer init_data) { | 267 pp::VarArrayBuffer init_data) { |
268 // Initialize() doesn't report an error, so CreateSession() can be called | 268 // Initialize() doesn't report an error, so CreateSession() can be called |
269 // even if Initialize() failed. | 269 // even if Initialize() failed. |
270 if (!cdm_) { | 270 if (!cdm_) { |
271 OnSessionError(session_id, cdm::kUnknownError, 0); | 271 OnSessionError(session_id, cdm::kUnknownError, 0); |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 #if defined(CHECK_DOCUMENT_URL) | 275 #if defined(CHECK_DOCUMENT_URL) |
276 PP_URLComponents_Dev url_components = {}; | 276 PP_URLComponents_Dev url_components = {}; |
277 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); | 277 const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); |
278 if (!url_util) { | 278 if (!url_util) { |
279 OnSessionError(session_id, cdm::kUnknownError, 0); | 279 OnSessionError(session_id, cdm::kUnknownError, 0); |
280 return; | 280 return; |
281 } | 281 } |
282 pp::Var href = url_util->GetDocumentURL( | 282 pp::Var href = url_util->GetDocumentURL( |
283 pp::InstanceHandle(pp_instance()), &url_components); | 283 pp::InstanceHandle(pp_instance()), &url_components); |
284 PP_DCHECK(href.is_string()); | 284 PP_DCHECK(href.is_string()); |
285 PP_DCHECK(!href.AsString().empty()); | 285 PP_DCHECK(!href.AsString().empty()); |
286 PP_DCHECK(url_components.host.begin); | 286 PP_DCHECK(url_components.host.begin); |
287 PP_DCHECK(0 < url_components.host.len); | 287 PP_DCHECK(0 < url_components.host.len); |
288 #endif // defined(CHECK_DOCUMENT_URL) | 288 #endif // defined(CHECK_DOCUMENT_URL) |
289 | 289 |
290 cdm_->CreateSession(session_id, | 290 cdm_->CreateSession(session_id, |
291 type.data(), | 291 content_type.data(), |
292 type.size(), | 292 content_type.size(), |
293 static_cast<const uint8_t*>(init_data.Map()), | 293 static_cast<const uint8_t*>(init_data.Map()), |
294 init_data.ByteLength()); | 294 init_data.ByteLength()); |
295 } | 295 } |
296 | 296 |
297 void CdmAdapter::LoadSession(uint32_t session_id, | |
298 const std::string& web_session_id) { | |
299 // Initialize() doesn't report an error, so LoadSession() can be called | |
300 // even if Initialize() failed. | |
301 if (!cdm_ || | |
ddorwin
2014/02/10 19:05:25
These two reasons for returning an error are disti
xhwang
2014/02/10 22:30:55
Done.
| |
302 cdm_->GetCdmVersion() < cdm::ContentDecryptionModule_4::kVersion) { | |
xhwang
2014/02/08 01:05:25
Currently CdmWrapper doesn't have access to SendSe
ddorwin
2014/02/10 19:05:25
Would it be better to temporarily add a bool retur
xhwang
2014/02/10 22:30:55
Done.
| |
303 OnSessionError(session_id, cdm::kUnknownError, 0); | |
304 return; | |
305 } | |
306 | |
307 cdm_->LoadSession(session_id, web_session_id.data(), web_session_id.size()); | |
308 } | |
309 | |
297 void CdmAdapter::UpdateSession(uint32_t session_id, | 310 void CdmAdapter::UpdateSession(uint32_t session_id, |
298 pp::VarArrayBuffer response) { | 311 pp::VarArrayBuffer response) { |
299 // TODO(jrummell): In EME WD, AddKey() can only be called on valid sessions. | 312 // 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. | 313 // We should be able to DCHECK(cdm_) when addressing http://crbug.com/249976. |
301 if (!cdm_) { | 314 if (!cdm_) { |
302 OnSessionError(session_id, cdm::kUnknownError, 0); | 315 OnSessionError(session_id, cdm::kUnknownError, 0); |
303 return; | 316 return; |
304 } | 317 } |
305 | 318 |
306 const uint8_t* response_ptr = static_cast<const uint8_t*>(response.Map()); | 319 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 | 1053 } // namespace media |
1041 | 1054 |
1042 namespace pp { | 1055 namespace pp { |
1043 | 1056 |
1044 // Factory function for your specialization of the Module object. | 1057 // Factory function for your specialization of the Module object. |
1045 Module* CreateModule() { | 1058 Module* CreateModule() { |
1046 return new media::CdmAdapterModule(); | 1059 return new media::CdmAdapterModule(); |
1047 } | 1060 } |
1048 | 1061 |
1049 } // namespace pp | 1062 } // namespace pp |
OLD | NEW |