Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
| 31 class RendererMediaPlayerManager; | 31 class RendererMediaPlayerManager; |
| 32 #endif // defined(OS_ANDROID) | 32 #endif // defined(OS_ANDROID) |
| 33 | 33 |
| 34 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. | 34 // ProxyDecryptor is for EME v0.1b only. It should not be used for the WD API. |
| 35 // A decryptor proxy that creates a real decryptor object on demand and | 35 // A decryptor proxy that creates a real decryptor object on demand and |
| 36 // forwards decryptor calls to it. | 36 // forwards decryptor calls to it. |
| 37 // | 37 // |
| 38 // Now that the Pepper API calls use reference ID to match responses with | 38 // Now that the Pepper API calls use session ID to match responses with |
| 39 // requests, this class maintains a mapping between reference ID and session ID. | 39 // requests, this class maintains a mapping between session ID and web session |
| 40 // Callers of this class expect session IDs in the responses. | 40 // ID. Callers of this class expect web session IDs in the responses. |
|
xhwang
2013/12/05 18:51:37
Can you briefly explain what a session ID is and w
jrummell
2013/12/06 23:42:35
Done.
| |
| 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 // session ID rather than a reference ID. | 48 // web session ID rather than a session ID. |
|
ddorwin
2013/12/05 00:44:52
s/a/the internal/
jrummell
2013/12/06 23:42:35
Done.
| |
| 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 int system_code)> KeyErrorCB; | 52 int 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 std::string& default_url)> KeyMessageCB; | 55 const std::string& default_url)> KeyMessageCB; |
| 56 | 56 |
| 57 ProxyDecryptor( | 57 ProxyDecryptor( |
| 58 #if defined(ENABLE_PEPPER_CDMS) | 58 #if defined(ENABLE_PEPPER_CDMS) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 79 // May only be called after InitializeCDM() succeeds. | 79 // May only be called after InitializeCDM() succeeds. |
| 80 bool GenerateKeyRequest(const std::string& type, | 80 bool GenerateKeyRequest(const std::string& type, |
| 81 const uint8* init_data, | 81 const uint8* init_data, |
| 82 int init_data_length); | 82 int init_data_length); |
| 83 void AddKey(const uint8* key, int key_length, | 83 void AddKey(const uint8* key, int key_length, |
| 84 const uint8* init_data, int init_data_length, | 84 const uint8* init_data, int init_data_length, |
| 85 const std::string& session_id); | 85 const std::string& session_id); |
| 86 void CancelKeyRequest(const std::string& session_id); | 86 void CancelKeyRequest(const std::string& session_id); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 // This is reference_id <-> session_id map. | 89 // This is session_id <-> web_session_id map. |
|
ddorwin
2013/12/05 00:44:52
remove "This is ". (It's missing an article anyway
jrummell
2013/12/06 23:42:35
Done.
| |
| 90 typedef std::map<uint32, std::string> SessionIdMap; | 90 typedef std::map<uint32, std::string> SessionIdMap; |
| 91 | 91 |
| 92 // Helper function to create MediaKeys to handle the given |key_system|. | 92 // Helper function to create MediaKeys to handle the given |key_system|. |
| 93 scoped_ptr<media::MediaKeys> CreateMediaKeys(const std::string& key_system, | 93 scoped_ptr<media::MediaKeys> CreateMediaKeys(const std::string& key_system, |
| 94 const GURL& frame_url); | 94 const GURL& frame_url); |
| 95 | 95 |
| 96 // Callbacks for firing session events. | 96 // Callbacks for firing session events. |
| 97 void OnSessionCreated(uint32 reference_id, const std::string& session_id); | 97 void OnSessionCreated(uint32 session_id, const std::string& web_session_id); |
| 98 void OnSessionMessage(uint32 reference_id, | 98 void OnSessionMessage(uint32 session_id, |
| 99 const std::vector<uint8>& message, | 99 const std::vector<uint8>& message, |
| 100 const std::string& default_url); | 100 const std::string& default_url); |
| 101 void OnSessionReady(uint32 reference_id); | 101 void OnSessionReady(uint32 session_id); |
| 102 void OnSessionClosed(uint32 reference_id); | 102 void OnSessionClosed(uint32 session_id); |
| 103 void OnSessionError(uint32 reference_id, | 103 void OnSessionError(uint32 session_id, |
| 104 media::MediaKeys::KeyError error_code, | 104 media::MediaKeys::KeyError error_code, |
| 105 int system_code); | 105 int system_code); |
| 106 | 106 |
| 107 // Helper function to determine reference_id for the provided |session_id|. | 107 // Helper function to determine session_id for the provided |web_session_id|. |
| 108 uint32 LookupReferenceId(const std::string& session_id); | 108 uint32 LookupReferenceId(const std::string& web_session_id); |
|
ddorwin
2013/12/05 00:44:52
LookupSessionId
jrummell
2013/12/06 23:42:35
Done.
| |
| 109 | 109 |
| 110 // Helper function to determine session_id for the provided |reference_id|. | 110 // Helper function to determine web_session_id for the provided |session_id|. |
| 111 // The returned session_id is only valid on the main thread, and should be | 111 // The returned web_session_id is only valid on the main thread, and should be |
| 112 // stored by copy. | 112 // stored by copy. |
| 113 const std::string& LookupSessionId(uint32 reference_id); | 113 const std::string& LookupSessionId(uint32 session_id); |
|
ddorwin
2013/12/05 00:44:52
Lookup*Web*SessionId
jrummell
2013/12/06 23:42:35
Done.
| |
| 114 | 114 |
| 115 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; | 115 base::WeakPtrFactory<ProxyDecryptor> weak_ptr_factory_; |
| 116 | 116 |
| 117 #if defined(ENABLE_PEPPER_CDMS) | 117 #if defined(ENABLE_PEPPER_CDMS) |
| 118 // Callback for cleaning up a Pepper-based CDM. | 118 // Callback for cleaning up a Pepper-based CDM. |
| 119 void DestroyHelperPlugin(); | 119 void DestroyHelperPlugin(); |
| 120 | 120 |
| 121 // Needed to create the PpapiDecryptor. | 121 // Needed to create the PpapiDecryptor. |
| 122 blink::WebMediaPlayerClient* web_media_player_client_; | 122 blink::WebMediaPlayerClient* web_media_player_client_; |
| 123 blink::WebFrame* web_frame_; | 123 blink::WebFrame* web_frame_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 134 KeyAddedCB key_added_cb_; | 134 KeyAddedCB key_added_cb_; |
| 135 KeyErrorCB key_error_cb_; | 135 KeyErrorCB key_error_cb_; |
| 136 KeyMessageCB key_message_cb_; | 136 KeyMessageCB key_message_cb_; |
| 137 | 137 |
| 138 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread | 138 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread |
| 139 // safe as per the Decryptor interface. | 139 // safe as per the Decryptor interface. |
| 140 base::Lock lock_; | 140 base::Lock lock_; |
| 141 | 141 |
| 142 media::DecryptorReadyCB decryptor_ready_cb_; | 142 media::DecryptorReadyCB decryptor_ready_cb_; |
| 143 | 143 |
| 144 // Reference IDs are used to uniquely track sessions so that CDM callbacks | 144 // Session IDs are used to uniquely track sessions so that CDM callbacks |
| 145 // can get mapped to the correct session ID. Reference ID should be unique | 145 // can get mapped to the correct session ID. Session ID should be unique |
| 146 // per renderer process for debugging purposes. | 146 // per renderer process for debugging purposes. |
| 147 static uint32 next_reference_id_; | 147 static uint32 next_session_id_; |
| 148 | 148 |
| 149 SessionIdMap sessions_; | 149 SessionIdMap sessions_; |
| 150 | 150 |
| 151 bool is_clear_key_; | 151 bool is_clear_key_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); | 153 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 } // namespace content | 156 } // namespace content |
| 157 | 157 |
| 158 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ | 158 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ |
| OLD | NEW |