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

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

Issue 3005036: Implement VP8 encoder for chromoting (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: just uploading Created 10 years, 2 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 | « media/base/media.h ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/path_service.h" 14 #include "base/path_service.h"
14 #include "media/ffmpeg/ffmpeg_common.h" 15 #include "media/ffmpeg/ffmpeg_common.h"
15 #include "third_party/ffmpeg/ffmpeg_stubs.h" 16 #include "third_party/ffmpeg/ffmpeg_stubs.h"
16 #if defined(OS_LINUX) 17 #if defined(OS_LINUX)
17 // OpenMAX IL stub is generated only on Linux. 18 // OpenMAX IL stub is generated only on Linux.
18 #include "third_party/openmax/il_stubs.h" 19 #include "third_party/openmax/il_stubs.h"
19 #endif 20 #endif
20 21
21 namespace tp_ffmpeg = third_party_ffmpeg; 22 namespace tp_ffmpeg = third_party_ffmpeg;
22 23
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 case tp_ffmpeg::kModuleAvutil50: 63 case tp_ffmpeg::kModuleAvutil50:
63 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION)); 64 return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION));
64 default: 65 default:
65 LOG(DFATAL) << "Invalid stub module requested: " << stub_key; 66 LOG(DFATAL) << "Invalid stub module requested: " << stub_key;
66 return FILE_PATH_LITERAL(""); 67 return FILE_PATH_LITERAL("");
67 } 68 }
68 } 69 }
69 70
70 } // namespace 71 } // namespace
71 72
73 // Address of vpx_codec_vp8_cx_algo.
74 static void* vp8_cx_algo_address = NULL;
75
72 // Attempts to initialize the media library (loading DSOs, etc.). 76 // Attempts to initialize the media library (loading DSOs, etc.).
73 // Returns true if everything was successfully initialized, false otherwise. 77 // Returns true if everything was successfully initialized, false otherwise.
74 bool InitializeMediaLibrary(const FilePath& module_dir) { 78 bool InitializeMediaLibrary(const FilePath& module_dir) {
75 // TODO(ajwong): We need error resolution. 79 // TODO(ajwong): We need error resolution.
76 tp_ffmpeg::StubPathMap paths; 80 tp_ffmpeg::StubPathMap paths;
77 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) { 81 for (int i = 0; i < static_cast<int>(tp_ffmpeg::kNumStubModules); ++i) {
78 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i); 82 tp_ffmpeg::StubModules module = static_cast<tp_ffmpeg::StubModules>(i);
79 83
80 // Add the sumo library first so it takes precedence. 84 // Add the sumo library first so it takes precedence.
81 paths[module].push_back(module_dir.Append(sumo_name).value()); 85 paths[module].push_back(module_dir.Append(sumo_name).value());
82 86
83 // Add the more specific FFmpeg library name. 87 // Add the more specific FFmpeg library name.
84 FilePath path = module_dir.Append(GetDSOName(module)); 88 FilePath path = module_dir.Append(GetDSOName(module));
85 paths[module].push_back(path.value()); 89 paths[module].push_back(path.value());
86 } 90 }
87 91
88 return tp_ffmpeg::InitializeStubs(paths); 92 bool ret = tp_ffmpeg::InitializeStubs(paths);
93
94 // TODO(hclam): This is temporary to obtain address of
95 // vpx_codec_vp8_cx_algo. This should be removed once libvpx has a
96 // getter method for it.
97 base::NativeLibrary sumo_lib =
98 base::LoadNativeLibrary(module_dir.Append(sumo_name));
99 if (sumo_lib) {
100 vp8_cx_algo_address = base::GetFunctionPointerFromNativeLibrary(
101 sumo_lib, "vpx_codec_vp8_cx_algo");
102 }
103 return ret;
89 } 104 }
90 105
91 #if defined(OS_LINUX) 106 #if defined(OS_LINUX)
92 namespace tp_openmax = third_party_openmax; 107 namespace tp_openmax = third_party_openmax;
93 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { 108 bool InitializeOpenMaxLibrary(const FilePath& module_dir) {
94 // TODO(ajwong): We need error resolution. 109 // TODO(ajwong): We need error resolution.
95 tp_openmax::StubPathMap paths; 110 tp_openmax::StubPathMap paths;
96 for (int i = 0; i < static_cast<int>(tp_openmax::kNumStubModules); ++i) { 111 for (int i = 0; i < static_cast<int>(tp_openmax::kNumStubModules); ++i) {
97 tp_openmax::StubModules module = static_cast<tp_openmax::StubModules>(i); 112 tp_openmax::StubModules module = static_cast<tp_openmax::StubModules>(i);
98 113
99 // Add the OpenMAX library first so it takes precedence. 114 // Add the OpenMAX library first so it takes precedence.
100 paths[module].push_back(module_dir.Append(openmax_name).value()); 115 paths[module].push_back(module_dir.Append(openmax_name).value());
101 } 116 }
102 117
103 bool result = tp_openmax::InitializeStubs(paths); 118 bool result = tp_openmax::InitializeStubs(paths);
104 if (!result) { 119 if (!result) {
105 LOG(FATAL) << "Cannot load " << openmax_name << "." 120 LOG(FATAL) << "Cannot load " << openmax_name << "."
106 << " Make sure it exists for OpenMAX."; 121 << " Make sure it exists for OpenMAX.";
107 } 122 }
108 return result; 123 return result;
109 } 124 }
110 #else 125 #else
111 bool InitializeOpenMaxLibrary(const FilePath& module_dir) { 126 bool InitializeOpenMaxLibrary(const FilePath& module_dir) {
112 NOTIMPLEMENTED() << "OpenMAX is only used in Linux."; 127 NOTIMPLEMENTED() << "OpenMAX is only used in Linux.";
113 return false; 128 return false;
114 } 129 }
115 #endif 130 #endif
116 131
132 void* GetVp8CxAlgoAddress() {
133 return vp8_cx_algo_address;
134 }
135
117 } // namespace media 136 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media.h ('k') | media/base/media_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698