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

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: rebase only Created 6 years, 8 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 : 49 :
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 weak_ptr_factory_(this) { 60 weak_ptr_factory_(this) {
62 #if defined(ENABLE_PEPPER_CDMS) 61 #if defined(ENABLE_PEPPER_CDMS)
63 DCHECK(!create_pepper_cdm_cb_.is_null()); 62 DCHECK(!create_pepper_cdm_cb_.is_null());
64 #endif // defined(ENABLE_PEPPER_CDMS) 63 #endif // defined(ENABLE_PEPPER_CDMS)
65 DCHECK(!key_added_cb_.is_null()); 64 DCHECK(!key_added_cb_.is_null());
66 DCHECK(!key_error_cb_.is_null()); 65 DCHECK(!key_error_cb_.is_null());
67 DCHECK(!key_message_cb_.is_null()); 66 DCHECK(!key_message_cb_.is_null());
68 } 67 }
69 68
70 ProxyDecryptor::~ProxyDecryptor() { 69 ProxyDecryptor::~ProxyDecryptor() {
71 // Destroy the decryptor explicitly before destroying the plugin. 70 // Destroy the decryptor explicitly before destroying the plugin.
72 media_keys_.reset(); 71 media_keys_.reset();
73 } 72 }
74 73
75 media::Decryptor* ProxyDecryptor::GetDecryptor() { 74 media::Decryptor* ProxyDecryptor::GetDecryptor() {
76 return media_keys_ ? media_keys_->GetDecryptor() : NULL; 75 return media_keys_ ? media_keys_->GetDecryptor() : NULL;
77 } 76 }
78 77
78 #if defined(OS_ANDROID)
79 int ProxyDecryptor::GetCdmId() {
80 return cdm_id_;
81 }
82 #endif
83
79 bool ProxyDecryptor::InitializeCDM(const std::string& key_system, 84 bool ProxyDecryptor::InitializeCDM(const std::string& key_system,
80 const GURL& frame_url) { 85 const GURL& frame_url) {
81 DVLOG(1) << "InitializeCDM: key_system = " << key_system; 86 DVLOG(1) << "InitializeCDM: key_system = " << key_system;
82 87
83 DCHECK(!media_keys_); 88 DCHECK(!media_keys_);
84 media_keys_ = CreateMediaKeys(key_system, frame_url); 89 media_keys_ = CreateMediaKeys(key_system, frame_url);
85 if (!media_keys_) 90 if (!media_keys_)
86 return false; 91 return false;
87 92
88 is_clear_key_ = 93 is_clear_key_ =
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 189
185 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys( 190 scoped_ptr<media::MediaKeys> ProxyDecryptor::CreateMediaKeys(
186 const std::string& key_system, 191 const std::string& key_system,
187 const GURL& frame_url) { 192 const GURL& frame_url) {
188 return ContentDecryptionModuleFactory::Create( 193 return ContentDecryptionModuleFactory::Create(
189 key_system, 194 key_system,
190 #if defined(ENABLE_PEPPER_CDMS) 195 #if defined(ENABLE_PEPPER_CDMS)
191 create_pepper_cdm_cb_, 196 create_pepper_cdm_cb_,
192 #elif defined(OS_ANDROID) 197 #elif defined(OS_ANDROID)
193 manager_, 198 manager_,
194 cdm_id_,
195 frame_url, 199 frame_url,
200 &cdm_id_,
196 #endif // defined(ENABLE_PEPPER_CDMS) 201 #endif // defined(ENABLE_PEPPER_CDMS)
197 base::Bind(&ProxyDecryptor::OnSessionCreated, 202 base::Bind(&ProxyDecryptor::OnSessionCreated,
198 weak_ptr_factory_.GetWeakPtr()), 203 weak_ptr_factory_.GetWeakPtr()),
199 base::Bind(&ProxyDecryptor::OnSessionMessage, 204 base::Bind(&ProxyDecryptor::OnSessionMessage,
200 weak_ptr_factory_.GetWeakPtr()), 205 weak_ptr_factory_.GetWeakPtr()),
201 base::Bind(&ProxyDecryptor::OnSessionReady, 206 base::Bind(&ProxyDecryptor::OnSessionReady,
202 weak_ptr_factory_.GetWeakPtr()), 207 weak_ptr_factory_.GetWeakPtr()),
203 base::Bind(&ProxyDecryptor::OnSessionClosed, 208 base::Bind(&ProxyDecryptor::OnSessionClosed,
204 weak_ptr_factory_.GetWeakPtr()), 209 weak_ptr_factory_.GetWeakPtr()),
205 base::Bind(&ProxyDecryptor::OnSessionError, 210 base::Bind(&ProxyDecryptor::OnSessionError,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 268
264 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) const { 269 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) const {
265 DCHECK_NE(session_id, kInvalidSessionId); 270 DCHECK_NE(session_id, kInvalidSessionId);
266 271
267 // Session may not exist if error happens during GenerateKeyRequest(). 272 // Session may not exist if error happens during GenerateKeyRequest().
268 SessionIdMap::const_iterator it = sessions_.find(session_id); 273 SessionIdMap::const_iterator it = sessions_.find(session_id);
269 return (it != sessions_.end()) ? it->second : base::EmptyString(); 274 return (it != sessions_.end()) ? it->second : base::EmptyString();
270 } 275 }
271 276
272 } // namespace content 277 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698