OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 T/Chromium Authors. All rights reserved. |
ddorwin
2014/02/10 19:05:25
oops
xhwang
2014/02/10 22:30:55
Done.
| |
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 #include "content/renderer/media/crypto/proxy_decryptor.h" | 5 #include "content/renderer/media/crypto/proxy_decryptor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "content/renderer/media/crypto/content_decryption_module_factory.h" | 11 #include "content/renderer/media/crypto/content_decryption_module_factory.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 DCHECK(!media_keys_); | 76 DCHECK(!media_keys_); |
77 media_keys_ = CreateMediaKeys(key_system, frame_url); | 77 media_keys_ = CreateMediaKeys(key_system, frame_url); |
78 if (!media_keys_) | 78 if (!media_keys_) |
79 return false; | 79 return false; |
80 | 80 |
81 is_clear_key_ = | 81 is_clear_key_ = |
82 media::IsClearKey(key_system) || media::IsExternalClearKey(key_system); | 82 media::IsClearKey(key_system) || media::IsExternalClearKey(key_system); |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 bool ProxyDecryptor::GenerateKeyRequest(const std::string& type, | 86 bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, |
87 const uint8* init_data, | 87 const uint8* init_data, |
88 int init_data_length) { | 88 int init_data_length) { |
89 // Use a unique reference id for this request. | 89 // Use a unique reference id for this request. |
90 uint32 session_id = next_session_id_++; | 90 uint32 session_id = next_session_id_++; |
91 if (!media_keys_->CreateSession( | 91 |
92 session_id, type, init_data, init_data_length)) { | 92 const uint8 kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|"; |
93 return false; | 93 const int kPrefixedApiLoadSessionHeaderLength = |
94 sizeof(kPrefixedApiLoadSessionHeader) - 1; | |
95 | |
96 if (init_data_length > kPrefixedApiLoadSessionHeaderLength && | |
97 std::equal(init_data, | |
98 init_data + kPrefixedApiLoadSessionHeaderLength, | |
99 kPrefixedApiLoadSessionHeader)) { | |
100 // TODO(xhwang): Track loadable session to handle OnSessionClosed(). | |
101 // See: http://crbug.com/340859. | |
102 return media_keys_->LoadSession( | |
103 session_id, | |
104 std::string(reinterpret_cast<const char*>( | |
105 init_data + kPrefixedApiLoadSessionHeaderLength), | |
106 init_data_length - kPrefixedApiLoadSessionHeaderLength)); | |
94 } | 107 } |
95 | 108 |
96 return true; | 109 return media_keys_->CreateSession( |
110 session_id, content_type, init_data, init_data_length); | |
97 } | 111 } |
98 | 112 |
99 void ProxyDecryptor::AddKey(const uint8* key, | 113 void ProxyDecryptor::AddKey(const uint8* key, |
100 int key_length, | 114 int key_length, |
101 const uint8* init_data, | 115 const uint8* init_data, |
102 int init_data_length, | 116 int init_data_length, |
103 const std::string& web_session_id) { | 117 const std::string& web_session_id) { |
104 DVLOG(1) << "AddKey()"; | 118 DVLOG(1) << "AddKey()"; |
105 | 119 |
106 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. | 120 // WebMediaPlayerImpl ensures GenerateKeyRequest() has been called. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 | 245 |
232 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) { | 246 const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) { |
233 DCHECK_NE(session_id, kInvalidSessionId); | 247 DCHECK_NE(session_id, kInvalidSessionId); |
234 | 248 |
235 // Session may not exist if error happens during GenerateKeyRequest(). | 249 // Session may not exist if error happens during GenerateKeyRequest(). |
236 SessionIdMap::iterator it = sessions_.find(session_id); | 250 SessionIdMap::iterator it = sessions_.find(session_id); |
237 return (it != sessions_.end()) ? it->second : base::EmptyString(); | 251 return (it != sessions_.end()) ? it->second : base::EmptyString(); |
238 } | 252 } |
239 | 253 |
240 } // namespace content | 254 } // namespace content |
OLD | NEW |