58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <TrackTypes.hpp>
|
|
#include <Types.hpp>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace Echoion::Core
|
|
{
|
|
|
|
// A playable handle produced by a source: either an http(s) URL the
|
|
// decoder can stream, or a local file path (downloaded audio) the caller
|
|
// must delete after playback.
|
|
struct StreamHandle {
|
|
std::string url;
|
|
bool isLocalFile = false;
|
|
std::string sourceName; // for logging / failure attribution
|
|
};
|
|
|
|
// One catalog/stream backend in the resolution chain. Implementations:
|
|
// InnertubeSource (native YouTube player API), YandexMusicSource (native
|
|
// Yandex Music), DirectUrlSource (raw audio URLs), YtDlpSource (direct
|
|
// and proxied yt-dlp).
|
|
class ITrackSource
|
|
{
|
|
public:
|
|
|
|
virtual ~ITrackSource() = default;
|
|
|
|
[[nodiscard]] virtual std::string_view name() const = 0;
|
|
|
|
// Can this source resolve the query at all? URLs are matched by
|
|
// host/scheme; bare text search is handled only by
|
|
// YouTube-catalog sources.
|
|
[[nodiscard]] virtual bool
|
|
canHandle(const std::string& query) const = 0;
|
|
|
|
// Health gate — sources with no healthy instances report false
|
|
// and are skipped by the router.
|
|
[[nodiscard]] virtual bool isAvailable() const = 0;
|
|
|
|
// Does this source implement text search?
|
|
[[nodiscard]] virtual bool supportsSearch() const = 0;
|
|
|
|
virtual Api::Result<Api::SearchResult>
|
|
search(std::string_view query) = 0;
|
|
|
|
// Resolve metadata for a URL or id this source canHandle().
|
|
virtual Api::Result<Api::TrackInfo>
|
|
resolve(const std::string& urlOrId) = 0;
|
|
|
|
// Produce a playable handle for a resolved track.
|
|
virtual Api::Result<StreamHandle>
|
|
getStream(const Api::TrackInfo& track) = 0;
|
|
};
|
|
|
|
} // namespace Echoion::Core
|