Format and .clang-format
This commit is contained in:
1 parent
6aed7b0027
commit
b94b634a87
47 files changed
+42341
-39711
No files matched your search
@@ -16,85 +16,105 @@
|
||||
#include <ts3_functions.h>
|
||||
#include <ts6bot/AudioDecoder.hpp>
|
||||
#include <vector>
|
||||
class MusicManager {
|
||||
public:
|
||||
explicit MusicManager(std::shared_ptr<TS3Functions> functions, std::uint64_t serverConnectionHandlerID = 0);
|
||||
~MusicManager();
|
||||
class MusicManager
|
||||
{
|
||||
public:
|
||||
|
||||
struct Music {
|
||||
std::string name;
|
||||
std::string shortUrl;
|
||||
std::string length;
|
||||
std::string videoId;
|
||||
std::string requestedBy;
|
||||
YouTube::Result<definitions::Streams> streams;
|
||||
};
|
||||
explicit MusicManager(std::shared_ptr<TS3Functions> functions,
|
||||
std::uint64_t serverConnectionHandlerID = 0);
|
||||
~MusicManager();
|
||||
|
||||
// Playback Control
|
||||
void stop();
|
||||
void skip();
|
||||
void forceSkip();
|
||||
void setStopAfterCurrent(bool val) { m_stopAfterCurrent = val; }
|
||||
bool isIdle() const { return m_isIdle; }
|
||||
std::uint64_t getServerConnectionHandlerID() const
|
||||
{return m_serverConnectionHandlerID; }
|
||||
void setServerConnectionHandlerID(std::uint64_t id) { m_serverConnectionHandlerID = id; }
|
||||
// Subscription (Whisper) Management
|
||||
void subscribe(anyID id);
|
||||
void moveSubscriberToOffline(anyID id);
|
||||
void moveSubscriberToOnline(anyID id);
|
||||
void addSubscriberToOnline(anyID id);
|
||||
void addSubscriberToOffline(anyID id);
|
||||
void unSubscribe(anyID id);
|
||||
std::set<uint64_t> getOnlineSubscribers() const;
|
||||
std::set<uint64_t> getOfflineSubscribers() const;
|
||||
// Queue Management
|
||||
std::vector<Music> getQueue() const;
|
||||
std::optional<Music> getCurrent() const { return m_current; }
|
||||
void removeFromQueue(std::size_t index);
|
||||
void removeFromQueue(const std::string &name);
|
||||
void addToQueueDirect(const std::string& vid, const std::string& title, const std::string& shortUrl, const std::string& length, const std::string& req, std::optional<definitions::Streams> streams);
|
||||
void checkQueueAndPlay();
|
||||
struct Music {
|
||||
std::string name;
|
||||
std::string shortUrl;
|
||||
std::string length;
|
||||
std::string videoId;
|
||||
std::string requestedBy;
|
||||
YouTube::Result<definitions::Streams> streams;
|
||||
};
|
||||
|
||||
// Youtube / Search
|
||||
std::vector<definitions::SearchResultItem> search(std::string name, int maxResults = 5) const;
|
||||
void playUrl(std::string url, const std::string &requester = "");
|
||||
void playPlaylist(const std::string& playlistId, const std::string& requester);
|
||||
// Helper to extract playlist ID from URL
|
||||
std::optional<std::string> extractPlaylistId(std::string_view url);
|
||||
// Selection Logic
|
||||
// Stores the results for a specific user to select later
|
||||
void storePendingSearch(anyID clientId,
|
||||
const std::vector<definitions::SearchResultItem> &results);
|
||||
bool selectSearchResult(anyID clientId, int index, const std::string& requesterName);
|
||||
// Playback Control
|
||||
void stop();
|
||||
void skip();
|
||||
void forceSkip();
|
||||
void setStopAfterCurrent(bool val) { m_stopAfterCurrent = val; }
|
||||
bool isIdle() const { return m_isIdle; }
|
||||
std::uint64_t getServerConnectionHandlerID() const
|
||||
{
|
||||
return m_serverConnectionHandlerID;
|
||||
}
|
||||
void setServerConnectionHandlerID(std::uint64_t id)
|
||||
{
|
||||
m_serverConnectionHandlerID = id;
|
||||
}
|
||||
// Subscription (Whisper) Management
|
||||
bool subscribe(anyID id);
|
||||
void moveSubscriberToOffline(anyID id);
|
||||
void moveSubscriberToOnline(anyID id);
|
||||
bool addSubscriberToOnline(anyID id);
|
||||
bool addSubscriberToOffline(anyID id);
|
||||
bool unSubscribe(anyID id);
|
||||
std::set<uint64_t> getOnlineSubscribers() const;
|
||||
std::set<uint64_t> getOfflineSubscribers() const;
|
||||
// Queue Management
|
||||
std::vector<Music> getQueue() const;
|
||||
std::optional<Music> getCurrent() const { return m_current; }
|
||||
void removeFromQueue(std::size_t index);
|
||||
void removeFromQueue(const std::string& name);
|
||||
void addToQueueDirect(const std::string& vid,
|
||||
const std::string& title,
|
||||
const std::string& shortUrl,
|
||||
const std::string& length,
|
||||
const std::string& req,
|
||||
std::optional<definitions::Streams>
|
||||
streams);
|
||||
void checkQueueAndPlay();
|
||||
|
||||
private:
|
||||
void loop(std::stop_token st);
|
||||
static std::string formatDuration(const std::string &isoDuration);
|
||||
void updateWhisperList();
|
||||
// Youtube / Search
|
||||
std::vector<definitions::SearchResultItem>
|
||||
search(std::string name, int maxResults = 5) const;
|
||||
bool playUrl(std::string url, const std::string& requester = "");
|
||||
bool playPlaylist(const std::string& playlistId,
|
||||
const std::string& requester);
|
||||
// Helper to extract playlist ID from URL
|
||||
std::optional<std::string> extractPlaylistId(std::string_view url);
|
||||
// Selection Logic
|
||||
// Stores the results for a specific user to select later
|
||||
void storePendingSearch(
|
||||
anyID clientId,
|
||||
const std::vector<definitions::SearchResultItem>& results);
|
||||
bool selectSearchResult(anyID clientId,
|
||||
int index,
|
||||
const std::string& requesterName);
|
||||
|
||||
std::shared_ptr<TS3Functions> m_functions{nullptr};
|
||||
std::unique_ptr<AudioDecoder> m_microphone{nullptr};
|
||||
std::unique_ptr<YouTube::Client> m_client{nullptr};
|
||||
private:
|
||||
|
||||
void loop(std::stop_token st);
|
||||
static std::string formatDuration(const std::string& isoDuration);
|
||||
void updateWhisperList();
|
||||
|
||||
std::atomic<bool> m_stopAfterCurrent{false};
|
||||
std::atomic<bool> m_isIdle{true};
|
||||
std::shared_ptr<TS3Functions> m_functions{nullptr};
|
||||
std::unique_ptr<AudioDecoder> m_microphone{nullptr};
|
||||
std::unique_ptr<YouTube::Client> m_client{nullptr};
|
||||
|
||||
std::deque<Music> m_queue{};
|
||||
mutable std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
std::atomic<bool> m_stopAfterCurrent{false};
|
||||
std::atomic<bool> m_isIdle{true};
|
||||
|
||||
std::set<anyID> m_onlineSubscribers;
|
||||
std::set<anyID> m_offlineSubscribers;
|
||||
// Playback Control
|
||||
std::atomic_bool m_skipRequested{false};
|
||||
std::deque<Music> m_queue{};
|
||||
mutable std::mutex m_queueMtx;
|
||||
std::condition_variable m_cv;
|
||||
|
||||
std::atomic<float> m_volume{0.5f}; // Default 50%
|
||||
std::uint64_t m_serverConnectionHandlerID = 0;
|
||||
std::optional<Music> m_current;
|
||||
std::mutex m_subMtx;
|
||||
std::map<anyID, std::vector<definitions::SearchResultItem>> m_pendingSearches;
|
||||
std::mutex m_pendingMtx;
|
||||
std::jthread m_worker;
|
||||
std::set<anyID> m_onlineSubscribers;
|
||||
std::set<anyID> m_offlineSubscribers;
|
||||
// Playback Control
|
||||
std::atomic_bool m_skipRequested{false};
|
||||
|
||||
std::atomic<float> m_volume{0.5f}; // Default 50%
|
||||
std::uint64_t m_serverConnectionHandlerID = 0;
|
||||
std::optional<Music> m_current;
|
||||
std::mutex m_subMtx;
|
||||
std::map<anyID, std::vector<definitions::SearchResultItem>>
|
||||
m_pendingSearches;
|
||||
std::mutex m_pendingMtx;
|
||||
std::jthread m_worker;
|
||||
};
|
||||
Reference in new issue
Block a user