diff --git a/NEWS b/NEWS index da37166ec..3203abefa 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ ver 0.22 (not yet released) * playlist - cue: integrate contents in database * decoder + - ffmpeg: support RTSP - mad: remove option "gapless", always do gapless - sidplay: add option "default_genre" - sidplay: map SID name field to "Album" tag diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index b164063a7..772a0f981 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -42,6 +42,7 @@ #include "pcm/CheckAudioFormat.hxx" #include "util/ScopeExit.hxx" #include "util/ConstBuffer.hxx" +#include "util/StringAPI.hxx" #include "LogV.hxx" extern "C" { @@ -638,6 +639,37 @@ ffmpeg_scan_stream(InputStream &is, TagHandler &handler) return FfmpegScanStream(*f, handler); } +static void +ffmpeg_uri_decode(DecoderClient &client, const char *uri) +{ + auto format_context = + FfmpegOpenInput(nullptr, uri, nullptr); + + const auto *input_format = format_context->iformat; + FormatDebug(ffmpeg_domain, "detected input format '%s' (%s)", + input_format->name, input_format->long_name); + + FfmpegDecode(client, nullptr, *format_context); +} + +static std::set +ffmpeg_protocols() noexcept +{ + std::set protocols; + + const AVInputFormat *format = nullptr; + void *opaque = nullptr; + while ((format = av_demuxer_iterate(&opaque)) != nullptr) { + if (StringIsEqual(format->name, "rtsp")) { + protocols.emplace("rtsp://"); + protocols.emplace("rtsps://"); + } else if (StringIsEqual(format->name, "rtp")) + protocols.emplace("rtp://"); + } + + return protocols; +} + /** * 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 @@ -761,5 +793,6 @@ static const char *const ffmpeg_mime_types[] = { constexpr DecoderPlugin ffmpeg_decoder_plugin = DecoderPlugin("ffmpeg", ffmpeg_decode, ffmpeg_scan_stream) .WithInit(ffmpeg_init, ffmpeg_finish) + .WithProtocols(ffmpeg_protocols, ffmpeg_uri_decode) .WithSuffixes(ffmpeg_suffixes) .WithMimeTypes(ffmpeg_mime_types);