[Sync] Move DataTypeStatusTable ownership into DataTypeManager.
[chromium-blink-merge.git] / media / base / media_posix.cc
blob4aabae9106e913d2f9f46f1868aa0adcbb2bbc87
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
3 // found in the LICENSE file.
5 #include "media/base/media.h"
7 #include <string>
9 #include "base/files/file_path.h"
10 #include "base/logging.h"
11 #include "base/path_service.h"
12 #include "base/strings/stringize_macros.h"
13 #include "media/ffmpeg/ffmpeg_common.h"
14 #include "third_party/ffmpeg/ffmpeg_stubs.h"
16 using third_party_ffmpeg::kNumStubModules;
17 using third_party_ffmpeg::kModuleFfmpegsumo;
18 using third_party_ffmpeg::InitializeStubs;
19 using third_party_ffmpeg::StubPathMap;
21 namespace media {
22 namespace internal {
24 // Handy to prevent shooting ourselves in the foot with macro wizardry.
25 #if !defined(LIBAVCODEC_VERSION_MAJOR) || \
26 !defined(LIBAVFORMAT_VERSION_MAJOR) || \
27 !defined(LIBAVUTIL_VERSION_MAJOR)
28 #error FFmpeg headers not included!
29 #endif
31 #define AVCODEC_VERSION STRINGIZE(LIBAVCODEC_VERSION_MAJOR)
32 #define AVFORMAT_VERSION STRINGIZE(LIBAVFORMAT_VERSION_MAJOR)
33 #define AVUTIL_VERSION STRINGIZE(LIBAVUTIL_VERSION_MAJOR)
35 #if defined(OS_MACOSX)
36 // TODO(evan): should be using .so like ffmepgsumo here.
37 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib")
38 static const base::FilePath::CharType kSumoLib[] =
39 FILE_PATH_LITERAL("ffmpegsumo.so");
40 #elif defined(OS_POSIX)
41 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION)
42 static const base::FilePath::CharType kSumoLib[] =
43 FILE_PATH_LITERAL("libffmpegsumo.so");
44 #else
45 #error "Do not know how to construct DSO name for this OS."
46 #endif
48 bool InitializeMediaLibraryInternal(const base::FilePath& module_dir) {
49 StubPathMap paths;
51 // First try to initialize with Chrome's sumo library.
52 DCHECK_EQ(kNumStubModules, 1);
53 paths[kModuleFfmpegsumo].push_back(module_dir.Append(kSumoLib).value());
55 // If that fails, see if any system libraries are available.
56 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
57 FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION))).value());
58 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
59 FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION))).value());
60 paths[kModuleFfmpegsumo].push_back(module_dir.Append(
61 FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION))).value());
63 return InitializeStubs(paths);
66 } // namespace internal
67 } // namespace media