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 |
215 void INITIALIZE_CDM_MODULE() { | 225 void INITIALIZE_CDM_MODULE() { |
216 DVLOG(1) << __FUNCTION__; | |
217 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 226 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
218 av_register_all(); | 227 av_register_all(); |
219 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 228 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
220 } | 229 } |
221 | 230 |
222 void DeinitializeCdmModule() { | 231 void DeinitializeCdmModule() { |
223 DVLOG(1) << __FUNCTION__; | |
224 } | 232 } |
225 | 233 |
226 void* CreateCdmInstance(int cdm_interface_version, | 234 void* CreateCdmInstance(int cdm_interface_version, |
227 const char* key_system, uint32_t key_system_size, | 235 const char* key_system, uint32_t key_system_size, |
228 GetCdmHostFunc get_cdm_host_func, | 236 GetCdmHostFunc get_cdm_host_func, |
229 void* user_data) { | 237 void* user_data) { |
230 DVLOG(1) << "CreateCdmInstance()"; | 238 DVLOG(1) << "CreateCdmInstance()"; |
231 | 239 |
232 std::string key_system_string(key_system, key_system_size); | 240 std::string key_system_string(key_system, key_system_size); |
233 if (key_system_string != kExternalClearKeyKeySystem && | 241 if (key_system_string != kExternalClearKeyKeySystem && |
234 key_system_string != kExternalClearKeyDecryptOnlyKeySystem && | 242 key_system_string != kExternalClearKeyDecryptOnlyKeySystem && |
235 key_system_string != kExternalClearKeyFileIOTestKeySystem && | 243 key_system_string != kExternalClearKeyFileIOTestKeySystem && |
236 key_system_string != kExternalClearKeyCrashKeySystem) { | 244 key_system_string != kExternalClearKeyCrashKeySystem) { |
237 DVLOG(1) << "Unsupported key system:" << key_system_string; | 245 DVLOG(1) << "Unsupported key system:" << key_system_string; |
238 return NULL; | 246 return NULL; |
239 } | 247 } |
240 | 248 |
241 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion) | 249 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion) |
242 return NULL; | 250 return NULL; |
243 | 251 |
244 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>( | 252 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>( |
245 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data)); | 253 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data)); |
246 if (!host) | 254 if (!host) |
247 return NULL; | 255 return NULL; |
248 | 256 |
249 // TODO(jrummell): Obtain the proper origin for this instance. | 257 // TODO(jrummell): Obtain the proper origin for this instance. |
250 GURL empty_gurl; | 258 return new media::ClearKeyCdm(host, key_system_string, GURL::EmptyGURL()); |
251 return new media::ClearKeyCdm(host, key_system_string, empty_gurl); | |
252 } | 259 } |
253 | 260 |
254 const char* GetCdmVersion() { | 261 const char* GetCdmVersion() { |
255 return kClearKeyCdmVersion; | 262 return kClearKeyCdmVersion; |
256 } | 263 } |
257 | 264 |
258 namespace media { | 265 namespace media { |
259 | 266 |
260 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, | 267 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, |
261 const std::string& key_system, | 268 const std::string& key_system, |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 void ClearKeyCdm::OnFileIOTestComplete(bool success) { | 909 void ClearKeyCdm::OnFileIOTestComplete(bool success) { |
903 DVLOG(1) << __FUNCTION__ << ": " << success; | 910 DVLOG(1) << __FUNCTION__ << ": " << success; |
904 std::string message = GetFileIOTestResultMessage(success); | 911 std::string message = GetFileIOTestResultMessage(success); |
905 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), | 912 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), |
906 cdm::kLicenseRequest, message.data(), | 913 cdm::kLicenseRequest, message.data(), |
907 message.length(), NULL, 0); | 914 message.length(), NULL, 0); |
908 file_io_test_runner_.reset(); | 915 file_io_test_runner_.reset(); |
909 } | 916 } |
910 | 917 |
911 } // namespace media | 918 } // namespace media |
OLD | NEW |