summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-10-25 00:36:52 +0300
committerJan Ekström <jeebjp@gmail.com>2021-10-26 01:21:56 +0300
commit78cfeee2b93830f2988508a653b508336147b79d (patch)
tree53cba15ed1e6e874a7c8fb9fb39e27fd1b4187dd
parentf56043759494dd584c8d82e7890f92fada18e34b (diff)
downloadmpv-78cfeee2b93830f2988508a653b508336147b79d.tar.bz2
mpv-78cfeee2b93830f2988508a653b508336147b79d.tar.xz
{wscript,demux_lavf}: clean up last bits of !FFMPEG_STRICT_ABI
The bytes_read struct member in AVIOContext is now officially public, so its usage no longer has to be specified as non-compliance with FFmpeg's ABI/API rules. That said, unfortunately there was a short period of time between August 2021 and October 2021 where the struct member did not exist in FFmpeg's git master, so keep a feature check for it alive for now to enable building with those versions. Thankfully, no release version of FFmpeg will be without this field, so it should be possible to drop this check with time. Finally, simplify the function in case the struct member is not found. After all, there is zero reason to iterate through the AVIO contexts if we cannot get the information we require.
-rw-r--r--demux/demux_lavf.c10
-rw-r--r--wscript12
2 files changed, 12 insertions, 10 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 942f29e61a..775f355a0c 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -257,22 +257,20 @@ typedef struct lavf_priv {
static void update_read_stats(struct demuxer *demuxer)
{
+#if !HAVE_FFMPEG_AVIOCONTEXT_BYTES_READ
+ return;
+#else
lavf_priv_t *priv = demuxer->priv;
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
- // mechanism by the HLS demuxer would get disabled).
int64_t cur = nest->id->bytes_read;
int64_t new = cur - nest->last_bytes;
nest->last_bytes = cur;
demux_report_unbuffered_read_bytes(demuxer, new);
-#endif
}
+#endif
}
// At least mp4 has name="mov,mp4,m4a,3gp,3g2,mj2", so we split the name
diff --git a/wscript b/wscript
index 4012fa1f7d..b44adc2ad4 100644
--- a/wscript
+++ b/wscript
@@ -412,10 +412,14 @@ FFmpeg libraries. Git master is recommended."
'desc': 'libavdevice',
'func': check_pkg_config('libavdevice', '>= 57.0.0'),
}, {
- 'name': '--ffmpeg-strict-abi',
- 'desc': 'Disable all known FFmpeg ABI violations',
- 'func': check_true,
- 'default': 'enable',
+ # The following should be removed in 2022 or if libavformat requirement
+ # is bumped to >= 59.8.100
+ 'name': 'ffmpeg-aviocontext-bytes-read',
+ 'desc': 'FFmpeg AVIOContext bytes_read statistic field',
+ 'deps': 'ffmpeg',
+ 'func': check_statement(['libavformat/avio.h'],
+ '(struct AVIOContext){ 0 }.bytes_read = 7357',
+ use=['ffmpeg']),
}
]