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 CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "media/base/cdm_factory.h" |
15 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
16 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
17 | 18 |
18 #if defined(ENABLE_PEPPER_CDMS) | |
19 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h" | |
20 #endif | |
21 | |
22 class GURL; | 19 class GURL; |
23 | 20 |
24 namespace content { | 21 namespace content { |
25 | 22 |
26 #if defined(ENABLE_BROWSER_CDMS) | 23 #if defined(ENABLE_BROWSER_CDMS) |
27 class RendererCdmManager; | 24 class RendererCdmManager; |
28 #endif // defined(ENABLE_BROWSER_CDMS) | 25 #endif // defined(ENABLE_BROWSER_CDMS) |
29 | 26 |
30 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. | 27 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. |
31 // A decryptor proxy that creates a real decryptor object on demand and | 28 // A decryptor proxy that creates a real decryptor object on demand and |
32 // forwards decryptor calls to it. | 29 // forwards decryptor calls to it. |
33 // | 30 // |
34 // TODO(xhwang): Currently we don't support run-time switching among decryptor | 31 // TODO(xhwang): Currently we don't support run-time switching among decryptor |
35 // objects. Fix this when needed. | 32 // objects. Fix this when needed. |
36 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! | 33 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! |
37 class ProxyDecryptor { | 34 class ProxyDecryptor { |
38 public: | 35 public: |
39 // These are similar to the callbacks in media_keys.h, but pass back the | 36 // These are similar to the callbacks in media_keys.h, but pass back the |
40 // web session ID rather than the internal session ID. | 37 // web session ID rather than the internal session ID. |
41 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; | 38 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; |
42 typedef base::Callback<void(const std::string& session_id, | 39 typedef base::Callback<void(const std::string& session_id, |
43 media::MediaKeys::KeyError error_code, | 40 media::MediaKeys::KeyError error_code, |
44 uint32 system_code)> KeyErrorCB; | 41 uint32 system_code)> KeyErrorCB; |
45 typedef base::Callback<void(const std::string& session_id, | 42 typedef base::Callback<void(const std::string& session_id, |
46 const std::vector<uint8>& message, | 43 const std::vector<uint8>& message, |
47 const GURL& destination_url)> KeyMessageCB; | 44 const GURL& destination_url)> KeyMessageCB; |
48 | 45 |
49 ProxyDecryptor( | 46 ProxyDecryptor(scoped_ptr<media::CdmFactory> cdm_factory, |
50 #if defined(ENABLE_PEPPER_CDMS) | 47 const KeyAddedCB& key_added_cb, |
51 const CreatePepperCdmCB& create_pepper_cdm_cb, | 48 const KeyErrorCB& key_error_cb, |
52 #elif defined(ENABLE_BROWSER_CDMS) | 49 const KeyMessageCB& key_message_cb); |
53 RendererCdmManager* manager, | |
54 #endif // defined(ENABLE_PEPPER_CDMS) | |
55 const KeyAddedCB& key_added_cb, | |
56 const KeyErrorCB& key_error_cb, | |
57 const KeyMessageCB& key_message_cb); | |
58 virtual ~ProxyDecryptor(); | 50 virtual ~ProxyDecryptor(); |
59 | 51 |
60 // Returns the Decryptor associated with this object. May be NULL if no | 52 // Returns the Decryptor associated with this object. May be NULL if no |
61 // Decryptor is associated. | 53 // Decryptor is associated. |
62 media::Decryptor* GetDecryptor(); | 54 media::Decryptor* GetDecryptor(); |
63 | 55 |
64 #if defined(ENABLE_BROWSER_CDMS) | 56 #if defined(ENABLE_BROWSER_CDMS) |
65 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no | 57 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no |
66 // CDM ID is associated, such as when Clear Key is used. | 58 // CDM ID is associated, such as when Clear Key is used. |
67 int GetCdmId(); | 59 int GetCdmId(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 enum SessionCreationType { | 95 enum SessionCreationType { |
104 TemporarySession, | 96 TemporarySession, |
105 PersistentSession, | 97 PersistentSession, |
106 LoadSession | 98 LoadSession |
107 }; | 99 }; |
108 | 100 |
109 // Called when a session is actually created or loaded. | 101 // Called when a session is actually created or loaded. |
110 void SetSessionId(SessionCreationType session_type, | 102 void SetSessionId(SessionCreationType session_type, |
111 const std::string& web_session_id); | 103 const std::string& web_session_id); |
112 | 104 |
113 #if defined(ENABLE_PEPPER_CDMS) | 105 scoped_ptr<media::CdmFactory> cdm_factory_; |
114 // Callback to create the Pepper plugin. | 106 |
115 CreatePepperCdmCB create_pepper_cdm_cb_; | 107 #if defined(ENABLE_BROWSER_CDMS) |
116 #elif defined(ENABLE_BROWSER_CDMS) | |
117 RendererCdmManager* manager_; | |
118 int cdm_id_; | 108 int cdm_id_; |
119 #endif // defined(ENABLE_PEPPER_CDMS) | 109 #endif |
120 | 110 |
121 // The real MediaKeys that manages key operations for the ProxyDecryptor. | 111 // The real MediaKeys that manages key operations for the ProxyDecryptor. |
122 scoped_ptr<media::MediaKeys> media_keys_; | 112 scoped_ptr<media::MediaKeys> media_keys_; |
123 | 113 |
124 // Callbacks for firing key events. | 114 // Callbacks for firing key events. |
125 KeyAddedCB key_added_cb_; | 115 KeyAddedCB key_added_cb_; |
126 KeyErrorCB key_error_cb_; | 116 KeyErrorCB key_error_cb_; |
127 KeyMessageCB key_message_cb_; | 117 KeyMessageCB key_message_cb_; |
128 | 118 |
129 // Keep track of both persistent and non-persistent sessions. | 119 // Keep track of both persistent and non-persistent sessions. |
130 base::hash_map<std::string, bool> active_sessions_; | 120 base::hash_map<std::string, bool> active_sessions_; |
131 | 121 |
132 bool is_clear_key_; | 122 bool is_clear_key_; |
133 | 123 |
134 // NOTE: Weak pointers must be invalidated before all other member variables. | 124 // NOTE: Weak pointers must be invalidated before all other member variables. |
135 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 125 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
136 | 126 |
137 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 127 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
138 }; | 128 }; |
139 | 129 |
140 } // namespace content | 130 } // namespace content |
141 | 131 |
142 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 132 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
OLD | NEW |