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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "media/base/decryptor.h" | 17 #include "media/base/decryptor.h" |
18 #include "media/base/media_keys.h" | 18 #include "media/base/media_keys.h" |
19 | 19 |
20 #if defined(ENABLE_PEPPER_CDMS) | 20 #if defined(ENABLE_PEPPER_CDMS) |
21 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h" | 21 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h" |
22 #endif | 22 #endif |
23 | 23 |
24 class GURL; | 24 class GURL; |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 | 27 |
28 #if defined(OS_ANDROID) | 28 #if defined(ENABLE_BROWSER_CDMS) |
29 class RendererCdmManager; | 29 class RendererCdmManager; |
30 #endif // defined(OS_ANDROID) | 30 #endif // defined(ENABLE_BROWSER_CDMS) |
31 | 31 |
32 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. | 32 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. |
33 // A decryptor proxy that creates a real decryptor object on demand and | 33 // A decryptor proxy that creates a real decryptor object on demand and |
34 // forwards decryptor calls to it. | 34 // forwards decryptor calls to it. |
35 // | 35 // |
36 // Now that the Pepper API calls use session ID to match responses with | 36 // Now that the Pepper API calls use session ID to match responses with |
37 // requests, this class maintains a mapping between session ID and web session | 37 // requests, this class maintains a mapping between session ID and web session |
38 // ID. Callers of this class expect web session IDs in the responses. | 38 // ID. Callers of this class expect web session IDs in the responses. |
39 // Session IDs are internal unique references to the session. Web session IDs | 39 // Session IDs are internal unique references to the session. Web session IDs |
40 // are the CDM generated ID for the session, and are what are visible to users. | 40 // are the CDM generated ID for the session, and are what are visible to users. |
41 // | 41 // |
42 // TODO(xhwang): Currently we don't support run-time switching among decryptor | 42 // TODO(xhwang): Currently we don't support run-time switching among decryptor |
43 // objects. Fix this when needed. | 43 // objects. Fix this when needed. |
44 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! | 44 // TODO(xhwang): The ProxyDecryptor is not a Decryptor. Find a better name! |
45 class ProxyDecryptor { | 45 class ProxyDecryptor { |
46 public: | 46 public: |
47 // These are similar to the callbacks in media_keys.h, but pass back the | 47 // These are similar to the callbacks in media_keys.h, but pass back the |
48 // web session ID rather than the internal session ID. | 48 // web session ID rather than the internal session ID. |
49 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; | 49 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; |
50 typedef base::Callback<void(const std::string& session_id, | 50 typedef base::Callback<void(const std::string& session_id, |
51 media::MediaKeys::KeyError error_code, | 51 media::MediaKeys::KeyError error_code, |
52 uint32 system_code)> KeyErrorCB; | 52 uint32 system_code)> KeyErrorCB; |
53 typedef base::Callback<void(const std::string& session_id, | 53 typedef base::Callback<void(const std::string& session_id, |
54 const std::vector<uint8>& message, | 54 const std::vector<uint8>& message, |
55 const GURL& destination_url)> KeyMessageCB; | 55 const GURL& destination_url)> KeyMessageCB; |
56 | 56 |
57 ProxyDecryptor( | 57 ProxyDecryptor( |
58 #if defined(ENABLE_PEPPER_CDMS) | 58 #if defined(ENABLE_PEPPER_CDMS) |
59 const CreatePepperCdmCB& create_pepper_cdm_cb, | 59 const CreatePepperCdmCB& create_pepper_cdm_cb, |
60 #elif defined(OS_ANDROID) | 60 #elif defined(ENABLE_BROWSER_CDMS) |
61 RendererCdmManager* manager, | 61 RendererCdmManager* manager, |
62 #endif // defined(ENABLE_PEPPER_CDMS) | 62 #endif // defined(ENABLE_PEPPER_CDMS) |
63 const KeyAddedCB& key_added_cb, | 63 const KeyAddedCB& key_added_cb, |
64 const KeyErrorCB& key_error_cb, | 64 const KeyErrorCB& key_error_cb, |
65 const KeyMessageCB& key_message_cb); | 65 const KeyMessageCB& key_message_cb); |
66 virtual ~ProxyDecryptor(); | 66 virtual ~ProxyDecryptor(); |
67 | 67 |
68 // Returns the Decryptor associated with this object. May be NULL if no | 68 // Returns the Decryptor associated with this object. May be NULL if no |
69 // Decryptor is associated. | 69 // Decryptor is associated. |
70 media::Decryptor* GetDecryptor(); | 70 media::Decryptor* GetDecryptor(); |
71 | 71 |
72 #if defined(OS_ANDROID) | 72 #if defined(ENABLE_BROWSER_CDMS) |
73 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no | 73 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no |
74 // CDM ID is associated, such as when Clear Key is used. | 74 // CDM ID is associated, such as when Clear Key is used. |
75 int GetCdmId(); | 75 int GetCdmId(); |
76 #endif | 76 #endif |
77 | 77 |
78 // Only call this once. | 78 // Only call this once. |
79 bool InitializeCDM(const std::string& key_system, | 79 bool InitializeCDM(const std::string& key_system, |
80 const GURL& security_origin); | 80 const GURL& security_origin); |
81 | 81 |
82 // May only be called after InitializeCDM() succeeds. | 82 // May only be called after InitializeCDM() succeeds. |
(...skipping 28 matching lines...) Expand all Loading... |
111 uint32 LookupSessionId(const std::string& web_session_id) const; | 111 uint32 LookupSessionId(const std::string& web_session_id) const; |
112 | 112 |
113 // Helper function to determine web_session_id for the provided |session_id|. | 113 // Helper function to determine web_session_id for the provided |session_id|. |
114 // The returned web_session_id is only valid on the main thread, and should be | 114 // The returned web_session_id is only valid on the main thread, and should be |
115 // stored by copy. | 115 // stored by copy. |
116 const std::string& LookupWebSessionId(uint32 session_id) const; | 116 const std::string& LookupWebSessionId(uint32 session_id) const; |
117 | 117 |
118 #if defined(ENABLE_PEPPER_CDMS) | 118 #if defined(ENABLE_PEPPER_CDMS) |
119 // Callback to create the Pepper plugin. | 119 // Callback to create the Pepper plugin. |
120 CreatePepperCdmCB create_pepper_cdm_cb_; | 120 CreatePepperCdmCB create_pepper_cdm_cb_; |
121 #elif defined(OS_ANDROID) | 121 #elif defined(ENABLE_BROWSER_CDMS) |
122 RendererCdmManager* manager_; | 122 RendererCdmManager* manager_; |
123 int cdm_id_; | 123 int cdm_id_; |
124 #endif // defined(ENABLE_PEPPER_CDMS) | 124 #endif // defined(ENABLE_PEPPER_CDMS) |
125 | 125 |
126 // The real MediaKeys that manages key operations for the ProxyDecryptor. | 126 // The real MediaKeys that manages key operations for the ProxyDecryptor. |
127 scoped_ptr<media::MediaKeys> media_keys_; | 127 scoped_ptr<media::MediaKeys> media_keys_; |
128 | 128 |
129 // Callbacks for firing key events. | 129 // Callbacks for firing key events. |
130 KeyAddedCB key_added_cb_; | 130 KeyAddedCB key_added_cb_; |
131 KeyErrorCB key_error_cb_; | 131 KeyErrorCB key_error_cb_; |
(...skipping 12 matching lines...) Expand all Loading... |
144 | 144 |
145 // NOTE: Weak pointers must be invalidated before all other member variables. | 145 // NOTE: Weak pointers must be invalidated before all other member variables. |
146 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 146 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 148 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
149 }; | 149 }; |
150 | 150 |
151 } // namespace content | 151 } // namespace content |
152 | 152 |
153 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 153 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
OLD | NEW |