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

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

Issue 15772012: Separate MediaKeys interface from Decryptor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android Created 7 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
« no previous file with comments | « webkit/media/crypto/ppapi_decryptor.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
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 #ifndef WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 5 #ifndef WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "media/base/decryptor.h" 13 #include "media/base/decryptor.h"
14 #include "media/base/media_keys.h"
14 15
15 namespace WebKit { 16 namespace WebKit {
16 class WebFrame; 17 class WebFrame;
17 class WebMediaPlayerClient; 18 class WebMediaPlayerClient;
18 } 19 }
19 20
20 namespace webkit_media { 21 namespace webkit_media {
21 22
22 // A decryptor proxy that creates a real decryptor object on demand and 23 // A decryptor proxy that creates a real decryptor object on demand and
23 // forwards decryptor calls to it. 24 // forwards decryptor calls to it.
24 // TODO(xhwang): Currently we don't support run-time switching among decryptor 25 // TODO(xhwang): Currently we don't support run-time switching among decryptor
25 // objects. Fix this when needed. 26 // objects. Fix this when needed.
26 class ProxyDecryptor { 27 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name!
28 class ProxyDecryptor : public media::MediaKeys {
27 public: 29 public:
28 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client, 30 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client,
29 WebKit::WebFrame* web_frame, 31 WebKit::WebFrame* web_frame,
30 const media::KeyAddedCB& key_added_cb, 32 const media::KeyAddedCB& key_added_cb,
31 const media::KeyErrorCB& key_error_cb, 33 const media::KeyErrorCB& key_error_cb,
32 const media::KeyMessageCB& key_message_cb, 34 const media::KeyMessageCB& key_message_cb,
33 const media::NeedKeyCB& need_key_cb); 35 const media::NeedKeyCB& need_key_cb);
34 virtual ~ProxyDecryptor(); 36 virtual ~ProxyDecryptor();
35 37
36 // Requests the ProxyDecryptor to notify the decryptor when it's ready through 38 // Requests the ProxyDecryptor to notify the decryptor when it's ready through
37 // the |decryptor_ready_cb| provided. 39 // the |decryptor_ready_cb| provided.
38 // If |decryptor_ready_cb| is null, the existing callback will be fired with 40 // If |decryptor_ready_cb| is null, the existing callback will be fired with
39 // NULL immediately and reset. 41 // NULL immediately and reset.
40 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); 42 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb);
41 43
42 bool GenerateKeyRequest(const std::string& key_system, 44 // MediaKeys implementation.
43 const std::string& type, 45 virtual bool GenerateKeyRequest(const std::string& key_system,
44 const uint8* init_data, int init_data_length); 46 const std::string& type,
45 void AddKey(const std::string& key_system, 47 const uint8* init_data,
46 const uint8* key, int key_length, 48 int init_data_length) OVERRIDE;
47 const uint8* init_data, int init_data_length, 49 virtual void AddKey(const std::string& key_system,
48 const std::string& session_id); 50 const uint8* key, int key_length,
49 void CancelKeyRequest(const std::string& key_system, 51 const uint8* init_data, int init_data_length,
50 const std::string& session_id); 52 const std::string& session_id) OVERRIDE;
53 virtual void CancelKeyRequest(const std::string& key_system,
54 const std::string& session_id) OVERRIDE;
51 55
52 private: 56 private:
53 // Helper functions to create decryptors to handle the given |key_system|. 57 // Helper functions to create decryptors to handle the given |key_system|.
54 #if defined(ENABLE_PEPPER_CDMS) 58 #if defined(ENABLE_PEPPER_CDMS)
55 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( 59 scoped_ptr<media::Decryptor> CreatePpapiDecryptor(
56 const std::string& key_system); 60 const std::string& key_system);
57 #endif // defined(ENABLE_PEPPER_CDMS) 61 #endif // defined(ENABLE_PEPPER_CDMS)
58 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); 62 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system);
59 63
60 // Callbacks for firing key events. 64 // Callbacks for firing key events.
61 void KeyAdded(const std::string& key_system, const std::string& session_id); 65 void KeyAdded(const std::string& key_system, const std::string& session_id);
62 void KeyError(const std::string& key_system, 66 void KeyError(const std::string& key_system,
63 const std::string& session_id, 67 const std::string& session_id,
64 media::Decryptor::KeyError error_code, 68 media::MediaKeys::KeyError error_code,
65 int system_code); 69 int system_code);
66 void KeyMessage(const std::string& key_system, 70 void KeyMessage(const std::string& key_system,
67 const std::string& session_id, 71 const std::string& session_id,
68 const std::string& message, 72 const std::string& message,
69 const std::string& default_url); 73 const std::string& default_url);
70 void NeedKey(const std::string& key_system, 74 void NeedKey(const std::string& key_system,
71 const std::string& session_id, 75 const std::string& session_id,
72 const std::string& type, 76 const std::string& type,
73 scoped_ptr<uint8[]> init_data, int init_data_size); 77 scoped_ptr<uint8[]> init_data, int init_data_size);
74 78
(...skipping 19 matching lines...) Expand all
94 scoped_ptr<media::Decryptor> decryptor_; 98 scoped_ptr<media::Decryptor> decryptor_;
95 99
96 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; 100 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_;
97 101
98 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); 102 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
99 }; 103 };
100 104
101 } // namespace webkit_media 105 } // namespace webkit_media
102 106
103 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 107 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
OLDNEW
« no previous file with comments | « webkit/media/crypto/ppapi_decryptor.cc ('k') | webkit/media/crypto/proxy_decryptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698