Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: media/base/media_posix.cc

Issue 12217101: Replace FilePath with base::FilePath in some more top level directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/win/audio_unified_win_unittest.cc ('k') | media/base/media_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 #error FFmpeg headers not included! 30 #error FFmpeg headers not included!
31 #endif 31 #endif
32 32
33 #define AVCODEC_VERSION STRINGIZE(LIBAVCODEC_VERSION_MAJOR) 33 #define AVCODEC_VERSION STRINGIZE(LIBAVCODEC_VERSION_MAJOR)
34 #define AVFORMAT_VERSION STRINGIZE(LIBAVFORMAT_VERSION_MAJOR) 34 #define AVFORMAT_VERSION STRINGIZE(LIBAVFORMAT_VERSION_MAJOR)
35 #define AVUTIL_VERSION STRINGIZE(LIBAVUTIL_VERSION_MAJOR) 35 #define AVUTIL_VERSION STRINGIZE(LIBAVUTIL_VERSION_MAJOR)
36 36
37 #if defined(OS_MACOSX) 37 #if defined(OS_MACOSX)
38 // TODO(evan): should be using .so like ffmepgsumo here. 38 // TODO(evan): should be using .so like ffmepgsumo here.
39 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib") 39 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib")
40 static const FilePath::CharType kSumoLib[] = 40 static const base::FilePath::CharType kSumoLib[] =
41 FILE_PATH_LITERAL("ffmpegsumo.so"); 41 FILE_PATH_LITERAL("ffmpegsumo.so");
42 #elif defined(OS_POSIX) 42 #elif defined(OS_POSIX)
43 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION) 43 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION)
44 static const FilePath::CharType kSumoLib[] = 44 static const base::FilePath::CharType kSumoLib[] =
45 FILE_PATH_LITERAL("libffmpegsumo.so"); 45 FILE_PATH_LITERAL("libffmpegsumo.so");
46 #else 46 #else
47 #error "Do not know how to construct DSO name for this OS." 47 #error "Do not know how to construct DSO name for this OS."
48 #endif 48 #endif
49 49
50 // Use a global to indicate whether the library has been initialized or not. We 50 // Use a global to indicate whether the library has been initialized or not. We
51 // rely on function level static initialization in InitializeMediaLibrary() to 51 // rely on function level static initialization in InitializeMediaLibrary() to
52 // guarantee this is only set once in a thread safe manner. 52 // guarantee this is only set once in a thread safe manner.
53 static bool g_media_library_is_initialized = false; 53 static bool g_media_library_is_initialized = false;
54 54
55 static bool InitializeMediaLibraryInternal(const FilePath& module_dir) { 55 static bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) {
56 DCHECK(!g_media_library_is_initialized); 56 DCHECK(!g_media_library_is_initialized);
57 57
58 #if defined(USE_SYSTEM_FFMPEG) 58 #if defined(USE_SYSTEM_FFMPEG)
59 // No initialization is necessary when using system ffmpeg, 59 // No initialization is necessary when using system ffmpeg,
60 // we just link directly with system ffmpeg libraries. 60 // we just link directly with system ffmpeg libraries.
61 g_media_library_is_initialized = true; 61 g_media_library_is_initialized = true;
62 #else 62 #else
63 StubPathMap paths; 63 StubPathMap paths;
64 64
65 // First try to initialize with Chrome's sumo library. 65 // First try to initialize with Chrome's sumo library.
66 DCHECK_EQ(kNumStubModules, 1); 66 DCHECK_EQ(kNumStubModules, 1);
67 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value()); 67 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value());
68 68
69 // If that fails, see if any system libraries are available. 69 // If that fails, see if any system libraries are available.
70 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 70 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
71 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value()); 71 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value());
72 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 72 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
73 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value()); 73 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value());
74 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 74 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
75 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value()); 75 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value());
76 76
77 g_media_library_is_initialized = InitializeStubs(paths); 77 g_media_library_is_initialized = InitializeStubs(paths);
78 #endif // !defined(USE_SYSTEM_FFMPEG) 78 #endif // !defined(USE_SYSTEM_FFMPEG)
79 return g_media_library_is_initialized; 79 return g_media_library_is_initialized;
80 } 80 }
81 81
82 bool InitializeMediaLibrary(const FilePath& base_path) { 82 bool InitializeMediaLibrary(const base::FilePath& base_path) {
83 static const bool kMediaLibraryInitialized = 83 static const bool kMediaLibraryInitialized =
84 InitializeMediaLibraryInternal(base_path); 84 InitializeMediaLibraryInternal(base_path);
85 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized); 85 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized);
86 return kMediaLibraryInitialized; 86 return kMediaLibraryInitialized;
87 } 87 }
88 88
89 void InitializeMediaLibraryForTesting() { 89 void InitializeMediaLibraryForTesting() {
90 FilePath file_path; 90 base::FilePath file_path;
91 CHECK(PathService::Get(base::DIR_EXE, &file_path)); 91 CHECK(PathService::Get(base::DIR_EXE, &file_path));
92 CHECK(InitializeMediaLibrary(file_path)); 92 CHECK(InitializeMediaLibrary(file_path));
93 } 93 }
94 94
95 bool IsMediaLibraryInitialized() { 95 bool IsMediaLibraryInitialized() {
96 return g_media_library_is_initialized; 96 return g_media_library_is_initialized;
97 } 97 }
98 98
99 } // namespace media 99 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_unified_win_unittest.cc ('k') | media/base/media_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698