TrackProvider.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <stdint.h> // for uint8_t
  3. #include <memory> // for shared_ptr, unique_ptr, weak_ptr
  4. #include <vector> // for vector
  5. #include "MercurySession.h" // for MercurySession
  6. #include "TrackReference.h" // for TrackReference
  7. #include "protobuf/metadata.pb.h" // for Episode, Restriction, Track
  8. namespace cspot {
  9. class AccessKeyFetcher;
  10. class CDNTrackStream;
  11. struct Context;
  12. class TrackProvider {
  13. public:
  14. TrackProvider(std::shared_ptr<cspot::Context> ctx);
  15. ~TrackProvider();
  16. std::shared_ptr<CDNTrackStream> loadFromTrackRef(TrackReference& trackRef);
  17. private:
  18. std::shared_ptr<AccessKeyFetcher> accessKeyFetcher;
  19. std::shared_ptr<cspot::Context> ctx;
  20. std::unique_ptr<cspot::CDNTrackStream> cdnStream;
  21. Track trackInfo;
  22. Episode episodeInfo;
  23. std::weak_ptr<CDNTrackStream> currentTrackReference;
  24. TrackReference trackIdInfo;
  25. void queryMetadata();
  26. void onMetadataResponse(MercurySession::Response& res);
  27. bool doRestrictionsApply(Restriction* restrictions, int count);
  28. void fetchFile(const std::vector<uint8_t>& fileId,
  29. const std::vector<uint8_t>& trackId);
  30. bool canPlayTrack(int index);
  31. };
  32. } // namespace cspot