From 0f3af2d20b201a07ad999699e07e59cf8066e32f Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 22 Apr 2023 19:46:45 +0200 Subject: [PATCH] Fix build for FFmpeg < 3.3 The constant AV_CODEC_ID_AV1 was introduced in FFmpeg 3.3. Add an ifdef to support older versions. Fixes #3939 --- app/src/compat.h | 6 ++++++ app/src/demuxer.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/src/compat.h b/app/src/compat.h index 00cb7204..e80a9dd2 100644 --- a/app/src/compat.h +++ b/app/src/compat.h @@ -25,6 +25,12 @@ # define SCRCPY_LAVF_REQUIRES_REGISTER_ALL #endif +// Not documented in ffmpeg/doc/APIchanges, but AV_CODEC_ID_AV1 has been added +// by FFmpeg commit d42809f9835a4e9e5c7c63210abb09ad0ef19cfb (included in tag +// n3.3). +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 89, 100) +# define SCRCPY_LAVC_HAS_AV1 +#endif // In ffmpeg/doc/APIchanges: // 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h diff --git a/app/src/demuxer.c b/app/src/demuxer.c index 5a613505..4fcdd9ad 100644 --- a/app/src/demuxer.c +++ b/app/src/demuxer.c @@ -33,7 +33,12 @@ sc_demuxer_to_avcodec_id(uint32_t codec_id) { case SC_CODEC_ID_H265: return AV_CODEC_ID_HEVC; case SC_CODEC_ID_AV1: +#ifdef SCRCPY_LAVC_HAS_AV1 return AV_CODEC_ID_AV1; +#else + LOGE("AV1 not supported by this FFmpeg version"); + return AV_CODEC_ID_NONE; +#endif case SC_CODEC_ID_OPUS: return AV_CODEC_ID_OPUS; case SC_CODEC_ID_AAC: