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