playlist/Plugin: add constructors
This commit is contained in:
@@ -38,20 +38,20 @@ struct PlaylistPlugin {
|
|||||||
* @return true if the plugin was initialized successfully,
|
* @return true if the plugin was initialized successfully,
|
||||||
* false if the plugin is not available
|
* false if the plugin is not available
|
||||||
*/
|
*/
|
||||||
bool (*init)(const ConfigBlock &block);
|
bool (*init)(const ConfigBlock &block) = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deinitialize a plugin which was initialized successfully.
|
* Deinitialize a plugin which was initialized successfully.
|
||||||
* Optional method.
|
* Optional method.
|
||||||
*/
|
*/
|
||||||
void (*finish)();
|
void (*finish)() = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the playlist on the specified URI. This URI has
|
* Opens the playlist on the specified URI. This URI has
|
||||||
* either matched one of the schemes or one of the suffixes.
|
* either matched one of the schemes or one of the suffixes.
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<SongEnumerator> (*open_uri)(const char *uri,
|
std::unique_ptr<SongEnumerator> (*open_uri)(const char *uri,
|
||||||
Mutex &mutex);
|
Mutex &mutex) = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the playlist in the specified input stream. It has
|
* Opens the playlist in the specified input stream. It has
|
||||||
@@ -61,11 +61,46 @@ struct PlaylistPlugin {
|
|||||||
* @parm is the input stream; the pointer will not be
|
* @parm is the input stream; the pointer will not be
|
||||||
* invalidated when the function returns nullptr
|
* invalidated when the function returns nullptr
|
||||||
*/
|
*/
|
||||||
std::unique_ptr<SongEnumerator> (*open_stream)(InputStreamPtr &&is);
|
std::unique_ptr<SongEnumerator> (*open_stream)(InputStreamPtr &&is) = nullptr;
|
||||||
|
|
||||||
const char *const*schemes;
|
const char *const*schemes = nullptr;
|
||||||
const char *const*suffixes;
|
const char *const*suffixes = nullptr;
|
||||||
const char *const*mime_types;
|
const char *const*mime_types = nullptr;
|
||||||
|
|
||||||
|
constexpr PlaylistPlugin(const char *_name,
|
||||||
|
std::unique_ptr<SongEnumerator> (*_open_uri)(const char *uri,
|
||||||
|
Mutex &mutex)) noexcept
|
||||||
|
:name(_name), open_uri(_open_uri) {}
|
||||||
|
|
||||||
|
constexpr PlaylistPlugin(const char *_name,
|
||||||
|
std::unique_ptr<SongEnumerator> (*_open_stream)(InputStreamPtr &&is)) noexcept
|
||||||
|
:name(_name), open_stream(_open_stream) {}
|
||||||
|
|
||||||
|
constexpr auto WithInit(bool (*_init)(const ConfigBlock &block),
|
||||||
|
void (*_finish)() noexcept = nullptr) noexcept {
|
||||||
|
auto copy = *this;
|
||||||
|
copy.init = _init;
|
||||||
|
copy.finish = _finish;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto WithSchemes(const char *const*_schemes) noexcept {
|
||||||
|
auto copy = *this;
|
||||||
|
copy.schemes = _schemes;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto WithSuffixes(const char *const*_suffixes) noexcept {
|
||||||
|
auto copy = *this;
|
||||||
|
copy.suffixes = _suffixes;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto WithMimeTypes(const char *const*_mime_types) noexcept {
|
||||||
|
auto copy = *this;
|
||||||
|
copy.mime_types = _mime_types;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -166,15 +166,7 @@ static const char *const asx_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin asx_playlist_plugin = {
|
const PlaylistPlugin asx_playlist_plugin =
|
||||||
"asx",
|
PlaylistPlugin("asx", asx_open_stream)
|
||||||
|
.WithSuffixes(asx_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(asx_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
asx_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
asx_suffixes,
|
|
||||||
asx_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -70,15 +70,7 @@ static const char *const cue_playlist_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin cue_playlist_plugin = {
|
const PlaylistPlugin cue_playlist_plugin =
|
||||||
"cue",
|
PlaylistPlugin("cue", cue_playlist_open_stream)
|
||||||
|
.WithSuffixes(cue_playlist_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(cue_playlist_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
cue_playlist_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
cue_playlist_suffixes,
|
|
||||||
cue_playlist_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -159,15 +159,6 @@ static const char *const embcue_playlist_suffixes[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin embcue_playlist_plugin = {
|
const PlaylistPlugin embcue_playlist_plugin =
|
||||||
"embcue",
|
PlaylistPlugin("embcue", embcue_playlist_open_uri)
|
||||||
|
.WithSuffixes(embcue_playlist_suffixes);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
embcue_playlist_open_uri,
|
|
||||||
nullptr,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
embcue_playlist_suffixes,
|
|
||||||
nullptr,
|
|
||||||
};
|
|
||||||
|
@@ -147,15 +147,7 @@ static const char *const extm3u_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin extm3u_playlist_plugin = {
|
const PlaylistPlugin extm3u_playlist_plugin =
|
||||||
"extm3u",
|
PlaylistPlugin("extm3u", extm3u_open_stream)
|
||||||
|
.WithSuffixes(extm3u_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(extm3u_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
extm3u_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
extm3u_suffixes,
|
|
||||||
extm3u_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -103,15 +103,6 @@ static const char *const flac_playlist_suffixes[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin flac_playlist_plugin = {
|
const PlaylistPlugin flac_playlist_plugin =
|
||||||
"flac",
|
PlaylistPlugin("flac", flac_playlist_open_stream)
|
||||||
|
.WithSuffixes(flac_playlist_suffixes);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
flac_playlist_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
flac_playlist_suffixes,
|
|
||||||
nullptr,
|
|
||||||
};
|
|
||||||
|
@@ -69,15 +69,7 @@ static const char *const m3u_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin m3u_playlist_plugin = {
|
const PlaylistPlugin m3u_playlist_plugin =
|
||||||
"m3u",
|
PlaylistPlugin("m3u", m3u_open_stream)
|
||||||
|
.WithSuffixes(m3u_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(m3u_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
m3u_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
m3u_suffixes,
|
|
||||||
m3u_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -172,15 +172,7 @@ static const char *const pls_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin pls_playlist_plugin = {
|
const PlaylistPlugin pls_playlist_plugin =
|
||||||
"pls",
|
PlaylistPlugin("pls", pls_open_stream)
|
||||||
|
.WithSuffixes(pls_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(pls_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
pls_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
pls_suffixes,
|
|
||||||
pls_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -165,15 +165,7 @@ static const char *const rss_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin rss_playlist_plugin = {
|
const PlaylistPlugin rss_playlist_plugin =
|
||||||
"rss",
|
PlaylistPlugin("rss", rss_open_stream)
|
||||||
|
.WithSuffixes(rss_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(rss_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
rss_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
rss_suffixes,
|
|
||||||
rss_mime_types,
|
|
||||||
};
|
|
||||||
|
@@ -288,17 +288,7 @@ static const char *const soundcloud_schemes[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin soundcloud_playlist_plugin = {
|
const PlaylistPlugin soundcloud_playlist_plugin =
|
||||||
"soundcloud",
|
PlaylistPlugin("soundcloud", soundcloud_open_uri)
|
||||||
|
.WithInit(soundcloud_init)
|
||||||
soundcloud_init,
|
.WithSchemes(soundcloud_schemes);
|
||||||
nullptr,
|
|
||||||
soundcloud_open_uri,
|
|
||||||
nullptr,
|
|
||||||
|
|
||||||
soundcloud_schemes,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -211,15 +211,7 @@ static const char *const xspf_mime_types[] = {
|
|||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlaylistPlugin xspf_playlist_plugin = {
|
const PlaylistPlugin xspf_playlist_plugin =
|
||||||
"xspf",
|
PlaylistPlugin("xspf", xspf_open_stream)
|
||||||
|
.WithSuffixes(xspf_suffixes)
|
||||||
nullptr,
|
.WithMimeTypes(xspf_mime_types);
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
xspf_open_stream,
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
xspf_suffixes,
|
|
||||||
xspf_mime_types,
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user