OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/media/crypto/proxy_decryptor.h" | 5 #include "webkit/media/crypto/proxy_decryptor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/crypto/aes_decryptor.h" | 10 #include "media/crypto/aes_decryptor.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // We do not support run-time switching of decryptors. GenerateKeyRequest() | 118 // We do not support run-time switching of decryptors. GenerateKeyRequest() |
119 // only creates a new decryptor when |decryptor_| is not initialized. | 119 // only creates a new decryptor when |decryptor_| is not initialized. |
120 DVLOG(1) << "GenerateKeyRequest: key_system = " << key_system; | 120 DVLOG(1) << "GenerateKeyRequest: key_system = " << key_system; |
121 | 121 |
122 base::AutoLock auto_lock(lock_); | 122 base::AutoLock auto_lock(lock_); |
123 | 123 |
124 if (!decryptor_) { | 124 if (!decryptor_) { |
125 decryptor_ = CreateDecryptor(key_system); | 125 decryptor_ = CreateDecryptor(key_system); |
126 if (!decryptor_) { | 126 if (!decryptor_) { |
127 key_error_cb_.Run( | 127 key_error_cb_.Run( |
128 key_system, std::string(), media::Decryptor::kClientError, 0); | 128 key_system, std::string(), media::MediaKeys::kClientError, 0); |
129 return false; | 129 return false; |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 if (!decryptor_->GenerateKeyRequest(key_system, type, | 133 if (!decryptor_->GetMediaKeys()->GenerateKeyRequest( |
134 init_data, init_data_length)) { | 134 key_system, type, init_data, init_data_length)) { |
135 decryptor_.reset(); | 135 decryptor_.reset(); |
136 return false; | 136 return false; |
137 } | 137 } |
138 | 138 |
139 if (!decryptor_ready_cb_.is_null()) | 139 if (!decryptor_ready_cb_.is_null()) |
140 base::ResetAndReturn(&decryptor_ready_cb_).Run(decryptor_.get()); | 140 base::ResetAndReturn(&decryptor_ready_cb_).Run(decryptor_.get()); |
141 | 141 |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 void ProxyDecryptor::AddKey(const std::string& key_system, | 145 void ProxyDecryptor::AddKey(const std::string& key_system, |
146 const uint8* key, | 146 const uint8* key, |
147 int key_length, | 147 int key_length, |
148 const uint8* init_data, | 148 const uint8* init_data, |
149 int init_data_length, | 149 int init_data_length, |
150 const std::string& session_id) { | 150 const std::string& session_id) { |
151 DVLOG(1) << "AddKey()"; | 151 DVLOG(1) << "AddKey()"; |
152 | 152 |
153 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. | 153 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. |
154 decryptor_->AddKey(key_system, key, key_length, init_data, init_data_length, | 154 decryptor_->GetMediaKeys()->AddKey( |
155 session_id); | 155 key_system, key, key_length, init_data, init_data_length, session_id); |
156 } | 156 } |
157 | 157 |
158 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system, | 158 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system, |
159 const std::string& session_id) { | 159 const std::string& session_id) { |
160 DVLOG(1) << "CancelKeyRequest()"; | 160 DVLOG(1) << "CancelKeyRequest()"; |
161 | 161 |
162 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. | 162 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. |
163 decryptor_->CancelKeyRequest(key_system, session_id); | 163 decryptor_->GetMediaKeys()->CancelKeyRequest(key_system, session_id); |
164 } | 164 } |
165 | 165 |
166 #if defined(ENABLE_PEPPER_CDMS) | 166 #if defined(ENABLE_PEPPER_CDMS) |
167 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor( | 167 scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor( |
168 const std::string& key_system) { | 168 const std::string& key_system) { |
169 DCHECK(web_media_player_client_); | 169 DCHECK(web_media_player_client_); |
170 DCHECK(web_frame_); | 170 DCHECK(web_frame_); |
171 | 171 |
172 std::string plugin_type = GetPepperType(key_system); | 172 std::string plugin_type = GetPepperType(key_system); |
173 DCHECK(!plugin_type.empty()); | 173 DCHECK(!plugin_type.empty()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 #endif // defined(ENABLE_PEPPER_CDMS) | 207 #endif // defined(ENABLE_PEPPER_CDMS) |
208 } | 208 } |
209 | 209 |
210 void ProxyDecryptor::KeyAdded(const std::string& key_system, | 210 void ProxyDecryptor::KeyAdded(const std::string& key_system, |
211 const std::string& session_id) { | 211 const std::string& session_id) { |
212 key_added_cb_.Run(key_system, session_id); | 212 key_added_cb_.Run(key_system, session_id); |
213 } | 213 } |
214 | 214 |
215 void ProxyDecryptor::KeyError(const std::string& key_system, | 215 void ProxyDecryptor::KeyError(const std::string& key_system, |
216 const std::string& session_id, | 216 const std::string& session_id, |
217 media::Decryptor::KeyError error_code, | 217 media::MediaKeys::KeyError error_code, |
218 int system_code) { | 218 int system_code) { |
219 key_error_cb_.Run(key_system, session_id, error_code, system_code); | 219 key_error_cb_.Run(key_system, session_id, error_code, system_code); |
220 } | 220 } |
221 | 221 |
222 void ProxyDecryptor::KeyMessage(const std::string& key_system, | 222 void ProxyDecryptor::KeyMessage(const std::string& key_system, |
223 const std::string& session_id, | 223 const std::string& session_id, |
224 const std::string& message, | 224 const std::string& message, |
225 const std::string& default_url) { | 225 const std::string& default_url) { |
226 key_message_cb_.Run(key_system, session_id, message, default_url); | 226 key_message_cb_.Run(key_system, session_id, message, default_url); |
227 } | 227 } |
228 | 228 |
229 void ProxyDecryptor::NeedKey(const std::string& key_system, | 229 void ProxyDecryptor::NeedKey(const std::string& key_system, |
230 const std::string& session_id, | 230 const std::string& session_id, |
231 const std::string& type, | 231 const std::string& type, |
232 scoped_ptr<uint8[]> init_data, | 232 scoped_ptr<uint8[]> init_data, |
233 int init_data_size) { | 233 int init_data_size) { |
234 need_key_cb_.Run(key_system, session_id, type, | 234 need_key_cb_.Run(key_system, session_id, type, |
235 init_data.Pass(), init_data_size); | 235 init_data.Pass(), init_data_size); |
236 } | 236 } |
237 | 237 |
238 } // namespace webkit_media | 238 } // namespace webkit_media |
OLD | NEW |