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

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

Issue 11364077: Linux: fix build with system ffmpeg (Chromium side). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 8 years, 1 month 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 | « build/common.gypi ('k') | media/ffmpeg/ffmpeg_common.h » ('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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/stringize_macros.h" 12 #include "base/stringize_macros.h"
13 #include "media/ffmpeg/ffmpeg_common.h" 13 #include "media/ffmpeg/ffmpeg_common.h"
14
15 #if !defined(USE_SYSTEM_FFMPEG)
14 #include "third_party/ffmpeg/ffmpeg_stubs.h" 16 #include "third_party/ffmpeg/ffmpeg_stubs.h"
15 17
16 using third_party_ffmpeg::kNumStubModules; 18 using third_party_ffmpeg::kNumStubModules;
17 using third_party_ffmpeg::kModuleFfmpegsumo; 19 using third_party_ffmpeg::kModuleFfmpegsumo;
18 using third_party_ffmpeg::InitializeStubs; 20 using third_party_ffmpeg::InitializeStubs;
19 using third_party_ffmpeg::StubPathMap; 21 using third_party_ffmpeg::StubPathMap;
22 #endif // !defined(USE_SYSTEM_FFMPEG)
20 23
21 namespace media { 24 namespace media {
22 25
23 // Handy to prevent shooting ourselves in the foot with macro wizardry. 26 // Handy to prevent shooting ourselves in the foot with macro wizardry.
24 #if !defined(LIBAVCODEC_VERSION_MAJOR) || \ 27 #if !defined(LIBAVCODEC_VERSION_MAJOR) || \
25 !defined(LIBAVFORMAT_VERSION_MAJOR) || \ 28 !defined(LIBAVFORMAT_VERSION_MAJOR) || \
26 !defined(LIBAVUTIL_VERSION_MAJOR) 29 !defined(LIBAVUTIL_VERSION_MAJOR)
27 #error FFmpeg headers not included! 30 #error FFmpeg headers not included!
28 #endif 31 #endif
29 32
(...skipping 15 matching lines...) Expand all
45 #endif 48 #endif
46 49
47 // 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
48 // rely on function level static initialization in InitializeMediaLibrary() to 51 // rely on function level static initialization in InitializeMediaLibrary() to
49 // guarantee this is only set once in a thread safe manner. 52 // guarantee this is only set once in a thread safe manner.
50 static bool g_media_library_is_initialized = false; 53 static bool g_media_library_is_initialized = false;
51 54
52 static bool InitializeMediaLibraryInternal(const FilePath& module_dir) { 55 static bool InitializeMediaLibraryInternal(const FilePath& module_dir) {
53 DCHECK(!g_media_library_is_initialized); 56 DCHECK(!g_media_library_is_initialized);
54 57
58 #if defined(USE_SYSTEM_FFMPEG)
59 // No initialization is necessary when using system ffmpeg,
60 // we just link directly with system ffmpeg libraries.
61 g_media_library_is_initialized = true;
62 #else
55 StubPathMap paths; 63 StubPathMap paths;
56 64
57 // First try to initialize with Chrome's sumo library. 65 // First try to initialize with Chrome's sumo library.
58 DCHECK_EQ(kNumStubModules, 1); 66 DCHECK_EQ(kNumStubModules, 1);
59 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value()); 67 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value());
60 68
61 // If that fails, see if any system libraries are available. 69 // If that fails, see if any system libraries are available.
62 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 70 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
63 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value()); 71 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value());
64 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 72 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
65 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value()); 73 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value());
66 paths[kModuleFfmpegsumo].push_back(module_dir.Append( 74 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
67 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value()); 75 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value());
68 76
69 g_media_library_is_initialized = InitializeStubs(paths); 77 g_media_library_is_initialized = InitializeStubs(paths);
78 #endif // !defined(USE_SYSTEM_FFMPEG)
70 return g_media_library_is_initialized; 79 return g_media_library_is_initialized;
71 } 80 }
72 81
73 bool InitializeMediaLibrary(const FilePath& base_path) { 82 bool InitializeMediaLibrary(const FilePath& base_path) {
74 static const bool kMediaLibraryInitialized = 83 static const bool kMediaLibraryInitialized =
75 InitializeMediaLibraryInternal(base_path); 84 InitializeMediaLibraryInternal(base_path);
76 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized); 85 DCHECK_EQ(kMediaLibraryInitialized, g_media_library_is_initialized);
77 return kMediaLibraryInitialized; 86 return kMediaLibraryInitialized;
78 } 87 }
79 88
80 void InitializeMediaLibraryForTesting() { 89 void InitializeMediaLibraryForTesting() {
81 FilePath file_path; 90 FilePath file_path;
82 CHECK(PathService::Get(base::DIR_EXE, &file_path)); 91 CHECK(PathService::Get(base::DIR_EXE, &file_path));
83 CHECK(InitializeMediaLibrary(file_path)); 92 CHECK(InitializeMediaLibrary(file_path));
84 } 93 }
85 94
86 bool IsMediaLibraryInitialized() { 95 bool IsMediaLibraryInitialized() {
87 return g_media_library_is_initialized; 96 return g_media_library_is_initialized;
88 } 97 }
89 98
90 } // namespace media 99 } // namespace media
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | media/ffmpeg/ffmpeg_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698