OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/media.h" | 5 #include "media/base/media.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/native_library.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 | 14 |
14 // Enable timing code by turning on TESTING macro. | 15 // Enable timing code by turning on TESTING macro. |
15 //#define TESTING 1 | 16 //#define TESTING 1 |
16 | 17 |
17 #ifdef TESTING | 18 #ifdef TESTING |
18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #endif | 21 #endif |
(...skipping 19 matching lines...) Expand all Loading... |
40 case FILE_LIBAVUTIL: | 41 case FILE_LIBAVUTIL: |
41 return FILE_PATH_LITERAL("avutil-50.dll"); | 42 return FILE_PATH_LITERAL("avutil-50.dll"); |
42 default: | 43 default: |
43 LOG(DFATAL) << "Invalid DLL key requested: " << dll_key; | 44 LOG(DFATAL) << "Invalid DLL key requested: " << dll_key; |
44 return FILE_PATH_LITERAL(""); | 45 return FILE_PATH_LITERAL(""); |
45 } | 46 } |
46 } | 47 } |
47 | 48 |
48 } // namespace | 49 } // namespace |
49 | 50 |
| 51 // Address of vpx_codec_vp8_cx_algo. |
| 52 static void* vp8_cx_algo_address = NULL; |
| 53 |
50 // Attempts to initialize the media library (loading DLLs, DSOs, etc.). | 54 // Attempts to initialize the media library (loading DLLs, DSOs, etc.). |
51 // Returns true if everything was successfully initialized, false otherwise. | 55 // Returns true if everything was successfully initialized, false otherwise. |
52 bool InitializeMediaLibrary(const FilePath& base_path) { | 56 bool InitializeMediaLibrary(const FilePath& base_path) { |
53 FFmpegDLLKeys path_keys[] = { | 57 FFmpegDLLKeys path_keys[] = { |
54 media::FILE_LIBAVCODEC, | 58 media::FILE_LIBAVCODEC, |
55 media::FILE_LIBAVFORMAT, | 59 media::FILE_LIBAVFORMAT, |
56 media::FILE_LIBAVUTIL | 60 media::FILE_LIBAVUTIL |
57 }; | 61 }; |
58 HMODULE libs[arraysize(path_keys)] = {NULL}; | 62 HMODULE libs[arraysize(path_keys)] = {NULL}; |
59 | 63 |
(...skipping 11 matching lines...) Expand all Loading... |
71 break; | 75 break; |
72 #ifdef TESTING | 76 #ifdef TESTING |
73 base::TimeTicks dll_loadtime_end = base::TimeTicks::HighResNow(); | 77 base::TimeTicks dll_loadtime_end = base::TimeTicks::HighResNow(); |
74 std::wstring outputbuf = StringPrintf(L"DLL loadtime %5.2f ms, %ls\n", | 78 std::wstring outputbuf = StringPrintf(L"DLL loadtime %5.2f ms, %ls\n", |
75 (dll_loadtime_end - dll_loadtime_start).InMillisecondsF(), | 79 (dll_loadtime_end - dll_loadtime_start).InMillisecondsF(), |
76 cpath); | 80 cpath); |
77 OutputDebugStringW(outputbuf.c_str()); | 81 OutputDebugStringW(outputbuf.c_str()); |
78 #endif | 82 #endif |
79 } | 83 } |
80 | 84 |
| 85 // TODO(hclam): This is temporary to obtain address of |
| 86 // vpx_codec_vp8_cx_algo. This should be removed once libvpx has a |
| 87 // getter method for it. |
| 88 base::NativeLibrary avcodec_lib = |
| 89 base::LoadNativeLibrary(FilePath(GetDLLName(media::FILE_LIBAVCODEC))); |
| 90 if (avcodec_lib) { |
| 91 vp8_cx_algo_address = base::GetFunctionPointerFromNativeLibrary( |
| 92 avcodec_lib, "vpx_codec_vp8_cx_algo"); |
| 93 } |
| 94 |
81 // Check that we loaded all libraries successfully. We only need to check the | 95 // Check that we loaded all libraries successfully. We only need to check the |
82 // last array element because the loop above will break without initializing | 96 // last array element because the loop above will break without initializing |
83 // it on any prior error. | 97 // it on any prior error. |
84 if (libs[arraysize(libs)-1]) | 98 if (libs[arraysize(libs)-1]) |
85 return true; | 99 return true; |
86 | 100 |
87 // Free any loaded libraries if we weren't successful. | 101 // Free any loaded libraries if we weren't successful. |
88 for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) { | 102 for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) { |
89 FreeLibrary(libs[i]); | 103 FreeLibrary(libs[i]); |
90 libs[i] = NULL; // Just to be safe. | 104 libs[i] = NULL; // Just to be safe. |
91 } | 105 } |
92 return false; | 106 return false; |
93 } | 107 } |
94 | 108 |
95 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { | 109 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { |
96 NOTIMPLEMENTED() << "OpenMAX is not used in Windows."; | 110 NOTIMPLEMENTED() << "OpenMAX is not used in Windows."; |
97 return false; | 111 return false; |
98 } | 112 } |
99 | 113 |
| 114 void* GetVp8CxAlgoAddress() { |
| 115 return vp8_cx_algo_address; |
| 116 } |
| 117 |
100 } // namespace media | 118 } // namespace media |
OLD | NEW |