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 message('type name: @0@'.format(dep.type_name()))
44 foreach dep: libav_deps
45 message('[@0@] / [@1@]'.format(libav_deps_type_name, dep.type_name()))
46 if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
47 error('Libav deps must be either all internal or all external')
49 libav_deps_type_name = dep.type_name()
52 if dep.type_name() != 'internal'
53 if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
54 error('Uncompatible libavcodec found')
58 cdata = configuration_data()
59 cdata.set('LIBAV_SOURCE', '"system install"')
60 cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
61 cdata.set('PACKAGE', '"gst-libav"')
63 # GStreamer package name and origin url
64 gst_package_name = get_option('package-name')
65 if gst_package_name == ''
66 if gst_version_nano == 0
67 gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
68 elif gst_version_nano == 1
69 gst_package_name = 'GStreamer FFMPEG Plug-ins git'
71 gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
74 cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
75 cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
78 check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
80 foreach h : check_headers
81 if cc.has_header(h.get(0))
82 cdata.set(h.get(1), 1)
86 gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
87 gst_dep = dependency('gstreamer-1.0', version : gst_req,
88 fallback : ['gstreamer', 'gst_dep'])
89 gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
90 fallback : ['gstreamer', 'gst_base_dep'])
92 gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
93 fallback : ['gst-plugins-base', 'video_dep'])
94 gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
95 fallback : ['gst-plugins-base', 'audio_dep'])
96 gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
97 fallback : ['gst-plugins-base', 'pbutils_dep'])
98 libm = cc.find_library('m', required : false)
100 configure_file(output : 'config.h', configuration : cdata)
102 gst_libav_args = ['-DHAVE_CONFIG_H']
103 if cc.get_id() == 'msvc'
104 # Ignore several spurious warnings for things gstreamer does very commonly
105 # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
106 # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
107 # NOTE: Only add warnings here if you are sure they're spurious
108 add_project_arguments(
109 '/wd4018', # implicit signed/unsigned conversion
110 '/wd4146', # unary minus on unsigned (beware INT_MIN)
111 '/wd4244', # lossy type conversion (e.g. double -> int)
112 '/wd4305', # truncating type conversion (e.g. double -> float)
117 if cc.has_argument('-fvisibility=hidden')
118 add_project_arguments('-fvisibility=hidden', language: 'c')
121 # Don't export any symbols from static ffmpeg libraries
122 if cc.has_link_argument('-Wl,--exclude-libs=ALL')
123 add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
126 # Disable strict aliasing
127 if cc.has_argument('-fno-strict-aliasing')
128 add_project_arguments('-fno-strict-aliasing', language: 'c')
131 if gst_dep.type_name() == 'internal'
132 gst_proj = subproject('gstreamer')
134 if not gst_proj.get_variable('gst_debug')
135 message('GStreamer debug system is disabled')
136 add_project_arguments('-Wno-unused', language: 'c')
138 message('GStreamer debug system is enabled')
141 # We can't check that in the case of subprojects as we won't
142 # be able to build against an internal dependency (which is not built yet)
143 if not cc.compiles('''
144 #include <gst/gstconfig.h>
145 #ifdef GST_DISABLE_GST_DEBUG
146 #error "debugging disabled, make compiler fail"
147 #endif''' , dependencies: gst_dep)
148 message('GStreamer debug system is disabled')
149 add_project_arguments('-Wno-unused', language: 'c')
151 message('GStreamer debug system is enabled')
156 '-Wmissing-declarations',
157 '-Wmissing-prototypes',
158 '-Wold-style-definition',
163 '-Wformat-nonliteral',
166 '-Wmissing-include-dirs',
169 '-Waggregate-return',
170 '-Wdeclaration-after-statement',
175 foreach extra_arg : warning_flags
176 if cc.has_argument (extra_arg)
177 add_project_arguments([extra_arg], language: 'c')
181 configinc = include_directories('.')
182 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
185 python3 = import('python').find_installation()
186 run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')