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

Side by Side Diff: media/crypto/aes_decryptor.cc

Issue 11144036: Update Decryptor interface to support audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify AudioBuffers Created 8 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 | Annotate | Revision Log
OLDNEW
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 "media/crypto/aes_decryptor.h" 5 #include "media/crypto/aes_decryptor.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 SetKey(key_id_string, decryption_key.Pass()); 193 SetKey(key_id_string, decryption_key.Pass());
194 client_->KeyAdded(key_system, session_id); 194 client_->KeyAdded(key_system, session_id);
195 } 195 }
196 196
197 void AesDecryptor::CancelKeyRequest(const std::string& key_system, 197 void AesDecryptor::CancelKeyRequest(const std::string& key_system,
198 const std::string& session_id) { 198 const std::string& session_id) {
199 } 199 }
200 200
201 void AesDecryptor::Decrypt(const scoped_refptr<DecoderBuffer>& encrypted, 201 void AesDecryptor::Decrypt(StreamType stream_type,
202 const scoped_refptr<DecoderBuffer>& encrypted,
202 const DecryptCB& decrypt_cb) { 203 const DecryptCB& decrypt_cb) {
203 CHECK(encrypted->GetDecryptConfig()); 204 CHECK(encrypted->GetDecryptConfig());
204 const std::string& key_id = encrypted->GetDecryptConfig()->key_id(); 205 const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
205 206
206 DecryptionKey* key = GetKey(key_id); 207 DecryptionKey* key = GetKey(key_id);
207 if (!key) { 208 if (!key) {
208 DVLOG(1) << "Could not find a matching key for the given key ID."; 209 DVLOG(1) << "Could not find a matching key for the given key ID.";
209 decrypt_cb.Run(kNoKey, NULL); 210 decrypt_cb.Run(kNoKey, NULL);
210 return; 211 return;
211 } 212 }
(...skipping 12 matching lines...) Expand all
224 decrypt_cb.Run(kError, NULL); 225 decrypt_cb.Run(kError, NULL);
225 return; 226 return;
226 } 227 }
227 } 228 }
228 229
229 decrypted->SetTimestamp(encrypted->GetTimestamp()); 230 decrypted->SetTimestamp(encrypted->GetTimestamp());
230 decrypted->SetDuration(encrypted->GetDuration()); 231 decrypted->SetDuration(encrypted->GetDuration());
231 decrypt_cb.Run(kSuccess, decrypted); 232 decrypt_cb.Run(kSuccess, decrypted);
232 } 233 }
233 234
234 void AesDecryptor::CancelDecrypt() { 235 void AesDecryptor::CancelDecrypt(StreamType stream_type) {
236 // Decrypt() calls the DecryptCB synchronously so there's nothing to cancel.
237 }
238
239 void AesDecryptor::InitializeAudioDecoder(scoped_ptr<AudioDecoderConfig> config,
240 const DecoderInitCB& init_cb,
241 const KeyAddedCB& key_added_cb) {
242 // AesDecryptor does not support audio decoding.
243 init_cb.Run(false);
235 } 244 }
236 245
237 void AesDecryptor::InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config, 246 void AesDecryptor::InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config,
238 const DecoderInitCB& init_cb, 247 const DecoderInitCB& init_cb,
239 const KeyAddedCB& key_added_cb) { 248 const KeyAddedCB& key_added_cb) {
240 // AesDecryptor does not support video decoding. 249 // AesDecryptor does not support video decoding.
241 init_cb.Run(false); 250 init_cb.Run(false);
242 } 251 }
243 252
253 void AesDecryptor::DecryptAndDecodeAudio(
254 const scoped_refptr<DecoderBuffer>& encrypted,
255 const AudioDecodeCB& audio_decode_cb) {
256 NOTREACHED() << "AesDecryptor does not support audio decoding";
257 }
258
244 void AesDecryptor::DecryptAndDecodeVideo( 259 void AesDecryptor::DecryptAndDecodeVideo(
245 const scoped_refptr<DecoderBuffer>& encrypted, 260 const scoped_refptr<DecoderBuffer>& encrypted,
246 const VideoDecodeCB& video_decode_cb) { 261 const VideoDecodeCB& video_decode_cb) {
247 NOTREACHED() << "AesDecryptor does not support video decoding"; 262 NOTREACHED() << "AesDecryptor does not support video decoding";
248 } 263 }
249 264
250 void AesDecryptor::CancelDecryptAndDecodeVideo() { 265 void AesDecryptor::ResetDecoder(StreamType stream_type) {
251 NOTREACHED() << "AesDecryptor does not support video decoding"; 266 NOTREACHED() << "AesDecryptor does not support audio/video decoding";
252 } 267 }
253 268
254 void AesDecryptor::StopVideoDecoder() { 269 void AesDecryptor::DeinitializeDecoder(StreamType stream_type) {
255 NOTREACHED() << "AesDecryptor does not support video decoding"; 270 NOTREACHED() << "AesDecryptor does not support audio/video decoding";
256 } 271 }
257 272
258 void AesDecryptor::SetKey(const std::string& key_id, 273 void AesDecryptor::SetKey(const std::string& key_id,
259 scoped_ptr<DecryptionKey> decryption_key) { 274 scoped_ptr<DecryptionKey> decryption_key) {
260 base::AutoLock auto_lock(key_map_lock_); 275 base::AutoLock auto_lock(key_map_lock_);
261 KeyMap::iterator found = key_map_.find(key_id); 276 KeyMap::iterator found = key_map_.find(key_id);
262 if (found != key_map_.end()) { 277 if (found != key_map_.end()) {
263 delete found->second; 278 delete found->second;
264 key_map_.erase(found); 279 key_map_.erase(found);
265 } 280 }
(...skipping 19 matching lines...) Expand all
285 bool AesDecryptor::DecryptionKey::Init() { 300 bool AesDecryptor::DecryptionKey::Init() {
286 CHECK(!secret_.empty()); 301 CHECK(!secret_.empty());
287 decryption_key_.reset(crypto::SymmetricKey::Import( 302 decryption_key_.reset(crypto::SymmetricKey::Import(
288 crypto::SymmetricKey::AES, secret_)); 303 crypto::SymmetricKey::AES, secret_));
289 if (!decryption_key_.get()) 304 if (!decryption_key_.get())
290 return false; 305 return false;
291 return true; 306 return true;
292 } 307 }
293 308
294 } // namespace media 309 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698