Commit 5130acf3 authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: implement protocols() and uri_decode() (for RTSP)

This implements the feature that was missing/broken in this bug report: https://github.com/MusicPlayerDaemon/MPD/issues/930
parent a22d1c88
......@@ -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
......
......@@ -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<std::string>
ffmpeg_protocols() noexcept
{
std::set<std::string> 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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment