| 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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 for (const auto& key_info : keys_info) { | 205 for (const auto& key_info : keys_info) { |
| 206 cdm::KeyInformation key; | 206 cdm::KeyInformation key; |
| 207 key.key_id = vector_as_array(&key_info->key_id); | 207 key.key_id = vector_as_array(&key_info->key_id); |
| 208 key.key_id_size = key_info->key_id.size(); | 208 key.key_id_size = key_info->key_id.size(); |
| 209 key.status = ConvertKeyStatus(key_info->status); | 209 key.status = ConvertKeyStatus(key_info->status); |
| 210 key.system_code = key_info->system_code; | 210 key.system_code = key_info->system_code; |
| 211 keys_vector->push_back(key); | 211 keys_vector->push_back(key); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 template<typename Type> | |
| 216 class ScopedResetter { | |
| 217 public: | |
| 218 explicit ScopedResetter(Type* object) : object_(object) {} | |
| 219 ~ScopedResetter() { object_->Reset(); } | |
| 220 | |
| 221 private: | |
| 222 Type* const object_; | |
| 223 }; | |
| 224 | |
| 225 void INITIALIZE_CDM_MODULE() { | 215 void INITIALIZE_CDM_MODULE() { |
| 216 DVLOG(1) << __FUNCTION__; |
| 226 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 217 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
| 227 av_register_all(); | 218 av_register_all(); |
| 228 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 219 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
| 229 } | 220 } |
| 230 | 221 |
| 231 void DeinitializeCdmModule() { | 222 void DeinitializeCdmModule() { |
| 223 DVLOG(1) << __FUNCTION__; |
| 232 } | 224 } |
| 233 | 225 |
| 234 void* CreateCdmInstance(int cdm_interface_version, | 226 void* CreateCdmInstance(int cdm_interface_version, |
| 235 const char* key_system, uint32_t key_system_size, | 227 const char* key_system, uint32_t key_system_size, |
| 236 GetCdmHostFunc get_cdm_host_func, | 228 GetCdmHostFunc get_cdm_host_func, |
| 237 void* user_data) { | 229 void* user_data) { |
| 238 DVLOG(1) << "CreateCdmInstance()"; | 230 DVLOG(1) << "CreateCdmInstance()"; |
| 239 | 231 |
| 240 std::string key_system_string(key_system, key_system_size); | 232 std::string key_system_string(key_system, key_system_size); |
| 241 if (key_system_string != kExternalClearKeyKeySystem && | 233 if (key_system_string != kExternalClearKeyKeySystem && |
| 242 key_system_string != kExternalClearKeyDecryptOnlyKeySystem && | 234 key_system_string != kExternalClearKeyDecryptOnlyKeySystem && |
| 243 key_system_string != kExternalClearKeyFileIOTestKeySystem && | 235 key_system_string != kExternalClearKeyFileIOTestKeySystem && |
| 244 key_system_string != kExternalClearKeyCrashKeySystem) { | 236 key_system_string != kExternalClearKeyCrashKeySystem) { |
| 245 DVLOG(1) << "Unsupported key system:" << key_system_string; | 237 DVLOG(1) << "Unsupported key system:" << key_system_string; |
| 246 return NULL; | 238 return NULL; |
| 247 } | 239 } |
| 248 | 240 |
| 249 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion) | 241 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion) |
| 250 return NULL; | 242 return NULL; |
| 251 | 243 |
| 252 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>( | 244 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>( |
| 253 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data)); | 245 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data)); |
| 254 if (!host) | 246 if (!host) |
| 255 return NULL; | 247 return NULL; |
| 256 | 248 |
| 257 // TODO(jrummell): Obtain the proper origin for this instance. | 249 // TODO(jrummell): Obtain the proper origin for this instance. |
| 258 return new media::ClearKeyCdm(host, key_system_string, GURL::EmptyGURL()); | 250 GURL empty_gurl; |
| 251 return new media::ClearKeyCdm(host, key_system_string, empty_gurl); |
| 259 } | 252 } |
| 260 | 253 |
| 261 const char* GetCdmVersion() { | 254 const char* GetCdmVersion() { |
| 262 return kClearKeyCdmVersion; | 255 return kClearKeyCdmVersion; |
| 263 } | 256 } |
| 264 | 257 |
| 265 namespace media { | 258 namespace media { |
| 266 | 259 |
| 267 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, | 260 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, |
| 268 const std::string& key_system, | 261 const std::string& key_system, |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 void ClearKeyCdm::OnFileIOTestComplete(bool success) { | 902 void ClearKeyCdm::OnFileIOTestComplete(bool success) { |
| 910 DVLOG(1) << __FUNCTION__ << ": " << success; | 903 DVLOG(1) << __FUNCTION__ << ": " << success; |
| 911 std::string message = GetFileIOTestResultMessage(success); | 904 std::string message = GetFileIOTestResultMessage(success); |
| 912 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), | 905 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), |
| 913 cdm::kLicenseRequest, message.data(), | 906 cdm::kLicenseRequest, message.data(), |
| 914 message.length(), NULL, 0); | 907 message.length(), NULL, 0); |
| 915 file_io_test_runner_.reset(); | 908 file_io_test_runner_.reset(); |
| 916 } | 909 } |
| 917 | 910 |
| 918 } // namespace media | 911 } // namespace media |
| OLD | NEW |