Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: content/renderer/media/cdm_session_adapter.cc

Issue 665563002: Add MediaKeys::GetCdmId(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Make GetCdmId() pure virtual. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/key_systems.h" 11 #include "content/renderer/media/crypto/key_systems.h"
12 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 12 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
13 #include "media/base/cdm_factory.h" 13 #include "media/base/cdm_factory.h"
14 #include "media/base/cdm_promise.h" 14 #include "media/base/cdm_promise.h"
15 #include "media/base/media_keys.h" 15 #include "media/base/media_keys.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 #if defined(ENABLE_BROWSER_CDMS)
19 #include "content/renderer/media/crypto/renderer_cdm_manager.h"
20 #endif // defined(ENABLE_BROWSER_CDMS)
21
22 namespace content { 18 namespace content {
23 19
24 const char kMediaEME[] = "Media.EME."; 20 const char kMediaEME[] = "Media.EME.";
25 const char kDot[] = "."; 21 const char kDot[] = ".";
26 22
27 CdmSessionAdapter::CdmSessionAdapter() : 23 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {
28 #if defined(ENABLE_BROWSER_CDMS) 24 }
29 // TODO(xhwang): Move kInvalidCdmId to src/media.
30 cdm_id_(RendererCdmManager::kInvalidCdmId),
31 #endif
32 weak_ptr_factory_(this) {}
33 25
34 CdmSessionAdapter::~CdmSessionAdapter() {} 26 CdmSessionAdapter::~CdmSessionAdapter() {}
35 27
36 bool CdmSessionAdapter::Initialize(media::CdmFactory* cdm_factory, 28 bool CdmSessionAdapter::Initialize(media::CdmFactory* cdm_factory,
37 const std::string& key_system, 29 const std::string& key_system,
38 const GURL& security_origin) { 30 const GURL& security_origin) {
39 // TODO(xhwang): This is why we need to include "key_systems.h". Move 31 // TODO(xhwang): This is why we need to include "key_systems.h". Move
40 // KeySystemNameForUMA out of src/content so we can move CdmSessionAdapter to 32 // KeySystemNameForUMA out of src/content so we can move CdmSessionAdapter to
41 // src/media. 33 // src/media.
42 key_system_uma_prefix_ = kMediaEME + KeySystemNameForUMA(key_system) + kDot; 34 key_system_uma_prefix_ = kMediaEME + KeySystemNameForUMA(key_system) + kDot;
43 35
44 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 36 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
45 media_keys_ = cdm_factory->Create( 37 media_keys_ = cdm_factory->Create(
46 key_system, 38 key_system,
47 security_origin, 39 security_origin,
48 #if defined(ENABLE_BROWSER_CDMS)
49 &cdm_id_,
50 #endif // defined(ENABLE_PEPPER_CDMS)
51 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 40 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
52 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), 41 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this),
53 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 42 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
54 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this), 43 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this),
55 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 44 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
56 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this)); 45 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this));
57 46
58 // Success if |media_keys_| created. 47 // Success if |media_keys_| created.
59 return media_keys_; 48 return media_keys_;
60 } 49 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 media::Decryptor* CdmSessionAdapter::GetDecryptor() { 125 media::Decryptor* CdmSessionAdapter::GetDecryptor() {
137 return media_keys_->GetDecryptor(); 126 return media_keys_->GetDecryptor();
138 } 127 }
139 128
140 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { 129 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
141 return key_system_uma_prefix_; 130 return key_system_uma_prefix_;
142 } 131 }
143 132
144 #if defined(ENABLE_BROWSER_CDMS) 133 #if defined(ENABLE_BROWSER_CDMS)
145 int CdmSessionAdapter::GetCdmId() const { 134 int CdmSessionAdapter::GetCdmId() const {
146 return cdm_id_; 135 return media_keys_->GetCdmId();
147 } 136 }
148 #endif // defined(ENABLE_BROWSER_CDMS) 137 #endif // defined(ENABLE_BROWSER_CDMS)
149 138
150 void CdmSessionAdapter::OnSessionMessage(const std::string& web_session_id, 139 void CdmSessionAdapter::OnSessionMessage(const std::string& web_session_id,
151 const std::vector<uint8>& message, 140 const std::vector<uint8>& message,
152 const GURL& destination_url) { 141 const GURL& destination_url) {
153 WebContentDecryptionModuleSessionImpl* session = GetSession(web_session_id); 142 WebContentDecryptionModuleSessionImpl* session = GetSession(web_session_id);
154 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " 143 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session "
155 << web_session_id; 144 << web_session_id;
156 if (session) 145 if (session)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 196 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
208 const std::string& web_session_id) { 197 const std::string& web_session_id) {
209 // Since session objects may get garbage collected, it is possible that there 198 // Since session objects may get garbage collected, it is possible that there
210 // are events coming back from the CDM and the session has been unregistered. 199 // are events coming back from the CDM and the session has been unregistered.
211 // We can not tell if the CDM is firing events at sessions that never existed. 200 // We can not tell if the CDM is firing events at sessions that never existed.
212 SessionMap::iterator session = sessions_.find(web_session_id); 201 SessionMap::iterator session = sessions_.find(web_session_id);
213 return (session != sessions_.end()) ? session->second.get() : NULL; 202 return (session != sessions_.end()) ? session->second.get() : NULL;
214 } 203 }
215 204
216 } // namespace content 205 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/cdm_session_adapter.h ('k') | content/renderer/media/crypto/proxy_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698