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

Side by Side Diff: content/renderer/media/crypto/proxy_decryptor.cc

Issue 193523002: Encrypted Media: Implement IPC based SetCdm(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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/proxy_decryptor.h" 5 #include "content/renderer/media/crypto/proxy_decryptor.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 24 matching lines...) Expand all
35 // Special system code to signal a closed persistent session in a SessionError() 35 // Special system code to signal a closed persistent session in a SessionError()
36 // call. This is needed because there is no SessionClosed() call in the prefixed 36 // call. This is needed because there is no SessionClosed() call in the prefixed
37 // EME API. 37 // EME API.
38 const int kSessionClosedSystemCode = 29127; 38 const int kSessionClosedSystemCode = 29127;
39 39
40 ProxyDecryptor::ProxyDecryptor( 40 ProxyDecryptor::ProxyDecryptor(
41 #if defined(ENABLE_PEPPER_CDMS) 41 #if defined(ENABLE_PEPPER_CDMS)
42 const CreatePepperCdmCB& create_pepper_cdm_cb, 42 const CreatePepperCdmCB& create_pepper_cdm_cb,
43 #elif defined(OS_ANDROID) 43 #elif defined(OS_ANDROID)
44 RendererMediaPlayerManager* manager, 44 RendererMediaPlayerManager* manager,
45 int cdm_id,
46 #endif // defined(ENABLE_PEPPER_CDMS) 45 #endif // defined(ENABLE_PEPPER_CDMS)
47 const KeyAddedCB& key_added_cb, 46 const KeyAddedCB& key_added_cb,
48 const KeyErrorCB& key_error_cb, 47 const KeyErrorCB& key_error_cb,
49 const KeyMessageCB& key_message_cb) 48 const KeyMessageCB& key_message_cb)
50 : weak_ptr_factory_(this), 49 : weak_ptr_factory_(this),
51 #if defined(ENABLE_PEPPER_CDMS) 50 #if defined(ENABLE_PEPPER_CDMS)
52 create_pepper_cdm_cb_(create_pepper_cdm_cb), 51 create_pepper_cdm_cb_(create_pepper_cdm_cb),
53 #elif defined(OS_ANDROID) 52 #elif defined(OS_ANDROID)
54 manager_(manager), 53 manager_(manager),
55 cdm_id_(cdm_id), 54 cdm_id_(RendererMediaPlayerManager::kInvalidCdmId),
56 #endif // defined(ENABLE_PEPPER_CDMS) 55 #endif // defined(ENABLE_PEPPER_CDMS)
57 key_added_cb_(key_added_cb), 56 key_added_cb_(key_added_cb),
58 key_error_cb_(key_error_cb), 57 key_error_cb_(key_error_cb),
59 key_message_cb_(key_message_cb), 58 key_message_cb_(key_message_cb),
60 is_clear_key_(false) { 59 is_clear_key_(false) {
61 #if defined(ENABLE_PEPPER_CDMS) 60 #if defined(ENABLE_PEPPER_CDMS)
62 DCHECK(!create_pepper_cdm_cb_.is_null()); 61 DCHECK(!create_pepper_cdm_cb_.is_null());
63 #endif // defined(ENABLE_PEPPER_CDMS) 62 #endif // defined(ENABLE_PEPPER_CDMS)
64 DCHECK(!key_added_cb_.is_null()); 63 DCHECK(!key_added_cb_.is_null());
65 DCHECK(!key_error_cb_.is_null()); 64 DCHECK(!key_error_cb_.is_null());
66 DCHECK(!key_message_cb_.is_null()); 65 DCHECK(!key_message_cb_.is_null());
67 } 66 }
68 67
69 ProxyDecryptor::~ProxyDecryptor() { 68 ProxyDecryptor::~ProxyDecryptor() {
70 // Destroy the decryptor explicitly before destroying the plugin. 69 // Destroy the decryptor explicitly before destroying the plugin.
71 media_keys_.reset(); 70 media_keys_.reset();
72 } 71 }
73 72
74 media::Decryptor* ProxyDecryptor::GetDecryptor() { 73 media::Decryptor* ProxyDecryptor::GetDecryptor() {
75 return media_keys_ ? media_keys_->GetDecryptor() : NULL; 74 return media_keys_ ? media_keys_->GetDecryptor() : NULL;
76 } 75 }
77 76
77 int ProxyDecryptor::GetCdmId() {
78 return cdm_id_;
79 }
80
78 bool ProxyDecryptor::InitializeCDM(const std::string& key_system, 81 bool ProxyDecryptor::InitializeCDM(const std::string& key_system,
79 const GURL& frame_url) { 82 const GURL& frame_url) {
80 DVLOG(1) << "InitializeCDM: key_system = " << key_system; 83 DVLOG(1) << "InitializeCDM: key_system = " << key_system;
81 84
82 DCHECK(!media_keys_); 85 DCHECK(!media_keys_);
83 media_keys_ = CreateMediaKeys(key_system, frame_url); 86 media_keys_ = CreateMediaKeys(key_system, frame_url);
84 if (!media_keys_) 87 if (!media_keys_)
85 return false; 88 return false;
86 89
87 is_clear_key_ = 90 is_clear_key_ =
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 186
184 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( 187 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys(
185 const std::string& key_system, 188 const std::string& key_system,
186 const GURL& frame_url) { 189 const GURL& frame_url) {
187 return ContentDecryptionModuleFactory::Create( 190 return ContentDecryptionModuleFactory::Create(
188 key_system, 191 key_system,
189 #if defined(ENABLE_PEPPER_CDMS) 192 #if defined(ENABLE_PEPPER_CDMS)
190 create_pepper_cdm_cb_, 193 create_pepper_cdm_cb_,
191 #elif defined(OS_ANDROID) 194 #elif defined(OS_ANDROID)
192 manager_, 195 manager_,
193 cdm_id_,
194 frame_url, 196 frame_url,
197 &cdm_id_,
195 #endif // defined(ENABLE_PEPPER_CDMS) 198 #endif // defined(ENABLE_PEPPER_CDMS)
196 base::Bind(&ProxyDecryptor::OnSessionCreated, 199 base::Bind(&ProxyDecryptor::OnSessionCreated,
197 weak_ptr_factory_.GetWeakPtr()), 200 weak_ptr_factory_.GetWeakPtr()),
198 base::Bind(&ProxyDecryptor::OnSessionMessage, 201 base::Bind(&ProxyDecryptor::OnSessionMessage,
199 weak_ptr_factory_.GetWeakPtr()), 202 weak_ptr_factory_.GetWeakPtr()),
200 base::Bind(&ProxyDecryptor::OnSessionReady, 203 base::Bind(&ProxyDecryptor::OnSessionReady,
201 weak_ptr_factory_.GetWeakPtr()), 204 weak_ptr_factory_.GetWeakPtr()),
202 base::Bind(&ProxyDecryptor::OnSessionClosed, 205 base::Bind(&ProxyDecryptor::OnSessionClosed,
203 weak_ptr_factory_.GetWeakPtr()), 206 weak_ptr_factory_.GetWeakPtr()),
204 base::Bind(&ProxyDecryptor::OnSessionError, 207 base::Bind(&ProxyDecryptor::OnSessionError,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 265
263 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) const { 266 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) const {
264 DCHECK_NE(session_id, kInvalidSessionId); 267 DCHECK_NE(session_id, kInvalidSessionId);
265 268
266 // Session may not exist if error happens during GenerateKeyRequest(). 269 // Session may not exist if error happens during GenerateKeyRequest().
267 SessionIdMap::const_iterator it = sessions_.find(session_id); 270 SessionIdMap::const_iterator it = sessions_.find(session_id);
268 return (it != sessions_.end()) ? it->second : base::EmptyString(); 271 return (it != sessions_.end()) ? it->second : base::EmptyString();
269 } 272 }
270 273
271 } // namespace content 274 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698