1 parent
d146f11f02
commit
5c036d91fb
72 files changed
+5875
-1243
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "NetworkClient.hpp"
|
||||
#include "PlaylistLoader.hpp"
|
||||
#include "RpcTypes.hpp"
|
||||
#include "Socks5HttpBridge.hpp"
|
||||
#include "SubscriptionManager.hpp"
|
||||
#include "SubscriptionService.hpp"
|
||||
#include "TrackCache.hpp"
|
||||
@@ -100,6 +101,21 @@ namespace Echoion::Core
|
||||
seek(std::chrono::milliseconds position);
|
||||
[[nodiscard]] Api::Result<void> setVolume(float volume);
|
||||
|
||||
// Vote-to-skip the current track. Votes are keyed by the voter's
|
||||
// stable uid and reset whenever the current track changes. The
|
||||
// threshold is features.voteSkipThreshold, or a majority of
|
||||
// online subscribers when 0. Reaching it skips the track.
|
||||
struct VoteSkipStatus {
|
||||
uint32_t votes = 0;
|
||||
uint32_t needed = 0;
|
||||
bool voted = false; // caller has an active vote
|
||||
bool skipped = false;
|
||||
};
|
||||
[[nodiscard]] Api::Result<VoteSkipStatus>
|
||||
voteSkip(const std::string& uid);
|
||||
[[nodiscard]] VoteSkipStatus
|
||||
voteSkipStatus(const std::string& uid) const;
|
||||
|
||||
[[nodiscard]] Api::Result<uint64_t>
|
||||
queueTrack(const Api::TrackInfo& track, uint64_t clientId);
|
||||
[[nodiscard]] Api::Result<void> removeFromQueue(uint32_t position);
|
||||
@@ -134,7 +150,7 @@ namespace Echoion::Core
|
||||
[[nodiscard]] std::chrono::milliseconds getPlaybackPosition() const;
|
||||
|
||||
// Which catalog(s) a text search targets.
|
||||
enum class SearchScope { All, YouTube, Yandex };
|
||||
enum class SearchScope { All, YouTube, Yandex, SoundCloud };
|
||||
|
||||
[[nodiscard]] Api::Result<Api::SearchResult>
|
||||
search(const std::string& query,
|
||||
@@ -158,6 +174,17 @@ namespace Echoion::Core
|
||||
return autoplay_.load();
|
||||
}
|
||||
|
||||
// Start playback (or seed radio) if nothing is playing and an
|
||||
// online subscriber is listening. Idempotent — safe to call after a
|
||||
// restore/hot-reload or when a subscriber connects, so radio resumes
|
||||
// without a manual !play / !radio toggle.
|
||||
void maybeAutoStart();
|
||||
|
||||
// Set shuffle/repeat mode directly (used when restoring persisted
|
||||
// state); persists the session snapshot.
|
||||
void setShuffle(bool enabled);
|
||||
void setRepeat(bool enabled);
|
||||
|
||||
// Help command
|
||||
[[nodiscard]] std::string getHelpText() const;
|
||||
|
||||
@@ -278,6 +305,17 @@ namespace Echoion::Core
|
||||
std::chrono::milliseconds duration) override;
|
||||
void onEngineIdle() override;
|
||||
void onLocalFileDone(const std::string& path) override;
|
||||
|
||||
// Persist the live queue + shuffle/repeat/autoplay to the database
|
||||
// (kv "session.state") so a full restart can restore them; restore
|
||||
// them at startup. persistSession() is a no-op while a restore is in
|
||||
// progress to avoid recursive writes. includeCurrent=false drops
|
||||
// the currently-playing track from the snapshot — used by stop(),
|
||||
// where the engine clears its entry asynchronously and would
|
||||
// otherwise be persisted as still queued.
|
||||
void persistSession(bool includeCurrent = true);
|
||||
void restoreSession();
|
||||
std::atomic<bool> restoringSession_{false};
|
||||
void onPlaybackError(const Api::Error& error,
|
||||
const std::optional<Api::QueueEntry>& entry)
|
||||
override;
|
||||
@@ -309,9 +347,13 @@ namespace Echoion::Core
|
||||
downloadAudioForPlayback(const Api::TrackInfo& track);
|
||||
void cleanupTempFile(const std::string& filepath);
|
||||
|
||||
// True when a SOCKS5 proxy is configured: ffmpeg cannot route
|
||||
// IP-locked googlevideo URLs through it, so those are downloaded.
|
||||
[[nodiscard]] bool socksProxyActive() const;
|
||||
// The proxy the playback engine (ffmpeg) should use. ffmpeg only
|
||||
// speaks HTTP CONNECT, so a SOCKS5 config starts the local
|
||||
// Socks5HttpBridge and is rewritten to an Http proxy pointing at
|
||||
// it; Http/none pass through unchanged (and stop the bridge).
|
||||
[[nodiscard]] std::optional<Void::Net::ProxyConfig>
|
||||
effectiveEngineProxy(
|
||||
const std::optional<Void::Net::ProxyConfig>& proxy);
|
||||
|
||||
// ---- state -----------------------------------------------------
|
||||
|
||||
@@ -342,6 +384,14 @@ namespace Echoion::Core
|
||||
QueueService queue_;
|
||||
std::unique_ptr<TrackCache> trackCache_;
|
||||
|
||||
// Vote-to-skip state: voter uids for the queue entry identified
|
||||
// by voteSkipQueueId_ (cleared lazily when the track changes).
|
||||
mutable std::mutex voteSkipMutex_;
|
||||
std::set<std::string> voteSkipUids_;
|
||||
uint64_t voteSkipQueueId_ = 0;
|
||||
std::atomic<uint32_t> voteSkipThreshold_{0}; // 0 = auto majority
|
||||
[[nodiscard]] uint32_t voteSkipNeeded() const;
|
||||
|
||||
// Autoplay state: seed track for recommendations + re-entrancy
|
||||
// guard for the async fetch. The seed's catalog decides where
|
||||
// related tracks are pulled from (YouTube radio mix vs. Yandex
|
||||
@@ -364,6 +414,10 @@ namespace Echoion::Core
|
||||
std::atomic<bool> importRunning_{false};
|
||||
std::jthread importThread_;
|
||||
std::unique_ptr<PlaybackEngine> engine_;
|
||||
// HTTP CONNECT -> SOCKS5 tunnel for ffmpeg (see
|
||||
// effectiveEngineProxy); only running while the configured proxy
|
||||
// is SOCKS5.
|
||||
std::unique_ptr<Socks5HttpBridge> ffmpegProxyBridge_;
|
||||
std::unique_ptr<SubscriptionService> subscriptions_;
|
||||
|
||||
// Pending search results per client (for select command)
|
||||
|
||||
Reference in new issue
Block a user