From ac59ec34f9d467b423b1f5f68bdfb2e7f2f944c3 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Mon, 31 May 2021 18:08:58 +0200
Subject: [PATCH] decoder/ffmpeg: fix build failure with FFmpeg 3.4

av_demuxer_iterate() was added in libavformat 58.9.100.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1178
---
 NEWS                                        | 1 +
 src/decoder/plugins/FfmpegDecoderPlugin.cxx | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/NEWS b/NEWS
index 47947cc16..abd79a459 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.22.9 (not yet released)
   - simple: load all .mpdignore files of all parent directories
 * decoder
   - ffmpeg: support the tags "sort_album", "album-sort", "artist-sort"
+  - ffmpeg: fix build failure with FFmpeg 3.4
 * Windows
   - fix build failure with SQLite
 
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
index 891f7846a..c817277e1 100644
--- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx
@@ -659,6 +659,8 @@ ffmpeg_scan_stream(InputStream &is, TagHandler &handler)
 	return FfmpegScanStream(*f, handler);
 }
 
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
+
 static void
 ffmpeg_uri_decode(DecoderClient &client, const char *uri)
 {
@@ -690,6 +692,8 @@ ffmpeg_protocols() noexcept
 	return protocols;
 }
 
+#endif
+
 /**
  * A list of extensions found for the formats supported by ffmpeg.
  * This list is current as of 02-23-09; To find out if there are more
@@ -813,6 +817,8 @@ static const char *const ffmpeg_mime_types[] = {
 constexpr DecoderPlugin ffmpeg_decoder_plugin =
 	DecoderPlugin("ffmpeg", ffmpeg_decode, ffmpeg_scan_stream)
 	.WithInit(ffmpeg_init, ffmpeg_finish)
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 9, 100)
 	.WithProtocols(ffmpeg_protocols, ffmpeg_uri_decode)
+#endif
 	.WithSuffixes(ffmpeg_suffixes)
 	.WithMimeTypes(ffmpeg_mime_types);