diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 20:50:56 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 20:50:56 +0000 |
commit | 2ac1e7ca438583c681cbb686122f3ec69fa1d5ff (patch) | |
tree | 500afab56a65e9f61e311ee42c5e1e969cf5915a | |
parent | de945c861f68df1f16d58b0570332976fed57f7d (diff) | |
download | chromium_src-2ac1e7ca438583c681cbb686122f3ec69fa1d5ff.zip chromium_src-2ac1e7ca438583c681cbb686122f3ec69fa1d5ff.tar.gz chromium_src-2ac1e7ca438583c681cbb686122f3ec69fa1d5ff.tar.bz2 |
Generate stubs for OpenMAX IL
Generate stubs for OpenMAX IL so we don't need a real OpenMAX library for
building. The actual library is loaded during runtime.
TEST=Build is green
TEST=Running omx_test works on hardware with OpenMAX support
Review URL: http://codereview.chromium.org/661135
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40418 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/render_process.cc | 9 | ||||
-rw-r--r-- | media/base/media.h | 8 | ||||
-rw-r--r-- | media/base/media_posix.cc | 33 | ||||
-rw-r--r-- | media/base/media_win.cc | 5 | ||||
-rw-r--r-- | media/tools/omx_test/omx_test.cc | 6 | ||||
-rw-r--r-- | media/tools/player_x11/player_x11.cc | 8 | ||||
-rwxr-xr-x | third_party/ffmpeg/ffmpeg.gyp | 2 | ||||
-rw-r--r-- | third_party/openmax/il.sigs | 11 | ||||
-rw-r--r-- | third_party/openmax/il_stub_headers.fragment | 8 | ||||
-rw-r--r-- | third_party/openmax/openmax.gyp | 78 | ||||
-rwxr-xr-x | tools/generate_stubs/generate_stubs.py (renamed from third_party/ffmpeg/generate_stubs.py) | 0 | ||||
-rwxr-xr-x | tools/generate_stubs/generate_stubs_unittest.py (renamed from third_party/ffmpeg/generate_stubs_unittest.py) | 0 |
12 files changed, 142 insertions, 26 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc index 5a5bfe7..f5d72c8 100644 --- a/chrome/renderer/render_process.cc +++ b/chrome/renderer/render_process.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,6 +31,7 @@ #include "ipc/ipc_channel.h" #include "ipc/ipc_message_utils.h" #include "media/base/media.h" +#include "media/base/media_switches.h" #include "native_client/src/trusted/plugin/nacl_entry_points.h" #include "webkit/glue/webkit_glue.h" @@ -105,6 +106,12 @@ RenderProcess::RenderProcess() initialized_media_library_ = PathService::Get(base::DIR_MODULE, &module_path) && media::InitializeMediaLibrary(module_path); + + // TODO(hclam): Add more checks here. Currently this is not used. + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableOpenMax)) { + media::InitializeOpenMaxLibrary(module_path); + } #endif } diff --git a/media/base/media.h b/media/base/media.h index 171d4e8..3d1a83a 100644 --- a/media/base/media.h +++ b/media/base/media.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,7 +20,11 @@ namespace media { // Returns true if everything was successfully initialized, false otherwise. bool InitializeMediaLibrary(const FilePath& module_dir); +// Attempts to initialize OpenMAX library. +// +// Returns true if OpenMAX was successfully initialized and loaded. +bool InitializeOpenMaxLibrary(const FilePath& module_dir); + } // namespace media #endif // MEDIA_BASE_MEDIA_H_ - diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 9b1035c..210bea3 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,6 +12,10 @@ #include "base/logging.h" #include "base/path_service.h" #include "third_party/ffmpeg/ffmpeg_stubs.h" +#if defined(OS_LINUX) +// OpenMAX IL stub is generated only on Linux. +#include "third_party/openmax/il_stubs.h" +#endif namespace tp_ffmpeg = third_party_ffmpeg; @@ -29,6 +33,7 @@ const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.so"); #else #error "Do not know how to construct DSO name for this OS." #endif +const FilePath::CharType openmax_name[] = FILE_PATH_LITERAL("libOmxCore.so"); // Retrieves the DSOName for the given key. std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { @@ -68,4 +73,30 @@ bool InitializeMediaLibrary(const FilePath& module_dir) { return tp_ffmpeg::InitializeStubs(paths); } +#if defined(OS_LINUX) +namespace tp_openmax = third_party_openmax; +bool InitializeOpenMaxLibrary(const FilePath& module_dir) { + // TODO(ajwong): We need error resolution. + tp_openmax::StubPathMap paths; + for (int i = 0; i < static_cast<int>(tp_openmax::kNumStubModules); ++i) { + tp_openmax::StubModules module = static_cast<tp_openmax::StubModules>(i); + + // Add the OpenMAX library first so it takes precedence. + paths[module].push_back(module_dir.Append(openmax_name).value()); + } + + bool result = tp_openmax::InitializeStubs(paths); + if (!result) { + LOG(FATAL) << "Cannot load " << openmax_name << "." + << " Make sure it exists for OpenMAX."; + } + return result; +} +#else +bool InitializeOpenMaxLibrary(const FilePath& module_dir) { + NOTIMPLEMENTED() << "OpenMAX is only used in Linux."; + return false; +} +#endif + } // namespace media diff --git a/media/base/media_win.cc b/media/base/media_win.cc index 975a301..e4d67f5 100644 --- a/media/base/media_win.cc +++ b/media/base/media_win.cc @@ -96,4 +96,9 @@ bool InitializeMediaLibrary(const FilePath& base_path) { return false; } +bool InitializeOpenMaxLibrary(const FilePath& module_dir) { + NOTIMPLEMENTED() << "OpenMAX is not used in Windows."; + return false; +} + } // namespace media diff --git a/media/tools/omx_test/omx_test.cc b/media/tools/omx_test/omx_test.cc index 428bacc..e90f150 100644 --- a/media/tools/omx_test/omx_test.cc +++ b/media/tools/omx_test/omx_test.cc @@ -320,6 +320,12 @@ int main(int argc, char** argv) { loop_count = 1; DCHECK_GE(loop_count, 1); + // Initialize OpenMAX. + if (!media::InitializeOpenMaxLibrary(FilePath())) { + LOG(ERROR) << "Unable to initialize OpenMAX library."; + return false; + } + // If FFmpeg should be used for demuxing load the library here and do // the initialization. if (use_ffmpeg && !InitFFmpeg()) { diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc index 41207fd..24ba556 100644 --- a/media/tools/player_x11/player_x11.cc +++ b/media/tools/player_x11/player_x11.cc @@ -64,6 +64,14 @@ bool InitX11() { bool InitPipeline(MessageLoop* message_loop, const char* filename, bool enable_audio, scoped_refptr<media::PipelineImpl>* pipeline) { + // Initialize OpenMAX. + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableOpenMax) && + !media::InitializeOpenMaxLibrary(FilePath())) { + std::cout << "Unable to initialize OpenMAX library."<< std::endl; + return false; + } + // Load media libraries. if (!media::InitializeMediaLibrary(FilePath())) { std::cout << "Unable to initialize the media library." << std::endl; diff --git a/third_party/ffmpeg/ffmpeg.gyp b/third_party/ffmpeg/ffmpeg.gyp index 1886d63..b093a75 100755 --- a/third_party/ffmpeg/ffmpeg.gyp +++ b/third_party/ffmpeg/ffmpeg.gyp @@ -592,7 +592,7 @@ 'targets': [ { 'variables': { - 'generate_stubs_script': 'generate_stubs.py', + 'generate_stubs_script': '../../tools/generate_stubs/generate_stubs.py', 'sig_files': [ # Note that these must be listed in dependency order. # (i.e. if A depends on B, then B must be listed before A.) diff --git a/third_party/openmax/il.sigs b/third_party/openmax/il.sigs new file mode 100644 index 0000000..20d6b98 --- /dev/null +++ b/third_party/openmax/il.sigs @@ -0,0 +1,11 @@ +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Functions from OpenMAX IL used in Chromium code. + +OMX_ERRORTYPE OMX_Init(void); +OMX_ERRORTYPE OMX_Deinit(void); +OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE* pHandle, OMX_STRING cComponentName, OMX_PTR pAppData, OMX_CALLBACKTYPE* pCallBacks); +OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent); +OMX_ERRORTYPE OMX_GetComponentsOfRole (OMX_STRING role, OMX_U32* pNumComps, OMX_U8** compNames); diff --git a/third_party/openmax/il_stub_headers.fragment b/third_party/openmax/il_stub_headers.fragment new file mode 100644 index 0000000..222f4dc --- /dev/null +++ b/third_party/openmax/il_stub_headers.fragment @@ -0,0 +1,8 @@ +// These are some extra includes needed in the generated stub file for defining +// various OpenMAX types. + +extern "C" { + +#include "third_party/openmax/il/OMX_Core.h" + +} diff --git a/third_party/openmax/openmax.gyp b/third_party/openmax/openmax.gyp index ef14e41..16293e4 100644 --- a/third_party/openmax/openmax.gyp +++ b/third_party/openmax/openmax.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2010 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -26,9 +26,12 @@ 'include_dirs': [ 'il', ], + 'defines': [ + '__OMX_EXPORTS', + ], }, 'conditions': [ - ['openmax_type=="stub"', { + ['OS!="linux"', { 'type': '<(library)', 'dependencies': [ '../../base/base.gyp:base', @@ -42,31 +45,64 @@ 'defines': [ '__OMX_EXPORTS', ], + }], + ['OS=="linux"', { + 'variables': { + 'generate_stubs_script': '../../tools/generate_stubs/generate_stubs.py', + 'sig_files': [ + 'il.sigs', + ], + 'extra_header': 'il_stub_headers.fragment', + 'outfile_type': 'posix_stubs', + 'stubs_filename_root': 'il_stubs', + 'project_path': 'third_party/openmax', + 'intermediate_dir': '<(INTERMEDIATE_DIR)', + 'output_root': '<(SHARED_INTERMEDIATE_DIR)/openmax', + }, + 'type': '<(library)', + 'dependencies': [ + '../../base/base.gyp:base', + ], + 'defines': [ + '__OMX_EXPORTS', + ], + 'include_dirs': [ + 'il', + '<(output_root)', + '../..', # The chromium 'src' directory. + ], 'direct_dependent_settings': { - 'defines': [ - '__OMX_EXPORTS', + 'include_dirs': [ + '<(output_root)', + '../..', # The chromium 'src' directory. ], }, - }], - ['openmax_type=="bellagio"', { - 'type': 'none', - 'direct_dependent_settings': { - 'link_settings': { - 'libraries': [ - '-lomxil-bellagio', + 'actions': [ + { + 'action_name': 'generate_stubs', + 'inputs': [ + '<(generate_stubs_script)', + '<(extra_header)', + '<@(sig_files)', ], - }, - }, - }], - ['openmax_type=="omxcore"', { - 'type': 'none', - 'direct_dependent_settings': { - 'link_settings': { - 'libraries': [ - '-lOmxCore', + 'outputs': [ + '<(intermediate_dir)/<(stubs_filename_root).cc', + '<(output_root)/<(project_path)/<(stubs_filename_root).h', + ], + 'action': ['python', + '<(generate_stubs_script)', + '-i', '<(intermediate_dir)', + '-o', '<(output_root)/<(project_path)', + '-t', '<(outfile_type)', + '-e', '<(extra_header)', + '-s', '<(stubs_filename_root)', + '-p', '<(project_path)', + '<@(_inputs)', ], + 'process_outputs_as_sources': 1, + 'message': 'Generating OpenMAX IL stubs for dynamic loading.', }, - }, + ], }], ], }, diff --git a/third_party/ffmpeg/generate_stubs.py b/tools/generate_stubs/generate_stubs.py index e1ba671..e1ba671 100755 --- a/third_party/ffmpeg/generate_stubs.py +++ b/tools/generate_stubs/generate_stubs.py diff --git a/third_party/ffmpeg/generate_stubs_unittest.py b/tools/generate_stubs/generate_stubs_unittest.py index cfab996..cfab996 100755 --- a/third_party/ffmpeg/generate_stubs_unittest.py +++ b/tools/generate_stubs/generate_stubs_unittest.py |