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