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/renderer/media/cdm_session_adapter.h" | 5 #include "content/renderer/media/cdm_session_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "content/renderer/media/crypto/content_decryption_module_factory.h" | 11 #include "content/renderer/media/crypto/content_decryption_module_factory.h" |
12 #include "content/renderer/media/crypto/key_systems.h" | |
12 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 13 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
13 #include "media/base/cdm_promise.h" | 14 #include "media/base/cdm_promise.h" |
14 #include "media/base/media_keys.h" | 15 #include "media/base/media_keys.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
20 // TODO(sandersd): De-dup with WMPI. | |
ddorwin
2014/08/08 03:35:40
It's not the end of the world if they are duplicat
sandersd (OOO until July 31)
2014/08/08 17:22:24
Done.
| |
21 const char kMediaEME[] = "Media.EME."; | |
22 | |
19 CdmSessionAdapter::CdmSessionAdapter() : | 23 CdmSessionAdapter::CdmSessionAdapter() : |
20 #if defined(ENABLE_BROWSER_CDMS) | 24 #if defined(ENABLE_BROWSER_CDMS) |
21 cdm_id_(0), | 25 cdm_id_(0), |
22 #endif | 26 #endif |
23 weak_ptr_factory_(this) {} | 27 weak_ptr_factory_(this) {} |
24 | 28 |
25 CdmSessionAdapter::~CdmSessionAdapter() {} | 29 CdmSessionAdapter::~CdmSessionAdapter() {} |
26 | 30 |
27 bool CdmSessionAdapter::Initialize( | 31 bool CdmSessionAdapter::Initialize( |
28 #if defined(ENABLE_PEPPER_CDMS) | 32 #if defined(ENABLE_PEPPER_CDMS) |
29 const CreatePepperCdmCB& create_pepper_cdm_cb, | 33 const CreatePepperCdmCB& create_pepper_cdm_cb, |
30 #elif defined(ENABLE_BROWSER_CDMS) | 34 #elif defined(ENABLE_BROWSER_CDMS) |
31 RendererCdmManager* manager, | 35 RendererCdmManager* manager, |
32 #endif // defined(ENABLE_PEPPER_CDMS) | 36 #endif // defined(ENABLE_PEPPER_CDMS) |
33 const std::string& key_system, | 37 const std::string& key_system, |
34 const GURL& security_origin) { | 38 const GURL& security_origin) { |
39 key_system_uma_prefix_ = kMediaEME + KeySystemNameForUMA(key_system); | |
35 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); | 40 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); |
36 media_keys_ = ContentDecryptionModuleFactory::Create( | 41 media_keys_ = ContentDecryptionModuleFactory::Create( |
37 key_system, | 42 key_system, |
38 security_origin, | 43 security_origin, |
39 #if defined(ENABLE_PEPPER_CDMS) | 44 #if defined(ENABLE_PEPPER_CDMS) |
40 create_pepper_cdm_cb, | 45 create_pepper_cdm_cb, |
41 #elif defined(ENABLE_BROWSER_CDMS) | 46 #elif defined(ENABLE_BROWSER_CDMS) |
42 manager, | 47 manager, |
43 &cdm_id_, | 48 &cdm_id_, |
44 #endif // defined(ENABLE_PEPPER_CDMS) | 49 #endif // defined(ENABLE_PEPPER_CDMS) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 void CdmSessionAdapter::ReleaseSession( | 101 void CdmSessionAdapter::ReleaseSession( |
97 const std::string& web_session_id, | 102 const std::string& web_session_id, |
98 scoped_ptr<media::SimpleCdmPromise> promise) { | 103 scoped_ptr<media::SimpleCdmPromise> promise) { |
99 media_keys_->ReleaseSession(web_session_id, promise.Pass()); | 104 media_keys_->ReleaseSession(web_session_id, promise.Pass()); |
100 } | 105 } |
101 | 106 |
102 media::Decryptor* CdmSessionAdapter::GetDecryptor() { | 107 media::Decryptor* CdmSessionAdapter::GetDecryptor() { |
103 return media_keys_->GetDecryptor(); | 108 return media_keys_->GetDecryptor(); |
104 } | 109 } |
105 | 110 |
111 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() { | |
112 return key_system_uma_prefix_; | |
113 } | |
114 | |
106 #if defined(ENABLE_BROWSER_CDMS) | 115 #if defined(ENABLE_BROWSER_CDMS) |
107 int CdmSessionAdapter::GetCdmId() const { | 116 int CdmSessionAdapter::GetCdmId() const { |
108 return cdm_id_; | 117 return cdm_id_; |
109 } | 118 } |
110 #endif // defined(ENABLE_BROWSER_CDMS) | 119 #endif // defined(ENABLE_BROWSER_CDMS) |
111 | 120 |
112 void CdmSessionAdapter::OnSessionMessage(const std::string& web_session_id, | 121 void CdmSessionAdapter::OnSessionMessage(const std::string& web_session_id, |
113 const std::vector<uint8>& message, | 122 const std::vector<uint8>& message, |
114 const GURL& destination_url) { | 123 const GURL& destination_url) { |
115 WebContentDecryptionModuleSessionImpl* session = GetSession(web_session_id); | 124 WebContentDecryptionModuleSessionImpl* session = GetSession(web_session_id); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( | 159 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( |
151 const std::string& web_session_id) { | 160 const std::string& web_session_id) { |
152 // Since session objects may get garbage collected, it is possible that there | 161 // Since session objects may get garbage collected, it is possible that there |
153 // are events coming back from the CDM and the session has been unregistered. | 162 // are events coming back from the CDM and the session has been unregistered. |
154 // We can not tell if the CDM is firing events at sessions that never existed. | 163 // We can not tell if the CDM is firing events at sessions that never existed. |
155 SessionMap::iterator session = sessions_.find(web_session_id); | 164 SessionMap::iterator session = sessions_.find(web_session_id); |
156 return (session != sessions_.end()) ? session->second.get() : NULL; | 165 return (session != sessions_.end()) ? session->second.get() : NULL; |
157 } | 166 } |
158 | 167 |
159 } // namespace content | 168 } // namespace content |
OLD | NEW |