| 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/content_decryption_module_factory.h" | 5 #include "content/renderer/media/crypto/render_cdm_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/media/crypto/key_systems.h" | 8 #include "content/renderer/media/crypto/key_systems.h" |
| 9 #include "media/cdm/aes_decryptor.h" | 9 #include "media/cdm/aes_decryptor.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 11 | 11 |
| 12 #if defined(ENABLE_PEPPER_CDMS) | 12 #if defined(ENABLE_PEPPER_CDMS) |
| 13 #include "content/renderer/media/crypto/ppapi_decryptor.h" | 13 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
| 14 #elif defined(ENABLE_BROWSER_CDMS) | 14 #elif defined(ENABLE_BROWSER_CDMS) |
| 15 #include "content/renderer/media/crypto/proxy_media_keys.h" | 15 #include "content/renderer/media/crypto/proxy_media_keys.h" |
| 16 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 16 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
| 17 #endif // defined(ENABLE_PEPPER_CDMS) | 17 #endif // defined(ENABLE_PEPPER_CDMS) |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create( | 21 #if defined(ENABLE_PEPPER_CDMS) |
| 22 RenderCdmFactory::RenderCdmFactory( |
| 23 const CreatePepperCdmCB& create_pepper_cdm_cb) |
| 24 : create_pepper_cdm_cb_(create_pepper_cdm_cb) { |
| 25 } |
| 26 #elif defined(ENABLE_BROWSER_CDMS) |
| 27 RenderCdmFactory::RenderCdmFactory(RendererCdmManager* manager) |
| 28 : manager_(manager) { |
| 29 } |
| 30 #else |
| 31 RenderCdmFactory::RenderCdmFactory() { |
| 32 } |
| 33 #endif // defined(ENABLE_PEPPER_CDMS) |
| 34 |
| 35 RenderCdmFactory::~RenderCdmFactory() { |
| 36 } |
| 37 |
| 38 scoped_ptr<media::MediaKeys> RenderCdmFactory::Create( |
| 22 const std::string& key_system, | 39 const std::string& key_system, |
| 23 const GURL& security_origin, | 40 const GURL& security_origin, |
| 24 #if defined(ENABLE_PEPPER_CDMS) | 41 #if defined(ENABLE_BROWSER_CDMS) |
| 25 const CreatePepperCdmCB& create_pepper_cdm_cb, | |
| 26 #elif defined(ENABLE_BROWSER_CDMS) | |
| 27 RendererCdmManager* manager, | |
| 28 int* cdm_id, | 42 int* cdm_id, |
| 29 #endif // defined(ENABLE_PEPPER_CDMS) | 43 #endif |
| 30 const media::SessionMessageCB& session_message_cb, | 44 const media::SessionMessageCB& session_message_cb, |
| 31 const media::SessionReadyCB& session_ready_cb, | 45 const media::SessionReadyCB& session_ready_cb, |
| 32 const media::SessionClosedCB& session_closed_cb, | 46 const media::SessionClosedCB& session_closed_cb, |
| 33 const media::SessionErrorCB& session_error_cb, | 47 const media::SessionErrorCB& session_error_cb, |
| 34 const media::SessionKeysChangeCB& session_keys_change_cb, | 48 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 35 const media::SessionExpirationUpdateCB& session_expiration_update_cb) { | 49 const media::SessionExpirationUpdateCB& session_expiration_update_cb) |
| 50 const { |
| 36 // TODO(jrummell): Pass |security_origin| to all constructors. | 51 // TODO(jrummell): Pass |security_origin| to all constructors. |
| 37 // TODO(jrummell): Enable the following line once blink code updated to | 52 // TODO(jrummell): Enable the following line once blink code updated to |
| 38 // check the security origin before calling. | 53 // check the security origin before calling. |
| 39 // DCHECK(security_origin.is_valid()); | 54 // DCHECK(security_origin.is_valid()); |
| 40 | 55 |
| 41 #if defined(ENABLE_BROWSER_CDMS) | 56 #if defined(ENABLE_BROWSER_CDMS) |
| 42 *cdm_id = RendererCdmManager::kInvalidCdmId; | 57 *cdm_id = RendererCdmManager::kInvalidCdmId; |
| 43 #endif | 58 #endif |
| 44 | 59 |
| 45 if (CanUseAesDecryptor(key_system)) { | 60 if (CanUseAesDecryptor(key_system)) { |
| 46 return scoped_ptr<media::MediaKeys>(new media::AesDecryptor( | 61 return scoped_ptr<media::MediaKeys>(new media::AesDecryptor( |
| 47 session_message_cb, session_closed_cb, session_keys_change_cb)); | 62 session_message_cb, session_closed_cb, session_keys_change_cb)); |
| 48 } | 63 } |
| 64 |
| 49 #if defined(ENABLE_PEPPER_CDMS) | 65 #if defined(ENABLE_PEPPER_CDMS) |
| 50 return scoped_ptr<media::MediaKeys>( | 66 return scoped_ptr<media::MediaKeys>( |
| 51 PpapiDecryptor::Create(key_system, | 67 PpapiDecryptor::Create(key_system, |
| 52 security_origin, | 68 security_origin, |
| 53 create_pepper_cdm_cb, | 69 create_pepper_cdm_cb_, |
| 54 session_message_cb, | 70 session_message_cb, |
| 55 session_ready_cb, | 71 session_ready_cb, |
| 56 session_closed_cb, | 72 session_closed_cb, |
| 57 session_error_cb, | 73 session_error_cb, |
| 58 session_keys_change_cb, | 74 session_keys_change_cb, |
| 59 session_expiration_update_cb)); | 75 session_expiration_update_cb)); |
| 60 #elif defined(ENABLE_BROWSER_CDMS) | 76 #elif defined(ENABLE_BROWSER_CDMS) |
| 61 scoped_ptr<ProxyMediaKeys> proxy_media_keys = | 77 scoped_ptr<ProxyMediaKeys> proxy_media_keys = |
| 62 ProxyMediaKeys::Create(key_system, | 78 ProxyMediaKeys::Create(key_system, |
| 63 security_origin, | 79 security_origin, |
| 64 manager, | 80 manager_, |
| 65 session_message_cb, | 81 session_message_cb, |
| 66 session_ready_cb, | 82 session_ready_cb, |
| 67 session_closed_cb, | 83 session_closed_cb, |
| 68 session_error_cb, | 84 session_error_cb, |
| 69 session_keys_change_cb, | 85 session_keys_change_cb, |
| 70 session_expiration_update_cb); | 86 session_expiration_update_cb); |
| 71 if (proxy_media_keys) | 87 if (proxy_media_keys) |
| 72 *cdm_id = proxy_media_keys->GetCdmId(); | 88 *cdm_id = proxy_media_keys->GetCdmId(); |
| 73 return proxy_media_keys.Pass(); | 89 return proxy_media_keys.Pass(); |
| 74 #else | 90 #else |
| 75 return nullptr; | 91 return nullptr; |
| 76 #endif // defined(ENABLE_PEPPER_CDMS) | 92 #endif // defined(ENABLE_PEPPER_CDMS) |
| 77 } | 93 } |
| 78 | 94 |
| 79 } // namespace content | 95 } // namespace content |
| OLD | NEW |