diff options
-rw-r--r-- | media/base/media_posix.cc | 25 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_common.h | 7 | ||||
-rw-r--r-- | third_party/ffmpeg/ffmpeg.gyp | 354 | ||||
-rw-r--r-- | third_party/ffmpeg/ffmpeg_stub_headers.fragment | 4 |
4 files changed, 184 insertions, 206 deletions
diff --git a/media/base/media_posix.cc b/media/base/media_posix.cc index 210bea3..eebae5e 100644 --- a/media/base/media_posix.cc +++ b/media/base/media_posix.cc @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/path_service.h" +#include "media/ffmpeg/ffmpeg_common.h" #include "third_party/ffmpeg/ffmpeg_stubs.h" #if defined(OS_LINUX) // OpenMAX IL stub is generated only on Linux. @@ -23,12 +24,26 @@ namespace media { namespace { +// Handy to prevent shooting ourselves in the foot with macro wizardry. +#if !defined(LIBAVCODEC_VERSION_MAJOR) || \ + !defined(LIBAVFORMAT_VERSION_MAJOR) || \ + !defined(LIBAVUTIL_VERSION_MAJOR) +#error FFmpeg headers not included! +#endif + +#define STRINGIZE(x) #x +#define STRINGIZE_MACRO(x) STRINGIZE(x) + +#define AVCODEC_VERSION STRINGIZE_MACRO(LIBAVCODEC_VERSION_MAJOR) +#define AVFORMAT_VERSION STRINGIZE_MACRO(LIBAVFORMAT_VERSION_MAJOR) +#define AVUTIL_VERSION STRINGIZE_MACRO(LIBAVUTIL_VERSION_MAJOR) + #if defined(OS_MACOSX) -#define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." #VERSION ".dylib") +#define DSO_NAME(MODULE, VERSION) ("lib" MODULE "." VERSION ".dylib") const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.dylib"); #elif defined(OS_POSIX) -#define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." #VERSION) +#define DSO_NAME(MODULE, VERSION) ("lib" MODULE ".so." VERSION) const FilePath::CharType sumo_name[] = FILE_PATH_LITERAL("libffmpegsumo.so"); #else #error "Do not know how to construct DSO name for this OS." @@ -41,11 +56,11 @@ std::string GetDSOName(tp_ffmpeg::StubModules stub_key) { // set a constant that we can switch implementations based off of. switch (stub_key) { case tp_ffmpeg::kModuleAvcodec52: - return FILE_PATH_LITERAL(DSO_NAME("avcodec", 52)); + return FILE_PATH_LITERAL(DSO_NAME("avcodec", AVCODEC_VERSION)); case tp_ffmpeg::kModuleAvformat52: - return FILE_PATH_LITERAL(DSO_NAME("avformat", 52)); + return FILE_PATH_LITERAL(DSO_NAME("avformat", AVFORMAT_VERSION)); case tp_ffmpeg::kModuleAvutil50: - return FILE_PATH_LITERAL(DSO_NAME("avutil", 50)); + return FILE_PATH_LITERAL(DSO_NAME("avutil", AVUTIL_VERSION)); default: LOG(DFATAL) << "Invalid stub module requested: " << stub_key; return FILE_PATH_LITERAL(""); diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h index 4b60046..555eb9a 100644 --- a/media/ffmpeg/ffmpeg_common.h +++ b/media/ffmpeg/ffmpeg_common.h @@ -19,9 +19,10 @@ extern "C" { // Temporarily disable possible loss of data warning. // TODO(scherkus): fix and upstream the compiler warnings. MSVC_PUSH_DISABLE_WARNING(4244); -#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavcodec/avcodec.h" -#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavformat/avformat.h" -#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavutil/log.h" +#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> +#include <libavutil/avutil.h> +#include <libavutil/log.h> MSVC_POP_WARNING(); } // extern "C" diff --git a/third_party/ffmpeg/ffmpeg.gyp b/third_party/ffmpeg/ffmpeg.gyp index e111887..40873e8 100644 --- a/third_party/ffmpeg/ffmpeg.gyp +++ b/third_party/ffmpeg/ffmpeg.gyp @@ -38,6 +38,12 @@ }, { 'ffmpeg_config%': '<(target_arch)', }], + ['target_arch=="x64" or target_arch=="ia32"', { + 'ffmpeg_asm_lib': 1, + }], + ['target_arch=="arm"', { + 'ffmpeg_asm_lib': 0, + }], ], 'ffmpeg_variant%': '<(target_arch)', @@ -49,30 +55,7 @@ 'asm_library': 'ffmpegasm', }, 'conditions': [ - # This condition is for migrating from pre-built binaries to an in-tree - # source build. Most of these should be removed once FFmpeg is built on - # mac and linux. Windows will take more work. - # - # TODO(ajwong): Per the comment above, reduce this conditional's size and - # determine if in-tree build in Windows is tractable. - ['(OS!="linux" and OS!="freebsd" and OS!="openbsd" and OS!="solaris" and OS!="mac") or use_system_ffmpeg!=0', { - 'variables': { - 'target_for_binaries': 'ffmpeg_binaries', - 'ffmpeg_include_root': 'source/patched-ffmpeg-mt', - }, - },{ # else OS=="linux" - 'variables': { - 'target_for_binaries': 'ffmpegsumo_nolink', - 'ffmpeg_include_root': 'source/patched-ffmpeg-mt', - 'conditions': [ - ['target_arch=="x64" or target_arch=="ia32"', { - 'ffmpeg_asm_lib': 1, - }], - ['target_arch=="arm"', { - 'ffmpeg_asm_lib': 0, - }], - ], - }, + ['OS!="win" and use_system_ffmpeg==0', { 'targets': [ { 'target_name': 'ffmpegsumo', @@ -597,7 +580,7 @@ }, ], }], - ], + ], # conditions 'targets': [ { 'variables': { @@ -611,28 +594,10 @@ ], 'extra_header': 'ffmpeg_stub_headers.fragment', }, + 'target_name': 'ffmpeg', 'msvs_guid': 'D7A94F58-576A-45D9-A45F-EB87C63ABBB0', - 'dependencies': [ - '<(target_for_binaries)', - 'ffmpeg_binaries', - ], 'sources': [ - '<(ffmpeg_include_root)/libavcodec/avcodec.h', - '<(ffmpeg_include_root)/libavcodec/opt.h', - '<(ffmpeg_include_root)/libavcodec/vdpau.h', - '<(ffmpeg_include_root)/libavcodec/xvmc.h', - '<(ffmpeg_include_root)/libavformat/avformat.h', - '<(ffmpeg_include_root)/libavformat/avio.h', - '<(ffmpeg_include_root)/libavutil/avstring.h', - '<(ffmpeg_include_root)/libavutil/crc.h', - '<(ffmpeg_include_root)/libavutil/intfloat_readwrite.h', - '<(ffmpeg_include_root)/libavutil/log.h', - '<(ffmpeg_include_root)/libavutil/mathematics.h', - '<(ffmpeg_include_root)/libavutil/mem.h', - '<(ffmpeg_include_root)/libavutil/pixfmt.h', - '<(ffmpeg_include_root)/libavutil/rational.h', - # Hacks to introduce C99 types into Visual Studio. 'include/win/inttypes.h', 'include/win/stdint.h', @@ -642,178 +607,175 @@ '<(extra_header)' ], 'hard_dependency': 1, - 'direct_dependent_settings': { - 'include_dirs': [ - 'source/patched-ffmpeg-mt', - 'source/config', - ], - }, + + # Do not fear the massive conditional blocks! They do the following: + # 1) Use the Window stub generator on Windows + # 2) Else, use the POSIX stub generator on non-Windows + # a) Use system includes when use_system_ffmpeg!=0 + # b) Else, use our local copy in source/patched-ffmpeg-mt 'conditions': [ - ['OS=="win"', - { - 'variables': { - 'outfile_type': 'windows_lib', - 'output_dir': '<(PRODUCT_DIR)/lib', - 'intermediate_dir': '<(INTERMEDIATE_DIR)', - }, - 'type': 'none', - 'sources!': [ - '<(extra_header)', + ['OS=="win"', { + 'variables': { + 'outfile_type': 'windows_lib', + 'output_dir': '<(PRODUCT_DIR)/lib', + 'intermediate_dir': '<(INTERMEDIATE_DIR)', + # TODO(scherkus): Change Windows DEPS directory so we don't need + # this conditional. + 'conditions': [ + [ 'ffmpeg_branding=="Chrome"', { + 'ffmpeg_bin_dir': 'chrome/<(OS)/<(ffmpeg_variant)', + }, { # else ffmpeg_branding!="Chrome", assume chromium. + 'ffmpeg_bin_dir': 'chromium/<(OS)/<(ffmpeg_variant)', + }], ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include/win', - ], - 'link_settings': { - 'libraries': [ - '<(output_dir)/avcodec-52.lib', - '<(output_dir)/avformat-52.lib', - '<(output_dir)/avutil-50.lib', - ], - 'msvs_settings': { - 'VCLinkerTool': { - 'DelayLoadDLLs': [ - 'avcodec-52.dll', - 'avformat-52.dll', - 'avutil-50.dll', - ], - }, + }, + 'type': 'none', + 'sources!': [ + '<(extra_header)', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + 'include/win', + 'source/config', + 'source/patched-ffmpeg-mt', + ], + 'link_settings': { + 'libraries': [ + '<(output_dir)/avcodec-52.lib', + '<(output_dir)/avformat-52.lib', + '<(output_dir)/avutil-50.lib', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'DelayLoadDLLs': [ + 'avcodec-52.dll', + 'avformat-52.dll', + 'avutil-50.dll', + ], }, }, }, - 'rules': [ - { - 'rule_name': 'generate_libs', - 'extension': 'sigs', - 'inputs': [ - '<(generate_stubs_script)', - '<@(sig_files)', - ], - 'outputs': [ - '<(output_dir)/<(RULE_INPUT_ROOT).lib', - ], - 'action': ['python', '<(generate_stubs_script)', - '-i', '<(intermediate_dir)', - '-o', '<(output_dir)', - '-t', '<(outfile_type)', - '<@(RULE_INPUT_PATH)', - ], - 'message': 'Generating FFmpeg import libraries.', - }, - ], - }, { # else OS!="win" - 'variables': { - 'outfile_type': 'posix_stubs', - 'stubs_filename_root': 'ffmpeg_stubs', - 'project_path': 'third_party/ffmpeg', - 'intermediate_dir': '<(INTERMEDIATE_DIR)', - 'output_root': '<(SHARED_INTERMEDIATE_DIR)/ffmpeg', + }, + 'rules': [ + { + 'rule_name': 'generate_libs', + 'extension': 'sigs', + 'inputs': [ + '<(generate_stubs_script)', + '<@(sig_files)', + ], + 'outputs': [ + '<(output_dir)/<(RULE_INPUT_ROOT).lib', + ], + 'action': ['python', '<(generate_stubs_script)', + '-i', '<(intermediate_dir)', + '-o', '<(output_dir)', + '-t', '<(outfile_type)', + '<@(RULE_INPUT_PATH)', + ], + 'message': 'Generating FFmpeg import libraries.', }, - 'type': '<(library)', + ], + + # Copy prebuilt binaries to build directory. + 'dependencies': ['../../build/win/system.gyp:cygwin'], + 'copies': [{ + 'destination': '<(PRODUCT_DIR)/', + 'files': [ + 'binaries/<(ffmpeg_bin_dir)/avcodec-52.dll', + 'binaries/<(ffmpeg_bin_dir)/avformat-52.dll', + 'binaries/<(ffmpeg_bin_dir)/avutil-50.dll', + ], + }], + }, { # else OS!="win", use POSIX stub generator + 'variables': { + 'outfile_type': 'posix_stubs', + 'stubs_filename_root': 'ffmpeg_stubs', + 'project_path': 'third_party/ffmpeg', + 'intermediate_dir': '<(INTERMEDIATE_DIR)', + 'output_root': '<(SHARED_INTERMEDIATE_DIR)/ffmpeg', + }, + 'type': '<(library)', + 'include_dirs': [ + '<(output_root)', + '../..', # The chromium 'src' directory. + ], + 'direct_dependent_settings': { + 'defines': [ + '__STDC_CONSTANT_MACROS', # FFmpeg uses INT64_C. + ], 'include_dirs': [ - 'source/patched-ffmpeg-mt', - 'source/config', '<(output_root)', '../..', # The chromium 'src' directory. ], - 'direct_dependent_settings': { - 'defines': [ - '__STDC_CONSTANT_MACROS', # FFmpeg uses INT64_C. - ], - 'include_dirs': [ - '<(output_root)', - '../..', # The chromium 'src' directory. + }, + 'actions': [ + { + 'action_name': 'generate_stubs', + 'inputs': [ + '<(generate_stubs_script)', + '<(extra_header)', + '<@(sig_files)', ], + '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 FFmpeg stubs for dynamic loading.', }, - 'actions': [ - { - 'action_name': 'generate_stubs', - 'inputs': [ - '<(generate_stubs_script)', - '<(extra_header)', - '<@(sig_files)', - ], - '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)', + ], + + 'conditions': [ + # Non-Mac platforms need libdl for dlopen() and friends. + ['OS!="mac"', { + 'link_settings': { + 'libraries': [ + '-ldl', ], - 'process_outputs_as_sources': 1, - 'message': 'Generating FFmpeg stubs for dynamic loading.', }, - ], - }, - ], - ['OS=="linux" or OS=="freebsd" or OS=="solaris"', { - 'link_settings': { - 'libraries': [ - # We need dl for dlopen() and friends. - '-ldl', - ], - }, - }], - ], # conditions - }, - { - 'target_name': 'ffmpeg_binaries', - 'type': 'none', - 'msvs_guid': '4E4070E1-EFD9-4EF1-8634-3960956F6F10', - 'variables': { - 'conditions': [ - [ 'ffmpeg_branding=="Chrome"', { - 'ffmpeg_bin_dir': 'chrome/<(OS)/<(ffmpeg_variant)', - }, { # else ffmpeg_branding!="Chrome", assume chromium. - 'ffmpeg_bin_dir': 'chromium/<(OS)/<(ffmpeg_variant)', - }], - ], - }, - 'conditions': [ - ['OS=="win"', { - 'variables': { - 'source_files': [ - 'binaries/<(ffmpeg_bin_dir)/avcodec-52.dll', - 'binaries/<(ffmpeg_bin_dir)/avformat-52.dll', - 'binaries/<(ffmpeg_bin_dir)/avutil-50.dll', - ], - }, - 'dependencies': ['../../build/win/system.gyp:cygwin'], - }], ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { - 'variables': { - # TODO(ajwong): Clean this up after we've finished - # migrating to in-tree build. - 'source_files': [ + }], + + # Add pkg-config result to include path when use_system_ffmpeg!=0 + ['use_system_ffmpeg!=0', { + 'cflags': [ + '<!@(pkg-config --cflags libavcodec libavformat libavutil)', + ], + 'direct_dependent_settings': { + 'cflags': [ + '<!@(pkg-config --cflags libavcodec libavformat libavutil)', ], }, - }], ['OS=="mac"', { - # TODO(ajwong): These files are also copied in: - # webkit/tools/test_shell/test_shell.gypi and - # chrome/chrome.gyp - # Need to consolidate the copies in one place. (BUG=23602) - 'variables': { - 'source_files': [ + }, { # else use_system_ffmpeg==0, add local copy to include path + 'include_dirs': [ + 'source/config', + 'source/patched-ffmpeg-mt', + ], + 'direct_dependent_settings': { + 'include_dirs': [ + 'source/config', + 'source/patched-ffmpeg-mt', ], }, + 'dependencies': [ + 'ffmpegsumo_nolink', + ], + }], + ], # conditions }], - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/', - 'files': [ - '<@(source_files)', - ] - }, - ], + ], # conditions }, - ], + ], # targets } # Local Variables: diff --git a/third_party/ffmpeg/ffmpeg_stub_headers.fragment b/third_party/ffmpeg/ffmpeg_stub_headers.fragment index a40cac9..b171690 100644 --- a/third_party/ffmpeg/ffmpeg_stub_headers.fragment +++ b/third_party/ffmpeg/ffmpeg_stub_headers.fragment @@ -3,8 +3,8 @@ extern "C" { -#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavcodec/avcodec.h" -#include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavformat/avformat.h" +#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> typedef int (*AVLockMgrOperation)(void**, enum AVLockOp); |