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

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: Move proxy_decryptor.* into webkit/media/crypto/ Created 8 years, 6 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
(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
12 namespace webkit_media {
13
14 namespace {
15
16 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
scherkus (not reviewing) 2012/06/21 21:17:16 this is declared in webkit/media/key_systems.cc --
xhwang 2012/06/22 16:57:30 Will do.
xhwang 2012/06/26 23:45:50 Done.
17
18 } // namespace
19
20 ProxyDecryptor::ProxyDecryptor(media::DecryptorClient* client)
21 : client_(client) {
22 }
23
24 ProxyDecryptor::~ProxyDecryptor() {
25 }
26
27 void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
28 const uint8* init_data,
29 int init_data_length) {
30 // We do not support run-time switching of decryptors. GenerateKeyRequest()
31 // should only be called when the decryptor is not initialized, or on the
32 // existing decryptor associated with the |current_key_system_|.
33 DCHECK(!decryptor_.get() || key_system == current_key_system_);
34
35 if (!decryptor_.get()) {
36 if (key_system == kClearKeyKeySystem) {
37 base::AutoLock auto_lock(lock_);
38 decryptor_.reset(new media::AesDecryptor(client_));
scherkus (not reviewing) 2012/06/21 21:17:16 is there a disadvantage to creating this in the ct
xhwang 2012/06/22 16:57:30 Currently we don't allow run-time switching betwee
39 current_key_system_ = key_system;
40 } else {
41 NOTREACHED();
scherkus (not reviewing) 2012/06/21 21:17:16 can these DCHECKs be triggered via JS? i.e., I cal
xhwang 2012/06/22 16:57:30 No. The WMPI will check IsSupportedKeySystem() and
42 }
43 }
44
45 decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length);
46 }
47
48 void ProxyDecryptor::AddKey(const std::string& key_system,
49 const uint8* key,
50 int key_length,
51 const uint8* init_data,
52 int init_data_length,
53 const std::string& session_id) {
54 DCHECK(decryptor_.get() && key_system == current_key_system_);
scherkus (not reviewing) 2012/06/21 21:17:16 instead of && split the DCHECKs
xhwang 2012/06/22 16:57:30 Will do.
xhwang 2012/06/26 23:45:50 Done.
55 decryptor_->AddKey(key_system, key, key_length, init_data, init_data_length,
56 session_id);
57 }
58
59 void ProxyDecryptor::CancelKeyRequest(const std::string& key_system,
60 const std::string& session_id) {
61 DCHECK(decryptor_.get() && key_system == current_key_system_);
scherkus (not reviewing) 2012/06/21 21:17:16 instead of && split the DCHECKs
xhwang 2012/06/22 16:57:30 Will do.
xhwang 2012/06/26 23:45:50 Done.
62 decryptor_->CancelKeyRequest(key_system, session_id);
63 }
64
65 scoped_refptr<media::DecoderBuffer> ProxyDecryptor::Decrypt(
66 const scoped_refptr<media::DecoderBuffer>& input) {
67 // This is safe as we do not replace/delete an existing decryptor at run-time.
68 Decryptor* decryptor = NULL;
69 {
70 base::AutoLock auto_lock(lock_);
71 decryptor = decryptor_.get();
72 }
73 if (!decryptor)
74 return NULL;
75
76 return decryptor->Decrypt(input);
77 }
78
79 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698