Chromium Code Reviews| 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/render_cdm_factory.h" | 5 #include "content/renderer/media/crypto/render_cdm_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "media/base/cdm_config.h" | |
| 12 #include "media/base/cdm_promise.h" | 13 #include "media/base/cdm_promise.h" |
| 13 #include "media/base/key_systems.h" | 14 #include "media/base/key_systems.h" |
| 14 #include "media/base/media_keys.h" | 15 #include "media/base/media_keys.h" |
| 15 #include "media/cdm/aes_decryptor.h" | 16 #include "media/cdm/aes_decryptor.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 #if defined(ENABLE_PEPPER_CDMS) | 18 #if defined(ENABLE_PEPPER_CDMS) |
| 18 #include "content/renderer/media/crypto/ppapi_decryptor.h" | 19 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
| 19 #elif defined(ENABLE_BROWSER_CDMS) | 20 #elif defined(ENABLE_BROWSER_CDMS) |
| 20 #include "content/renderer/media/crypto/proxy_media_keys.h" | 21 #include "content/renderer/media/crypto/proxy_media_keys.h" |
| 21 #endif // defined(ENABLE_PEPPER_CDMS) | 22 #endif // defined(ENABLE_PEPPER_CDMS) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 37 #endif // defined(ENABLE_PEPPER_CDMS) | 38 #endif // defined(ENABLE_PEPPER_CDMS) |
| 38 { | 39 { |
| 39 } | 40 } |
| 40 | 41 |
| 41 RenderCdmFactory::~RenderCdmFactory() { | 42 RenderCdmFactory::~RenderCdmFactory() { |
| 42 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void RenderCdmFactory::Create( | 46 void RenderCdmFactory::Create( |
| 46 const std::string& key_system, | 47 const std::string& key_system, |
| 47 bool allow_distinctive_identifier, | |
| 48 bool allow_persistent_state, | |
| 49 const GURL& security_origin, | 48 const GURL& security_origin, |
| 49 const media::CdmConfig& cdm_config, | |
| 50 const media::SessionMessageCB& session_message_cb, | 50 const media::SessionMessageCB& session_message_cb, |
| 51 const media::SessionClosedCB& session_closed_cb, | 51 const media::SessionClosedCB& session_closed_cb, |
| 52 const media::LegacySessionErrorCB& legacy_session_error_cb, | 52 const media::LegacySessionErrorCB& legacy_session_error_cb, |
| 53 const media::SessionKeysChangeCB& session_keys_change_cb, | 53 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 54 const media::SessionExpirationUpdateCB& session_expiration_update_cb, | 54 const media::SessionExpirationUpdateCB& session_expiration_update_cb, |
| 55 const media::CdmCreatedCB& cdm_created_cb) { | 55 const media::CdmCreatedCB& cdm_created_cb) { |
| 56 DCHECK(thread_checker_.CalledOnValidThread()); | 56 DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 | 57 |
| 58 if (!security_origin.is_valid()) { | 58 if (!security_origin.is_valid()) { |
| 59 base::MessageLoopProxy::current()->PostTask( | 59 base::MessageLoopProxy::current()->PostTask( |
| 60 FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin.")); | 60 FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin.")); |
| 61 return; | 61 return; |
| 62 } | 62 } |
| 63 | 63 |
| 64 if (media::CanUseAesDecryptor(key_system)) { | 64 if (media::CanUseAesDecryptor(key_system)) { |
| 65 // TODO(sandersd): Currently the prefixed API always allows distinctive | 65 // TODO(sandersd): Currently the prefixed API always allows distinctive |
| 66 // identifiers and persistent state. Once that changes we can sanity check | 66 // identifiers and persistent state. Once that changes we can sanity check |
| 67 // here that neither is allowed for AesDecryptor, since it does not support | 67 // here that neither is allowed for AesDecryptor, since it does not support |
| 68 // them and should never be configured that way. http://crbug.com/455271 | 68 // them and should never be configured that way. http://crbug.com/455271 |
| 69 scoped_ptr<media::MediaKeys> cdm( | 69 scoped_ptr<media::MediaKeys> cdm( |
| 70 new media::AesDecryptor(security_origin, session_message_cb, | 70 new media::AesDecryptor(security_origin, session_message_cb, |
| 71 session_closed_cb, session_keys_change_cb)); | 71 session_closed_cb, session_keys_change_cb)); |
| 72 base::MessageLoopProxy::current()->PostTask( | 72 base::MessageLoopProxy::current()->PostTask( |
| 73 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), "")); | 73 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), "")); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 #if defined(ENABLE_PEPPER_CDMS) | 77 #if defined(ENABLE_PEPPER_CDMS) |
| 78 DCHECK(!cdm_config.use_secure_codecs); | |
|
ddorwin
2015/05/13 06:03:20
Since we just pass around a type now instead of pa
sandersd (OOO until July 31)
2015/05/14 00:06:57
Acknowledged.
| |
| 78 PpapiDecryptor::Create( | 79 PpapiDecryptor::Create( |
| 79 key_system, allow_distinctive_identifier, allow_persistent_state, | 80 key_system, security_origin, cdm_config.allow_distinctive_identifier, |
| 80 security_origin, create_pepper_cdm_cb_, session_message_cb, | 81 cdm_config.allow_persistent_state, create_pepper_cdm_cb_, |
| 81 session_closed_cb, legacy_session_error_cb, session_keys_change_cb, | 82 session_message_cb, session_closed_cb, legacy_session_error_cb, |
| 82 session_expiration_update_cb, cdm_created_cb); | 83 session_keys_change_cb, session_expiration_update_cb, cdm_created_cb); |
| 83 #elif defined(ENABLE_BROWSER_CDMS) | 84 #elif defined(ENABLE_BROWSER_CDMS) |
| 84 DCHECK(allow_distinctive_identifier); | 85 DCHECK(cdm_config.allow_distinctive_identifier); |
|
ddorwin
2015/05/13 06:03:20
These DCHECKs are consistent with the KS selector
gunsch
2015/05/13 06:52:37
One odd edge case we ran into on Chromecast today:
ddorwin
2015/05/14 00:17:31
Hmm. Let's discuss. There is definitely an assumpt
gunsch
2015/05/14 01:35:52
Agreed, we realize commenting it out isn't valid a
| |
| 85 DCHECK(allow_persistent_state); | 86 DCHECK(cdm_config.allow_persistent_state); |
| 86 ProxyMediaKeys::Create(key_system, security_origin, manager_, | 87 ProxyMediaKeys::Create( |
| 87 session_message_cb, session_closed_cb, | 88 key_system, security_origin, cdm_config.use_secure_codecs, manager_, |
| 88 legacy_session_error_cb, session_keys_change_cb, | 89 session_message_cb, session_closed_cb, legacy_session_error_cb, |
| 89 session_expiration_update_cb, cdm_created_cb); | 90 session_keys_change_cb, session_expiration_update_cb, cdm_created_cb); |
| 90 #else | 91 #else |
| 91 // No possible CDM to create, so fail the request. | 92 // No possible CDM to create, so fail the request. |
| 92 base::MessageLoopProxy::current()->PostTask( | 93 base::MessageLoopProxy::current()->PostTask( |
| 93 FROM_HERE, | 94 FROM_HERE, |
| 94 base::Bind(cdm_created_cb, nullptr, "Key system not supported.")); | 95 base::Bind(cdm_created_cb, nullptr, "Key system not supported.")); |
| 95 #endif // defined(ENABLE_PEPPER_CDMS) | 96 #endif // defined(ENABLE_PEPPER_CDMS) |
| 96 } | 97 } |
| 97 | 98 |
| 98 } // namespace content | 99 } // namespace content |
| OLD | NEW |