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
3 // found in the LICENSE file.
5 #include "content/renderer/media/crypto/content_decryption_module_factory.h"
7 #include "base/logging.h"
8 #include "content/renderer/media/crypto/key_systems.h"
9 #include "media/cdm/aes_decryptor.h"
12 #if defined(ENABLE_PEPPER_CDMS)
13 #include "content/renderer/media/crypto/ppapi_decryptor.h"
14 #elif defined(ENABLE_BROWSER_CDMS)
15 #include "content/renderer/media/crypto/proxy_media_keys.h"
16 #include "content/renderer/media/crypto/renderer_cdm_manager.h"
17 #endif // defined(ENABLE_PEPPER_CDMS)
21 scoped_ptr
<media::MediaKeys
> ContentDecryptionModuleFactory::Create(
22 const std::string
& key_system
,
23 const GURL
& security_origin
,
24 #if defined(ENABLE_PEPPER_CDMS)
25 const CreatePepperCdmCB
& create_pepper_cdm_cb
,
26 #elif defined(ENABLE_BROWSER_CDMS)
27 RendererCdmManager
* manager
,
29 #endif // defined(ENABLE_PEPPER_CDMS)
30 const media::SessionMessageCB
& session_message_cb
,
31 const media::SessionReadyCB
& session_ready_cb
,
32 const media::SessionClosedCB
& session_closed_cb
,
33 const media::SessionErrorCB
& session_error_cb
) {
34 // TODO(jrummell): Pass |security_origin| to all constructors.
35 // TODO(jrummell): Enable the following line once blink code updated to
36 // check the security origin before calling.
37 // DCHECK(security_origin.is_valid());
39 #if defined(ENABLE_BROWSER_CDMS)
40 *cdm_id
= RendererCdmManager::kInvalidCdmId
;
43 if (CanUseAesDecryptor(key_system
)) {
44 return scoped_ptr
<media::MediaKeys
>(
45 new media::AesDecryptor(session_message_cb
, session_closed_cb
));
47 #if defined(ENABLE_PEPPER_CDMS)
48 return scoped_ptr
<media::MediaKeys
>(
49 PpapiDecryptor::Create(key_system
,
56 #elif defined(ENABLE_BROWSER_CDMS)
57 scoped_ptr
<ProxyMediaKeys
> proxy_media_keys
=
58 ProxyMediaKeys::Create(key_system
,
66 *cdm_id
= proxy_media_keys
->GetCdmId();
67 return proxy_media_keys
.PassAs
<media::MediaKeys
>();
69 return scoped_ptr
<media::MediaKeys
>();
70 #endif // defined(ENABLE_PEPPER_CDMS)
73 } // namespace content