1 parent
295542ab9e
commit
24075fbd52
11 files changed
+305
-133
No files matched your search
@@ -0,0 +1,111 @@
|
||||
#pragma once
|
||||
|
||||
#include <PluginTypes.hpp>
|
||||
#include <TrackTypes.hpp>
|
||||
#include <Types.hpp>
|
||||
#include <Void/Plugin/Plugin.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Api
|
||||
{
|
||||
struct ExtensionCommand {
|
||||
std::string name;
|
||||
std::vector<std::string> aliases;
|
||||
std::string description;
|
||||
std::string usage;
|
||||
std::uint8_t category = 5;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionRpc {
|
||||
std::string name;
|
||||
bool adminOnly = false;
|
||||
};
|
||||
|
||||
struct ExtensionMediaSource {
|
||||
std::string name;
|
||||
bool supportsSearch = false;
|
||||
};
|
||||
|
||||
struct ExtensionWebAsset {
|
||||
std::string id;
|
||||
std::string javascript;
|
||||
std::string css;
|
||||
};
|
||||
|
||||
struct ExtensionCommandRequest {
|
||||
std::string command;
|
||||
std::string arguments;
|
||||
std::uint64_t clientId = 0;
|
||||
std::string invokerName;
|
||||
};
|
||||
|
||||
struct ExtensionRpcRequest {
|
||||
std::string method;
|
||||
std::string params;
|
||||
std::uint64_t clientId = 0;
|
||||
};
|
||||
|
||||
struct ExtensionStream {
|
||||
std::string url;
|
||||
bool localFile = false;
|
||||
};
|
||||
|
||||
// Native, trusted Echoion extension contract. Calls are always made while
|
||||
// the host holds a Void::Plugin::PluginHandle, so a hot reload cannot
|
||||
// unmap code that is still executing.
|
||||
class IExtensionPlugin : public Void::Plugin::IPlugin
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] virtual std::vector<ExtensionCommand> commands() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionRpc> rpcMethods() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionMediaSource> mediaSources() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
[[nodiscard]] virtual std::vector<ExtensionWebAsset> webAssets() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
virtual Result<std::string> executeCommand(
|
||||
const ExtensionCommandRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension command is not supported");
|
||||
}
|
||||
virtual Result<std::string> callRpc(const ExtensionRpcRequest&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension RPC is not supported");
|
||||
}
|
||||
virtual void onEvent(const PluginEvent&) {}
|
||||
[[nodiscard]] virtual bool canHandleMedia(
|
||||
std::string_view, const std::string&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual Result<SearchResult> searchMedia(
|
||||
std::string_view, std::string_view)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension search is not supported");
|
||||
}
|
||||
virtual Result<TrackInfo> resolveMedia(
|
||||
std::string_view, const std::string&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension resolve is not supported");
|
||||
}
|
||||
virtual Result<ExtensionStream> streamMedia(
|
||||
std::string_view, const TrackInfo&)
|
||||
{
|
||||
return fail(ErrorCode::NotSupported, "extension stream is not supported");
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user