Teaspeak-Server/server/src/client/music/MusicQueue.h

61 lines
2.1 KiB
C++

#pragma once
#include "../ConnectedClient.h"
#include "Song.h"
#include <teaspeak/MusicPlayer.h>
#include <utility>
namespace ts {
namespace server {
class MusicClient;
}
namespace music {
class MusicHistoryEntry : public SongInfo {
public:
MusicHistoryEntry(std::string url, ClientDbId invoker, ts::SongId songId) : url(std::move(url)), invoker(invoker), id(songId) {}
std::string getUrl() const override { return this->url; }
ts::ClientDbId getInvoker() const override { return this->invoker; }
ts::SongId getSongId() const override { return this->id; }
private:
ts::SongId id;
std::string url;
ts::ClientDbId invoker;
};
class MusicQueue {
public:
MusicQueue(server::MusicClient*);
~MusicQueue();
std::shared_ptr<PlayableSong> currentSong();
std::deque<std::shared_ptr<PlayableSong>> queueEntries();
std::deque<std::shared_ptr<SongInfo>> history(); //near to past
std::shared_ptr<PlayableSong> rewind();
std::shared_ptr<PlayableSong> getNextSong();
std::shared_ptr<PlayableSong> find_queue(ts::SongId);
std::shared_ptr<SongInfo> find(ts::SongId);
bool deleteEntry(const std::shared_ptr<PlayableSong>&);
int changeOrder(const std::shared_ptr<PlayableSong>&, int position);
std::shared_ptr<PlayableSong> insertEntry(const std::string& url, const tsclient& invoker, const std::shared_ptr<PlayableSong::song_loader_t>& loader = nullptr);
void notifySongEnded();
void notifySongAbort();
private:
server::MusicClient* handle;
threads::Mutex lock;
std::shared_ptr<PlayableSong> current;
std::deque<std::shared_ptr<PlayableSong>> queue;
uint32_t song_id_index = 1;
std::deque<std::shared_ptr<SongInfo>> _history;
};
}
}