1 project('gst-libav', 'c', 'cpp',
3 meson_version : '>= 0.46.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()
18 libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
19 fallback: ['FFmpeg', 'libavfilter_dep'])
20 libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
21 fallback: ['FFmpeg', 'libavformat_dep'])
22 libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
23 fallback: ['FFmpeg', 'libavcodec_dep'])
24 libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
25 fallback: ['FFmpeg', 'libavutil_dep'])
27 libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
29 cc = meson.get_compiler('c')
31 check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
32 #if LIBAVCODEC_VERSION_MICRO >= 100
33 /* FFmpeg uses 100+ as its micro version */
35 #error libav provider should be FFmpeg
38 libav_deps_type_name = ''
40 foreach 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')
44 libav_deps_type_name = dep.type_name()
47 if 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')
53 cdata = configuration_data()
54 cdata.set('LIBAV_SOURCE', '"system install"')
55 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
56 cdata.set('PACKAGE', '"gst-libav"')
58 # GStreamer package name and origin url
59 gst_package_name = get_option('package-name')
60 if 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'
66 gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
69 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
70 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
73 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
75 foreach h : check_headers
76 if cc.has_header(h.get(0))
77 cdata.set(h.get(1), 1)
81 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
82 gst_dep = dependency('gstreamer-1.0', version : gst_req,
83 fallback : ['gstreamer', 'gst_dep'])
84 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
85 fallback : ['gstreamer', 'gst_base_dep'])
87 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
88 fallback : ['gst-plugins-base', 'video_dep'])
89 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
90 fallback : ['gst-plugins-base', 'audio_dep'])
91 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
92 fallback : ['gst-plugins-base', 'pbutils_dep'])
93 libm = cc.find_library('m', required : false)
95 configure_file(output : 'config.h', configuration : cdata)
97 gst_libav_args = ['-DHAVE_CONFIG_H']
98 if 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)
112 if cc.has_argument('-fvisibility=hidden')
113 add_project_arguments('-fvisibility=hidden', language: 'c')
116 # Don't export any symbols from static ffmpeg libraries
117 if cc.has_link_argument('-Wl,--exclude-libs=ALL')
118 add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
121 # Disable strict aliasing
122 if cc.has_argument('-fno-strict-aliasing')
123 add_project_arguments('-fno-strict-aliasing', language: 'c')
126 if gst_dep.type_name() == 'internal'
127 gst_proj = subproject('gstreamer')
129 if not gst_proj.get_variable('gst_debug')
130 message('GStreamer debug system is disabled')
131 add_project_arguments('-Wno-unused', language: 'c')
133 message('GStreamer debug system is enabled')
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')
146 message('GStreamer debug system is enabled')
151 '-Wmissing-declarations',
152 '-Wmissing-prototypes',
153 '-Wold-style-definition',
158 '-Wformat-nonliteral',
161 '-Wmissing-include-dirs',
164 '-Waggregate-return',
165 '-Wdeclaration-after-statement',
170 foreach extra_arg : warning_flags
171 if cc.has_argument (extra_arg)
172 add_project_arguments([extra_arg], language: 'c')
176 configinc = include_directories('.')
177 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
178 pkgconfig = import('pkgconfig')
179 plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
180 if 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()
186 python3 = import('python').find_installation()
187 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')