OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #endif | 45 #endif |
46 | 46 |
47 // Use a global to indicate whether the library has been initialized or not. We | 47 // Use a global to indicate whether the library has been initialized or not. We |
48 // rely on function level static initialization in InitializeMediaLibrary() to | 48 // rely on function level static initialization in InitializeMediaLibrary() to |
49 // guarantee this is only set once in a thread safe manner. | 49 // guarantee this is only set once in a thread safe manner. |
50 static bool g_media_library_is_initialized = false; | 50 static bool g_media_library_is_initialized = false; |
51 | 51 |
52 static bool InitializeMediaLibraryInternal(const FilePath& module_dir) { | 52 static bool InitializeMediaLibraryInternal(const FilePath& module_dir) { |
53 DCHECK(!g_media_library_is_initialized); | 53 DCHECK(!g_media_library_is_initialized); |
54 | 54 |
| 55 #if defined(USE_SYSTEM_FFMPEG) |
| 56 // No initialization is necessary when using system ffmpeg, |
| 57 // we just link directly with system ffmpeg libraries. |
| 58 g_media_library_is_initialized = true; |
| 59 #else |
55 StubPathMap paths; | 60 StubPathMap paths; |
56 | 61 |
57 // First try to initialize with Chrome's sumo library. | 62 // First try to initialize with Chrome's sumo library. |
58 DCHECK_EQ(kNumStubModules, 1); | 63 DCHECK_EQ(kNumStubModules, 1); |
59 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value()); | 64 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value()); |
60 | 65 |
61 // If that fails, see if any system libraries are available. | 66 // If that fails, see if any system libraries are available. |
62 paths[kModuleFfmpegsumo].push_back(module_dir.Append( | 67 paths[kModuleFfmpegsumo].push_back(module_dir.Append( |
63 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value()); | 68 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value()); |
64 paths[kModuleFfmpegsumo].push_back(module_dir.Append( | 69 paths[kModuleFfmpegsumo].push_back(module_dir.Append( |
65 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value()); | 70 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value()); |
66 paths[kModuleFfmpegsumo].push_back(module_dir.Append( | 71 paths[kModuleFfmpegsumo].push_back(module_dir.Append( |
67 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value()); | 72 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value()); |
68 | 73 |
69 g_media_library_is_initialized = InitializeStubs(paths); | 74 g_media_library_is_initialized = InitializeStubs(paths); |
| 75 #endif // !defined(USE_SYSTEM_FFMPEG) |
70 return g_media_library_is_initialized; | 76 return g_media_library_is_initialized; |
71 } | 77 } |
72 | 78 |
73 bool InitializeMediaLibrary(const FilePath& base_path) { | 79 bool InitializeMediaLibrary(const FilePath& base_path) { |
74 static const bool kMediaLibraryInitialized = | 80 static const bool kMediaLibraryInitialized = |
75 InitializeMediaLibraryInternal(base_path); | 81 InitializeMediaLibraryInternal(base_path); |
76 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized); | 82 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized); |
77 return kMediaLibraryInitialized; | 83 return kMediaLibraryInitialized; |
78 } | 84 } |
79 | 85 |
80 void InitializeMediaLibraryForTesting() { | 86 void InitializeMediaLibraryForTesting() { |
81 FilePath file_path; | 87 FilePath file_path; |
82 CHECK(PathService::Get(base::DIR_EXE, &file_path)); | 88 CHECK(PathService::Get(base::DIR_EXE, &file_path)); |
83 CHECK(InitializeMediaLibrary(file_path)); | 89 CHECK(InitializeMediaLibrary(file_path)); |
84 } | 90 } |
85 | 91 |
86 bool IsMediaLibraryInitialized() { | 92 bool IsMediaLibraryInitialized() { |
87 return g_media_library_is_initialized; | 93 return g_media_library_is_initialized; |
88 } | 94 } |
89 | 95 |
90 } // namespace media | 96 } // namespace media |
OLD | NEW |