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

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

Issue 149632: Add in macro to abstract the differences in library naming conventions between mac and linux. (Closed)
Patch Set: Created 11 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <dlfcn.h> 9 #include <dlfcn.h>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "third_party/ffmpeg/ffmpeg_stubs.h" 14 #include "third_party/ffmpeg/ffmpeg_stubs.h"
15 15
16 namespace tp_ffmpeg = third_party_ffmpeg; 16 namespace tp_ffmpeg = third_party_ffmpeg;
17 17
18 namespace media { 18 namespace media {
19 19
20 namespace { 20 namespace {
21 21
22 #if defined(OS_MACOSX)
23 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." #VERSION ".dylib")
24 #elif defined(OS_LINUX)
25 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." #VERSION)
26 #else
27 #error Unsupported OS.
28 #endif
29
22 // Retrieves the DSOName for the given key. 30 // Retrieves the DSOName for the given key.
23 std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { 31 std::string GetDSOName(tp_ffmpeg::StubModules stub_key) {
24 // TODO(ajwong): Do we want to lock to a specific ffmpeg version?
25 // TODO(port): These library names are incorrect for mac. We need .dynlib
26 // suffixes.
27 switch (stub_key) { 32 switch (stub_key) {
28 case tp_ffmpeg::kModuleAvcodec52: 33 case tp_ffmpeg::kModuleAvcodec52:
29 return FILE_PATH_LITERAL("libavcodec.so.52"); 34 return FILE_PATH_LITERAL(DSO_NAME("avcodec", 52));
30 case tp_ffmpeg::kModuleAvformat52: 35 case tp_ffmpeg::kModuleAvformat52:
31 return FILE_PATH_LITERAL("libavformat.so.52"); 36 return FILE_PATH_LITERAL(DSO_NAME("avformat", 52));
32 case tp_ffmpeg::kModuleAvutil50: 37 case tp_ffmpeg::kModuleAvutil50:
33 return FILE_PATH_LITERAL("libavutil.so.50"); 38 return FILE_PATH_LITERAL(DSO_NAME("avutil", 50));
34 default: 39 default:
35 LOG(DFATAL) << "Invalid stub module requested: " << stub_key; 40 LOG(DFATAL) << "Invalid stub module requested: " << stub_key;
36 return FILE_PATH_LITERAL(""); 41 return FILE_PATH_LITERAL("");
37 } 42 }
38 } 43 }
39 44
40 } // namespace 45 } // namespace
41 46
42 // Attempts to initialize the media library (loading DSOs, etc.). 47 // Attempts to initialize the media library (loading DSOs, etc.).
43 // Returns true if everything was successfully initialized, false otherwise. 48 // Returns true if everything was successfully initialized, false otherwise.
44 bool InitializeMediaLibrary(const FilePath& module_dir) { 49 bool InitializeMediaLibrary(const FilePath& module_dir) {
45 // TODO(ajwong): We need error resolution. 50 // TODO(ajwong): We need error resolution.
46 tp_ffmpeg::StubPathMap paths; 51 tp_ffmpeg::StubPathMap paths;
47 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) { 52 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) {
48 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i); 53 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i);
49 FilePath path = module_dir.Append(GetDSOName(module)); 54 FilePath path = module_dir.Append(GetDSOName(module));
50 paths[module].push_back(path.value()); 55 paths[module].push_back(path.value());
51 } 56 }
52 57
53 return tp_ffmpeg::InitializeStubs(paths); 58 return tp_ffmpeg::InitializeStubs(paths);
54 } 59 }
55 60
56 } // namespace media 61 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698