OLD | NEW |
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 class ProxyDecryptor : public media::MediaKeys { |
27 public: | 28 public: |
28 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client, | 29 ProxyDecryptor(WebKit::WebMediaPlayerClient* web_media_player_client, |
29 WebKit::WebFrame* web_frame, | 30 WebKit::WebFrame* web_frame, |
30 const media::KeyAddedCB& key_added_cb, | 31 const media::KeyAddedCB& key_added_cb, |
31 const media::KeyErrorCB& key_error_cb, | 32 const media::KeyErrorCB& key_error_cb, |
32 const media::KeyMessageCB& key_message_cb, | 33 const media::KeyMessageCB& key_message_cb, |
33 const media::NeedKeyCB& need_key_cb); | 34 const media::NeedKeyCB& need_key_cb); |
34 virtual ~ProxyDecryptor(); | 35 virtual ~ProxyDecryptor(); |
35 | 36 |
36 // Requests the ProxyDecryptor to notify the decryptor when it's ready through | 37 // Requests the ProxyDecryptor to notify the decryptor when it's ready through |
37 // the |decryptor_ready_cb| provided. | 38 // the |decryptor_ready_cb| provided. |
38 // If |decryptor_ready_cb| is null, the existing callback will be fired with | 39 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
39 // NULL immediately and reset. | 40 // NULL immediately and reset. |
40 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 41 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
41 | 42 |
42 bool GenerateKeyRequest(const std::string& key_system, | 43 // MediaKeys implementation. |
43 const std::string& type, | 44 virtual bool GenerateKeyRequest(const std::string& key_system, |
44 const uint8* init_data, int init_data_length); | 45 const std::string& type, |
45 void AddKey(const std::string& key_system, | 46 const uint8* init_data, |
46 const uint8* key, int key_length, | 47 int init_data_length) OVERRIDE; |
47 const uint8* init_data, int init_data_length, | 48 virtual void AddKey(const std::string& key_system, |
48 const std::string& session_id); | 49 const uint8* key, int key_length, |
49 void CancelKeyRequest(const std::string& key_system, | 50 const uint8* init_data, int init_data_length, |
50 const std::string& session_id); | 51 const std::string& session_id) OVERRIDE; |
| 52 virtual void CancelKeyRequest(const std::string& key_system, |
| 53 const std::string& session_id) OVERRIDE; |
51 | 54 |
52 private: | 55 private: |
53 // Helper functions to create decryptors to handle the given |key_system|. | 56 // Helper functions to create decryptors to handle the given |key_system|. |
54 #if defined(ENABLE_PEPPER_CDMS) | 57 #if defined(ENABLE_PEPPER_CDMS) |
55 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( | 58 scoped_ptr<media::Decryptor> CreatePpapiDecryptor( |
56 const std::string& key_system); | 59 const std::string& key_system); |
57 #endif // defined(ENABLE_PEPPER_CDMS) | 60 #endif // defined(ENABLE_PEPPER_CDMS) |
58 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); | 61 scoped_ptr<media::Decryptor> CreateDecryptor(const std::string& key_system); |
59 | 62 |
60 // Callbacks for firing key events. | 63 // Callbacks for firing key events. |
61 void KeyAdded(const std::string& key_system, const std::string& session_id); | 64 void KeyAdded(const std::string& key_system, const std::string& session_id); |
62 void KeyError(const std::string& key_system, | 65 void KeyError(const std::string& key_system, |
63 const std::string& session_id, | 66 const std::string& session_id, |
64 media::Decryptor::KeyError error_code, | 67 media::MediaKeys::KeyError error_code, |
65 int system_code); | 68 int system_code); |
66 void KeyMessage(const std::string& key_system, | 69 void KeyMessage(const std::string& key_system, |
67 const std::string& session_id, | 70 const std::string& session_id, |
68 const std::string& message, | 71 const std::string& message, |
69 const std::string& default_url); | 72 const std::string& default_url); |
70 void NeedKey(const std::string& key_system, | 73 void NeedKey(const std::string& key_system, |
71 const std::string& session_id, | 74 const std::string& session_id, |
72 const std::string& type, | 75 const std::string& type, |
73 scoped_ptr<uint8[]> init_data, int init_data_size); | 76 scoped_ptr<uint8[]> init_data, int init_data_size); |
74 | 77 |
(...skipping 19 matching lines...) Expand all Loading... |
94 scoped_ptr<media::Decryptor> decryptor_; | 97 scoped_ptr<media::Decryptor> decryptor_; |
95 | 98 |
96 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 99 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
97 | 100 |
98 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 101 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
99 }; | 102 }; |
100 | 103 |
101 } // namespace webkit_media | 104 } // namespace webkit_media |
102 | 105 |
103 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 106 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
OLD | NEW |