From 9565ff522b946489c43508444c5e04812d1bdbbb Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 21 Oct 2019 01:37:56 +0200 Subject: [PATCH] build: add --enable-ffmpeg-strict-abi option This can be used by distros to disable all known FFmpeg ABI violations. Currently only 1 is known, in demux_lavf.c. In addition to if-defing out the access to the private FFmpeg field, this disables the possibly fragile nested open callbacks, which make sense only if the aforementioned field can be accessed. --- demux/demux_lavf.c | 4 ++++ wscript | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index c7eeb0b13e..670b611375 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -247,6 +247,7 @@ static void update_read_stats(struct demuxer *demuxer) for (int n = 0; n < priv->num_nested; n++) { struct nested_stream *nest = &priv->nested[n]; +#if !HAVE_FFMPEG_STRICT_ABI // Note: accessing the bytes_read field is not allowed by FFmpeg's API. // This is fully intentional - there is no other way to get this // information (not even by custom I/O, because the connection reuse @@ -255,6 +256,7 @@ static void update_read_stats(struct demuxer *demuxer) int64_t new = cur - nest->last_bytes; nest->last_bytes = cur; demux_report_unbuffered_read_bytes(demuxer, new); +#endif } } @@ -970,8 +972,10 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) if (demuxer->access_references) { priv->default_io_open = avfc->io_open; priv->default_io_close = avfc->io_close; +#if !HAVE_FFMPEG_STRICT_ABI avfc->io_open = nested_io_open; avfc->io_close = nested_io_close; +#endif } else { avfc->io_open = block_io_open; } diff --git a/wscript b/wscript index 77fe5521b8..b1fc93a8e0 100644 --- a/wscript +++ b/wscript @@ -490,6 +490,10 @@ FFmpeg/Libav libraries. Git master is recommended." 'name': '--libavdevice', 'desc': 'libavdevice', 'func': check_pkg_config('libavdevice', '>= 57.0.0'), + }, { + 'name': '--ffmpeg-strict-abi', + 'desc': 'Disable all known FFmpeg ABI violations', + 'default': 'disable', } ]