1project('gst-libav', 'c', 'cpp', 2 version : '1.16.2', 3 meson_version : '>= 0.46.0', 4 default_options : [ 'warning_level=1', 5 'buildtype=debugoptimized' ]) 6 7gst_version = meson.project_version() 8version_arr = gst_version.split('.') 9gst_version_major = version_arr[0].to_int() 10gst_version_minor = version_arr[1].to_int() 11gst_version_micro = version_arr[2].to_int() 12 if version_arr.length() == 4 13 gst_version_nano = version_arr[3].to_int() 14else 15 gst_version_nano = 0 16endif 17 18libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100', 19 fallback: ['FFmpeg', 'libavfilter_dep']) 20libavformat_dep = dependency('libavformat', version: '>= 58.12.100', 21 fallback: ['FFmpeg', 'libavformat_dep']) 22libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100', 23 fallback: ['FFmpeg', 'libavcodec_dep']) 24libavutil_dep = dependency('libavutil', version: '>= 56.14.100', 25 fallback: ['FFmpeg', 'libavutil_dep']) 26 27libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep] 28 29cc = meson.get_compiler('c') 30 31check_ffmpeg_src = '''#include <libavcodec/avcodec.h> 32#if LIBAVCODEC_VERSION_MICRO >= 100 33/* FFmpeg uses 100+ as its micro version */ 34#else 35#error libav provider should be FFmpeg 36#endif''' 37 38libav_deps_type_name = '' 39 40foreach dep: libav_deps 41 if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name 42 error('Libav deps must be either all internal or all external') 43 endif 44 libav_deps_type_name = dep.type_name() 45endforeach 46 47if dep.type_name() != 'internal' 48 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg') 49 error('Uncompatible libavcodec found') 50 endif 51endif 52 53cdata = configuration_data() 54cdata.set('LIBAV_SOURCE', '"system install"') 55cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version)) 56cdata.set('PACKAGE', '"gst-libav"') 57 58# GStreamer package name and origin url 59gst_package_name = get_option('package-name') 60if gst_package_name == '' 61 if gst_version_nano == 0 62 gst_package_name = 'GStreamer FFMPEG Plug-ins source release' 63 elif gst_version_nano == 1 64 gst_package_name = 'GStreamer FFMPEG Plug-ins git' 65 else 66 gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease' 67 endif 68endif 69cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name) 70cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin')) 71 72 73check_headers = [['unistd.h', 'HAVE_UNISTD_H']] 74 75foreach h : check_headers 76 if cc.has_header(h.get(0)) 77 cdata.set(h.get(1), 1) 78 endif 79endforeach 80 81gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor) 82gst_dep = dependency('gstreamer-1.0', version : gst_req, 83 fallback : ['gstreamer', 'gst_dep']) 84gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req, 85 fallback : ['gstreamer', 'gst_base_dep']) 86 87gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req, 88 fallback : ['gst-plugins-base', 'video_dep']) 89gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req, 90 fallback : ['gst-plugins-base', 'audio_dep']) 91gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req, 92 fallback : ['gst-plugins-base', 'pbutils_dep']) 93libm = cc.find_library('m', required : false) 94 95configure_file(output : 'config.h', configuration : cdata) 96 97gst_libav_args = ['-DHAVE_CONFIG_H'] 98if cc.get_id() == 'msvc' 99 # Ignore several spurious warnings for things gstreamer does very commonly 100 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it 101 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once 102 # NOTE: Only add warnings here if you are sure they're spurious 103 add_project_arguments( 104 '/wd4018', # implicit signed/unsigned conversion 105 '/wd4146', # unary minus on unsigned (beware INT_MIN) 106 '/wd4244', # lossy type conversion (e.g. double -> int) 107 '/wd4305', # truncating type conversion (e.g. double -> float) 108 language : 'c') 109endif 110 111# Symbol visibility 112if cc.has_argument('-fvisibility=hidden') 113 add_project_arguments('-fvisibility=hidden', language: 'c') 114endif 115 116# Don't export any symbols from static ffmpeg libraries 117if cc.has_link_argument('-Wl,--exclude-libs=ALL') 118 add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c') 119endif 120 121# Disable strict aliasing 122if cc.has_argument('-fno-strict-aliasing') 123 add_project_arguments('-fno-strict-aliasing', language: 'c') 124endif 125 126if gst_dep.type_name() == 'internal' 127 gst_proj = subproject('gstreamer') 128 129 if not gst_proj.get_variable('gst_debug') 130 message('GStreamer debug system is disabled') 131 add_project_arguments('-Wno-unused', language: 'c') 132 else 133 message('GStreamer debug system is enabled') 134 endif 135else 136 # We can't check that in the case of subprojects as we won't 137 # be able to build against an internal dependency (which is not built yet) 138 if not cc.compiles(''' 139#include <gst/gstconfig.h> 140#ifdef GST_DISABLE_GST_DEBUG 141#error "debugging disabled, make compiler fail" 142#endif''' , dependencies: gst_dep) 143 message('GStreamer debug system is disabled') 144 add_project_arguments('-Wno-unused', language: 'c') 145 else 146 message('GStreamer debug system is enabled') 147 endif 148endif 149 150warning_flags = [ 151 '-Wmissing-declarations', 152 '-Wmissing-prototypes', 153 '-Wold-style-definition', 154 '-Wredundant-decls', 155 '-Wundef', 156 '-Wwrite-strings', 157 '-Wformat', 158 '-Wformat-nonliteral', 159 '-Wformat-security', 160 '-Winit-self', 161 '-Wmissing-include-dirs', 162 '-Waddress', 163 '-Wno-multichar', 164 '-Waggregate-return', 165 '-Wdeclaration-after-statement', 166 '-Wvla', 167 '-Wpointer-arith', 168] 169 170foreach extra_arg : warning_flags 171 if cc.has_argument (extra_arg) 172 add_project_arguments([extra_arg], language: 'c') 173 endif 174endforeach 175 176configinc = include_directories('.') 177plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir')) 178pkgconfig = import('pkgconfig') 179plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig') 180if get_option('default_library') == 'shared' 181 # If we don't build static plugins there is no need to generate pc files 182 plugins_pkgconfig_install_dir = disabler() 183endif 184subdir('ext/libav') 185 186python3 = import('python').find_installation() 187run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")') 188