decoder/plugin: add method protocols()
Similar to commit 4e2a551f30 but for
decoder plugins. This is tailored for the FFmpeg decoder plugin which
implements some protocols (e.g. RTSP) as demuxer plugin.
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <forward_list> // IWYU pragma: export
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
struct ConfigBlock;
|
||||
class InputStream;
|
||||
@@ -50,6 +52,16 @@ struct DecoderPlugin {
|
||||
*/
|
||||
void (*finish)() noexcept = nullptr;
|
||||
|
||||
/**
|
||||
* Return a set of supported protocols.
|
||||
*/
|
||||
std::set<std::string> (*protocols)() noexcept = nullptr;
|
||||
|
||||
/**
|
||||
* Decode an URI with a protocol listed in protocols().
|
||||
*/
|
||||
void (*uri_decode)(DecoderClient &client, const char *uri) = nullptr;
|
||||
|
||||
/**
|
||||
* Decode a stream (data read from an #InputStream object).
|
||||
*
|
||||
@@ -143,6 +155,14 @@ struct DecoderPlugin {
|
||||
return copy;
|
||||
}
|
||||
|
||||
constexpr auto WithProtocols(std::set<std::string> (*_protocols)() noexcept,
|
||||
void (*_uri_decode)(DecoderClient &client, const char *uri)) noexcept {
|
||||
auto copy = *this;
|
||||
copy.protocols = _protocols;
|
||||
copy.uri_decode = _uri_decode;
|
||||
return copy;
|
||||
}
|
||||
|
||||
constexpr auto WithSuffixes(const char *const*_suffixes) noexcept {
|
||||
auto copy = *this;
|
||||
copy.suffixes = _suffixes;
|
||||
@@ -183,6 +203,13 @@ struct DecoderPlugin {
|
||||
stream_decode(client, is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode an URI which is supported (check SupportsUri()).
|
||||
*/
|
||||
void UriDecode(DecoderClient &client, const char *uri) const {
|
||||
uri_decode(client, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a file.
|
||||
*/
|
||||
@@ -218,6 +245,9 @@ struct DecoderPlugin {
|
||||
return container_scan(path, tnum);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool SupportsUri(const char *uri) const noexcept;
|
||||
|
||||
/**
|
||||
* Does the plugin announce the specified file name suffix?
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user