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

Side by Side Diff: webkit/media/crypto/proxy_decryptor.cc

Issue 10575026: Add ProxyDecryptor which wraps concrete Decryptor implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits and rebased. Created 8 years, 5 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 | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/key_systems.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/media/crypto/proxy_decryptor.h"
6
7 #include "base/logging.h"
8 #include "media/base/decoder_buffer.h"
9 #include "media/base/decryptor_client.h"
10 #include "media/crypto/aes_decryptor.h"
11 #include "webkit/media/crypto/key_systems.h"
12
13 namespace webkit_media {
14
15 ProxyDecryptor::ProxyDecryptor(media::DecryptorClient* client)
16 : client_(client) {
17 }
18
19 ProxyDecryptor::~ProxyDecryptor() {
20 }
21
22 void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
23 const uint8* init_data,
24 int init_data_length) {
25 // We do not support run-time switching of decryptors. GenerateKeyRequest()
26 // only creates a new decryptor when |decryptor_| is not initialized.
27 if (!decryptor_.get()) {
28 base::AutoLock auto_lock(lock_);
29 decryptor_ = CreateDecryptor(key_system, client_);
30 }
31
32 DCHECK(decryptor_.get());
33 decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length);
34 }
35
36 void ProxyDecryptor::AddKey(const std::string& key_system,
37 const uint8* key,
38 int key_length,
39 const uint8* init_data,
40 int init_data_length,
41 const std::string& session_id) {
42 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called.
43 DCHECK(decryptor_.get());
44 decryptor_->AddKey(key_system, key, key_length, init_data, init_data_length,
45 session_id);
46 }
47
48 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system,
49 const std::string& session_id) {
50 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called.
51 DCHECK(decryptor_.get());
52 decryptor_->CancelKeyRequest(key_system, session_id);
53 }
54
55 scoped_refptr<media::DecoderBuffer> ProxyDecryptor::Decrypt(
56 const scoped_refptr<media::DecoderBuffer>& input) {
57 // This is safe as we do not replace/delete an existing decryptor at run-time.
58 Decryptor* decryptor = NULL;
59 {
60 base::AutoLock auto_lock(lock_);
61 decryptor = decryptor_.get();
62 }
63 if (!decryptor)
64 return NULL;
65
66 return decryptor->Decrypt(input);
67 }
68
69 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/key_systems.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698