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

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

Issue 6628020: Cleaning up src/media to be consistent with static versus anonymous namespaces. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix namespaces Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/native_library.h" 13 #include "base/native_library.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/stringize_macros.h" 15 #include "base/stringize_macros.h"
16 #include "media/ffmpeg/ffmpeg_common.h" 16 #include "media/ffmpeg/ffmpeg_common.h"
17 #include "third_party/ffmpeg/ffmpeg_stubs.h" 17 #include "third_party/ffmpeg/ffmpeg_stubs.h"
18 #if defined(OS_LINUX) 18 #if defined(OS_LINUX)
19 // OpenMAX IL stub is generated only on Linux. 19 // OpenMAX IL stub is generated only on Linux.
20 #include "third_party/openmax/il_stubs.h" 20 #include "third_party/openmax/il_stubs.h"
21 #endif 21 #endif
22 22
23 namespace tp_ffmpeg = third_party_ffmpeg; 23 namespace tp_ffmpeg = third_party_ffmpeg;
24 24
25 namespace media { 25 namespace media {
26 26
27 namespace {
28
29 // Handy to prevent shooting ourselves in the foot with macro wizardry. 27 // Handy to prevent shooting ourselves in the foot with macro wizardry.
30 #if !defined(LIBAVCODEC_VERSION_MAJOR) || \ 28 #if !defined(LIBAVCODEC_VERSION_MAJOR) || \
31 !defined(LIBAVFORMAT_VERSION_MAJOR) || \ 29 !defined(LIBAVFORMAT_VERSION_MAJOR) || \
32 !defined(LIBAVUTIL_VERSION_MAJOR) 30 !defined(LIBAVUTIL_VERSION_MAJOR)
33 #error FFmpeg headers not included! 31 #error FFmpeg headers not included!
34 #endif 32 #endif
35 33
36 #define AVCODEC_VERSION STRINGIZE(LIBAVCODEC_VERSION_MAJOR) 34 #define AVCODEC_VERSION STRINGIZE(LIBAVCODEC_VERSION_MAJOR)
37 #define AVFORMAT_VERSION STRINGIZE(LIBAVFORMAT_VERSION_MAJOR) 35 #define AVFORMAT_VERSION STRINGIZE(LIBAVFORMAT_VERSION_MAJOR)
38 #define AVUTIL_VERSION STRINGIZE(LIBAVUTIL_VERSION_MAJOR) 36 #define AVUTIL_VERSION STRINGIZE(LIBAVUTIL_VERSION_MAJOR)
39 37
40 #if defined(OS_MACOSX) 38 #if defined(OS_MACOSX)
41 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib") 39 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib")
42 const FilePath::CharType sumo_name[] = 40 static const FilePath::CharType sumo_name[] =
43 FILE_PATH_LITERAL("libffmpegsumo.dylib"); 41 FILE_PATH_LITERAL("libffmpegsumo.dylib");
44 #elif defined(OS_POSIX) 42 #elif defined(OS_POSIX)
45 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION) 43 #define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION)
46 const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.so"); 44 static const FilePath::CharType sumo_name[] =
45 FILE_PATH_LITERAL("libffmpegsumo.so");
47 #else 46 #else
48 #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."
49 #endif 48 #endif
50 const FilePath::CharType openmax_name[] = FILE_PATH_LITERAL("libOmxCore.so"); 49 static const FilePath::CharType openmax_name[] =
50 FILE_PATH_LITERAL("libOmxCore.so");
51 51
52 // Retrieves the DSOName for the given key. 52 // Retrieves the DSOName for the given key.
53 std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { 53 static std::string GetDSOName(tp_ffmpeg::StubModules stub_key) {
54 // TODO(ajwong): Remove this once mac is migrated. Either that, or have GYP 54 // TODO(ajwong): Remove this once mac is migrated. Either that, or have GYP
55 // set a constant that we can switch implementations based off of. 55 // set a constant that we can switch implementations based off of.
56 switch (stub_key) { 56 switch (stub_key) {
57 case tp_ffmpeg::kModuleAvcodec52: 57 case tp_ffmpeg::kModuleAvcodec52:
58 return FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION)); 58 return FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION));
59 case tp_ffmpeg::kModuleAvformat52: 59 case tp_ffmpeg::kModuleAvformat52:
60 return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION)); 60 return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION));
61 case tp_ffmpeg::kModuleAvutil50: 61 case tp_ffmpeg::kModuleAvutil50:
62 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION)); 62 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION));
63 default: 63 default:
64 LOG(DFATAL) << "Invalid stub module requested: " << stub_key; 64 LOG(DFATAL) << "Invalid stub module requested: " << stub_key;
65 return FILE_PATH_LITERAL(""); 65 return FILE_PATH_LITERAL("");
66 } 66 }
67 } 67 }
68 68
69 } // namespace
70
71 // Attempts to initialize the media library (loading DSOs, etc.). 69 // Attempts to initialize the media library (loading DSOs, etc.).
72 // Returns true if everything was successfully initialized, false otherwise. 70 // Returns true if everything was successfully initialized, false otherwise.
73 bool InitializeMediaLibrary(const FilePath& module_dir) { 71 bool InitializeMediaLibrary(const FilePath& module_dir) {
74 // TODO(ajwong): We need error resolution. 72 // TODO(ajwong): We need error resolution.
75 tp_ffmpeg::StubPathMap paths; 73 tp_ffmpeg::StubPathMap paths;
76 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) { 74 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) {
77 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i); 75 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i);
78 76
79 // Add the sumo library first so it takes precedence. 77 // Add the sumo library first so it takes precedence.
80 paths[module].push_back(module_dir.Append(sumo_name).value()); 78 paths[module].push_back(module_dir.Append(sumo_name).value());
(...skipping 27 matching lines...) Expand all
108 return result; 106 return result;
109 } 107 }
110 #else 108 #else
111 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { 109 bool InitializeOpenMaxLibrary(const FilePath& module_dir) {
112 NOTIMPLEMENTED() << "OpenMAX is only used in Linux."; 110 NOTIMPLEMENTED() << "OpenMAX is only used in Linux.";
113 return false; 111 return false;
114 } 112 }
115 #endif 113 #endif
116 114
117 } // namespace media 115 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698