1vpx_sources = [
2  'gstvp8dec.c',
3  'gstvp8enc.c',
4  'gstvp8utils.c',
5  'gstvp9dec.c',
6  'gstvp9enc.c',
7  'gstvpxdec.c',
8  'gstvpxenc.c',
9  'plugin.c',
10]
11
12vpx_features = [
13  [ 'vpx/vp8cx.h', 'vpx_codec_vp8_cx_algo', '-DHAVE_VP8_ENCODER', 'VP8 encoder' ],
14  [ 'vpx/vp8dx.h', 'vpx_codec_vp8_dx_algo', '-DHAVE_VP8_DECODER', 'VP8 decoder' ],
15  [ 'vpx/vp8cx.h', 'vpx_codec_vp9_cx_algo', '-DHAVE_VP9_ENCODER', 'VP9 encoder' ],
16  [ 'vpx/vp8dx.h', 'vpx_codec_vp9_dx_algo', '-DHAVE_VP9_DECODER', 'VP9 decoder' ],
17]
18
19vpx_option = get_option('vpx')
20vpx_dep = dependency('vpx', version : '>=1.3.0', required : vpx_option)
21
22if vpx_dep.found()
23  vpx_args = []
24  foreach f : vpx_features
25    header = f.get(0)
26    codec_iface = f.get(1)
27    extra_define = f.get(2)
28    link_code = '''#include <@0@>
29                   int main (int a, char ** g) {
30                     const vpx_codec_iface_t *c = &@1@;
31                     return c != 0;
32                   }'''.format(header,codec_iface)
33    if cc.links(link_code, dependencies : vpx_dep)
34      vpx_args += extra_define
35      message('libvpx provides @0@ interface (@1@)'.format(f.get(3),f.get(1)))
36      have_vpx_feature = true
37    else
38      message('libvpx does not provide @0@ interface (@1@)'.format(f.get(3),f.get(1)))
39      have_vpx_feature = false
40    endif
41    set_variable('have_' + f.get(3).to_lower().underscorify(), have_vpx_feature)
42  endforeach
43
44  if vpx_args.length() == 0
45    msg = 'libvpx was built without any encoder or decoder features!'
46    # Error out if explicitly enabled, but continue with a warning if the
47    # plugin is in auto-detect mode to reduce build-time friction.
48    if vpx_option.enabled()
49      error(msg)
50    endif
51    warning(msg)
52  endif
53
54  if dependency('vpx', version : '>=1.4.0', required : false).found()
55    vpx_args += '-DHAVE_VPX_1_4'
56  endif
57
58  if dependency('vpx', version : '>=1.8.0', required : false).found()
59    vpx_args += '-DHAVE_VPX_1_8'
60  endif
61
62  gstvpx = library('gstvpx',
63    vpx_sources,
64    c_args : gst_plugins_good_args + vpx_args,
65    include_directories : [configinc],
66    dependencies : [gstbase_dep, gsttag_dep, gstvideo_dep, vpx_dep],
67    install : true,
68    install_dir : plugins_install_dir,
69  )
70  pkgconfig.generate(gstvpx, install_dir : plugins_pkgconfig_install_dir)
71
72  install_data(sources: ['GstVP8Enc.prs'], install_dir: presetdir)
73endif
74