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