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

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

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/key_systems.cc ('k') | webkit/media/crypto/proxy_decryptor.cc » ('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 #ifndef WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "media/base/decryptor.h"
13
14 namespace media {
15 class DecryptorClient;
16 }
17
18 namespace webkit_media {
19
20 // A decryptor proxy that creates a real decryptor object on demand and
21 // forwards decryptor calls to it.
22 // TODO(xhwang): Currently we don't support run-time switching among decryptor
23 // objects. Fix this when needed.
24 class ProxyDecryptor : public media::Decryptor {
25 public:
26 explicit ProxyDecryptor(media::DecryptorClient* client);
27 virtual ~ProxyDecryptor();
28
29 // media::Decryptor implementation.
30 virtual void GenerateKeyRequest(const std::string& key_system,
31 const uint8* init_data,
32 int init_data_length) OVERRIDE;
33 virtual void AddKey(const std::string& key_system,
34 const uint8* key,
35 int key_length,
36 const uint8* init_data,
37 int init_data_length,
38 const std::string& session_id) OVERRIDE;
39 virtual void CancelKeyRequest(const std::string& key_system,
40 const std::string& session_id) OVERRIDE;
41 virtual scoped_refptr<media::DecoderBuffer> Decrypt(
42 const scoped_refptr<media::DecoderBuffer>& input) OVERRIDE;
43
44 private:
45 media::DecryptorClient* const client_;
46 // Protects the |decryptor_|. The Decryptor interface specifies that the
47 // Decrypt() function will be called on the decoder thread and all other
48 // methods on the renderer thread. The |decryptor_| itself is thread safe
49 // when this rule is obeyed. This lock is solely to prevent the race condition
50 // between setting the |decryptor_| in GenerateKeyRequest() and using it in
51 // Decrypt().
52 base::Lock lock_;
53 scoped_ptr<media::Decryptor> decryptor_; // Protected by the |lock_|.
54
55 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
56 };
57
58 } // namespace webkit_media
59
60 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
OLDNEW
« no previous file with comments | « webkit/media/crypto/key_systems.cc ('k') | webkit/media/crypto/proxy_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698