LADI
/
spa
1
Fork 0

meson: Rework FFmpeg / tinycompress detection and add pw-cat-ffmpeg option

* Decouple FFmpeg integration in pw-cat from the ffmpeg option; if
  one wants to use Compress-Offload but not the ffmpeg SPA plugin,
  it is then possible to just pass -Dpw-cat-ffmpeg=enabled to meson.
  Likewise, this also makes it possible to build the ffmpeg plugin
  without extending pw-cat.
* tinycompress does not need to be detected in the root meson.build,
  since it is only needed by the alsa plugin.
This commit is contained in:
Carlos Rafael Giani 2022-11-23 16:22:30 +01:00 committed by Wim Taymans
parent e9a2c6aa34
commit 6284cf39c0
4 changed files with 29 additions and 12 deletions

View File

@ -266,14 +266,17 @@ if not readline_dep.found()
readline_dep = cc.find_library('readline', required : get_option('readline'))
endif
need_avcodec = get_option('ffmpeg').enabled() or get_option('pw-cat').enabled()
avcodec_dep = dependency('libavcodec', required: need_avcodec)
avformat_dep = dependency('libavformat', required: get_option('pw-cat'))
summary({'Libav for pw-cat': avcodec_dep.found() and avformat_dep.found()}, bool_yn: true, section: 'Support for ALSA Compress-Offload API')
tinycompress_dep = cc.find_library('tinycompress', has_headers: ['tinycompress/tinycompress.h' ], required: get_option('compress-offload'))
summary({'Compress-Offload sink': tinycompress_dep.found()}, bool_yn: true, section: 'Support for ALSA Compress-Offload API')
compress_offload_enabled = avcodec_dep.found() and avformat_dep.found() and tinycompress_dep.found()
cdata.set('HAVE_ALSA_COMPRESS_OFFLOAD', compress_offload_enabled)
# Both the FFmpeg SPA plugin and the pw-cat FFmpeg integration use libavcodec.
# But only the latter also needs libavformat.
# Search for these libraries here, globally, so both of these subprojects can reuse the results.
pw_cat_ffmpeg = get_option('pw-cat-ffmpeg')
ffmpeg = get_option('ffmpeg')
if pw_cat_ffmpeg.allowed() or ffmpeg.allowed()
avcodec_dep = dependency('libavcodec', required: pw_cat_ffmpeg.enabled() or ffmpeg.enabled())
avformat_dep = dependency('libavformat', required: pw_cat_ffmpeg.enabled())
else
avcodec_dep = dependency('', required: false)
endif
summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section: 'Misc dependencies')
cdata.set('HAVE_READLINE', readline_dep.found())

View File

@ -188,6 +188,10 @@ option('pw-cat',
description: 'Build pw-cat/pw-play/pw-record',
type: 'feature',
value: 'auto')
option('pw-cat-ffmpeg',
description: 'Enable FFmpeg integration in pw-cat/pw-play/pw-record',
type: 'feature',
value: 'disabled')
option('udev',
description: 'Enable Udev integration',
type: 'feature',

View File

@ -83,6 +83,10 @@ if get_option('spa-plugins').allowed()
libcamera_dep = dependency('libcamera', required: get_option('libcamera'))
summary({'libcamera': libcamera_dep.found()}, bool_yn: true, section: 'Backend')
tinycompress_dep = cc.find_library('tinycompress', has_headers: ['tinycompress/tinycompress.h' ], required: get_option('compress-offload'))
summary({'Compress-Offload': tinycompress_dep.found()}, bool_yn: true, section: 'Backend')
cdata.set('HAVE_ALSA_COMPRESS_OFFLOAD', tinycompress_dep.found())
# common dependencies
libudev_dep = dependency('libudev', required: alsa_dep.found() or get_option('udev').enabled() or get_option('v4l2').enabled())
summary({'Udev': libudev_dep.found()}, bool_yn: true, section: 'Backend')

View File

@ -32,15 +32,18 @@ if ncurses_dep.found()
endif
build_pw_cat = false
build_pw_cat_with_ffmpeg = false
pwcat_deps = [ sndfile_dep ]
if avcodec_dep.found() and avformat_dep.found()
pwcat_deps += avcodec_dep
pwcat_deps += avformat_dep
endif
if get_option('pw-cat').allowed() and sndfile_dep.found()
build_pw_cat = true
if pw_cat_ffmpeg.allowed() and avcodec_dep.found() and avformat_dep.found()
pwcat_deps += avcodec_dep
pwcat_deps += avformat_dep
build_pw_cat_with_ffmpeg = true
endif
pwcat_sources = [
'pw-cat.c',
'midifile.c',
@ -70,6 +73,9 @@ elif not sndfile_dep.found() and get_option('pw-cat').enabled()
error('pw-cat is enabled but required dependency `sndfile` was not found.')
endif
summary({'Build pw-cat tool': build_pw_cat}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump tool')
if build_pw_cat
summary({'Build pw-cat with FFmpeg integration': build_pw_cat_with_ffmpeg}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump tool')
endif
if dbus_dep.found()
executable('pw-reserve',