| 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 #include "content/renderer/media/crypto/proxy_decryptor.h" | 5 #include "content/renderer/media/crypto/proxy_decryptor.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 std::string(reinterpret_cast<const char*>( | 121 std::string(reinterpret_cast<const char*>( |
| 122 init_data + strlen(kPrefixedApiLoadSessionHeader)), | 122 init_data + strlen(kPrefixedApiLoadSessionHeader)), |
| 123 init_data_length - strlen(kPrefixedApiLoadSessionHeader)), | 123 init_data_length - strlen(kPrefixedApiLoadSessionHeader)), |
| 124 promise.Pass()); | 124 promise.Pass()); |
| 125 return true; | 125 return true; |
| 126 } | 126 } |
| 127 | 127 |
| 128 media::MediaKeys::SessionType session_type = | 128 media::MediaKeys::SessionType session_type = |
| 129 persistent ? media::MediaKeys::PERSISTENT_SESSION | 129 persistent ? media::MediaKeys::PERSISTENT_SESSION |
| 130 : media::MediaKeys::TEMPORARY_SESSION; | 130 : media::MediaKeys::TEMPORARY_SESSION; |
| 131 media_keys_->CreateSession( | 131 |
| 132 content_type, init_data, init_data_length, session_type, promise.Pass()); | 132 // Convert MIME types used in the prefixed implementation. |
| 133 std::string init_data_type; |
| 134 if (content_type == "audio/mp4" || content_type == "video/mp4") { |
| 135 init_data_type = "cenc"; |
| 136 } else if (content_type == "audio/webm" || content_type == "video/webm") { |
| 137 init_data_type = "webm"; |
| 138 } else { |
| 139 NOTREACHED(); |
| 140 init_data_type = content_type; |
| 141 } |
| 142 |
| 143 media_keys_->CreateSession(init_data_type, init_data, init_data_length, |
| 144 session_type, promise.Pass()); |
| 133 return true; | 145 return true; |
| 134 } | 146 } |
| 135 | 147 |
| 136 void ProxyDecryptor::AddKey(const uint8* key, | 148 void ProxyDecryptor::AddKey(const uint8* key, |
| 137 int key_length, | 149 int key_length, |
| 138 const uint8* init_data, | 150 const uint8* init_data, |
| 139 int init_data_length, | 151 int init_data_length, |
| 140 const std::string& web_session_id) { | 152 const std::string& web_session_id) { |
| 141 DVLOG(1) << "AddKey()"; | 153 DVLOG(1) << "AddKey()"; |
| 142 | 154 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 297 } |
| 286 key_error_cb_.Run(web_session_id, error_code, system_code); | 298 key_error_cb_.Run(web_session_id, error_code, system_code); |
| 287 } | 299 } |
| 288 | 300 |
| 289 void ProxyDecryptor::SetSessionId(bool persistent, | 301 void ProxyDecryptor::SetSessionId(bool persistent, |
| 290 const std::string& web_session_id) { | 302 const std::string& web_session_id) { |
| 291 active_sessions_.insert(std::make_pair(web_session_id, persistent)); | 303 active_sessions_.insert(std::make_pair(web_session_id, persistent)); |
| 292 } | 304 } |
| 293 | 305 |
| 294 } // namespace content | 306 } // namespace content |
| OLD | NEW |