Add runtime enumeration of supported schemas.

Fix src/ls.cxx to only print unique schemas.
Refactor src/ls.cxx to use src/input/InputPlugin functionality.

Add dynamic enumeration support to curl plugin.
This commit is contained in:
Eugene Gorodinsky
2019-04-17 21:47:55 +03:00
committed by Eugene Gorodinsky
parent 38d0f02e83
commit 4e2a551f30
12 changed files with 137 additions and 32 deletions
+24 -12
View File
@@ -25,8 +25,13 @@
#include "lib/ffmpeg/Init.hxx"
#include "lib/ffmpeg/Error.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "PluginUnavailable.hxx"
#include "util/StringAPI.hxx"
#include "../InputPlugin.hxx"
#include <iostream>
#include <exception>
#include <typeinfo>
#include <stdexcept>
class FfmpegInputStream final : public InputStream {
Ffmpeg::IOContext io;
@@ -71,6 +76,22 @@ input_ffmpeg_init(EventLoop &, const ConfigBlock &)
throw PluginUnavailable("No protocol");
}
static std::set<std::string>
input_ffmpeg_protocols() {
void *opaque = nullptr;
const char* protocol;
std::set<std::string> protocols;
while ((protocol = avio_enum_protocols(&opaque, 0))) {
if (protocol_is_whitelisted(protocol)) {
std::string schema(protocol);
schema.append("://");
protocols.emplace(schema);
}
}
return protocols;
}
static InputStreamPtr
input_ffmpeg_open(const char *uri,
Mutex &mutex)
@@ -111,20 +132,11 @@ FfmpegInputStream::Seek(offset_type new_offset)
offset = result;
}
static constexpr const char *ffmpeg_prefixes[] = {
"gopher://",
"rtp://",
"rtsp://",
"rtmp://",
"rtmpt://",
"rtmps://",
nullptr
};
const InputPlugin input_plugin_ffmpeg = {
"ffmpeg",
ffmpeg_prefixes,
nullptr,
input_ffmpeg_init,
nullptr,
input_ffmpeg_open,
input_ffmpeg_protocols
};