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 26 matching lines...) Expand all Loading... |
37 #include "media/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h" | 37 #include "media/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h" |
38 | 38 |
39 // Include FFmpeg avformat.h for av_register_all(). | 39 // Include FFmpeg avformat.h for av_register_all(). |
40 extern "C" { | 40 extern "C" { |
41 // Temporarily disable possible loss of data warning. | 41 // Temporarily disable possible loss of data warning. |
42 MSVC_PUSH_DISABLE_WARNING(4244); | 42 MSVC_PUSH_DISABLE_WARNING(4244); |
43 #include <libavformat/avformat.h> | 43 #include <libavformat/avformat.h> |
44 MSVC_POP_WARNING(); | 44 MSVC_POP_WARNING(); |
45 } // extern "C" | 45 } // extern "C" |
46 | 46 |
47 // TODO(tomfinegan): When COMPONENT_BUILD is not defined an AtExitManager must | |
48 // exist before the call to InitializeFFmpegLibraries(). This should no longer | |
49 // be required after http://crbug.com/91970 because we'll be able to get rid of | |
50 // InitializeFFmpegLibraries(). | |
51 #if !defined COMPONENT_BUILD | 47 #if !defined COMPONENT_BUILD |
52 static base::AtExitManager g_at_exit_manager; | 48 static base::AtExitManager g_at_exit_manager; |
53 #endif | 49 #endif |
54 | 50 |
55 // TODO(tomfinegan): InitializeFFmpegLibraries() and |g_cdm_module_initialized| | 51 // Prepare media library. |
56 // are required for running in the sandbox, and should no longer be required | |
57 // after http://crbug.com/91970 is fixed. | |
58 static bool InitializeFFmpegLibraries() { | 52 static bool InitializeFFmpegLibraries() { |
59 base::FilePath file_path; | 53 media::InitializeMediaLibrary(); |
60 CHECK(PathService::Get(base::DIR_MODULE, &file_path)); | |
61 CHECK(media::InitializeMediaLibrary(file_path)); | |
62 return true; | 54 return true; |
63 } | 55 } |
| 56 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries(); |
64 | 57 |
65 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries(); | |
66 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 58 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
67 | 59 |
68 const char kClearKeyCdmVersion[] = "0.1.0.1"; | 60 const char kClearKeyCdmVersion[] = "0.1.0.1"; |
69 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; | 61 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
70 const char kExternalClearKeyDecryptOnlyKeySystem[] = | 62 const char kExternalClearKeyDecryptOnlyKeySystem[] = |
71 "org.chromium.externalclearkey.decryptonly"; | 63 "org.chromium.externalclearkey.decryptonly"; |
72 const char kExternalClearKeyFileIOTestKeySystem[] = | 64 const char kExternalClearKeyFileIOTestKeySystem[] = |
73 "org.chromium.externalclearkey.fileiotest"; | 65 "org.chromium.externalclearkey.fileiotest"; |
74 const char kExternalClearKeyCrashKeySystem[] = | 66 const char kExternalClearKeyCrashKeySystem[] = |
75 "org.chromium.externalclearkey.crash"; | 67 "org.chromium.externalclearkey.crash"; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 public: | 215 public: |
224 explicit ScopedResetter(Type* object) : object_(object) {} | 216 explicit ScopedResetter(Type* object) : object_(object) {} |
225 ~ScopedResetter() { object_->Reset(); } | 217 ~ScopedResetter() { object_->Reset(); } |
226 | 218 |
227 private: | 219 private: |
228 Type* const object_; | 220 Type* const object_; |
229 }; | 221 }; |
230 | 222 |
231 void INITIALIZE_CDM_MODULE() { | 223 void INITIALIZE_CDM_MODULE() { |
232 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 224 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
233 DVLOG(2) << "FFmpeg libraries initialized: " << g_ffmpeg_lib_initialized; | |
234 av_register_all(); | 225 av_register_all(); |
235 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 226 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
236 } | 227 } |
237 | 228 |
238 void DeinitializeCdmModule() { | 229 void DeinitializeCdmModule() { |
239 } | 230 } |
240 | 231 |
241 void* CreateCdmInstance(int cdm_interface_version, | 232 void* CreateCdmInstance(int cdm_interface_version, |
242 const char* key_system, uint32_t key_system_size, | 233 const char* key_system, uint32_t key_system_size, |
243 GetCdmHostFunc get_cdm_host_func, | 234 GetCdmHostFunc get_cdm_host_func, |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 void ClearKeyCdm::OnFileIOTestComplete(bool success) { | 914 void ClearKeyCdm::OnFileIOTestComplete(bool success) { |
924 DVLOG(1) << __FUNCTION__ << ": " << success; | 915 DVLOG(1) << __FUNCTION__ << ": " << success; |
925 std::string message = GetFileIOTestResultMessage(success); | 916 std::string message = GetFileIOTestResultMessage(success); |
926 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), | 917 host_->OnSessionMessage(last_session_id_.data(), last_session_id_.length(), |
927 cdm::kLicenseRequest, message.data(), | 918 cdm::kLicenseRequest, message.data(), |
928 message.length(), NULL, 0); | 919 message.length(), NULL, 0); |
929 file_io_test_runner_.reset(); | 920 file_io_test_runner_.reset(); |
930 } | 921 } |
931 | 922 |
932 } // namespace media | 923 } // namespace media |
OLD | NEW |