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
This commit is contained in:
parent
a22d1c88d7
commit
5130acf3ea
1
NEWS
1
NEWS
|
@ -18,6 +18,7 @@ ver 0.22 (not yet released)
|
||||||
* playlist
|
* playlist
|
||||||
- cue: integrate contents in database
|
- cue: integrate contents in database
|
||||||
* decoder
|
* decoder
|
||||||
|
- ffmpeg: support RTSP
|
||||||
- mad: remove option "gapless", always do gapless
|
- mad: remove option "gapless", always do gapless
|
||||||
- sidplay: add option "default_genre"
|
- sidplay: add option "default_genre"
|
||||||
- sidplay: map SID name field to "Album" tag
|
- sidplay: map SID name field to "Album" tag
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "pcm/CheckAudioFormat.hxx"
|
#include "pcm/CheckAudioFormat.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
|
#include "util/StringAPI.hxx"
|
||||||
#include "LogV.hxx"
|
#include "LogV.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -638,6 +639,37 @@ ffmpeg_scan_stream(InputStream &is, TagHandler &handler)
|
||||||
return FfmpegScanStream(*f, 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.
|
* 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
|
* 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 =
|
constexpr DecoderPlugin ffmpeg_decoder_plugin =
|
||||||
DecoderPlugin("ffmpeg", ffmpeg_decode, ffmpeg_scan_stream)
|
DecoderPlugin("ffmpeg", ffmpeg_decode, ffmpeg_scan_stream)
|
||||||
.WithInit(ffmpeg_init, ffmpeg_finish)
|
.WithInit(ffmpeg_init, ffmpeg_finish)
|
||||||
|
.WithProtocols(ffmpeg_protocols, ffmpeg_uri_decode)
|
||||||
.WithSuffixes(ffmpeg_suffixes)
|
.WithSuffixes(ffmpeg_suffixes)
|
||||||
.WithMimeTypes(ffmpeg_mime_types);
|
.WithMimeTypes(ffmpeg_mime_types);
|
||||||
|
|
Loading…
Reference in New Issue