#ifndef SPOTIFYTRACK_H #define SPOTIFYTRACK_H #include #include #include #include "MercuryManager.h" #include "Utils.h" #include "MercuryResponse.h" #include #include "Crypto.h" #include #include "ChunkedAudioStream.h" #include "TrackReference.h" #include "NanoPBHelper.h" #include "protobuf/metadata.pb.h" #include #include struct TrackInfo { std::string name; std::string album; std::string artist; std::string imageUrl; int duration; }; typedef std::function trackChangedCallback; class SpotifyTrack { private: std::shared_ptr manager; void trackInformationCallback(std::unique_ptr response, uint32_t position_ms, bool isPaused); void episodeInformationCallback(std::unique_ptr response, uint32_t position_ms, bool isPaused); void requestAudioKey(std::vector fileId, std::vector trackId, int32_t trackDuration, uint32_t position_ms, bool isPaused); bool countryListContains(char *countryList, char *country); bool canPlayTrack(int altIndex); Track trackInfo; Episode episodeInfo; std::vector fileId; std::vector currentChunkData; std::vector currentChunkHeader; public: SpotifyTrack(std::shared_ptr manager, std::shared_ptr trackRef, uint32_t position_ms, bool isPaused); ~SpotifyTrack(); uint64_t reqSeqNum = -1; std::atomic loaded = false; std::function loadedTrackCallback; std::unique_ptr audioStream; trackChangedCallback trackInfoReceived; audioKeyCallback audioKeyLambda; mercuryCallback responseLambda; }; #endif