OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 5 #ifndef WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
6 #define WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 6 #define WEBKIT_RENDERER_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 #include "media/base/media_keys.h" |
15 | 15 |
16 namespace WebKit { | 16 namespace WebKit { |
17 class WebFrame; | 17 class WebFrame; |
18 class WebMediaPlayerClient; | 18 class WebMediaPlayerClient; |
19 } | 19 } |
20 | 20 |
21 namespace webkit_media { | 21 namespace webkit_media { |
22 | 22 |
23 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) | |
24 class WebMediaPlayerProxyAndroid; | |
25 #endif | |
26 | |
27 // 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 |
28 // forwards decryptor calls to it. | 24 // forwards decryptor calls to it. |
29 // 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 |
30 // objects. Fix this when needed. | 26 // objects. Fix this when needed. |
31 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! | 27 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! |
32 class ProxyDecryptor : public media::MediaKeys { | 28 class ProxyDecryptor : public media::MediaKeys { |
33 public: | 29 public: |
34 ProxyDecryptor( | 30 ProxyDecryptor( |
35 #if defined(ENABLE_PEPPER_CDMS) | 31 #if defined(ENABLE_PEPPER_CDMS) |
36 WebKit::WebMediaPlayerClient* web_media_player_client, | 32 WebKit::WebMediaPlayerClient* web_media_player_client, |
37 WebKit::WebFrame* web_frame, | 33 WebKit::WebFrame* web_frame, |
38 #endif | 34 #elif defined(OS_ANDROID) && !defined(GOOGLE_TV) |
39 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) | 35 scoped_ptr<media::MediaKeys> media_keys, |
40 WebMediaPlayerProxyAndroid* proxy, | |
41 int media_keys_id, | |
42 #endif | 36 #endif |
43 const media::KeyAddedCB& key_added_cb, | 37 const media::KeyAddedCB& key_added_cb, |
44 const media::KeyErrorCB& key_error_cb, | 38 const media::KeyErrorCB& key_error_cb, |
45 const media::KeyMessageCB& key_message_cb); | 39 const media::KeyMessageCB& key_message_cb); |
46 virtual ~ProxyDecryptor(); | 40 virtual ~ProxyDecryptor(); |
47 | 41 |
48 // Only call this once. | 42 // Only call this once. |
49 bool InitializeCDM(const std::string& key_system); | 43 bool InitializeCDM(const std::string& key_system); |
50 | 44 |
51 // Requests the ProxyDecryptor to notify the decryptor when it's ready through | 45 // Requests the ProxyDecryptor to notify the decryptor when it's ready through |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 const std::string& default_url); | 79 const std::string& default_url); |
86 | 80 |
87 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 81 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
88 | 82 |
89 #if defined(ENABLE_PEPPER_CDMS) | 83 #if defined(ENABLE_PEPPER_CDMS) |
90 // Needed to create the PpapiDecryptor. | 84 // Needed to create the PpapiDecryptor. |
91 WebKit::WebMediaPlayerClient* web_media_player_client_; | 85 WebKit::WebMediaPlayerClient* web_media_player_client_; |
92 WebKit::WebFrame* web_frame_; | 86 WebKit::WebFrame* web_frame_; |
93 #endif // defined(ENABLE_PEPPER_CDMS) | 87 #endif // defined(ENABLE_PEPPER_CDMS) |
94 | 88 |
95 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) | 89 // The real MediaKeys that manages key operations for the ProxyDecryptor. |
96 // |proxy_| must outlive this object. | 90 // This pointer is protected by the |lock_|. |
97 WebMediaPlayerProxyAndroid* proxy_; | 91 scoped_ptr<media::MediaKeys> media_keys_; |
98 | |
99 int media_keys_id_; | |
100 #endif // defined(OS_ANDROID) && !defined(GOOGLE_TV) | |
101 | 92 |
102 // Callbacks for firing key events. | 93 // Callbacks for firing key events. |
103 media::KeyAddedCB key_added_cb_; | 94 media::KeyAddedCB key_added_cb_; |
104 media::KeyErrorCB key_error_cb_; | 95 media::KeyErrorCB key_error_cb_; |
105 media::KeyMessageCB key_message_cb_; | 96 media::KeyMessageCB key_message_cb_; |
106 | 97 |
107 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread | 98 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread |
108 // safe as per the Decryptor interface. | 99 // safe as per the Decryptor interface. |
109 base::Lock lock_; | 100 base::Lock lock_; |
110 | 101 |
111 media::DecryptorReadyCB decryptor_ready_cb_; | 102 media::DecryptorReadyCB decryptor_ready_cb_; |
112 | 103 |
113 // The real MediaKeys that manages key operations for the ProxyDecryptor. | |
114 // This pointer is protected by the |lock_|. | |
115 scoped_ptr<media::MediaKeys> media_keys_; | |
116 | |
117 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 104 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
118 }; | 105 }; |
119 | 106 |
120 } // namespace webkit_media | 107 } // namespace webkit_media |
121 | 108 |
122 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 109 #endif // WEBKIT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
OLD | NEW |