OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/media/cdm/browser_cdm_manager.h" | 5 #include "content/browser/media/cdm/browser_cdm_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 #endif | 302 #endif |
303 } | 303 } |
304 | 304 |
305 return cdm_factory_.get(); | 305 return cdm_factory_.get(); |
306 } | 306 } |
307 | 307 |
308 void BrowserCdmManager::OnSessionMessage(int render_frame_id, | 308 void BrowserCdmManager::OnSessionMessage(int render_frame_id, |
309 int cdm_id, | 309 int cdm_id, |
310 const std::string& session_id, | 310 const std::string& session_id, |
311 MediaKeys::MessageType message_type, | 311 MediaKeys::MessageType message_type, |
312 const std::vector<uint8_t>& message, | 312 const std::vector<uint8_t>& message) { |
313 const GURL& legacy_destination_url) { | |
314 GURL verified_gurl = legacy_destination_url; | |
315 if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { | |
316 DLOG(WARNING) << "SessionMessage legacy_destination_url is invalid : " | |
317 << legacy_destination_url.possibly_invalid_spec(); | |
318 verified_gurl = | |
319 GURL::EmptyGURL(); // Replace invalid legacy_destination_url. | |
320 } | |
321 | |
322 Send(new CdmMsg_SessionMessage(render_frame_id, cdm_id, session_id, | 313 Send(new CdmMsg_SessionMessage(render_frame_id, cdm_id, session_id, |
323 message_type, message, verified_gurl)); | 314 message_type, message)); |
324 } | 315 } |
325 | 316 |
326 void BrowserCdmManager::OnSessionClosed(int render_frame_id, | 317 void BrowserCdmManager::OnSessionClosed(int render_frame_id, |
327 int cdm_id, | 318 int cdm_id, |
328 const std::string& session_id) { | 319 const std::string& session_id) { |
329 Send(new CdmMsg_SessionClosed(render_frame_id, cdm_id, session_id)); | 320 Send(new CdmMsg_SessionClosed(render_frame_id, cdm_id, session_id)); |
330 } | 321 } |
331 | 322 |
332 void BrowserCdmManager::OnLegacySessionError( | |
333 int render_frame_id, | |
334 int cdm_id, | |
335 const std::string& session_id, | |
336 MediaKeys::Exception exception_code, | |
337 uint32_t system_code, | |
338 const std::string& error_message) { | |
339 Send(new CdmMsg_LegacySessionError(render_frame_id, cdm_id, session_id, | |
340 exception_code, system_code, | |
341 error_message)); | |
342 } | |
343 | |
344 void BrowserCdmManager::OnSessionKeysChange(int render_frame_id, | 323 void BrowserCdmManager::OnSessionKeysChange(int render_frame_id, |
345 int cdm_id, | 324 int cdm_id, |
346 const std::string& session_id, | 325 const std::string& session_id, |
347 bool has_additional_usable_key, | 326 bool has_additional_usable_key, |
348 media::CdmKeysInfo keys_info) { | 327 media::CdmKeysInfo keys_info) { |
349 std::vector<media::CdmKeyInformation> key_info_vector; | 328 std::vector<media::CdmKeyInformation> key_info_vector; |
350 for (auto* key_info : keys_info) | 329 for (auto* key_info : keys_info) |
351 key_info_vector.push_back(*key_info); | 330 key_info_vector.push_back(*key_info); |
352 Send(new CdmMsg_SessionKeysChange(render_frame_id, cdm_id, session_id, | 331 Send(new CdmMsg_SessionKeysChange(render_frame_id, cdm_id, session_id, |
353 has_additional_usable_key, | 332 has_additional_usable_key, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 // |allow_persistent_state| from the render process. | 376 // |allow_persistent_state| from the render process. |
398 media::CdmConfig cdm_config; | 377 media::CdmConfig cdm_config; |
399 cdm_config.allow_distinctive_identifier = true; | 378 cdm_config.allow_distinctive_identifier = true; |
400 cdm_config.allow_persistent_state = true; | 379 cdm_config.allow_persistent_state = true; |
401 cdm_config.use_hw_secure_codecs = params.use_hw_secure_codecs; | 380 cdm_config.use_hw_secure_codecs = params.use_hw_secure_codecs; |
402 | 381 |
403 GetCdmFactory()->Create( | 382 GetCdmFactory()->Create( |
404 params.key_system, params.security_origin, cdm_config, | 383 params.key_system, params.security_origin, cdm_config, |
405 BROWSER_CDM_MANAGER_CB(OnSessionMessage), | 384 BROWSER_CDM_MANAGER_CB(OnSessionMessage), |
406 BROWSER_CDM_MANAGER_CB(OnSessionClosed), | 385 BROWSER_CDM_MANAGER_CB(OnSessionClosed), |
407 BROWSER_CDM_MANAGER_CB(OnLegacySessionError), | |
408 BROWSER_CDM_MANAGER_CB(OnSessionKeysChange), | 386 BROWSER_CDM_MANAGER_CB(OnSessionKeysChange), |
409 BROWSER_CDM_MANAGER_CB(OnSessionExpirationUpdate), | 387 BROWSER_CDM_MANAGER_CB(OnSessionExpirationUpdate), |
410 BROWSER_CDM_MANAGER_CB(OnCdmCreated, params.security_origin, | 388 BROWSER_CDM_MANAGER_CB(OnCdmCreated, params.security_origin, |
411 base::Passed(&promise))); | 389 base::Passed(&promise))); |
412 } | 390 } |
413 | 391 |
414 void BrowserCdmManager::OnSetServerCertificate( | 392 void BrowserCdmManager::OnSetServerCertificate( |
415 int render_frame_id, | 393 int render_frame_id, |
416 int cdm_id, | 394 int cdm_id, |
417 uint32_t promise_id, | 395 uint32_t promise_id, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); | 707 scoped_refptr<MediaKeys> cdm = GetCdm(render_frame_id, cdm_id); |
730 if (!cdm) { | 708 if (!cdm) { |
731 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); | 709 promise->reject(MediaKeys::INVALID_STATE_ERROR, 0, "CDM not found."); |
732 return; | 710 return; |
733 } | 711 } |
734 | 712 |
735 cdm->LoadSession(session_type, session_id, std::move(promise)); | 713 cdm->LoadSession(session_type, session_id, std::move(promise)); |
736 } | 714 } |
737 | 715 |
738 } // namespace content | 716 } // namespace content |
OLD | NEW |