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

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: remove leftover unretained 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
« no previous file with comments | « media/crypto/aes_decryptor.h ('k') | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "crypto/encryptor.h" 12 #include "crypto/encryptor.h"
13 #include "crypto/symmetric_key.h" 13 #include "crypto/symmetric_key.h"
14 #include "media/base/audio_decoder_config.h"
14 #include "media/base/decoder_buffer.h" 15 #include "media/base/decoder_buffer.h"
15 #include "media/base/decrypt_config.h" 16 #include "media/base/decrypt_config.h"
16 #include "media/base/decryptor_client.h" 17 #include "media/base/decryptor_client.h"
17 #include "media/base/video_decoder_config.h" 18 #include "media/base/video_decoder_config.h"
18 #include "media/base/video_frame.h" 19 #include "media/base/video_frame.h"
19 20
20 namespace media { 21 namespace media {
21 22
22 uint32 AesDecryptor::next_session_id_ = 1; 23 uint32 AesDecryptor::next_session_id_ = 1;
23 24
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 192 }
192 193
193 SetKey(key_id_string, decryption_key.Pass()); 194 SetKey(key_id_string, decryption_key.Pass());
194 client_->KeyAdded(key_system, session_id); 195 client_->KeyAdded(key_system, session_id);
195 } 196 }
196 197
197 void AesDecryptor::CancelKeyRequest(const std::string& key_system, 198 void AesDecryptor::CancelKeyRequest(const std::string& key_system,
198 const std::string& session_id) { 199 const std::string& session_id) {
199 } 200 }
200 201
201 void AesDecryptor::Decrypt(const scoped_refptr<DecoderBuffer>& encrypted, 202 void AesDecryptor::Decrypt(StreamType stream_type,
203 const scoped_refptr<DecoderBuffer>& encrypted,
202 const DecryptCB& decrypt_cb) { 204 const DecryptCB& decrypt_cb) {
203 CHECK(encrypted->GetDecryptConfig()); 205 CHECK(encrypted->GetDecryptConfig());
204 const std::string& key_id = encrypted->GetDecryptConfig()->key_id(); 206 const std::string& key_id = encrypted->GetDecryptConfig()->key_id();
205 207
206 DecryptionKey* key = GetKey(key_id); 208 DecryptionKey* key = GetKey(key_id);
207 if (!key) { 209 if (!key) {
208 DVLOG(1) << "Could not find a matching key for the given key ID."; 210 DVLOG(1) << "Could not find a matching key for the given key ID.";
209 decrypt_cb.Run(kNoKey, NULL); 211 decrypt_cb.Run(kNoKey, NULL);
210 return; 212 return;
211 } 213 }
(...skipping 12 matching lines...) Expand all
224 decrypt_cb.Run(kError, NULL); 226 decrypt_cb.Run(kError, NULL);
225 return; 227 return;
226 } 228 }
227 } 229 }
228 230
229 decrypted->SetTimestamp(encrypted->GetTimestamp()); 231 decrypted->SetTimestamp(encrypted->GetTimestamp());
230 decrypted->SetDuration(encrypted->GetDuration()); 232 decrypted->SetDuration(encrypted->GetDuration());
231 decrypt_cb.Run(kSuccess, decrypted); 233 decrypt_cb.Run(kSuccess, decrypted);
232 } 234 }
233 235
234 void AesDecryptor::CancelDecrypt() { 236 void AesDecryptor::CancelDecrypt(StreamType stream_type) {
237 // Decrypt() calls the DecryptCB synchronously so there's nothing to cancel.
238 }
239
240 void AesDecryptor::InitializeAudioDecoder(scoped_ptr<AudioDecoderConfig> config,
241 const DecoderInitCB& init_cb,
242 const KeyAddedCB& key_added_cb) {
243 // AesDecryptor does not support audio decoding.
244 init_cb.Run(false);
235 } 245 }
236 246
237 void AesDecryptor::InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config, 247 void AesDecryptor::InitializeVideoDecoder(scoped_ptr<VideoDecoderConfig> config,
238 const DecoderInitCB& init_cb, 248 const DecoderInitCB& init_cb,
239 const KeyAddedCB& key_added_cb) { 249 const KeyAddedCB& key_added_cb) {
240 // AesDecryptor does not support video decoding. 250 // AesDecryptor does not support video decoding.
241 init_cb.Run(false); 251 init_cb.Run(false);
242 } 252 }
243 253
254 void AesDecryptor::DecryptAndDecodeAudio(
255 const scoped_refptr<DecoderBuffer>& encrypted,
256 const AudioDecodeCB& audio_decode_cb) {
257 NOTREACHED() << "AesDecryptor does not support audio decoding";
258 }
259
244 void AesDecryptor::DecryptAndDecodeVideo( 260 void AesDecryptor::DecryptAndDecodeVideo(
245 const scoped_refptr<DecoderBuffer>& encrypted, 261 const scoped_refptr<DecoderBuffer>& encrypted,
246 const VideoDecodeCB& video_decode_cb) { 262 const VideoDecodeCB& video_decode_cb) {
247 NOTREACHED() << "AesDecryptor does not support video decoding"; 263 NOTREACHED() << "AesDecryptor does not support video decoding";
248 } 264 }
249 265
250 void AesDecryptor::CancelDecryptAndDecodeVideo() { 266 void AesDecryptor::ResetDecoder(StreamType stream_type) {
251 NOTREACHED() << "AesDecryptor does not support video decoding"; 267 NOTREACHED() << "AesDecryptor does not support audio/video decoding";
252 } 268 }
253 269
254 void AesDecryptor::StopVideoDecoder() { 270 void AesDecryptor::DeinitializeDecoder(StreamType stream_type) {
255 NOTREACHED() << "AesDecryptor does not support video decoding"; 271 NOTREACHED() << "AesDecryptor does not support audio/video decoding";
256 } 272 }
257 273
258 void AesDecryptor::SetKey(const std::string& key_id, 274 void AesDecryptor::SetKey(const std::string& key_id,
259 scoped_ptr<DecryptionKey> decryption_key) { 275 scoped_ptr<DecryptionKey> decryption_key) {
260 base::AutoLock auto_lock(key_map_lock_); 276 base::AutoLock auto_lock(key_map_lock_);
261 KeyMap::iterator found = key_map_.find(key_id); 277 KeyMap::iterator found = key_map_.find(key_id);
262 if (found != key_map_.end()) { 278 if (found != key_map_.end()) {
263 delete found->second; 279 delete found->second;
264 key_map_.erase(found); 280 key_map_.erase(found);
265 } 281 }
(...skipping 19 matching lines...) Expand all
285 bool AesDecryptor::DecryptionKey::Init() { 301 bool AesDecryptor::DecryptionKey::Init() {
286 CHECK(!secret_.empty()); 302 CHECK(!secret_.empty());
287 decryption_key_.reset(crypto::SymmetricKey::Import( 303 decryption_key_.reset(crypto::SymmetricKey::Import(
288 crypto::SymmetricKey::AES, secret_)); 304 crypto::SymmetricKey::AES, secret_));
289 if (!decryption_key_.get()) 305 if (!decryption_key_.get())
290 return false; 306 return false;
291 return true; 307 return true;
292 } 308 }
293 309
294 } // namespace media 310 } // namespace media
OLDNEW
« no previous file with comments | « media/crypto/aes_decryptor.h ('k') | media/crypto/aes_decryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698