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