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